From b3ced83ac5e9d9a23769b54ab04f74c237befb1c Mon Sep 17 00:00:00 2001 From: Simon Baeumer Date: Tue, 11 May 2021 17:34:51 +0200 Subject: [PATCH 1/2] Add annotation package docs --- pkg/annotation/annotation.go | 39 ++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/pkg/annotation/annotation.go b/pkg/annotation/annotation.go index 329ef1e..7a42b1f 100644 --- a/pkg/annotation/annotation.go +++ b/pkg/annotation/annotation.go @@ -14,6 +14,30 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package annotation allows to set custom install, upgrade or uninstall options on custom resource objects with annotations. +// To create custom annotations implement the Install, Upgrade or Uninstall interface. +// +// Example: +// +// To disable hooks based on annotations the InstallDisableHooks is passed to the reconciler as an option. +// +// r, err := reconciler.New( +// reconciler.WithChart(*w.Chart), +// reconciler.WithGroupVersionKind(w.GroupVersionKind), +// reconciler.WithInstallAnnotations(annotation.InstallDisableHook{}), +// ) +// +// If the reconciler detects an annotation named "helm.sdk.operatorframework.io/install-disable-hooks" +// on the watched custom resource it sets the install.DisableHooks option to the annotations value. For more information +// take a look at the InstallDisableHooks.InstallOption method. +// +// kind: OperatorHelmKind +// apiVersion: test.example.com/v1 +// metadata: +// name: nginx-sample +// annotations: +// "helm.sdk.operatorframework.io/install-disable-hooks": true +// package annotation import ( @@ -30,27 +54,24 @@ var ( DefaultUninstallAnnotations = []Uninstall{UninstallDescription{}, UninstallDisableHooks{}} ) +// Install configures an install annotation. type Install interface { Name() string InstallOption(string) helmclient.InstallOption } +// Upgrade configures an upgrade annotation. type Upgrade interface { Name() string UpgradeOption(string) helmclient.UpgradeOption } +// Uninstall configures an install annotation. type Uninstall interface { Name() string UninstallOption(string) helmclient.UninstallOption } -type InstallDisableHooks struct { - CustomName string -} - -var _ Install = &InstallDisableHooks{} - const ( defaultDomain = "helm.sdk.operatorframework.io" defaultInstallDisableHooksName = defaultDomain + "/install-disable-hooks" @@ -64,6 +85,12 @@ const ( defaultUninstallDescriptionName = defaultDomain + "/uninstall-description" ) +type InstallDisableHooks struct { + CustomName string +} + +var _ Install = &InstallDisableHooks{} + func (i InstallDisableHooks) Name() string { if i.CustomName != "" { return i.CustomName From 1fb158bb52eb9a45d00e2aa187e1e10f23d4d9e0 Mon Sep 17 00:00:00 2001 From: Simon Baeumer Date: Tue, 18 May 2021 14:23:43 +0200 Subject: [PATCH 2/2] fix typos --- pkg/annotation/annotation.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/annotation/annotation.go b/pkg/annotation/annotation.go index 7a42b1f..b286e31 100644 --- a/pkg/annotation/annotation.go +++ b/pkg/annotation/annotation.go @@ -24,11 +24,11 @@ limitations under the License. // r, err := reconciler.New( // reconciler.WithChart(*w.Chart), // reconciler.WithGroupVersionKind(w.GroupVersionKind), -// reconciler.WithInstallAnnotations(annotation.InstallDisableHook{}), +// reconciler.WithInstallAnnotations(annotation.InstallDisableHooks{}), // ) // // If the reconciler detects an annotation named "helm.sdk.operatorframework.io/install-disable-hooks" -// on the watched custom resource it sets the install.DisableHooks option to the annotations value. For more information +// on the watched custom resource, it sets the install.DisableHooks option to the annotations value. For more information // take a look at the InstallDisableHooks.InstallOption method. // // kind: OperatorHelmKind @@ -66,7 +66,7 @@ type Upgrade interface { UpgradeOption(string) helmclient.UpgradeOption } -// Uninstall configures an install annotation. +// Uninstall configures an uninstall annotation. type Uninstall interface { Name() string UninstallOption(string) helmclient.UninstallOption