Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit 9f7b46e

Browse files
authored
[BUG FIX] Handles Issue 205 (#206)
* initialize fix for #205 * reorder netpol
1 parent b19f650 commit 9f7b46e

File tree

3 files changed

+68
-11
lines changed

3 files changed

+68
-11
lines changed

cmd/autofix_util.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ var identifyingKey = map[string]string{
424424
"options": "name", // PodDNSConfig.options : PodDNSConfigOption.name
425425
// TopologySelectorTerm.matchLabelExpressions : TopologySelectorLabelRequirement.key
426426
"matchLabelExpressions": "key",
427-
"paths": "path", // HTTPIngressRuleValue.paths : HTTPIngressPath.path
428427
"pending": "name", // Initializers.pending : Initializer.name
429428
"readinessGates": "conditionType", // PodSpec.readinessGates : PodReadinessGate.conditionType
430429
// PodAffinity.requiredDuringSchedulingIgnoredDuringExecution : PodAffinityTerm.labelSelector
@@ -559,17 +558,12 @@ func sequenceItemMatch(sequenceKey string, item1, item2 yaml.SequenceItem) bool
559558
// IngressSpec.rules : IngressRule.http
560559
// Role.rules : PolicyRule.resources
561560
case "rules":
562-
// ClusterRole.rules : PolicyRule.resources
563-
// Role.rules : PolicyRule.resources
564-
if mapPairMatch("resources", map1, map2) {
565-
return true
566-
}
567-
// IngressSpec.rules : IngressRule.http
568-
if mapPairMatch("http", map1, map2) {
569-
return true
561+
if val1, index1 := findItemInMapSlice("host", map1); index1 != -1 {
562+
if val2, index2 := findItemInMapSlice("host", map2); index2 != -1 {
563+
return val1.Value == val2.Value
564+
}
565+
return false
570566
}
571-
// IngressSpec.rules : IngressRule.host
572-
return mapPairMatch("host", map1, map2)
573567

574568
// ProjectedVolumeSource.sources
575569
case "sources":

fixtures/autofix-all-resources-fixed_v1.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,38 @@ spec:
216216
automountServiceAccountToken: false
217217
selector: null
218218
status: {}
219+
---
220+
apiVersion: extensions/v1beta1
221+
kind: Ingress
222+
metadata:
223+
name: web
224+
annotations:
225+
kubernetes.io/ingress.class: nginx
226+
kubernetes.io/tls-acme: "false"
227+
labels:
228+
name: web
229+
app: testApp
230+
env: production
231+
spec:
232+
tls:
233+
- hosts:
234+
- testapp.shopifycloud.com
235+
- testapp.shopifyapps.com
236+
secretName: someSecret
237+
rules:
238+
- host: testapp.shopifycloud.com # comment 2
239+
http: # comment 2
240+
paths: # comment 2
241+
- backend: # comment 2
242+
serviceName: web # comment 2
243+
servicePort: 80 # comment 2
244+
- host: testapp.shopifyapps.com # comment
245+
http: # comment
246+
paths: # comment
247+
- backend: # comment
248+
serviceName: web # comment
249+
servicePort: 80 # comment
250+
219251
---
220252
apiVersion: networking.k8s.io/v1
221253
kind: NetworkPolicy

fixtures/autofix-all-resources_v1.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,34 @@ spec:
145145
name: fakeContainerImg
146146
resources: {}
147147
status: {}
148+
---
149+
apiVersion: extensions/v1beta1
150+
kind: Ingress
151+
metadata:
152+
name: web
153+
annotations:
154+
kubernetes.io/ingress.class: nginx
155+
kubernetes.io/tls-acme: "false"
156+
labels:
157+
name: web
158+
app: testApp
159+
env: production
160+
spec:
161+
tls:
162+
- hosts:
163+
- testapp.shopifycloud.com
164+
- testapp.shopifyapps.com
165+
secretName: someSecret
166+
rules:
167+
- host: testapp.shopifycloud.com # comment 2
168+
http: # comment 2
169+
paths: # comment 2
170+
- backend: # comment 2
171+
serviceName: web # comment 2
172+
servicePort: 80 # comment 2
173+
- host: testapp.shopifyapps.com # comment
174+
http: # comment
175+
paths: # comment
176+
- backend: # comment
177+
serviceName: web # comment
178+
servicePort: 80 # comment

0 commit comments

Comments
 (0)