Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
09903f44
Commit
09903f44
authored
3 years ago
by
Mahmood Ali
Browse files
Options
Download
Email Patches
Plain Diff
support gateway mesh
parent
f5069abf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
jobspec/parse_service.go
+22
-9
jobspec/parse_service.go
jobspec/parse_test.go
+22
-0
jobspec/parse_test.go
jobspec/test-fixtures/tg-service-connect-gateway-mesh.hcl
+19
-0
jobspec/test-fixtures/tg-service-connect-gateway-mesh.hcl
with
63 additions
and
9 deletions
+63
-9
jobspec/parse_service.go
+
22
-
9
View file @
09903f44
...
...
@@ -227,6 +227,7 @@ func parseGateway(o *ast.ObjectItem) (*api.ConsulGateway, error) {
"proxy"
,
"ingress"
,
"terminating"
,
"mesh"
,
}
if
err
:=
checkHCLKeys
(
o
.
Val
,
valid
);
err
!=
nil
{
...
...
@@ -242,6 +243,7 @@ func parseGateway(o *ast.ObjectItem) (*api.ConsulGateway, error) {
delete
(
m
,
"proxy"
)
delete
(
m
,
"ingress"
)
delete
(
m
,
"terminating"
)
delete
(
m
,
"mesh"
)
dec
,
err
:=
mapstructure
.
NewDecoder
(
&
mapstructure
.
DecoderConfig
{
DecodeHook
:
mapstructure
.
StringToTimeDurationHookFunc
(),
...
...
@@ -275,8 +277,11 @@ func parseGateway(o *ast.ObjectItem) (*api.ConsulGateway, error) {
gateway
.
Proxy
=
proxy
// extract and parse the ingress block
io
:=
listVal
.
Filter
(
"ingress"
)
if
len
(
io
.
Items
)
==
1
{
if
io
:=
listVal
.
Filter
(
"ingress"
);
len
(
io
.
Items
)
>
0
{
if
len
(
io
.
Items
)
>
1
{
return
nil
,
fmt
.
Errorf
(
"ingress, %s"
,
"multiple ingress stanzas not allowed"
)
}
ingress
,
err
:=
parseIngressConfigEntry
(
io
.
Items
[
0
])
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"ingress, %v"
,
err
)
...
...
@@ -284,12 +289,11 @@ func parseGateway(o *ast.ObjectItem) (*api.ConsulGateway, error) {
gateway
.
Ingress
=
ingress
}
if
len
(
io
.
Items
)
>
1
{
return
nil
,
fmt
.
Errorf
(
"ingress, %s"
,
"multiple ingress stanzas not allowed"
)
}
if
to
:=
listVal
.
Filter
(
"terminating"
);
len
(
to
.
Items
)
>
0
{
if
len
(
to
.
Items
)
>
1
{
return
nil
,
fmt
.
Errorf
(
"terminating, %s"
,
"multiple terminating stanzas not allowed"
)
}
to
:=
listVal
.
Filter
(
"terminating"
)
if
len
(
to
.
Items
)
==
1
{
terminating
,
err
:=
parseTerminatingConfigEntry
(
to
.
Items
[
0
])
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"terminating, %v"
,
err
)
...
...
@@ -297,8 +301,17 @@ func parseGateway(o *ast.ObjectItem) (*api.ConsulGateway, error) {
gateway
.
Terminating
=
terminating
}
if
len
(
to
.
Items
)
>
1
{
return
nil
,
fmt
.
Errorf
(
"terminating, %s"
,
"multiple terminating stanzas not allowed"
)
if
mo
:=
listVal
.
Filter
(
"mesh"
);
len
(
mo
.
Items
)
>
0
{
if
len
(
mo
.
Items
)
>
1
{
return
nil
,
fmt
.
Errorf
(
"mesh, %s"
,
"multiple mesh stanzas not allowed"
)
}
// mesh should have no keys
if
err
:=
checkHCLKeys
(
mo
.
Items
[
0
]
.
Val
,
[]
string
{});
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"mesh, %s"
,
err
)
}
gateway
.
Mesh
=
&
api
.
ConsulMeshConfigEntry
{}
}
return
&
gateway
,
nil
...
...
This diff is collapsed.
Click to expand it.
jobspec/parse_test.go
+
22
-
0
View file @
09903f44
...
...
@@ -1584,6 +1584,28 @@ func TestParse(t *testing.T) {
},
false
,
},
{
"tg-service-connect-gateway-mesh.hcl"
,
&
api
.
Job
{
ID
:
stringToPtr
(
"connect_gateway_mesh"
),
Name
:
stringToPtr
(
"connect_gateway_mesh"
),
TaskGroups
:
[]
*
api
.
TaskGroup
{{
Name
:
stringToPtr
(
"group"
),
Services
:
[]
*
api
.
Service
{{
Name
:
"mesh-gateway-service"
,
Connect
:
&
api
.
ConsulConnect
{
Gateway
:
&
api
.
ConsulGateway
{
Proxy
:
&
api
.
ConsulGatewayProxy
{
Config
:
map
[
string
]
interface
{}{
"foo"
:
"bar"
},
},
Mesh
:
&
api
.
ConsulMeshConfigEntry
{},
},
},
}},
}},
},
false
,
},
{
"tg-scaling-policy-minimal.hcl"
,
&
api
.
Job
{
...
...
This diff is collapsed.
Click to expand it.
jobspec/test-fixtures/tg-service-connect-gateway-mesh.hcl
0 → 100644
+
19
-
0
View file @
09903f44
job
"connect_gateway_mesh"
{
group
"group"
{
service
{
name
=
"mesh-gateway-service"
connect
{
gateway
{
proxy
{
config
{
foo
=
"bar"
}
}
mesh
{}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help