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

Add Support for Observe Only Resources #1726

Closed
turkenh opened this issue Apr 14, 2023 · 5 comments · Fixed by #1744
Closed

Add Support for Observe Only Resources #1726

turkenh opened this issue Apr 14, 2023 · 5 comments · Fixed by #1744
Assignees
Labels
enhancement New feature or request

Comments

@turkenh
Copy link
Collaborator

turkenh commented Apr 14, 2023

What problem are you facing?

We need to add support for Observe Only resources.

See this PR as an example: crossplane-contrib/provider-gcp#503

How could Crossplane help solve your problem?

Add support for observe only resources with a feature flag.

@turkenh turkenh added the enhancement New feature or request label Apr 14, 2023
@chlunde
Copy link
Collaborator

chlunde commented Apr 26, 2023

@turkenh did you do this manually, or scriptet in any way?

@turkenh
Copy link
Collaborator Author

turkenh commented Apr 26, 2023

@turkenh did you do this manually, or scriptet in any way?

@chlunde unfortunately manual.
We have a guide and automation for upjet based ones, which you can still check to get some insights.
But for native ones, adding options to the controllers was manual.

@chlunde
Copy link
Collaborator

chlunde commented Apr 27, 2023

@turkenh OK, I can try to script it, unless you're already working on it?

@chlunde chlunde self-assigned this Apr 27, 2023
chlunde added a commit to chlunde/provider-aws that referenced this issue Apr 27, 2023
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]>
chlunde added a commit to chlunde/provider-aws that referenced this issue Apr 28, 2023
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]>
haarchri pushed a commit to chlunde/provider-aws that referenced this issue Aug 4, 2023
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]>
@github-actions
Copy link

github-actions bot commented Aug 5, 2023

Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.

@github-actions github-actions bot added the stale label Aug 5, 2023
@bobh66
Copy link
Contributor

bobh66 commented Aug 6, 2023

/fresh

@github-actions github-actions bot removed the stale label Aug 7, 2023
haarchri added a commit that referenced this issue Aug 7, 2023
* 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 #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]>
dee0 pushed a commit to dee0sap/provider-aws that referenced this issue Aug 28, 2023
* 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]>
threadproc pushed a commit to swisscom/provider-aws that referenced this issue Sep 1, 2023
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants