Skip to content

Commit 3a869ed

Browse files
authored
Merge pull request #29 from datum-cloud/feature/instance-lifecycle-control
feat: Direct lifecycle control of GCP instances
2 parents 4783764 + 30253d5 commit 3a869ed

57 files changed

Lines changed: 5246 additions & 3990 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ jobs:
1818
go-version: '~1.23'
1919

2020
- name: Run linter
21-
uses: golangci/golangci-lint-action@v6
21+
uses: golangci/golangci-lint-action@v7
2222
with:
23-
version: v1.61
23+
version: v2.1.5

.golangci.yml

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
1+
version: "2"
12
run:
2-
timeout: 5m
33
allow-parallel-runners: true
4-
5-
issues:
6-
# don't skip warning about doc comments
7-
# don't exclude the default set of lint
8-
exclude-use-default: false
9-
# restore some of the defaults
10-
# (fill in the rest as needed)
11-
exclude-rules:
12-
- path: "api/*"
13-
linters:
14-
- lll
15-
- path: "internal/*"
16-
linters:
17-
- dupl
18-
- lll
194
linters:
20-
disable-all: true
5+
default: none
216
enable:
7+
- copyloopvar
228
- dupl
239
- errcheck
24-
- copyloopvar
2510
- ginkgolinter
2611
- goconst
2712
- gocyclo
28-
- gofmt
29-
- goimports
30-
- gosimple
3113
- govet
3214
- ineffassign
3315
- lll
@@ -36,12 +18,34 @@ linters:
3618
- prealloc
3719
- revive
3820
- staticcheck
39-
- typecheck
4021
- unconvert
4122
- unparam
4223
- unused
43-
44-
linters-settings:
45-
revive:
24+
settings:
25+
revive:
26+
rules:
27+
- name: comment-spacings
28+
exclusions:
29+
generated: lax
4630
rules:
47-
- name: comment-spacings
31+
- linters:
32+
- lll
33+
path: api/*
34+
- linters:
35+
- dupl
36+
- lll
37+
path: internal/*
38+
paths:
39+
- third_party$
40+
- builtin$
41+
- examples$
42+
formatters:
43+
enable:
44+
- gofmt
45+
- goimports
46+
exclusions:
47+
generated: lax
48+
paths:
49+
- third_party$
50+
- builtin$
51+
- examples$

Makefile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@ help: ## Display this help.
4545

4646
.PHONY: manifests
4747
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
48-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
48+
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./internal/controller/rbac/..." output:crd:artifacts:config=config/crd/bases
49+
$(CONTROLLER_GEN) rbac:roleName=upstream-manager-role crd webhook paths="./internal/controller/rbac/upstream" output:rbac:artifacts:config=config/rbac_upstream
50+
$(CONTROLLER_GEN) rbac:roleName=downstream-manager-role crd webhook paths="./internal/controller/rbac/downstream" output:rbac:artifacts:config=config/rbac_downstream
4951

5052
.PHONY: generate
51-
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
53+
generate: controller-gen defaulter-gen
5254
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
55+
$(DEFAULTER_GEN) ./internal/config --output-file=zz_generated.defaults.go
5356

5457
.PHONY: fmt
5558
fmt: ## Run go fmt against code.
@@ -94,8 +97,7 @@ build: manifests generate fmt vet ## Build manager binary.
9497
.PHONY: run
9598
run: manifests generate fmt vet ## Run a controller from your host.
9699
go run ./cmd/main.go -health-probe-bind-address 0 \
97-
--upstream-kubeconfig=$(shell pwd)/upstream.kubeconfig \
98-
--infra-namespace=default
100+
--server-config ./config/dev/config.yaml
99101

100102
# If you wish to build the manager image targeting other platforms you can use the --platform flag.
101103
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
@@ -165,14 +167,16 @@ $(LOCALBIN):
165167
KUBECTL ?= kubectl
166168
KUSTOMIZE ?= $(LOCALBIN)/kustomize
167169
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
170+
DEFAULTER_GEN ?= $(LOCALBIN)/defaulter-gen
168171
ENVTEST ?= $(LOCALBIN)/setup-envtest
169172
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
170173

171174
## Tool Versions
172175
KUSTOMIZE_VERSION ?= v5.4.3
173176
CONTROLLER_TOOLS_VERSION ?= v0.16.1
177+
DEFAULTER_GEN_VERSION ?= v0.32.3
174178
ENVTEST_VERSION ?= release-0.19
175-
GOLANGCI_LINT_VERSION ?= v1.62.0
179+
GOLANGCI_LINT_VERSION ?= v2.1.5
176180

177181
.PHONY: kustomize
178182
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -184,6 +188,11 @@ controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessar
184188
$(CONTROLLER_GEN): $(LOCALBIN)
185189
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION))
186190

191+
.PHONY: defaulter-gen
192+
defaulter-gen: $(DEFAULTER_GEN) ## Download defaulter-gen locally if necessary.
193+
$(DEFAULTER_GEN): $(LOCALBIN)
194+
$(call go-install-tool,$(DEFAULTER_GEN),k8s.io/code-generator/cmd/defaulter-gen,$(DEFAULTER_GEN_VERSION))
195+
187196
.PHONY: envtest
188197
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary.
189198
$(ENVTEST): $(LOCALBIN)
@@ -192,7 +201,7 @@ $(ENVTEST): $(LOCALBIN)
192201
.PHONY: golangci-lint
193202
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
194203
$(GOLANGCI_LINT): $(LOCALBIN)
195-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
204+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
196205

197206
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
198207
# $1 - target path with name of binary

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ direct VM instance control.
3535
- kubectl version v1.31.0+.
3636
- Access to a Kubernetes v1.31.0+ cluster.
3737

38-
This provider makes use of the [GCP Config Connector][k8s-config-connector]
39-
project to manage resources in GCP. It is expected that the config connector
40-
and associated CRDs have been installed in the cluster.
38+
This provider makes use of [Crossplane][crossplane] to manage resources in GCP.
39+
It is expected that Crossplane and the following Crossplane GCP providers have
40+
been installed in the downstream cluster:
4141

42-
[k8s-config-connector]: https://github.com/GoogleCloudPlatform/k8s-config-connector
42+
- [provider-gcp-cloudplatform](https://marketplace.upbound.io/providers/upbound/provider-gcp-cloudplatform)
43+
- [provider-gcp-compute](https://marketplace.upbound.io/providers/upbound/provider-gcp-compute)
44+
- [provider-gcp-secretmanager](https://marketplace.upbound.io/providers/upbound/provider-gcp-secretmanager)
45+
46+
[crossplane]: https://crossplane.io/
4347

4448
### To Deploy on the cluster
4549

@@ -51,7 +55,7 @@ make docker-build docker-push IMG=<some-registry>/tmp:tag
5155

5256
**NOTE:** This image ought to be published in the personal registry you specified.
5357
And it is required to have access to pull the image from the working environment.
54-
Make sure you have the proper permission to the registry if the above commands dont work.
58+
Make sure you have the proper permission to the registry if the above commands don't work.
5559

5660
**Install the CRDs into the cluster:**
5761

0 commit comments

Comments
 (0)