Skip to content

Commit 58b634e

Browse files
committed
configure endpoints by pattern
1 parent 9992221 commit 58b634e

File tree

2 files changed

+113
-62
lines changed

2 files changed

+113
-62
lines changed

src-colladmin/actions/tag_action.rb

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,21 @@ def urls
5757
res = {}
5858
return res unless @state == 'running'
5959

60-
@config.fetch('endpoints', {}).fetch(@subservice, {}).each do |k, v|
61-
if k == 'state' && @subservice == 'ui'
62-
m = @name.match(/(ui0[0-9])x2-stg/)
63-
if m
64-
res[k.to_s] = "https://#{m[1]}-aws-stg.cdlib.org/state.json"
60+
@config.fetch('server-configs', {}).each do |confname, sconf|
61+
match = sconf.fetch('match', '.*')
62+
next unless @name =~ Regexp.new(match)
63+
sconf.fetch('endpoints', {}).fetch(@subservice, {}).each do |k, v|
64+
if v =~ /^http/
65+
res[k] = v
66+
elsif v =~ /^\//
67+
# UI uses this
68+
res[k] = "https://#{@name}.cdlib.org#{v}"
6569
else
66-
m = @name.match(/(ui0[0-9])x2/)
67-
res[k.to_s] = "https://#{m[1]}-aws.cdlib.org/state.json" if m
70+
# assume value starts with port number, no http expected
71+
res[k] = "http://#{@name}.cdlib.org:#{v}"
6872
end
69-
elsif k == 'audit_rep' && @subservice == 'ui'
70-
m = @name.match(/(ui0[0-9])x2-stg/)
71-
if m
72-
res[k.to_s] = "https://#{m[1]}-aws-stg.cdlib.org/state-audit-replic.json"
73-
else
74-
m = @name.match(/(ui0[0-9])x2/)
75-
res[k.to_s] = "https://#{m[1]}-aws.cdlib.org/state-audit-replic.json" if m
76-
end
77-
elsif v =~ /^http/
78-
res[k] = v
79-
else
80-
res[k] = "http://#{@name}.cdlib.org:#{v}"
8173
end
74+
break
8275
end
8376
res
8477
end
@@ -93,6 +86,7 @@ def format_urls
9386
end
9487

9588
def notes(action)
89+
return '' if urls.empty?
9690
note = @config.fetch('notes', {}).fetch(@subservice, '').split("\n").join(',')
9791
if @subservice == 'access'
9892
srvr = action.get_ssm('store/zoo/AccessLarge')

src-colladmin/config/database.ssm.yml

