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

Miscelaneous helm release fixes #1826

Merged
merged 2 commits into from
Dec 9, 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## HEAD (Unreleased)
- Helm Release: Helm Release imports support (https://github.com/pulumi/pulumi-kubernetes/pull/1818)

- Helm Release: fix username fetch option (https://github.com/pulumi/pulumi-kubernetes/pull/1824)
- Helm Release: Use URN name as base for autonaming, Drop warning, fix default value for
keyring (https://github.com/pulumi/pulumi-kubernetes/pull/1826)

## 3.12.0 (December 7, 2021)

Expand Down
2 changes: 1 addition & 1 deletion provider/pkg/provider/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type customResourceProvider interface {
// Check validates that the given property bag is valid for a resource of the given type and returns
// the inputs that should be passed to successive calls to Diff, Create, or Update for this
// resource.
Check(ctx context.Context, req *pulumirpc.CheckRequest, displayBetaWarning bool) (*pulumirpc.CheckResponse, error)
Check(ctx context.Context, req *pulumirpc.CheckRequest) (*pulumirpc.CheckResponse, error)
// Diff checks what impacts a hypothetical update will have on the resource's properties.
Diff(ctx context.Context, req *pulumirpc.DiffRequest) (*pulumirpc.DiffResponse, error)
// Create allocates a new instance of the provided resource and returns its unique ID afterwards. (The input ID
Expand Down
9 changes: 3 additions & 6 deletions provider/pkg/provider/helm_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,10 @@ func decodeRelease(pm resource.PropertyMap) (*Release, error) {
return &release, nil
}

func (r *helmReleaseProvider) Check(ctx context.Context, req *pulumirpc.CheckRequest, displayBetaWarning bool) (*pulumirpc.CheckResponse, error) {
func (r *helmReleaseProvider) Check(ctx context.Context, req *pulumirpc.CheckRequest) (*pulumirpc.CheckResponse, error) {
urn := resource.URN(req.GetUrn())
label := fmt.Sprintf("Provider[%s].Check(%s)", r.name, urn)

if displayBetaWarning {
_ = r.host.LogStatus(ctx, diag.Warning, urn, "Helm Release resource is currently in beta and may change. Use in production environments is discouraged.")
}
// Obtain old resource inputs. This is the old version of the resource(s) supplied by the user as
// an update.
oldResInputs := req.GetOlds()
Expand Down Expand Up @@ -303,7 +300,7 @@ func (r *helmReleaseProvider) Check(ctx context.Context, req *pulumirpc.CheckReq
if len(olds.Mappable()) > 0 {
adoptOldNameIfUnnamed(new, old)
}
assignNameIfAutonameable(new, news, "release")
assignNameIfAutonameable(new, news, urn.Name())
r.setDefaults(new)

conf, err := r.getActionConfig(new.Namespace)
Expand Down Expand Up @@ -365,7 +362,7 @@ func (r *helmReleaseProvider) setDefaults(new *Release) {
new.Timeout = defaultTimeoutSeconds
}

if new.Keyring == "" {
if new.Keyring == "" && new.Verify {
new.Keyring = os.ExpandEnv("$HOME/.gnupg/pubring.gpg")
}
}
Expand Down
28 changes: 7 additions & 21 deletions provider/pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ type kubeProvider struct {
suppressDeprecationWarnings bool
suppressHelmHookWarnings bool

suppressHelmReleaseBetaWarning bool
helmDriver string
helmPluginsPath string
helmRegistryConfigPath string
helmRepositoryConfigPath string
helmRepositoryCache string
helmReleaseProvider customResourceProvider
helmDriver string
helmPluginsPath string
helmRegistryConfigPath string
helmRepositoryConfigPath string
helmRepositoryCache string
helmReleaseProvider customResourceProvider

yamlRenderMode bool
yamlDirectory string
Expand Down Expand Up @@ -544,19 +543,6 @@ func (k *kubeProvider) Configure(_ context.Context, req *pulumirpc.ConfigureRequ
}
k.helmRepositoryCache = helmRepositoryCache()

suppressHelmReleaseBetaWarning := func() bool {
if helmReleaseSettings.SuppressBetaWarning != nil {
return *helmReleaseSettings.SuppressBetaWarning
}

// If the provider flag is not set, fall back to the ENV var.
if disabled, exists := os.LookupEnv("PULUMI_K8S_SUPPRESS_HELM_RELEASE_BETA_WARNING"); exists {
return disabled == trueStr
}
return false
}
k.suppressHelmReleaseBetaWarning = suppressHelmReleaseBetaWarning()

// Rather than erroring out on an invalid k8s config, mark the cluster as unreachable and conditionally bail out on
// operations that require a valid cluster. This will allow us to perform invoke operations using the default
// provider.
Expand Down Expand Up @@ -1231,7 +1217,7 @@ func (k *kubeProvider) Check(ctx context.Context, req *pulumirpc.CheckRequest) (

if isHelmRelease(urn) && !hasComputedValue(newInputs) {
if !k.clusterUnreachable {
return k.helmReleaseProvider.Check(ctx, req, !k.suppressHelmReleaseBetaWarning)
return k.helmReleaseProvider.Check(ctx, req)
}
return nil, fmt.Errorf("can't use Helm Release with unreachable cluster. Reason: %q", k.clusterUnreachableReason)
}
Expand Down