Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiclusterhub pkg: added package and unit tests #451

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ linters-settings:
- "github.com/kelseyhightower/envconfig"
- "github.com/red-hat-storage/ocs-operator"
- "github.com/stmcginnis/gofish"
- "github.com/stolostron/multiclusterhub-operator/api/v1"
revive:
rules:
- name: indent-error-flow
Expand Down Expand Up @@ -126,13 +127,10 @@ output:
issues:
include:
- EXC0002 # disable excluding of issues about comments from golint
- EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
- EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
- EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
- EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
exclude-rules:
#- # Exclude some linters from running on tests files.
- path: 'pkg/polarion'
- path: "pkg/polarion"
linters:
- exhaustive



32 changes: 18 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/openshift/cluster-logging-operator v0.0.0-20240606085930-750f369019d4 // release-5.8
github.com/openshift/cluster-nfd-operator v0.0.0-20240604082319-19bf50784aa7
github.com/openshift/cluster-node-tuning-operator v0.0.0-20240606084543-6d2e11aec345
github.com/openshift/hive/apis v0.0.0-20220707210052-4804c09ccc5a
github.com/openshift/hive/apis v0.0.0-20240402204308-5f27f3c5d23e
github.com/openshift/local-storage-operator v0.0.0-20240422172451-2a80d7f6681d // release-4.16
github.com/openshift/machine-config-operator v0.0.1-0.20230811181556-63d7be1ef18b
github.com/openshift/ptp-operator v0.0.0-20240404165119-29a3d7b3d60b
Expand All @@ -46,6 +46,21 @@ require (
sigs.k8s.io/controller-runtime v0.17.5
)

require (
github.com/kelseyhightower/envconfig v1.4.0
github.com/openshift/assisted-service/api v0.0.0
github.com/openshift/assisted-service/models v0.0.0
github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87
github.com/openshift/elasticsearch-operator v0.0.0-20220613183908-e1648e67c298
github.com/red-hat-storage/ocs-operator v0.4.13
github.com/stmcginnis/gofish v0.15.0
github.com/stolostron/multiclusterhub-operator v0.0.0-20240611190757-99792ed9ee61
github.com/stretchr/testify v1.9.0
github.com/vmware-tanzu/velero v1.13.2
golang.org/x/crypto v0.24.0
open-cluster-management.io/api v0.13.0
)

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
Expand Down Expand Up @@ -97,7 +112,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/cel-go v0.18.2 // indirect
github.com/google/cel-go v0.20.1 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
Expand Down Expand Up @@ -128,7 +143,6 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kedacore/keda/v2 v2.14.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/libopenstorage/secrets v0.0.0-20231011182615-5f4b25ceede1 // indirect
Expand All @@ -151,10 +165,6 @@ require (
github.com/oklog/ulid v1.3.1 // indirect
github.com/onsi/gomega v1.33.1 // indirect
github.com/openshift/assisted-service v1.0.10-0.20230830164851-6573b5d7021d // indirect
github.com/openshift/assisted-service/api v0.0.0
github.com/openshift/assisted-service/models v0.0.0
github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87
github.com/openshift/elasticsearch-operator v0.0.0-20220613183908-e1648e67c298
github.com/openshift/library-go v0.0.0-20240419113445-f1541d628746 // indirect
github.com/operator-framework/operator-registry v1.41.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
Expand All @@ -163,8 +173,7 @@ require (
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.53.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/red-hat-storage/ocs-operator v0.4.13
github.com/prometheus/procfs v0.13.0 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/rook/rook/pkg/apis v0.0.0-20231215165123-32de0fb5f69b // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand All @@ -174,17 +183,13 @@ require (
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace // indirect
github.com/stmcginnis/gofish v0.15.0
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/stretchr/testify v1.9.0
github.com/thoas/go-funk v0.9.2 // indirect
github.com/vincent-petithory/dataurl v1.0.0 // indirect
github.com/vmware-tanzu/velero v1.13.2
github.com/xlab/treeprint v1.2.0 // indirect
go.mongodb.org/mongo-driver v1.15.0 // indirect
go.starlark.net v0.0.0-20240123142251-f86470692795 // indirect
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
golang.org/x/crypto v0.24.0
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
Expand All @@ -208,7 +213,6 @@ require (
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-aggregator v0.29.4 // indirect
k8s.io/kube-openapi v0.0.0-20240411171206-dc4e619f62f3 // indirect
open-cluster-management.io/api v0.13.0
sigs.k8s.io/container-object-storage-interface-api v0.1.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kube-storage-version-migrator v0.0.6-0.20230721195810-5c8923c5ff96 // indirect
Expand Down
18 changes: 10 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,8 @@ github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuPGoOVeF2fE4Og9otCc70=
github.com/bshuster-repo/logrus-logstash-hook v1.0.0/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk=
github.com/bshuster-repo/logrus-logstash-hook v1.0.2 h1:JYRWo+QGnQdedgshosug9hxpPYTB9oJ1ZZD3fY31alU=
github.com/bshuster-repo/logrus-logstash-hook v1.0.2/go.mod h1:HgYntJprnHSPaF9VPPPLP1L5S1vMWxRfa1J+vzDrDTw=
github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
Expand Down Expand Up @@ -1227,8 +1227,8 @@ github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9
github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=
github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
github.com/google/cel-go v0.17.7/go.mod h1:HXZKzB0LXqer5lHHgfWAnlYwJaQBDKMjxjulNQzhwhY=
github.com/google/cel-go v0.18.2 h1:L0B6sNBSVmt0OyECi8v6VOS74KOc9W/tLiWKfZABvf4=
github.com/google/cel-go v0.18.2/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg=
github.com/google/cel-go v0.20.1 h1:nDx9r8S3L4pE61eDdt8igGj8rf5kjYR3ILxWIpWNi84=
github.com/google/cel-go v0.20.1/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg=
github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ=
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
Expand Down Expand Up @@ -1674,8 +1674,8 @@ github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87
github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87/go.mod h1:DB/Mf2oTeiAmVVX1gN+NEqweonAPY0TKUwADizj8+ZA=
github.com/openshift/elasticsearch-operator v0.0.0-20220613183908-e1648e67c298 h1:/CbENmI9HuJHd8N/h3eaUkqhHoQjj1BdwIGOF+X3wnM=
github.com/openshift/elasticsearch-operator v0.0.0-20220613183908-e1648e67c298/go.mod h1:6dxhWPY3Wr/0b0eGrFpV7gcyeS+ne48Mo9OQ9dxrLNI=
github.com/openshift/hive/apis v0.0.0-20220707210052-4804c09ccc5a h1:dLIHdqEHpmfzKdAmP0+xWUVAsXcJQxH0hlqDJgs169c=
github.com/openshift/hive/apis v0.0.0-20220707210052-4804c09ccc5a/go.mod h1:XWo9dsulk75E9xkfxS/GNpJrL5UHgn3wuSyPeO39NME=
github.com/openshift/hive/apis v0.0.0-20240402204308-5f27f3c5d23e h1:+3m4QQu5vmDZeDT12zLVxXvPKWiMF4GlZEUyLM4NJxU=
github.com/openshift/hive/apis v0.0.0-20240402204308-5f27f3c5d23e/go.mod h1:aPqNTO2rfKg3uk77cvAMhcSFeoCydSuCg47z/gvRULY=
github.com/openshift/library-go v0.0.0-20240419113445-f1541d628746 h1:MyLp0GgPyIgeVd1scI0iUasVgd6Xpy/t04Rk+I23wRE=
github.com/openshift/library-go v0.0.0-20240419113445-f1541d628746/go.mod h1:m/HsttSi90vSixwoy5mPUBHcZid2YRw/QbsLErLxF9s=
github.com/openshift/local-storage-operator v0.0.0-20240422172451-2a80d7f6681d h1:mt3yAY6v+0YFik/wY79uwkvzBZvVoEIDDUj1Pu68dn0=
Expand Down Expand Up @@ -1771,8 +1771,8 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o=
github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/red-hat-storage/ocs-operator v0.4.13 h1:+FdRGqgewn7v22LvhQUV8iSzLm8d6k4T+zyX0Zjo7qw=
github.com/red-hat-storage/ocs-operator v0.4.13/go.mod h1:92CGJGBXykejC89+h8s0pohpb0JRwfwPE9IwUNF5+sY=
Expand Down Expand Up @@ -1860,6 +1860,8 @@ github.com/stmcginnis/gofish v0.15.0/go.mod h1:BLDSFTp8pDlf/xDbLZa+F7f7eW0E/CHCb
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs=
github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo=
github.com/stolostron/multiclusterhub-operator v0.0.0-20240611190757-99792ed9ee61 h1:Jy9SrUBGc+NmMJhmISXb3bOVKiris72YApfq2n/cc+g=
github.com/stolostron/multiclusterhub-operator v0.0.0-20240611190757-99792ed9ee61/go.mod h1:fVXNVgAb4lcyAurs9qi3UG5bkpRCO2hYmEkj9s9++MY=
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
2 changes: 1 addition & 1 deletion pkg/assisted/agentclusterinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ func (builder *AgentClusterInstallBuilder) getCondition(conditionType string) (*
}

for _, condition := range builder.Object.Status.Conditions {
if condition.Type == conditionType {
if string(condition.Type) == conditionType {
return &condition, nil
}
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import (
agentInstallV1Beta1 "github.com/openshift/assisted-service/api/v1beta1"
hiveV1 "github.com/openshift/hive/apis/hive/v1"
moduleV1Beta1 "github.com/rh-ecosystem-edge/kernel-module-management/api/v1beta1"
mchv1 "github.com/stolostron/multiclusterhub-operator/api/v1"
"k8s.io/client-go/kubernetes/scheme"
coreV1Client "k8s.io/client-go/kubernetes/typed/core/v1"
storageV1Client "k8s.io/client-go/kubernetes/typed/storage/v1"
Expand Down Expand Up @@ -272,6 +273,10 @@ func SetScheme(crScheme *runtime.Scheme) error {
return err
}

if err := mchv1.AddToScheme(crScheme); err != nil {
return err
}

if err := configV1.Install(crScheme); err != nil {
return err
}
Expand Down Expand Up @@ -529,6 +534,8 @@ func GetTestClients(tcp TestClientParams) *Settings {
genericClientObjects = append(genericClientObjects, v)
case *performanceV2.PerformanceProfile:
genericClientObjects = append(genericClientObjects, v)
case *mchv1.MultiClusterHub:
genericClientObjects = append(genericClientObjects, v)
case *tunedv1.Tuned:
genericClientObjects = append(genericClientObjects, v)
case *kedav1alpha1.KedaController:
Expand Down
Loading
Loading