Lines changed: 100 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -62,49 +62,106 @@ default:
6262
ldap: |
6363
ALB exists. LDAP admin requires credentials to access. Navigate to "Merritt User Accounts" to query LDAP.
6464
# Provide state endpoints for specific subservices - not applicable for docker
65-
endpoints:
66-
ingest:
67-
state: "{!SSM: ingest/port}/state?t=json"
68-
build-info: "{!SSM: ingest/port}/static/build.content.txt"
69-
ALB: "{!SSM: colladmin/ingest-service}state?t=json"
70-
store:
71-
jsonstatus: "{!SSM: store/port}/jsonstatus"
72-
state: "{!SSM: store/port}/state?t=json"
73-
ping: "{!SSM: store/port}/ping?t=json"
74-
hostname: "{!SSM: store/port}/hostname"
75-
build-info: "{!SSM: store/port}/static/build.content.txt"
76-
ALB: "{!SSM: colladmin/storage-service}/state?t=json"
77-
access:
78-
jsonstatus: "{!SSM: store/port}/jsonstatus"
79-
state: "{!SSM: store/port}/state?t=json"
80-
ping: "{!SSM: store/port}/ping?t=json"
81-
hostname: "{!SSM: store/port}/hostname"
82-
build-info: "{!SSM: store/port}/static/build.content.txt"
83-
ALB: "{!SSM: colladmin/access-service}/state?t=json"
84-
inventory:
85-
state: "{!SSM: inventory/port}/mrtinv/state?t=json"
86-
build-info: "{!SSM: inventory/port}/mrtinv/static/build.content.txt"
87-
start: "{!SSM: inventory/port}/mrtinv/service/start?t=json"
88-
stop: "{!SSM: inventory/port}/mrtinv/service/stop?t=json"
89-
ALB: "{!SSM: colladmin/inventory-service}/state?t=json"
90-
audit:
91-
jsonstatus: "{!SSM: audit/port}/mrtaudit/jsonstatus"
92-
state: "{!SSM: audit/port}/mrtaudit/state?t=json"
93-
build-info: "{!SSM: audit/port}/mrtaudit/static/build.content.txt"
94-
start: "{!SSM: audit/port}/mrtaudit/service/start?t=json"
95-
stop: "{!SSM: audit/port}/mrtaudit/service/stop?t=json"
96-
replic:
97-
jsonstatus: "{!SSM: replic/port}/mrtreplic/jsonstatus"
98-
state: "{!SSM: replic/port}/mrtreplic/state?t=json"
99-
build-info: "{!SSM: replic/port}/mrtreplic/static/build.content.txt"
100-
start: "{!SSM: replic/port}/mrtreplic/service/start?t=json"
101-
stop: "{!SSM: replic/port}/mrtreplic/service/stop?t=json"
102-
ui:
103-
state: "/state.json"
104-
audit_rep: "/state-audit-replic.json"
105-
+ALB: "{!ENV: MERRITT_PATH}/state.json"
106-
ldap:
107-
-ALB: "https://{!SSM: ldap/host}"
65+
server-configs:
66+
al2-stg:
67+
match: '.*x2-stg$'
68+
endpoints:
69+
ui:
70+
state: "/state.json"
71+
audit_rep: "/state-audit-replic.json"
72+
+ALB: "{!ENV: MERRITT_PATH}/state.json"
73+
ldap:
74+
-ALB: "https://{!SSM: ldap/host}"
75+
al2023:
76+
match: '.*stg[0-9][0-9]$'
77+
endpoints:
78+
ingest:
79+
state: "{!SSM: ingest/port}/state?t=json"
80+
build-info: "{!SSM: ingest/port}/static/build.content.txt"
81+
ALB: "{!SSM: colladmin/ingest-service}state?t=json"
82+
store:
83+
jsonstatus: "{!SSM: store/port}/jsonstatus"
84+
state: "{!SSM: store/port}/state?t=json"
85+
ping: "{!SSM: store/port}/ping?t=json"
86+
hostname: "{!SSM: store/port}/hostname"
87+
build-info: "{!SSM: store/port}/static/build.content.txt"
88+
ALB: "{!SSM: colladmin/storage-service}/state?t=json"
89+
access:
90+
jsonstatus: "{!SSM: store/port}/jsonstatus"
91+
state: "{!SSM: store/port}/state?t=json"
92+
ping: "{!SSM: store/port}/ping?t=json"
93+
hostname: "{!SSM: store/port}/hostname"
94+
build-info: "{!SSM: store/port}/static/build.content.txt"
95+
ALB: "{!SSM: colladmin/access-service}/state?t=json"
96+
inventory:
97+
state: "{!SSM: inventory/port}/state?t=json"
98+
build-info: "{!SSM: inventory/port}/static/build.content.txt"
99+
start: "{!SSM: inventory/port}/service/start?t=json"
100+
stop: "{!SSM: inventory/port}/service/stop?t=json"
101+
ALB: "{!SSM: colladmin/inventory-service}/state?t=json"
102+
audit:
103+
jsonstatus: "{!SSM: audit/port}/jsonstatus"
104+
state: "{!SSM: audit/port}/state?t=json"
105+
build-info: "{!SSM: audit/port}/static/build.content.txt"
106+
start: "{!SSM: audit/port}/service/start?t=json"
107+
stop: "{!SSM: audit/port}/service/stop?t=json"
108+
replic:
109+
jsonstatus: "{!SSM: replic/port}/jsonstatus"
110+
state: "{!SSM: replic/port}/state?t=json"
111+
build-info: "{!SSM: replic/port}/static/build.content.txt"
112+
start: "{!SSM: replic/port}/service/start?t=json"
113+
stop: "{!SSM: replic/port}/service/stop?t=json"
114+
ui:
115+
state: "/state.json"
116+
audit_rep: "/state-audit-replic.json"
117+
+ALB: "{!ENV: MERRITT_PATH}/state.json"
118+
ldap:
119+
-ALB: "https://{!SSM: ldap/host}"
120+
default:
121+
match: '.*'
122+
endpoints:
123+
ingest:
124+
state: "{!SSM: ingest/port}/state?t=json"
125+
build-info: "{!SSM: ingest/port}/static/build.content.txt"
126+
ALB: "{!SSM: colladmin/ingest-service}state?t=json"
127+
store:
128+
jsonstatus: "{!SSM: store/port}/jsonstatus"
129+
state: "{!SSM: store/port}/state?t=json"
130+
ping: "{!SSM: store/port}/ping?t=json"
131+
hostname: "{!SSM: store/port}/hostname"
132+
build-info: "{!SSM: store/port}/static/build.content.txt"
133+
ALB: "{!SSM: colladmin/storage-service}/state?t=json"
134+
access:
135+
jsonstatus: "{!SSM: store/port}/jsonstatus"
136+
state: "{!SSM: store/port}/state?t=json"
137+
ping: "{!SSM: store/port}/ping?t=json"
138+
hostname: "{!SSM: store/port}/hostname"
139+
build-info: "{!SSM: store/port}/static/build.content.txt"
140+
ALB: "{!SSM: colladmin/access-service}/state?t=json"
141+
inventory:
142+
state: "{!SSM: inventory/port}/mrtinv/state?t=json"
143+
build-info: "{!SSM: inventory/port}/mrtinv/static/build.content.txt"
144+
start: "{!SSM: inventory/port}/mrtinv/service/start?t=json"
145+
stop: "{!SSM: inventory/port}/mrtinv/service/stop?t=json"
146+
ALB: "{!SSM: colladmin/inventory-service}/state?t=json"
147+
audit:
148+
jsonstatus: "{!SSM: audit/port}/mrtaudit/jsonstatus"
149+
state: "{!SSM: audit/port}/mrtaudit/state?t=json"
150+
build-info: "{!SSM: audit/port}/mrtaudit/static/build.content.txt"
151+
start: "{!SSM: audit/port}/mrtaudit/service/start?t=json"
152+
stop: "{!SSM: audit/port}/mrtaudit/service/stop?t=json"
153+
replic:
154+
jsonstatus: "{!SSM: replic/port}/mrtreplic/jsonstatus"
155+
state: "{!SSM: replic/port}/mrtreplic/state?t=json"
156+
build-info: "{!SSM: replic/port}/mrtreplic/static/build.content.txt"
157+
start: "{!SSM: replic/port}/mrtreplic/service/start?t=json"
158+
stop: "{!SSM: replic/port}/mrtreplic/service/stop?t=json"
159+
ui:
160+
state: "/state.json"
161+
audit_rep: "/state-audit-replic.json"
162+
+ALB: "{!ENV: MERRITT_PATH}/state.json"
163+
ldap:
164+
-ALB: "https://{!SSM: ldap/host}"
108165
replic-service: "{!SSM: colladmin/replic-service}"
109166
storage-service: "{!SSM: colladmin/storage-service}"
110167
access-service: "{!SSM: colladmin/access-service}"

0 commit comments

Comments
 (0)