Skip to content

Commit 4cbac54

Browse files
ciaranRocheclaude
andcommitted
HYPERFLEET-1405 - fix: regenerate stale manager RBAC, restore lint rules, fill in README
manager-role still granted get;list;watch on core pods, a leftover from before HyperFleetConfig existed. It never picked up the hyperfleetconfigs CRUD/status/finalizers permissions the controller's kubebuilder:rbac markers declare, so the deployed operator had no access to its own CR. Regenerated via `make manifests`. Also restores the depguard (sort->slices) and modernize lint rules dropped in the operator-sdk re-scaffold, and replaces the placeholder README overview/description with real content. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 921cb47 commit 4cbac54

10 files changed

Lines changed: 103 additions & 92 deletions

File tree

.github/workflows/lint.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/test-e2e.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.golangci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ linters:
55
default: none
66
enable:
77
- copyloopvar
8+
- depguard
89
- dupl
910
- errcheck
1011
- ginkgolinter
@@ -13,6 +14,7 @@ linters:
1314
- govet
1415
- ineffassign
1516
- lll
17+
- modernize
1618
- misspell
1719
- nakedret
1820
- prealloc
@@ -22,10 +24,20 @@ linters:
2224
- unparam
2325
- unused
2426
settings:
27+
depguard:
28+
rules:
29+
forbid-sort-pkg:
30+
deny:
31+
- pkg: sort
32+
desc: Should be replaced with slices package
2533
revive:
2634
rules:
2735
- name: comment-spacings
2836
- name: import-shadowing
37+
modernize:
38+
disable:
39+
- omitzero
40+
- newexpr
2941
exclusions:
3042
generated: lax
3143
rules:

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,16 @@ vet: ## Run go vet against code.
123123
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
124124
KIND_CLUSTER ?= hyperfleet-operator-test-e2e
125125

126-
127126
# TODO(user): To use a different vendor for e2e tests, modify the setup under 'tests/e2e'.
128127
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
129128
# CertManager is installed by default; skip with:
130129
# - CERT_MANAGER_INSTALL_SKIP=true
131130

132131
.PHONY: test
133132
test: manifests generate fmt vet ## Run tests.
134-
KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
133+
ENVTEST_CACHE_DIR=$$(mktemp -d -t envtest-XXXXXXXXXX) && chmod 0700 $$ENVTEST_CACHE_DIR && \
134+
XDG_CACHE_HOME=$$ENVTEST_CACHE_DIR KUBEBUILDER_ASSETS="$$(XDG_CACHE_HOME=$$ENVTEST_CACHE_DIR $(SETUP_ENVTEST) use '$(ENVTEST_K8S_VERSION)' -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out; \
135+
rm -rf $$ENVTEST_CACHE_DIR
135136

136137
.PHONY: setup-test-e2e
137138
setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# hyperfleet-operator
2-
// TODO(user): Add simple overview of use/purpose
2+
3+
A Kubernetes operator for HyperFleet cluster lifecycle management.
34

45
## Description
5-
// TODO(user): An in-depth paragraph about your project and overview of use
6+
7+
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.
68

79
## Getting Started
810

911
### Prerequisites
10-
- go version v1.24.0+
12+
- go version v1.26.0+
1113
- docker version 17.03+.
1214
- kubectl version v1.11.3+.
1315
- Access to a Kubernetes v1.11.3+ cluster.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.21.0
7+
name: hyperfleetconfigs.hyperfleet.redhat.com
8+
spec:
9+
group: hyperfleet.redhat.com
10+
names:
11+
kind: HyperFleetConfig
12+
listKind: HyperFleetConfigList
13+
plural: hyperfleetconfigs
14+
singular: hyperfleetconfig
15+
scope: Namespaced
16+
versions:
17+
- name: v1alpha
18+
schema:
19+
openAPIV3Schema:
20+
description: HyperFleetConfig is the Schema for the hyperfleetconfigs API.
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: HyperFleetConfigSpec defines the desired state of HyperFleetConfig.
41+
properties:
42+
foo:
43+
description: Foo is an example field of HyperFleetConfig. Edit hyperfleetconfig_types.go
44+
to remove/update
45+
type: string
46+
type: object
47+
status:
48+
description: HyperFleetConfigStatus defines the observed state of HyperFleetConfig.
49+
type: object
50+
type: object
51+
served: true
52+
storage: true
53+
subresources:
54+
status: {}

config/rbac/role.yaml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
1+
---
12
apiVersion: rbac.authorization.k8s.io/v1
23
kind: ClusterRole
34
metadata:
4-
labels:
5-
app.kubernetes.io/name: hyperfleet-operator
6-
app.kubernetes.io/managed-by: kustomize
75
name: manager-role
86
rules:
9-
- apiGroups: [""]
10-
resources: ["pods"]
11-
verbs: ["get", "list", "watch"]
7+
- apiGroups:
8+
- hyperfleet.redhat.com
9+
resources:
10+
- hyperfleetconfigs
11+
verbs:
12+
- create
13+
- delete
14+
- get
15+
- list
16+
- patch
17+
- update
18+
- watch
19+
- apiGroups:
20+
- hyperfleet.redhat.com
21+
resources:
22+
- hyperfleetconfigs/finalizers
23+
verbs:
24+
- update
25+
- apiGroups:
26+
- hyperfleet.redhat.com
27+
resources:
28+
- hyperfleetconfigs/status
29+
verbs:
30+
- get
31+
- patch
32+
- update

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/openshift-hyperfleet/hyperfleet-operator
22

3-
go 1.24.0
3+
go 1.26.0
44

55
require (
66
github.com/onsi/ginkgo/v2 v2.22.0

test/utils/utils.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ func LoadImageToKindClusterWithName(name string) error {
181181
// according to line breakers, and ignores the empty elements in it.
182182
func GetNonEmptyLines(output string) []string {
183183
var res []string
184-
elements := strings.Split(output, "\n")
185-
for _, element := range elements {
184+
for element := range strings.SplitSeq(output, "\n") {
186185
if element != "" {
187186
res = append(res, element)
188187
}

0 commit comments

Comments
 (0)