add checkOCI helper method

Signed-off-by: Josh Dolitsky <josh@dolit.ski>
pull/9782/head
Josh Dolitsky 4 years ago
parent a38f56c692
commit fc98f2e6a3
No known key found for this signature in database
GPG Key ID: B2B93673243A65FB

@ -19,7 +19,6 @@ package main
import ( import (
"io" "io"
"log" "log"
"strings"
"time" "time"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -183,10 +182,8 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options
} }
client.ReleaseName = name client.ReleaseName = name
if strings.HasPrefix(chart, "oci://") { if err := checkOCI(chart); err != nil {
if !FeatureGateOCI.IsEnabled() { return nil, err
return nil, FeatureGateOCI.Error()
}
} }
cp, err := client.ChartPathOptions.LocateChart(chart, settings) cp, err := client.ChartPathOptions.LocateChart(chart, settings)

@ -20,7 +20,6 @@ import (
"fmt" "fmt"
"io" "io"
"log" "log"
"strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -65,10 +64,8 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
client.Version = ">0.0.0-0" client.Version = ">0.0.0-0"
} }
if strings.HasPrefix(args[0], "oci://") { if err := checkOCI(args[0]); err != nil {
if !FeatureGateOCI.IsEnabled() { return err
return FeatureGateOCI.Error()
}
} }
for i := 0; i < len(args); i++ { for i := 0; i < len(args); i++ {

@ -262,3 +262,12 @@ func checkForExpiredRepos(repofile string) {
} }
} }
// When dealing with OCI-based charts, ensure that the user has
// enabled the experimental feature gate prior to continuing
func checkOCI(ref string) error {
if registry.IsOCI(ref) && !FeatureGateOCI.IsEnabled() {
return FeatureGateOCI.Error()
}
return nil
}

@ -20,7 +20,6 @@ import (
"fmt" "fmt"
"io" "io"
"log" "log"
"strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -177,10 +176,8 @@ func runShow(args []string, client *action.Show) (string, error) {
client.Version = ">0.0.0-0" client.Version = ">0.0.0-0"
} }
if strings.HasPrefix(args[0], "oci://") { if err := checkOCI(args[0]); err != nil {
if !FeatureGateOCI.IsEnabled() { return "", err
return "", FeatureGateOCI.Error()
}
} }
cp, err := client.ChartPathOptions.LocateChart(args[0], settings) cp, err := client.ChartPathOptions.LocateChart(args[0], settings)

@ -20,7 +20,6 @@ import (
"fmt" "fmt"
"io" "io"
"log" "log"
"strings"
"time" "time"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -84,10 +83,8 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return nil, cobra.ShellCompDirectiveNoFileComp return nil, cobra.ShellCompDirectiveNoFileComp
}, },
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
if strings.HasPrefix(args[1], "oci://") { if err := checkOCI(args[1]); err != nil {
if !FeatureGateOCI.IsEnabled() { return err
return FeatureGateOCI.Error()
}
} }
client.Namespace = settings.Namespace() client.Namespace = settings.Namespace()

Loading…
Cancel
Save