Add support support for Go SDK
@@ -157,6 +157,17 @@ func parseChart(ctx *pulumi.Context, name string, args chartArgs, opts ...pulumi
helmArgs = append(helmArgs, "--namespace", args.Namespace)
}
+ // Check for helm version
+ v3, err := isHelmV3()
+
+ if err != nil {
+ return nil, err
+ }
+
+ if v3 {
+ helmArgs = append(helmArgs, "--include-crds")
+ }
+
helmCmd := exec.Command("helm", helmArgs...)
var stderr bytes.Buffer
helmCmd.Stderr = &stderr
@@ -191,6 +202,35 @@ func yamlDecode(ctx *pulumi.Context, text, namespace string) ([]map[string]inter
return ret.Result, nil
}
+func isHelmV3() (bool, error) {
+
+ /*
+ Helm v2 returns version like this:
+ Client: v2.16.7+g5f2584f
+ Helm v3 returns a version like this:
+ v3.1.2+gd878d4d
+ We can reasonably assume helm v2 if the version starts with Client
+ */
+ helmVerArgs := []string{"version", "--short"}
+ helmVerCmd := exec.Command("helm", helmVerArgs...)
+
+ var stderr bytes.Buffer
+ helmVerCmd.Stderr = &stderr
+
+ version, err := helmVerCmd.Output()
+ if err != nil {
+ return false, errors.Wrap(err, fmt.Sprintf("failed to check helm version: %s", stderr.String()))
+ }
+
+ matched, err := regexp.MatchString(`(?:^|\W)v3.[1-9](?:$|\W)`, string(version))
+ if err != nil {
+ return false, errors.Wrap(err, fmt.Sprintf("failed to perform regex match: %s", stderr.String()))
+ }
+
+ return matched, nil
+
+}
+
func fetch(name string, args fetchArgs) error {
helmArgs := []string{"fetch", name}
