Skip to content

Commit 1d7ea8c

Browse files
committed
feat: simplify security and list structures in profile schema and example
1 parent 88bf851 commit 1d7ea8c

File tree

3 files changed

+48
-60
lines changed

3 files changed

+48
-60
lines changed

apis/nextdnsprofile/composition.yaml

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,25 @@ spec:
4848
{
4949
"name": {{ .observed.composite.resource.spec.name | toJson }}
5050
{{- if .observed.composite.resource.spec.security }},
51-
"security": {{ .observed.composite.resource.spec.security | toJson }}
51+
"security": {
52+
{{- $needsComma := false }}
53+
{{- range $key, $value := .observed.composite.resource.spec.security }}
54+
{{- if ne $key "tlds" }}
55+
{{- if $needsComma }},{{- end }}
56+
{{ $key | toJson }}: {{ $value | toJson }}
57+
{{- $needsComma = true }}
58+
{{- end }}
59+
{{- end }}
60+
{{- if .observed.composite.resource.spec.security.tlds }}
61+
{{- if $needsComma }},{{- end }}
62+
"tlds": [
63+
{{- range $i, $tld := .observed.composite.resource.spec.security.tlds }}
64+
{{- if $i }},{{- end }}
65+
{"id": {{ $tld | toJson }}}
66+
{{- end }}
67+
]
68+
{{- end }}
69+
}
5270
{{- end }}
5371
{{- if .observed.composite.resource.spec.privacy }},
5472
"privacy": {
@@ -84,37 +102,17 @@ spec:
84102
{{- end }}
85103
{{- if .observed.composite.resource.spec.denylist }},
86104
"denylist": [
87-
{{- range $i, $entry := .observed.composite.resource.spec.denylist }}
105+
{{- range $i, $domain := .observed.composite.resource.spec.denylist }}
88106
{{- if $i }},{{- end }}
89-
{{- if kindIs "string" $entry }}
90-
{"id": {{ $entry | toJson }}, "active": true}
91-
{{- else }}
92-
{{- $domain := "" }}
93-
{{- range $key, $value := $entry }}
94-
{{- if ne $key "active" }}
95-
{{- $domain = $key }}
96-
{{- end }}
97-
{{- end }}
98-
{"id": {{ $domain | toJson }}, "active": {{ $entry.active | default true }}}
99-
{{- end }}
107+
{"id": {{ $domain | toJson }}, "active": true}
100108
{{- end }}
101109
]
102110
{{- end }}
103111
{{- if .observed.composite.resource.spec.allowlist }},
104112
"allowlist": [
105-
{{- range $i, $entry := .observed.composite.resource.spec.allowlist }}
113+
{{- range $i, $domain := .observed.composite.resource.spec.allowlist }}
106114
{{- if $i }},{{- end }}
107-
{{- if kindIs "string" $entry }}
108-
{"id": {{ $entry | toJson }}, "active": true}
109-
{{- else }}
110-
{{- $domain := "" }}
111-
{{- range $key, $value := $entry }}
112-
{{- if ne $key "active" }}
113-
{{- $domain = $key }}
114-
{{- end }}
115-
{{- end }}
116-
{"id": {{ $domain | toJson }}, "active": {{ $entry.active | default true }}}
117-
{{- end }}
115+
{"id": {{ $domain | toJson }}, "active": true}
118116
{{- end }}
119117
]
120118
{{- end }}

apis/nextdnsprofile/definition.yaml

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,7 @@ spec:
5959
tlds:
6060
type: array
6161
items:
62-
type: object
63-
properties:
64-
id:
65-
type: string
66-
active:
67-
type: boolean
62+
type: string
6863
typosquatting:
6964
type: boolean
7065
privacy:
@@ -112,25 +107,11 @@ spec:
112107
denylist:
113108
type: array
114109
items:
115-
oneOf:
116-
- type: string
117-
- type: object
118-
properties:
119-
active:
120-
type: boolean
121-
additionalProperties:
122-
type: string
110+
type: string
123111
allowlist:
124112
type: array
125113
items:
126-
oneOf:
127-
- type: string
128-
- type: object
129-
properties:
130-
active:
131-
type: boolean
132-
additionalProperties:
133-
type: string
114+
type: string
134115
settings:
135116
type: object
136117
properties:

example/nextdnsprofile/claim.yaml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@ spec:
1212
privacy:
1313
disguisedTrackers: true
1414
allowAffiliate: false
15+
blocklists:
16+
- oisd
17+
- steven-black
18+
- easyprivacy
19+
- hagezi-multi-pro
1520
natives:
16-
- id: windows
17-
- id: apple
18-
- id: samsung
19-
- id: xiaomi
20-
- id: huawei
21-
- id: alexa
22-
- id: roku
23-
- id: sonos
21+
- windows
22+
- apple
23+
- samsung
24+
- xiaomi
25+
- huawei
26+
- alexa
27+
- roku
28+
- sonos
2429
security:
2530
threatIntelligenceFeeds: true
2631
aiThreatDetection: true
@@ -35,12 +40,16 @@ spec:
3540
parking: true
3641
csam: true
3742
tlds:
38-
- id: ru
39-
- id: ch
40-
- id: pizza
43+
- ru
44+
- ch
45+
- pizza
4146
parentalControl:
4247
safeSearch: false
4348
youtubeRestrictedMode: true
49+
allowlist:
50+
- mixpanel.com
51+
- newrelic.com
52+
- mailchimp.com
53+
- hulu.com
4454
denylist:
45-
- id: accuweather.com
46-
active: true
55+
- accuweather.com

0 commit comments

Comments
 (0)