Skip to content

Commit 963a1cf

Browse files
authored
Add annotation package docs (operator-framework#1)
1 parent 746daba commit 963a1cf

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

pkg/annotation/annotation.go

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,30 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Package annotation allows to set custom install, upgrade or uninstall options on custom resource objects with annotations.
18+
// To create custom annotations implement the Install, Upgrade or Uninstall interface.
19+
//
20+
// Example:
21+
//
22+
// To disable hooks based on annotations the InstallDisableHooks is passed to the reconciler as an option.
23+
//
24+
// r, err := reconciler.New(
25+
// reconciler.WithChart(*w.Chart),
26+
// reconciler.WithGroupVersionKind(w.GroupVersionKind),
27+
// reconciler.WithInstallAnnotations(annotation.InstallDisableHooks{}),
28+
// )
29+
//
30+
// If the reconciler detects an annotation named "helm.sdk.operatorframework.io/install-disable-hooks"
31+
// on the watched custom resource, it sets the install.DisableHooks option to the annotations value. For more information
32+
// take a look at the InstallDisableHooks.InstallOption method.
33+
//
34+
// kind: OperatorHelmKind
35+
// apiVersion: test.example.com/v1
36+
// metadata:
37+
// name: nginx-sample
38+
// annotations:
39+
// "helm.sdk.operatorframework.io/install-disable-hooks": true
40+
//
1741
package annotation
1842

1943
import (
@@ -30,27 +54,24 @@ var (
3054
DefaultUninstallAnnotations = []Uninstall{UninstallDescription{}, UninstallDisableHooks{}}
3155
)
3256

57+
// Install configures an install annotation.
3358
type Install interface {
3459
Name() string
3560
InstallOption(string) helmclient.InstallOption
3661
}
3762

63+
// Upgrade configures an upgrade annotation.
3864
type Upgrade interface {
3965
Name() string
4066
UpgradeOption(string) helmclient.UpgradeOption
4167
}
4268

69+
// Uninstall configures an uninstall annotation.
4370
type Uninstall interface {
4471
Name() string
4572
UninstallOption(string) helmclient.UninstallOption
4673
}
4774

48-
type InstallDisableHooks struct {
49-
CustomName string
50-
}
51-
52-
var _ Install = &InstallDisableHooks{}
53-
5475
const (
5576
defaultDomain = "helm.sdk.operatorframework.io"
5677
defaultInstallDisableHooksName = defaultDomain + "/install-disable-hooks"
@@ -64,6 +85,12 @@ const (
6485
defaultUninstallDescriptionName = defaultDomain + "/uninstall-description"
6586
)
6687

88+
type InstallDisableHooks struct {
89+
CustomName string
90+
}
91+
92+
var _ Install = &InstallDisableHooks{}
93+
6794
func (i InstallDisableHooks) Name() string {
6895
if i.CustomName != "" {
6996
return i.CustomName

0 commit comments

Comments
 (0)