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

Print warning for Helm resources using unsupported hooks #1460

Merged
merged 5 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- [Go SDK] Fix bug with v1/List in YAML parsing (https://github.com/pulumi/pulumi-kubernetes/pull/1457)
- Fix bug rendering Helm v3 resources that include hooks (https://github.com/pulumi/pulumi-kubernetes/pull/1459)
- Print warning for Helm resources using unsupported hooks (https://github.com/pulumi/pulumi-kubernetes/pull/1460)

## 2.7.8 (January 27, 2021)

Expand Down
7 changes: 7 additions & 0 deletions provider/pkg/metadata/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const (
AnnotationSkipAwait = AnnotationPrefix + "skipAwait"
AnnotationTimeoutSeconds = AnnotationPrefix + "timeoutSeconds"
AnnotationInitialAPIVersion = AnnotationPrefix + "initialApiVersion"

AnnotationHelmHook = "helm.sh/hook"
)

// Annotations for internal Pulumi use only.
Expand All @@ -47,6 +49,11 @@ func IsInternalAnnotation(key string) bool {
return false
}

// IsHelmHookAnnotation returns true if the specified annotation has the `helm.sh/hook` prefix, false otherwise.
func IsHelmHookAnnotation(key string) bool {
return strings.HasPrefix(key, AnnotationHelmHook)
}

// SetAnnotation sets the specified key, value annotation on the provided Unstructured object.
// TODO(levi): This won't work for Pulumi-computed values. https://github.com/pulumi/pulumi-kubernetes/issues/826
func SetAnnotation(obj *unstructured.Unstructured, key, value string) {
Expand Down
14 changes: 13 additions & 1 deletion provider/pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,12 +1034,24 @@ func (k *kubeProvider) Check(ctx context.Context, req *pulumirpc.CheckRequest) (

var failures []*pulumirpc.CheckFailure

// If annotations with a reserved internal prefix exist, ignore them.
hasHelmHook := false
for key := range newInputs.GetAnnotations() {
// If annotations with a reserved internal prefix exist, ignore them.
if metadata.IsInternalAnnotation(key) {
_ = k.host.Log(ctx, diag.Warning, urn,
fmt.Sprintf("ignoring user-specified value for internal annotation %q", key))
}

// If the Helm hook annotation is found, set the hasHelmHook flag.
if has := metadata.IsHelmHookAnnotation(key); has {
hasHelmHook = hasHelmHook || has
}
}
if hasHelmHook {
_ = k.host.Log(ctx, diag.Warning, urn,
"This resource contains Helm hooks that are not currently supported by Pulumi. The resource will"+
"be created, but any hooks will not be executed. Hooks support is tracked at "+
"https://github.com/pulumi/pulumi-kubernetes/issues/555")
}

annotatedInputs, err := legacyInitialAPIVersion(oldInputs, newInputs)
Expand Down