Skip to content

Commit 8db9bb6

Browse files
committed
feat(alb): switch source of templates to yaml to allow comments
1 parent e814b50 commit 8db9bb6

File tree

5 files changed

+116
-159
lines changed

5 files changed

+116
-159
lines changed

internal/cmd/beta/alb/template/template-alb.json

Lines changed: 0 additions & 125 deletions
This file was deleted.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: my-load-balancer
2+
# public ip, must be removed when ephemeral address option is true
3+
externalAddress: 123.123.123.123
4+
5+
# public listening interfaces of the loadbalancer
6+
listeners:
7+
- displayName: listener1
8+
# for plain http the https block must be removed
9+
# http: {}
10+
https:
11+
certificateConfig:
12+
certificateIds:
13+
- cert-1
14+
- cert-2
15+
- cert-3
16+
port: 443
17+
# protocal may be PROTOCOL_HTTPS or PROTOCOL_HTTP
18+
protocol: PROTOCOL_HTTPS
19+
rules:
20+
# fqdn of the virtual host of the load balancer
21+
- host: front.facing.host
22+
http:
23+
subRules:
24+
- cookiePersistence:
25+
name: cookie1
26+
ttl: 120s
27+
headers:
28+
- name: testheader1
29+
exactMatch: X-test-header1
30+
- name: testheader2
31+
exactMatch: X-test-header2
32+
- name: testheader3
33+
exactMatch: X-test-header3
34+
pathPrefix: /foo
35+
queryParameters:
36+
- name: query-param
37+
exactMatch: q
38+
- name: region
39+
exactMatch: region
40+
targetPool: my-target-pool
41+
webSocket: false
42+
networks:
43+
- networkId: 00000000-0000-0000-0000-000000000000
44+
role: ROLE_LISTENERS_AND_TARGETS
45+
- networkId: 00000000-0000-0000-0000-000000000001
46+
role: ROLE_LISTENERS_AND_TARGETS
47+
options:
48+
accessControl:
49+
# which host may access the loadbalancer in prefix notation
50+
allowedSourceRanges:
51+
- 10.100.42.0/24
52+
ephemeralAddress: true
53+
privateNetworkOnly: true
54+
55+
# Enable observability features. Appropriate credentials must be made
56+
# available using the credentials endpoint
57+
# observability:
58+
# logs:
59+
# credentialsRef: my-credentials
60+
# pushUrl: https://my.observability.host/<observability-instance-id>/loki/api/v1/push
61+
# metrics:
62+
# credentialsRef: my-credentials
63+
# pushUrl: https://my.observability.host/<observability-instance-id>/<argus-instance-id>/api/v1/receive
64+
65+
planId: p10
66+
67+
# definition of the backend servers
68+
targetPools:
69+
- name: my-target-pool
70+
activeHealthCheck:
71+
healthyThreshold: 3
72+
httpHealthChecks:
73+
okStatuses:
74+
- "200"
75+
path: /health
76+
interval: 10s
77+
intervalJitter: 3s
78+
timeout: 5s
79+
unhealthyThreshold: 1
80+
targetPort: 5732
81+
targets:
82+
# configuration of the backend servers
83+
- displayName: my-target1
84+
ip: 192.11.2.5
85+
# if the backend servers must be accessed via TLS the following block
86+
# allows defining the TLS configuration
87+
# tlsConfig:
88+
# # A PEM and base64 encoded certificate
89+
# customCa: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tDQpNSUlEbkRDQ0EwS2dBd0lCQWdJUkFNUmhrL3pZWkh5UUVDRjQwd3JrTHMwd0NnWUlLb1pJemowRUF3SXdPekVMDQpNQWtHQTFVRUJoTUNWVk14SGpBY0JnTlZCQW9URlVkdmIyZHNaU0JVY25WemRDQlRaWEoyYVdObGN6RU1NQW9HDQpBMVVFQXhNRFYwVXlNQjRYRFRJMU1ETXlNREV4TWpFeU0xb1hEVEkxTURZeE1qRXhNakV5TWxvd0ZqRVVNQklHDQpBMVVFQXd3TEtpNW5iMjluYkdVdVpHVXdXVEFUQmdjcWhrak9QUUlCQmdncWhrak9QUU1CQndOQ0FBUUtNUldLDQpyZTV2RUtkVkNVam9oSlJxSitZdnJ6Mmg2RlpwTGo4SkpHTUlEajh1VlNzY0MvNG9jOURtRDI1c0ZhWnhlUytRDQozcVpGU1FkamxLTGdaRTdPbzRJQ1NqQ0NBa1l3RGdZRFZSMFBBUUgvQkFRREFnZUFNQk1HQTFVZEpRUU1NQW9HDQpDQ3NHQVFVRkJ3TUJNQXdHQTFVZEV3RUIvd1FDTUFBd0hRWURWUjBPQkJZRUZHQVY3ekQvT0Nvd1RrTmhjNG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ZYbGFJZ3FqV0tFM043VmdPDQpqYWthT1lZcnZmdnVqT0pmTUxwNzlBPT0NCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0NCg==
90+
# enabled: true
91+
# skipCertificateValidation: false

internal/cmd/beta/alb/template/template-pool.json

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
activeHealthCheck:
2+
healthyThreshold: 1
3+
httpHealthChecks:
4+
okStatuses:
5+
- string
6+
path: string
7+
interval: 3s
8+
intervalJitter: 3s
9+
timeout: 3s
10+
unhealthyThreshold: 1
11+
name: my-target-pool
12+
targetPort: 5732
13+
targets:
14+
- displayName: my-target
15+
ip: 192.0.2.5
16+
tlsConfig:
17+
customCa: string
18+
enabled: true
19+
skipCertificateValidation: true

internal/cmd/beta/alb/template/template.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ type inputModel struct {
2929
}
3030

3131
var (
32-
//go:embed template-alb.json
32+
//go:embed template-alb.yaml
3333
templateAlb string
34-
//go:embed template-pool.json
34+
//go:embed template-pool.yaml
3535
templatePool string
3636
)
3737

@@ -69,13 +69,13 @@ func NewCmd(p *print.Printer) *cobra.Command {
6969
target = alb.UpdateTargetPoolPayload{}
7070
}
7171

72-
if model.Format == nil || *model.Format == "json" {
72+
if model.Format == nil || *model.Format == "yaml" {
7373
p.Outputln(template)
74-
} else if *model.Format == "yaml" {
75-
if err := json.Unmarshal([]byte(template), &target); err != nil {
74+
} else if *model.Format == "json" {
75+
if err := yaml.Unmarshal([]byte(template), &target); err != nil {
7676
return fmt.Errorf("cannot unmarshal template: %w", err)
7777
}
78-
encoder := yaml.NewEncoder(os.Stdout, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
78+
encoder := json.NewEncoder(os.Stdout)
7979
if err := encoder.Encode(target); err != nil {
8080
return fmt.Errorf("cannot marshal template to yaml: %w", err)
8181
}

0 commit comments

Comments
 (0)