Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request helm#10546 from dperaza4dustbit/move_oci_out_exper…
Browse files Browse the repository at this point in the history
…imental

Move oci out experimental
  • Loading branch information
mattfarina authored Jan 13, 2022
2 parents a27c468 + 9661e39 commit c137bfb
Show file tree
Hide file tree
Showing 38 changed files with 56 additions and 132 deletions.
5 changes: 0 additions & 5 deletions cmd/helm/dependency_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ func TestDependencyBuildCmd(t *testing.T) {
}
ociSrv.Run(t, repotest.WithDependingChart(c))

err = os.Setenv("HELM_EXPERIMENTAL_OCI", "1")
if err != nil {
t.Fatal("failed to set environment variable enabling OCI support")
}

dir := func(p ...string) string {
return filepath.Join(append([]string{srv.Root()}, p...)...)
}
Expand Down
5 changes: 0 additions & 5 deletions cmd/helm/dependency_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ func TestDependencyUpdateCmd(t *testing.T) {
}
ociSrv.Run(t, repotest.WithDependingChart(c))

err = os.Setenv("HELM_EXPERIMENTAL_OCI", "1")
if err != nil {
t.Fatal("failed to set environment variable enabling OCI support")
}

if err := srv.LinkIndices(); err != nil {
t.Fatal(err)
}
Expand Down
13 changes: 0 additions & 13 deletions cmd/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ import (

"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/gates"
"helm.sh/helm/v3/pkg/kube"
kubefake "helm.sh/helm/v3/pkg/kube/fake"
"helm.sh/helm/v3/pkg/release"
"helm.sh/helm/v3/pkg/storage/driver"
)

// FeatureGateOCI is the feature gate for checking if `helm chart` and `helm registry` commands should work
const FeatureGateOCI = gates.Gate("HELM_EXPERIMENTAL_OCI")

var settings = cli.New()

func init() {
Expand Down Expand Up @@ -95,15 +91,6 @@ func main() {
}
}

func checkOCIFeatureGate() func(_ *cobra.Command, _ []string) error {
return func(_ *cobra.Command, _ []string) error {
if !FeatureGateOCI.IsEnabled() {
return FeatureGateOCI.Error()
}
return nil
}
}

// This function loads releases into the memory storage if the
// environment variable is properly set.
func loadReleasesInMemory(actionConfig *action.Configuration) {
Expand Down
4 changes: 0 additions & 4 deletions cmd/helm/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options
}
client.ReleaseName = name

if err := checkOCI(chart); err != nil {
return nil, err
}

cp, err := client.ChartPathOptions.LocateChart(chart, settings)
if err != nil {
return nil, err
Expand Down
4 changes: 0 additions & 4 deletions cmd/helm/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
client.Version = ">0.0.0-0"
}

if err := checkOCI(args[0]); err != nil {
return err
}

