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

Fixes to allow import of helm release #2136

Merged
merged 3 commits into from
Aug 15, 2022
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,6 +1,7 @@
## Unreleased

- Fix Helm charts being ignored by policy packs. (https://github.com/pulumi/pulumi-kubernetes/pull/2133)
- Fix Helm charts being ignored by policy packs. (https://github.com/pulumi/pulumi-kubernetes/pull/2133)
- Fixes to allow import of helm release (https://github.com/pulumi/pulumi-kubernetes/pull/2136)

## 3.20.3 (August 9, 2022)

Expand Down
18 changes: 14 additions & 4 deletions provider/pkg/provider/helm_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/fs"
"net/url"
"os"
"path/filepath"
Expand Down Expand Up @@ -347,10 +348,18 @@ func (r *helmReleaseProvider) Check(ctx context.Context, req *pulumirpc.CheckReq
}

resourceNames, err := r.computeResourceNames(new)
if err != nil {
if err != nil && errors.Is(err, fs.ErrNotExist) {
// Likely because the chart is not readily available (e.g. import of chart where no repo info is stored).
// Declare bankruptcy in being able to determine the underlying resources and hope for the best
// further down the operations.
resourceNames = nil
} else if err != nil {
return nil, err
}
new.ResourceNames = resourceNames

if len(new.ResourceNames) == 0 {
new.ResourceNames = resourceNames
}
logger.V(9).Infof("New: %+v", new)
news = resource.NewPropertyMap(new)
}
Expand Down Expand Up @@ -389,8 +398,9 @@ func (r *helmReleaseProvider) setDefaults(target resource.PropertyMap) {

skipAwaitVal, ok := target["skipAwait"]
if !ok || (skipAwaitVal.IsBool() && !skipAwaitVal.BoolValue()) {
timeout, has := target["timeout"]
if !has || (timeout.IsNumber() && timeout.NumberValue() == 0) {
// If timeout is specified (even if zero value), use that. Otherwise use default.
_, has := target["timeout"]
if !has {
target["timeout"] = resource.NewNumberProperty(defaultTimeoutSeconds)
}
}
Expand Down
3 changes: 2 additions & 1 deletion tests/sdk/go/helm-release-import/step1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ func main() {
Chart: pulumi.String("nginx"),
Version: pulumi.String("6.0.5"),
Values: pulumi.Map{"service": pulumi.StringMap{"type": pulumi.String("ClusterIP")}},
Timeout: pulumi.Int(300),
// Timeouts are not recorded in the release by Helm either.
Timeout: pulumi.Int(0),
}, pulumi.Import(pulumi.ID(fmt.Sprintf("%s/mynginx", namespace))))
if err != nil {
return err
Expand Down