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 all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
4 changes: 2 additions & 2 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ replace (
require (
github.com/pulumi/pulumi-kubernetes/provider/v2 v2.0.0
github.com/pulumi/pulumi-kubernetes/sdk/v2 v2.4.3
github.com/pulumi/pulumi/pkg/v2 v2.18.1-0.20210120203508-ef66287b7b90
github.com/pulumi/pulumi/sdk/v2 v2.18.1-0.20210120203508-ef66287b7b90
github.com/pulumi/pulumi/pkg/v2 v2.18.3-0.20210126224412-216fd2bed529
github.com/pulumi/pulumi/sdk/v2 v2.18.3-0.20210126224412-216fd2bed529
github.com/stretchr/testify v1.6.1
)
10 changes: 5 additions & 5 deletions tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -899,11 +899,11 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/pulumi/pulumi/pkg/v2 v2.18.1-0.20210120203508-ef66287b7b90 h1:LMnNWqFTmVKJQIfNwCJ9jlcs+hMuN00fMJVtHpsZwGQ=
github.com/pulumi/pulumi/pkg/v2 v2.18.1-0.20210120203508-ef66287b7b90/go.mod h1:bAbzFeU3gHu1diqcckqUqaFf5dP02BfJlP8dnHwm00k=
github.com/pulumi/pulumi/pkg/v2 v2.18.3-0.20210126224412-216fd2bed529 h1:eWGiFS3P+Nw/gG/MSlOiAsRT/ssEi/fh/q1KS9qe8Q8=
github.com/pulumi/pulumi/pkg/v2 v2.18.3-0.20210126224412-216fd2bed529/go.mod h1:bAbzFeU3gHu1diqcckqUqaFf5dP02BfJlP8dnHwm00k=
github.com/pulumi/pulumi/sdk/v2 v2.2.1/go.mod h1:QNbWpL4gvf3X0lUFT7TXA2Jo1ff/Ti2l97AyFGYwvW4=
github.com/pulumi/pulumi/sdk/v2 v2.18.1-0.20210120203508-ef66287b7b90 h1:WisNgaTEbSpCsFm3UD3jgXMbLsIMgata17Og/wGW1Cc=
github.com/pulumi/pulumi/sdk/v2 v2.18.1-0.20210120203508-ef66287b7b90/go.mod h1:fCFhRV6NmidWetmgDPA76efL+s0JqLlS54JJIwfOt+o=
github.com/pulumi/pulumi/sdk/v2 v2.18.3-0.20210126224412-216fd2bed529 h1:PKX++TRfU+a8tG0MajO/ghxEU0DxC8vpc+q9jsXkts4=
github.com/pulumi/pulumi/sdk/v2 v2.18.3-0.20210126224412-216fd2bed529/go.mod h1:fCFhRV6NmidWetmgDPA76efL+s0JqLlS54JJIwfOt+o=
github.com/qri-io/starlib v0.4.2-0.20200213133954-ff2e8cd5ef8d/go.mod h1:7DPO4domFU579Ga6E61sB9VFNaniPVwJP5C4bBCu3wA=
github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:5STLWrekHfjyYwxBRVRXNOSewLJ3PWfDJd1VyTS21fI=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
Expand Down Expand Up @@ -1521,7 +1521,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
helm.sh/helm/v3 v3.5.0/go.mod h1:bjwXfmGAF+SEuJZ2AtN1xmTuz4FqaNYOJrXP+vtj6Tw=
helm.sh/helm/v3 v3.5.1/go.mod h1:bjwXfmGAF+SEuJZ2AtN1xmTuz4FqaNYOJrXP+vtj6Tw=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
2 changes: 1 addition & 1 deletion tests/sdk/python/python_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestGet(t *testing.T) {
if !assert.NoError(t, err) {
t.FailNow()
}
for _, dir := range []string{ "get-old"} {
for _, dir := range []string{"get-old"} {
t.Run(dir, func(t *testing.T) {
options := baseOptions.With(integration.ProgramTestOptions{
ExpectRefreshChanges: true, // CRD changes on refresh
Expand Down