-
Notifications
You must be signed in to change notification settings - Fork 2
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
Allow setting up dependent watches for some resource types, even if dependent watches are disabled #19
Open
misberner
wants to merge
14
commits into
main
Choose a base branch
from
mi/custom-dependent-watches
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Allow setting up dependent watches for some resource types, even if dependent watches are disabled #19
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
963a1cf
Add annotation package docs (#1)
SimonBaeumer a116e55
Fork helm-operator adjustments for CI and documentation (#4)
SimonBaeumer 3d560ce
Updated README (#5)
22a7408
fixed typo in README (#7)
88508a2
Add a WithValueTranslator option to Reconciller. (#6)
porridge c3df552
Pass context to Translate(). (#8)
porridge 7710c0b
Disable scheme registration in SetupWithManager (#10)
SimonBaeumer d81ccf4
Allow adding reconciliation extensions (#9)
misberner 5094baf
Allow limiting the maximum release history on upgrades (#14)
misberner c7be7f8
Allow marking releases stuck in a pending state as failed (#16)
misberner e0130a4
Allow stripping manifest from the CR status (#18)
misberner 7857f66
ROX-7242: Make the operator preserve custom statuses, and allow updat…
misberner c4258db
X-Smart-Branch-Parent: main
e82aeba
allow custom dependent watches
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
upstream-triage: | ||
- "./*" | ||
area/main-binary: | ||
- 'main.go' | ||
- 'internal/**/*' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: [ main ] | ||
- push | ||
|
||
jobs: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,47 @@ | ||
# helm-operator | ||
|
||
[![Build Status](https://github.com/joelanford/helm-operator/workflows/CI/badge.svg?branch=master) | ||
[![Coverage Status](https://coveralls.io/repos/github/joelanford/helm-operator/badge.svg?branch=master)](https://coveralls.io/github/joelanford/helm-operator?branch=master) | ||
![Build Status](https://github.com/stackrox/helm-operator/workflows/CI/badge.svg?branch=main) | ||
|
||
Experimental refactoring of the operator-framework's helm operator. | ||
|
||
## Why a fork? | ||
|
||
The Helm operator type automates Helm chart operations | ||
by mapping the [values](https://helm.sh/docs/chart_template_guide/values_files/) of a Helm chart exactly to a | ||
`CustomResourceDefinition` and defining its watched resources in a `watches.yaml` | ||
[configuration](https://sdk.operatorframework.io/docs/building-operators/helm/tutorial/#watch-the-nginx-cr) file. | ||
|
||
For creating a [Level II+](https://sdk.operatorframework.io/docs/advanced-topics/operator-capabilities/operator-capabilities/) operator | ||
that reuses an already existing Helm chart, we need a [hybrid](https://github.com/operator-framework/operator-sdk/issues/670) | ||
between the Go and Helm operator types. | ||
|
||
The hybrid approach allows adding customizations to the Helm operator, such as: | ||
- value mapping based on cluster state, or | ||
- executing code in specific events. | ||
|
||
## Quick start | ||
|
||
- Add this module as a replace directive to your `go.mod`: | ||
|
||
``` | ||
go mod edit -replace=github.com/joelanford/helm-operator=github.com/stackrox/helm-operator@main | ||
``` | ||
|
||
For example: | ||
|
||
```go | ||
chart, err := loader.Load("path/to/chart") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
reconciler := reconciler.New( | ||
reconciler.WithChart(*chart), | ||
reconciler.WithGroupVersionKind(gvk), | ||
) | ||
|
||
if err := reconciler.SetupWithManager(mgr); err != nil { | ||
panic(fmt.Sprintf("unable to create reconciler: %s", err)) | ||
} | ||
``` | ||
|
||
Experimental refactoring of the operator-framework's helm operator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package extensions | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/go-logr/logr" | ||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
) | ||
|
||
// UpdateStatusFunc is a function that updates an unstructured status. If the status has been modified, | ||
// true must be returned, false otherwise. | ||
type UpdateStatusFunc func(*unstructured.Unstructured) bool | ||
|
||
// ReconcileExtension is an arbitrary extension that can be implemented to run either before | ||
// or after the main Helm reconciliation action. | ||
// An error returned by a ReconcileExtension will cause the Reconcile to fail, unlike a hook error. | ||
type ReconcileExtension func(context.Context, *unstructured.Unstructured, func(UpdateStatusFunc), logr.Logger) error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is confusing to have
watchReleaseResources
andextraWatches
as parameters in one function and letting the caller decide which one to choose.Imho adding two functions with different names delegating to a private
newDependentResourceWatcher
is preferred by me.Writing documentation for it is imho more complex and involves mental overhead to understand the concept to why I should add
extraWatches
if I already added all watched dependencies by settingwatchReleaseResources = true
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But with this change we can no longer separate the "skip dependent watches" and "watch extra resources" parameters. This has to be a single watcher, we cannot just call this function once with
watchReleaseResources = true
and then with the extra watches; if we ever go back to not skipping dependent watches, this would cause two reconciliations for each update to the resources specified here. Maybe not a concern because we would just drop the extra watches then, but it does complicate the option design substantially.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree!