diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 86e3845..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Lint - -on: - push: - pull_request: - -jobs: - lint: - name: Run on Ubuntu - runs-on: ubuntu-latest - steps: - - name: Clone the code - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Run linter - uses: golangci/golangci-lint-action@v8 - with: - version: v2.1.0 diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml deleted file mode 100644 index 68fd1ed..0000000 --- a/.github/workflows/test-e2e.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: E2E Tests - -on: - push: - pull_request: - -jobs: - test-e2e: - name: Run on Ubuntu - runs-on: ubuntu-latest - steps: - - name: Clone the code - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Install the latest version of kind - run: | - curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 - chmod +x ./kind - sudo mv ./kind /usr/local/bin/kind - - - name: Verify kind installation - run: kind version - - - name: Running Test e2e - run: | - go mod tidy - make test-e2e diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index fc2e80d..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Tests - -on: - push: - pull_request: - -jobs: - test: - name: Run on Ubuntu - runs-on: ubuntu-latest - steps: - - name: Clone the code - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Running Tests - run: | - go mod tidy - make test diff --git a/.golangci.yml b/.golangci.yml index e5b21b0..51e331e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,6 +5,7 @@ linters: default: none enable: - copyloopvar + - depguard - dupl - errcheck - ginkgolinter @@ -13,6 +14,7 @@ linters: - govet - ineffassign - lll + - modernize - misspell - nakedret - prealloc @@ -22,10 +24,20 @@ linters: - unparam - unused settings: + depguard: + rules: + forbid-sort-pkg: + deny: + - pkg: sort + desc: Should be replaced with slices package revive: rules: - name: comment-spacings - name: import-shadowing + modernize: + disable: + - omitzero + - newexpr exclusions: generated: lax rules: diff --git a/Makefile b/Makefile index fd8d299..e3ec01b 100644 --- a/Makefile +++ b/Makefile @@ -123,15 +123,18 @@ vet: ## Run go vet against code. ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}') KIND_CLUSTER ?= hyperfleet-operator-test-e2e - # TODO(user): To use a different vendor for e2e tests, modify the setup under 'tests/e2e'. # The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally. # CertManager is installed by default; skip with: # - CERT_MANAGER_INSTALL_SKIP=true +.PHONY: setup-envtest +setup-envtest: $(LOCALBIN) ## Download the envtest binaries (etcd, kube-apiserver) into the local bin directory. + $(SETUP_ENVTEST) use '$(ENVTEST_K8S_VERSION)' --bin-dir $(LOCALBIN) -p path + .PHONY: test -test: manifests generate fmt vet ## Run tests. - KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out +test: manifests generate fmt vet setup-envtest ## Run tests. + KUBEBUILDER_ASSETS="$$($(SETUP_ENVTEST) use '$(ENVTEST_K8S_VERSION)' --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out .PHONY: setup-test-e2e setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist diff --git a/README.md b/README.md index 50bd72e..0488e88 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,15 @@ # hyperfleet-operator -// TODO(user): Add simple overview of use/purpose + +A Kubernetes operator for HyperFleet cluster lifecycle management. ## Description -// TODO(user): An in-depth paragraph about your project and overview of use + +hyperfleet-operator packages and delivers HyperFleet as a standard Kubernetes operator, installed and managed through OLM. It exposes a single cluster-scoped custom resource, `HyperFleetConfig`, as the entire partner-facing surface: install, configure, and observe HyperFleet through that one CR and its status conditions, with everything else the operator manages kept internal. ## Getting Started ### Prerequisites -- go version v1.24.0+ +- go version v1.26.0+ - docker version 17.03+. - kubectl version v1.11.3+. - Access to a Kubernetes v1.11.3+ cluster. diff --git a/config/crd/bases/hyperfleet.redhat.com_hyperfleetconfigs.yaml b/config/crd/bases/hyperfleet.redhat.com_hyperfleetconfigs.yaml new file mode 100644 index 0000000..81d883a --- /dev/null +++ b/config/crd/bases/hyperfleet.redhat.com_hyperfleetconfigs.yaml @@ -0,0 +1,54 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.21.0 + name: hyperfleetconfigs.hyperfleet.redhat.com +spec: + group: hyperfleet.redhat.com + names: + kind: HyperFleetConfig + listKind: HyperFleetConfigList + plural: hyperfleetconfigs + singular: hyperfleetconfig + scope: Namespaced + versions: + - name: v1alpha + schema: + openAPIV3Schema: + description: HyperFleetConfig is the Schema for the hyperfleetconfigs API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: HyperFleetConfigSpec defines the desired state of HyperFleetConfig. + properties: + foo: + description: Foo is an example field of HyperFleetConfig. Edit hyperfleetconfig_types.go + to remove/update + type: string + type: object + status: + description: HyperFleetConfigStatus defines the observed state of HyperFleetConfig. + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index db7eabe..e3e10d9 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -1,11 +1,32 @@ +--- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - labels: - app.kubernetes.io/name: hyperfleet-operator - app.kubernetes.io/managed-by: kustomize name: manager-role rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get", "list", "watch"] +- apiGroups: + - hyperfleet.redhat.com + resources: + - hyperfleetconfigs + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - hyperfleet.redhat.com + resources: + - hyperfleetconfigs/finalizers + verbs: + - update +- apiGroups: + - hyperfleet.redhat.com + resources: + - hyperfleetconfigs/status + verbs: + - get + - patch + - update diff --git a/go.mod b/go.mod index baa5e32..d4b495d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/openshift-hyperfleet/hyperfleet-operator -go 1.24.0 +go 1.26.0 require ( github.com/onsi/ginkgo/v2 v2.22.0 diff --git a/test/utils/utils.go b/test/utils/utils.go index 448055b..45b7f65 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -181,8 +181,7 @@ func LoadImageToKindClusterWithName(name string) error { // according to line breakers, and ignores the empty elements in it. func GetNonEmptyLines(output string) []string { var res []string - elements := strings.Split(output, "\n") - for _, element := range elements { + for element := range strings.SplitSeq(output, "\n") { if element != "" { res = append(res, element) }