for i := 0; i < len(args); i++ {
output, err := client.Run(args[i])
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion cmd/helm/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func TestPullCmd(t *testing.T) {
}
defer srv.Stop()

os.Setenv("HELM_EXPERIMENTAL_OCI", "1")
ociSrv, err := repotest.NewOCIServer(t, srv.Root())
if err != nil {
t.Fatal(err)
Expand Down
13 changes: 5 additions & 8 deletions cmd/helm/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/spf13/cobra"

"helm.sh/helm/v3/cmd/helm/require"
experimental "helm.sh/helm/v3/internal/experimental/action"
"helm.sh/helm/v3/pkg/action"
)

Expand All @@ -35,15 +34,13 @@ it will also be uploaded.
`

func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
client := experimental.NewPushWithOpts(experimental.WithPushConfig(cfg))
client := action.NewPushWithOpts(action.WithPushConfig(cfg))

cmd := &cobra.Command{
Use: "push [chart] [remote]",
Short: "push a chart to remote",
Long: pushDesc,
Hidden: !FeatureGateOCI.IsEnabled(),
PersistentPreRunE: checkOCIFeatureGate(),
Args: require.MinimumNArgs(2),
Use: "push [chart] [remote]",
Short: "push a chart to remote",
Long: pushDesc,
Args: require.MinimumNArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
chartRef := args[0]
remote := args[1]
Expand Down
8 changes: 3 additions & 5 deletions cmd/helm/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ This command consists of multiple subcommands to interact with registries.

func newRegistryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "registry",
Short: "login to or logout from a registry",
Long: registryHelp,
Hidden: !FeatureGateOCI.IsEnabled(),
PersistentPreRunE: checkOCIFeatureGate(),
Use: "registry",
Short: "login to or logout from a registry",
Long: registryHelp,
}
cmd.AddCommand(
newRegistryLoginCmd(cfg, out),
Expand Down
12 changes: 5 additions & 7 deletions cmd/helm/registry_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/spf13/cobra"

"helm.sh/helm/v3/cmd/helm/require"
experimental "helm.sh/helm/v3/internal/experimental/action"
"helm.sh/helm/v3/pkg/action"
)

Expand All @@ -42,11 +41,10 @@ func newRegistryLoginCmd(cfg *action.Configuration, out io.Writer) *cobra.Comman
var passwordFromStdinOpt, insecureOpt bool

cmd := &cobra.Command{
Use: "login [host]",
Short: "login to a registry",
Long: registryLoginDesc,
Args: require.MinimumNArgs(1),
Hidden: !FeatureGateOCI.IsEnabled(),
Use: "login [host]",
Short: "login to a registry",
Long: registryLoginDesc,
Args: require.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
hostname := args[0]

Expand All @@ -55,7 +53,7 @@ func newRegistryLoginCmd(cfg *action.Configuration, out io.Writer) *cobra.Comman
return err
}

return experimental.NewRegistryLogin(cfg).Run(out, hostname, username, password, insecureOpt)
return action.NewRegistryLogin(cfg).Run(out, hostname, username, password, insecureOpt)
},
}

Expand Down
12 changes: 5 additions & 7 deletions cmd/helm/registry_logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/spf13/cobra"

"helm.sh/helm/v3/cmd/helm/require"
experimental "helm.sh/helm/v3/internal/experimental/action"
"helm.sh/helm/v3/pkg/action"
)

Expand All @@ -32,14 +31,13 @@ Remove credentials stored for a remote registry.

func newRegistryLogoutCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return &cobra.Command{
Use: "logout [host]",
Short: "logout from a registry",
Long: registryLogoutDesc,
Args: require.MinimumNArgs(1),
Hidden: !FeatureGateOCI.IsEnabled(),
Use: "logout [host]",
Short: "logout from a registry",
Long: registryLogoutDesc,
Args: require.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
hostname := args[0]
return experimental.NewRegistryLogout(cfg).Run(out, hostname)
return action.NewRegistryLogout(cfg).Run(out, hostname)
},
}
}
12 changes: 1 addition & 11 deletions cmd/helm/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/clientcmd"

"helm.sh/helm/v3/internal/experimental/registry"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/registry"
"helm.sh/helm/v3/pkg/repo"
)

Expand Down Expand Up @@ -193,7 +193,6 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string
newDocsCmd(out),
)

// Add *experimental* subcommands
cmd.AddCommand(
newRegistryCmd(actionConfig, out),
newPushCmd(actionConfig, out),
Expand Down Expand Up @@ -258,12 +257,3 @@ 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
}
4 changes: 0 additions & 4 deletions cmd/helm/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ func runShow(args []string, client *action.Show) (string, error) {
client.Version = ">0.0.0-0"
}

if err := checkOCI(args[0]); err != nil {
return "", err
}

cp, err := client.ChartPathOptions.LocateChart(args[0], settings)
if err != nil {
return "", err
Expand Down
4 changes: 0 additions & 4 deletions cmd/helm/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return nil, cobra.ShellCompDirectiveNoFileComp
},
RunE: func(cmd *cobra.Command, args []string) error {
if err := checkOCI(args[1]); err != nil {
return err
}

client.Namespace = settings.Namespace()

// Fixes #7002 - Support reading values from STDIN for `upgrade` command
Expand Down
10 changes: 1 addition & 9 deletions internal/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@ import (
"github.com/Masterminds/semver/v3"
"github.com/pkg/errors"

"helm.sh/helm/v3/internal/experimental/registry"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/gates"
"helm.sh/helm/v3/pkg/helmpath"
"helm.sh/helm/v3/pkg/provenance"
"helm.sh/helm/v3/pkg/registry"
"helm.sh/helm/v3/pkg/repo"
)

const FeatureGateOCI = gates.Gate("HELM_EXPERIMENTAL_OCI")

// Resolver resolves dependencies from semantic version ranges to a particular version.
type Resolver struct {
chartpath string
Expand Down Expand Up @@ -138,11 +135,6 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
found = false
} else {
version = d.Version
if !FeatureGateOCI.IsEnabled() {
return nil, errors.Wrapf(FeatureGateOCI.Error(),
"repository %s is an OCI registry", d.Repository)
}

// Retrieve list of tags for repository
ref := fmt.Sprintf("%s/%s", strings.TrimPrefix(d.Repository, fmt.Sprintf("%s://", registry.OCIScheme)), d.Name)
tags, err := r.registryClient.Tags(ref)
Expand Down
2 changes: 1 addition & 1 deletion internal/resolver/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"runtime"
"testing"

"helm.sh/helm/v3/internal/experimental/registry"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/registry"
)

func TestResolve(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

"helm.sh/helm/v3/internal/experimental/registry"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/engine"
"helm.sh/helm/v3/pkg/kube"
"helm.sh/helm/v3/pkg/postrender"
"helm.sh/helm/v3/pkg/registry"
"helm.sh/helm/v3/pkg/release"
"helm.sh/helm/v3/pkg/releaseutil"
"helm.sh/helm/v3/pkg/storage"
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (

fakeclientset "k8s.io/client-go/kubernetes/fake"

"helm.sh/helm/v3/internal/experimental/registry"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chartutil"
kubefake "helm.sh/helm/v3/pkg/kube/fake"
"helm.sh/helm/v3/pkg/registry"
"helm.sh/helm/v3/pkg/release"
"helm.sh/helm/v3/pkg/storage"
"helm.sh/helm/v3/pkg/storage/driver"
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"k8s.io/cli-runtime/pkg/resource"
"sigs.k8s.io/yaml"

"helm.sh/helm/v3/internal/experimental/registry"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/cli"
Expand All @@ -47,6 +46,7 @@ import (
"helm.sh/helm/v3/pkg/kube"
kubefake "helm.sh/helm/v3/pkg/kube/fake"
"helm.sh/helm/v3/pkg/postrender"
"helm.sh/helm/v3/pkg/registry"
"helm.sh/helm/v3/pkg/release"
"helm.sh/helm/v3/pkg/releaseutil"
"helm.sh/helm/v3/pkg/repo"
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (

"github.com/pkg/errors"

"helm.sh/helm/v3/internal/experimental/registry"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/downloader"
"helm.sh/helm/v3/pkg/getter"
"helm.sh/helm/v3/pkg/registry"
"helm.sh/helm/v3/pkg/repo"
)

Expand Down
11 changes: 5 additions & 6 deletions internal/experimental/action/push.go → pkg/action/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,25 @@ package action
import (
"strings"

"helm.sh/helm/v3/internal/experimental/pusher"
"helm.sh/helm/v3/internal/experimental/registry"
"helm.sh/helm/v3/internal/experimental/uploader"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/pusher"
"helm.sh/helm/v3/pkg/registry"
"helm.sh/helm/v3/pkg/uploader"
)

// Push is the action for uploading a chart.
//
// It provides the implementation of 'helm push'.
type Push struct {
Settings *cli.EnvSettings
cfg *action.Configuration
cfg *Configuration
}

// PushOpt is a type of function that sets options for a push action.
type PushOpt func(*Push)

// WithPushConfig sets the cfg field on the push configuration object.
func WithPushConfig(cfg *action.Configuration) PushOpt {
func WithPushConfig(cfg *Configuration) PushOpt {
return func(p *Push) {
p.cfg = cfg
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ package action
import (
"io"

"helm.sh/helm/v3/internal/experimental/registry"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/registry"
)

// RegistryLogin performs a registry login operation.
type RegistryLogin struct {
cfg *action.Configuration
cfg *Configuration
}

// NewRegistryLogin creates a new RegistryLogin object with the given configuration.
func NewRegistryLogin(cfg *action.Configuration) *RegistryLogin {
func NewRegistryLogin(cfg *Configuration) *RegistryLogin {
return &RegistryLogin{
cfg: cfg,
}
Expand Down
Loading

0 comments on commit c137bfb

Please sign in to comment.