Skip to content

Commit

Permalink
Add Support for Observe Only Resources (crossplane-contrib#1744)
Browse files Browse the repository at this point in the history
* crossplane-{tools,runtime}@master, go generate

	go get github.com/crossplane/crossplane-tools@master
	go mod tidy
	make generate # failed

	go get github.com/crossplane/crossplane-runtime@master
	go mod tidy
	make generate # retry, OK

https://github.com/upbound/upjet/blob/main/docs/adding-support-for-observe-only.md

Signed-off-by: Carl Henrik Lunde <[email protected]>

* Add --enable-management-policies flag

Signed-off-by: Carl Henrik Lunde <[email protected]>

* Pass management policy flag to the controllers

Fixes crossplane-contrib#1726

hacked using emacs:

	for f in $(grep -lr 'func Setup' pkg/controller/  ); do emacs --load refactor.el "$f"; done

refactor.el:

	(defun last-macro ()
	  (interactive)
	  (atomic-change-group
		(search-forward "func Setup")
		(search-forward "managed.NewReconciler")
		(search-backward "m")
		(set-mark-command nil)
		(search-forward "(")
		(left-char 1)
		(forward-sexp 1 (point))

		(kill-region nil nil 'region)
		(insert "r")

		(search-backward "return")

		(previous-line 1 1)
		(end-of-line)
		(newline nil 1)
		(insert "r := ")
		(yank nil)
		(newline nil 1)
		(search-backward "r := ")
		(search-forward "resource.ManagedKind")
		(forward-sexp 1 (point))
		(move-end-of-line 1)

		(newline nil 1)
		(insert "reconcilerOpts...")
		(set-mark-command nil)
		(search-backward "managed.NewReconciler")
		(search-forward "(")
		(left-char 1)
		(forward-sexp 1 (point))
		(left-char 1)
		(kill-region nil nil 'region)

		(search-backward "r :=")
		(previous-line 1 1)
		(insert "

	reconcilerOpts := []managed.ReconcilerOption{")
		(yank nil)
		(insert ",
	}

	")
		(insert "if o.Features.Enabled(features.EnableAlphaManagementPolicies) {
			reconcilerOpts = append(reconcilerOpts, managed.WithManagementPolicies())
		}
	")

		(goto-line 1)
		(search-forward "github.com/crossplane-contrib/provider-aws")
		(end-of-line)
		(insert "\n\"github.com/crossplane-contrib/provider-aws/pkg/features\"")

		(save-buffer 1)
		))

	(add-hook 'go-mode-hook #'last-macro)

Signed-off-by: Carl Henrik Lunde <[email protected]>

* feat(bump): bump crossplane-runtime and crospslane-tools

Signed-off-by: Christopher Haar <[email protected]>

* feat(bump): rebase and bump

Signed-off-by: Christopher Haar <[email protected]>

* feat(bump): set up_version v0.18.0 to fits build module

Signed-off-by: Christopher Haar <[email protected]>

* feat(bump): set golangci_version to v1.53.3

Signed-off-by: Christopher Haar <[email protected]>

---------

Signed-off-by: Carl Henrik Lunde <[email protected]>
Signed-off-by: Christopher Haar <[email protected]>
Co-authored-by: Christopher Haar <[email protected]>
  • Loading branch information
2 people authored and dee0sap committed Aug 28, 2023
1 parent c97753a commit 96999c7
Show file tree
Hide file tree
Showing 436 changed files with 11,642 additions and 2,665 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# The main gotchas with this action are that it _only_ supports merge commits,
# and that PRs _must_ be labelled before they're merged to trigger a backport.
open-pr:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: github.event.pull_request.merged
steps:
- name: Checkout
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:

env:
# Common versions
GO_VERSION: '1.18'
GOLANGCI_VERSION: 'v1.47.1'
GO_VERSION: '1.19'
GOLANGCI_VERSION: 'v1.53.3'
DOCKER_BUILDX_VERSION: 'v0.8.2'

# Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run
Expand All @@ -23,7 +23,7 @@ env:

jobs:
detect-noop:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
outputs:
noop: ${{ steps.noop.outputs.should_skip }}
steps:
Expand All @@ -36,7 +36,7 @@ jobs:
do_not_skip: '["workflow_dispatch", "schedule", "push"]'

report-breaking-changes:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'
steps:
Expand All @@ -59,7 +59,7 @@ jobs:
make crddiff
lint:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
version: ${{ env.GOLANGCI_VERSION }}

check-diff:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
run: make check-diff

unit-tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

Expand Down Expand Up @@ -192,7 +192,7 @@ jobs:
file: _output/tests/linux_amd64/coverage.txt

e2e-tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

Expand Down Expand Up @@ -254,7 +254,7 @@ jobs:
run: make e2e USE_HELM3=true

publish-artifacts:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: issue_comment

jobs:
points:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: startsWith(github.event.comment.body, '/points')

steps:
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
# NOTE(negz): See also backport.yml, which is the variant that triggers on PR
# merge rather than on comment.
backport:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/backport')
steps:
- name: Extract Command
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
# Common versions
GO_VERSION: '1.18'
GO_VERSION: '1.19'

# Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run
# a step 'if env.AWS_USR' != ""', so we copy these to succinctly test whether
Expand All @@ -23,7 +23,7 @@ env:

jobs:
promote-artifacts:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
create-tag:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ GO111MODULE = on
# ====================================================================================
# Setup Kubernetes tools

UP_VERSION = v0.13.0
UP_VERSION = v0.18.0
UP_CHANNEL = stable
UPTEST_VERSION = v0.5.0

Expand Down
10 changes: 10 additions & 0 deletions apis/acm/v1alpha1/zz_generated.managed.go

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

10 changes: 10 additions & 0 deletions apis/acm/v1beta1/zz_generated.managed.go

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

20 changes: 20 additions & 0 deletions apis/acmpca/v1alpha1/zz_generated.managed.go

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

20 changes: 20 additions & 0 deletions apis/acmpca/v1beta1/zz_generated.managed.go

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

Loading

0 comments on commit 96999c7

Please sign in to comment.