Skip to content

Commit

Permalink
clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
edcdavid committed Sep 13, 2024
1 parent f188172 commit 79840fc
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 47 deletions.
8 changes: 4 additions & 4 deletions config/samples/oran.openshift.io_v1alpha1_clusterrequest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ spec:
- NTP.server1
- 1.1.1.1
baseDomain: example.com
clusterLabels:
common: "true"
group-du-sno: test
sites: site-sno-du-1
clusterName: site-sno-du-1
extraAnnotations:
AgentClusterInstall:
extra-annotation-key: extra-annotation-value
extraLabels:
AgentClusterInstall:
extra-label-key: extra-label-value
ManagedCluster:
common: "true"
group-du-sno: test
sites: site-sno-du-1
ingressVIPs:
- 192.0.2.3
machineNetwork:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ spec:
description: BaseDomain is the base domain to use for the deployed
cluster.
type: string
clusterLabels:
additionalProperties:
type: string
description: ClusterLabels is used to assign labels to the cluster
to assist with policy binding.
type: object
clusterName:
description: ClusterName is the name of the cluster.
type: string
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
github.com/prometheus/client_golang v1.18.0
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace
github.com/stolostron/siteconfig v0.0.0-20240829200117-2bbb072ca7bf
github.com/stolostron/siteconfig v0.0.0-20240911204707-0bba68d7dcc0
github.com/thoas/go-funk v0.9.3
github.com/xeipuuv/gojsonschema v1.2.0
go.uber.org/mock v0.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace h1:9PNP1jnUjRhfmGMlkXHjYPishpcw4jpSt/V/xYY3FMA=
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/stolostron/siteconfig v0.0.0-20240829200117-2bbb072ca7bf h1:YGcTFhrRp1ozKua9SibeWQoK74pzak8VxBdah5viwxs=
github.com/stolostron/siteconfig v0.0.0-20240829200117-2bbb072ca7bf/go.mod h1:9Pts6mE/54rIWZ9LIa37qO++V3dV3+H61toWYC6kdWM=
github.com/stolostron/siteconfig v0.0.0-20240911204707-0bba68d7dcc0 h1:vUAPqSJN6Y8RQ3p+t+Dxq7zjC7Hiy8dzsZv4NUNCaN0=
github.com/stolostron/siteconfig v0.0.0-20240911204707-0bba68d7dcc0/go.mod h1:9Pts6mE/54rIWZ9LIa37qO++V3dV3+H61toWYC6kdWM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
Expand Down
42 changes: 24 additions & 18 deletions internal/controllers/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,15 @@ properties:
type: array
baseDomain:
type: string
clusterLabels:
additionalProperties:
type: string
type: object
clusterName:
description: ClusterName is the name of the cluster.
type: string
extraLabels:
additionalProperties:
additionalProperties:
type: string
type: object
type: object
extraAnnotations:
additionalProperties:
additionalProperties:
Expand Down Expand Up @@ -591,13 +593,15 @@ properties:
type: array
baseDomain:
type: string
clusterLabels:
additionalProperties:
type: string
type: object
clusterName:
description: ClusterName is the name of the cluster.
type: string
extraLabels:
additionalProperties:
additionalProperties:
type: string
type: object
type: object
extraAnnotations:
additionalProperties:
additionalProperties:
Expand Down Expand Up @@ -743,16 +747,17 @@ nodes:
})

It("Return error if field is of different type", func() {
// clusterLabels is a map instead of list.
// ExtraLabels - ManagedCluster is a map instead of list.
input := `
clusterName: sno1
machineNetwork:
- cidr: 192.0.2.0/24
serviceNetwork:
- cidr: 172.30.0.0/16
clusterLabels:
- label1
- label2
extraLabels:
ManagedCluster:
- label1
- label2
nodes:
- hostName: sno1.example.com
nodeNetwork:
Expand Down Expand Up @@ -784,7 +789,7 @@ nodes:
err = ValidateJsonAgainstJsonSchema(schemaMap, inputMap)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(
ContainSubstring("invalid input: clusterLabels: Invalid type. Expected: object, given: array"))
ContainSubstring("invalid input: extraLabels.ManagedCluster: Invalid type. Expected: object, given: array"))
})

It("Returns success if optional field with required fields is missing", func() {
Expand Down Expand Up @@ -883,7 +888,7 @@ var _ = Describe("RenderTemplateForK8sCR", func() {
"additionalNTPSources": []string{"NTP.server1", "10.16.231.22"},
"apiVIPs": []string{"10.0.0.1", "10.0.0.2"},
"caBundleRef": map[string]interface{}{"name": "my-bundle-ref"},
"clusterLabels": map[string]string{"common": "true", "group-du-sno": "test", "sites": "site-sno-du-1"},
"extraLabels": map[string]map[string]string{"ManagedCluster": {"common": "true", "group-du-sno": "test", "sites": "site-sno-du-1"}},
"clusterType": "SNO",
"clusterNetwork": []map[string]interface{}{{"cidr": "10.128.0.0/14", "hostPrefix": 23}},
"machineNetwork": []map[string]interface{}{{"cidr": "10.16.231.0/24"}},
Expand Down Expand Up @@ -999,10 +1004,11 @@ spec:
caBundleRef:
name: my-bundle-ref
clusterImageSetNameRef: "4.16"
clusterLabels:
common: "true"
group-du-sno: test
sites: site-sno-du-1
extraLabels:
ManagedCluster:
common: "true"
group-du-sno: test
sites: site-sno-du-1
clusterName: site-sno-du-1
clusterNetwork:
- cidr: 10.128.0.0/14
Expand Down
4 changes: 0 additions & 4 deletions internal/files/controllers/clusterinstance-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ spec:
{{- $ref := .Cluster.caBundleRef | validateMapType "spec.caBundleRef" }}
name: "{{ $ref.name | validateNonEmpty "spec.caBundleRef.name" }}"
{{- end }}
{{- if .Cluster.clusterLabels }}
clusterLabels:
{{ .Cluster.clusterLabels | toYaml | indent 4 }}
{{- end }}
{{- if .Cluster.clusterType }}
clusterType: "{{ .Cluster.clusterType }}"
{{- end }}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 79840fc

Please sign in to comment.