could remove embedded field X from selector

Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
pull/30752/head
Benoit Tigeot 5 months ago
parent b2ac216763
commit a9b7732367
No known key found for this signature in database
GPG Key ID: 8E6D4FC8AEBDA62C

@ -143,19 +143,19 @@ func NewInstall(cfg *Configuration) *Install {
in := &Install{ in := &Install{
cfg: cfg, cfg: cfg,
} }
in.ChartPathOptions.registryClient = cfg.RegistryClient in.registryClient = cfg.RegistryClient
return in return in
} }
// SetRegistryClient sets the registry client for the install action // SetRegistryClient sets the registry client for the install action
func (i *Install) SetRegistryClient(registryClient *registry.Client) { func (i *Install) SetRegistryClient(registryClient *registry.Client) {
i.ChartPathOptions.registryClient = registryClient i.registryClient = registryClient
} }
// GetRegistryClient get the registry client. // GetRegistryClient get the registry client.
func (i *Install) GetRegistryClient() *registry.Client { func (i *Install) GetRegistryClient() *registry.Client {
return i.ChartPathOptions.registryClient return i.registryClient
} }
func (i *Install) installCRDs(crds []chart.CRD) error { func (i *Install) installCRDs(crds []chart.CRD) error {

@ -69,14 +69,14 @@ func NewShow(output ShowOutputFormat, cfg *Configuration) *Show {
sh := &Show{ sh := &Show{
OutputFormat: output, OutputFormat: output,
} }
sh.ChartPathOptions.registryClient = cfg.RegistryClient sh.registryClient = cfg.RegistryClient
return sh return sh
} }
// SetRegistryClient sets the registry client to use when pulling a chart from a registry. // SetRegistryClient sets the registry client to use when pulling a chart from a registry.
func (s *Show) SetRegistryClient(client *registry.Client) { func (s *Show) SetRegistryClient(client *registry.Client) {
s.ChartPathOptions.registryClient = client s.registryClient = client
} }
// Run executes 'helm show' against the given release. // Run executes 'helm show' against the given release.

@ -132,14 +132,14 @@ func NewUpgrade(cfg *Configuration) *Upgrade {
up := &Upgrade{ up := &Upgrade{
cfg: cfg, cfg: cfg,
} }
up.ChartPathOptions.registryClient = cfg.RegistryClient up.registryClient = cfg.RegistryClient
return up return up
} }
// SetRegistryClient sets the registry client to use when fetching charts. // SetRegistryClient sets the registry client to use when fetching charts.
func (u *Upgrade) SetRegistryClient(client *registry.Client) { func (u *Upgrade) SetRegistryClient(client *registry.Client) {
u.ChartPathOptions.registryClient = client u.registryClient = client
} }
// Run executes the upgrade on the given release. // Run executes the upgrade on the given release.

@ -130,8 +130,8 @@ func Save(c *chart.Chart, outDir string) (string, error) {
// Wrap in gzip writer // Wrap in gzip writer
zipper := gzip.NewWriter(f) zipper := gzip.NewWriter(f)
zipper.Header.Extra = headerBytes zipper.Extra = headerBytes
zipper.Header.Comment = "Helm" zipper.Comment = "Helm"
// Wrap in tar writer // Wrap in tar writer
twriter := tar.NewWriter(zipper) twriter := tar.NewWriter(zipper)

@ -260,7 +260,7 @@ func compVersionFlag(chartRef string, _ string) ([]string, cobra.ShellCompDirect
var versions []string var versions []string
if indexFile, err := repo.LoadIndexFile(path); err == nil { if indexFile, err := repo.LoadIndexFile(path); err == nil {
for _, details := range indexFile.Entries[chartName] { for _, details := range indexFile.Entries[chartName] {
appVersion := details.Metadata.AppVersion appVersion := details.AppVersion
appVersionDesc := "" appVersionDesc := ""
if appVersion != "" { if appVersion != "" {
appVersionDesc = fmt.Sprintf("App: %s, ", appVersion) appVersionDesc = fmt.Sprintf("App: %s, ", appVersion)
@ -271,10 +271,10 @@ func compVersionFlag(chartRef string, _ string) ([]string, cobra.ShellCompDirect
createdDesc = fmt.Sprintf("Created: %s ", created) createdDesc = fmt.Sprintf("Created: %s ", created)
} }
deprecated := "" deprecated := ""
if details.Metadata.Deprecated { if details.Deprecated {
deprecated = "(deprecated)" deprecated = "(deprecated)"
} }
versions = append(versions, fmt.Sprintf("%s\t%s%s%s", details.Metadata.Version, appVersionDesc, createdDesc, deprecated)) versions = append(versions, fmt.Sprintf("%s\t%s%s%s", details.Version, appVersionDesc, createdDesc, deprecated))
} }
} }

@ -242,7 +242,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options
} }
client.ReleaseName = name client.ReleaseName = name
cp, err := client.ChartPathOptions.LocateChart(chart, settings) cp, err := client.LocateChart(chart, settings)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -279,7 +279,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options
man := &downloader.Manager{ man := &downloader.Manager{
Out: out, Out: out,
ChartPath: cp, ChartPath: cp,
Keyring: client.ChartPathOptions.Keyring, Keyring: client.Keyring,
SkipUpdate: false, SkipUpdate: false,
Getters: p, Getters: p,
RepositoryConfig: settings.RepositoryConfig, RepositoryConfig: settings.RepositoryConfig,

@ -218,7 +218,7 @@ func runShow(args []string, client *action.Show) (string, error) {
client.Version = ">0.0.0-0" client.Version = ">0.0.0-0"
} }
cp, err := client.ChartPathOptions.LocateChart(args[0], settings) cp, err := client.LocateChart(args[0], settings)
if err != nil { if err != nil {
return "", err return "", err
} }

@ -178,7 +178,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
client.Version = ">0.0.0-0" client.Version = ">0.0.0-0"
} }
chartPath, err := client.ChartPathOptions.LocateChart(args[1], settings) chartPath, err := client.LocateChart(args[1], settings)
if err != nil { if err != nil {
return err return err
} }
@ -205,7 +205,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
man := &downloader.Manager{ man := &downloader.Manager{
Out: out, Out: out,
ChartPath: chartPath, ChartPath: chartPath,
Keyring: client.ChartPathOptions.Keyring, Keyring: client.Keyring,
SkipUpdate: false, SkipUpdate: false,
Getters: p, Getters: p,
RepositoryConfig: settings.RepositoryConfig, RepositoryConfig: settings.RepositoryConfig,

@ -288,8 +288,8 @@ func (c *ReadyChecker) deploymentReady(rs *appsv1.ReplicaSet, dep *appsv1.Deploy
return false return false
} }
// Verify the generation observed by the deployment controller matches the spec generation // Verify the generation observed by the deployment controller matches the spec generation
if dep.Status.ObservedGeneration != dep.ObjectMeta.Generation { if dep.Status.ObservedGeneration != dep.Generation {
slog.Debug("Deployment is not ready, observedGeneration does not match spec generation", "namespace", dep.GetNamespace(), "name", dep.GetName(), "actualGeneration", dep.Status.ObservedGeneration, "expectedGeneration", dep.ObjectMeta.Generation) slog.Debug("Deployment is not ready, observedGeneration does not match spec generation", "namespace", dep.GetNamespace(), "name", dep.GetName(), "actualGeneration", dep.Status.ObservedGeneration, "expectedGeneration", dep.Generation)
return false return false
} }
@ -304,8 +304,8 @@ func (c *ReadyChecker) deploymentReady(rs *appsv1.ReplicaSet, dep *appsv1.Deploy
func (c *ReadyChecker) daemonSetReady(ds *appsv1.DaemonSet) bool { func (c *ReadyChecker) daemonSetReady(ds *appsv1.DaemonSet) bool {
// Verify the generation observed by the daemonSet controller matches the spec generation // Verify the generation observed by the daemonSet controller matches the spec generation
if ds.Status.ObservedGeneration != ds.ObjectMeta.Generation { if ds.Status.ObservedGeneration != ds.Generation {
slog.Debug("DaemonSet is not ready, observedGeneration does not match spec generation", "namespace", ds.GetNamespace(), "name", ds.GetName(), "observedGeneration", ds.Status.ObservedGeneration, "expectedGeneration", ds.ObjectMeta.Generation) slog.Debug("DaemonSet is not ready, observedGeneration does not match spec generation", "namespace", ds.GetNamespace(), "name", ds.GetName(), "observedGeneration", ds.Status.ObservedGeneration, "expectedGeneration", ds.Generation)
return false return false
} }
@ -381,8 +381,8 @@ func (c *ReadyChecker) crdReady(crd apiextv1.CustomResourceDefinition) bool {
func (c *ReadyChecker) statefulSetReady(sts *appsv1.StatefulSet) bool { func (c *ReadyChecker) statefulSetReady(sts *appsv1.StatefulSet) bool {
// Verify the generation observed by the statefulSet controller matches the spec generation // Verify the generation observed by the statefulSet controller matches the spec generation
if sts.Status.ObservedGeneration != sts.ObjectMeta.Generation { if sts.Status.ObservedGeneration != sts.Generation {
slog.Debug("StatefulSet is not ready, observedGeneration doest not match spec generation", "namespace", sts.GetNamespace(), "name", sts.GetName(), "actualGeneration", sts.Status.ObservedGeneration, "expectedGeneration", sts.ObjectMeta.Generation) slog.Debug("StatefulSet is not ready, observedGeneration doest not match spec generation", "namespace", sts.GetNamespace(), "name", sts.GetName(), "actualGeneration", sts.Status.ObservedGeneration, "expectedGeneration", sts.Generation)
return false return false
} }
@ -435,8 +435,8 @@ func (c *ReadyChecker) statefulSetReady(sts *appsv1.StatefulSet) bool {
func (c *ReadyChecker) replicationControllerReady(rc *corev1.ReplicationController) bool { func (c *ReadyChecker) replicationControllerReady(rc *corev1.ReplicationController) bool {
// Verify the generation observed by the replicationController controller matches the spec generation // Verify the generation observed by the replicationController controller matches the spec generation
if rc.Status.ObservedGeneration != rc.ObjectMeta.Generation { if rc.Status.ObservedGeneration != rc.Generation {
slog.Debug("ReplicationController is not ready, observedGeneration doest not match spec generation", "namespace", rc.GetNamespace(), "name", rc.GetName(), "actualGeneration", rc.Status.ObservedGeneration, "expectedGeneration", rc.ObjectMeta.Generation) slog.Debug("ReplicationController is not ready, observedGeneration doest not match spec generation", "namespace", rc.GetNamespace(), "name", rc.GetName(), "actualGeneration", rc.Status.ObservedGeneration, "expectedGeneration", rc.Generation)
return false return false
} }
return true return true
@ -444,8 +444,8 @@ func (c *ReadyChecker) replicationControllerReady(rc *corev1.ReplicationControll
func (c *ReadyChecker) replicaSetReady(rs *appsv1.ReplicaSet) bool { func (c *ReadyChecker) replicaSetReady(rs *appsv1.ReplicaSet) bool {
// Verify the generation observed by the replicaSet controller matches the spec generation // Verify the generation observed by the replicaSet controller matches the spec generation
if rs.Status.ObservedGeneration != rs.ObjectMeta.Generation { if rs.Status.ObservedGeneration != rs.Generation {
slog.Debug("ReplicaSet is not ready, observedGeneration doest not match spec generation", "namespace", rs.GetNamespace(), "name", rs.GetName(), "actualGeneration", rs.Status.ObservedGeneration, "expectedGeneration", rs.ObjectMeta.Generation) slog.Debug("ReplicaSet is not ready, observedGeneration doest not match spec generation", "namespace", rs.GetNamespace(), "name", rs.GetName(), "actualGeneration", rs.Status.ObservedGeneration, "expectedGeneration", rs.Generation)
return false return false
} }
return true return true

@ -157,7 +157,7 @@ func (i *HTTPInstaller) Update() error {
// Path is overridden because we want to join on the plugin name not the file name // Path is overridden because we want to join on the plugin name not the file name
func (i HTTPInstaller) Path() string { func (i HTTPInstaller) Path() string {
if i.base.Source == "" { if i.Source == "" {
return "" return ""
} }
return helmpath.DataPath("plugins", i.PluginName) return helmpath.DataPath("plugins", i.PluginName)

@ -123,17 +123,17 @@ func TestIndexFile(t *testing.T) {
} }
cv, err := i.Get("setter", "0.1.9") cv, err := i.Get("setter", "0.1.9")
if err == nil && !strings.Contains(cv.Metadata.Version, "0.1.9") { if err == nil && !strings.Contains(cv.Version, "0.1.9") {
t.Errorf("Unexpected version: %s", cv.Metadata.Version) t.Errorf("Unexpected version: %s", cv.Version)
} }
cv, err = i.Get("setter", "0.1.9+alpha") cv, err = i.Get("setter", "0.1.9+alpha")
if err != nil || cv.Metadata.Version != "0.1.9+alpha" { if err != nil || cv.Version != "0.1.9+alpha" {
t.Errorf("Expected version: 0.1.9+alpha") t.Errorf("Expected version: 0.1.9+alpha")
} }
cv, err = i.Get("setter", "0.1.8") cv, err = i.Get("setter", "0.1.8")
if err != nil || cv.Metadata.Version != "0.1.8" { if err != nil || cv.Version != "0.1.8" {
t.Errorf("Expected version: 0.1.8") t.Errorf("Expected version: 0.1.8")
} }
} }

@ -78,7 +78,7 @@ func (cfgmaps *ConfigMaps) Get(key string) (*rspb.Release, error) {
slog.Debug("failed to decode data", "key", key, slog.Any("error", err)) slog.Debug("failed to decode data", "key", key, slog.Any("error", err))
return nil, err return nil, err
} }
r.Labels = filterSystemLabels(obj.ObjectMeta.Labels) r.Labels = filterSystemLabels(obj.Labels)
// return the release object // return the release object
return r, nil return r, nil
} }
@ -107,7 +107,7 @@ func (cfgmaps *ConfigMaps) List(filter func(*rspb.Release) bool) ([]*rspb.Releas
continue continue
} }
rls.Labels = item.ObjectMeta.Labels rls.Labels = item.Labels
if filter(rls) { if filter(rls) {
results = append(results, rls) results = append(results, rls)
@ -146,7 +146,7 @@ func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, err
slog.Debug("failed to decode release", slog.Any("error", err)) slog.Debug("failed to decode release", slog.Any("error", err))
continue continue
} }
rls.Labels = item.ObjectMeta.Labels rls.Labels = item.Labels
results = append(results, rls) results = append(results, rls)
} }
return results, nil return results, nil

@ -130,7 +130,7 @@ func (mock *MockConfigMapsInterface) List(_ context.Context, opts metav1.ListOpt
} }
for _, cfgmap := range mock.objects { for _, cfgmap := range mock.objects {
if labelSelector.Matches(kblabels.Set(cfgmap.ObjectMeta.Labels)) { if labelSelector.Matches(kblabels.Set(cfgmap.Labels)) {
list.Items = append(list.Items, *cfgmap) list.Items = append(list.Items, *cfgmap)
} }
} }
@ -139,7 +139,7 @@ func (mock *MockConfigMapsInterface) List(_ context.Context, opts metav1.ListOpt
// Create creates a new ConfigMap. // Create creates a new ConfigMap.
func (mock *MockConfigMapsInterface) Create(_ context.Context, cfgmap *v1.ConfigMap, _ metav1.CreateOptions) (*v1.ConfigMap, error) { func (mock *MockConfigMapsInterface) Create(_ context.Context, cfgmap *v1.ConfigMap, _ metav1.CreateOptions) (*v1.ConfigMap, error) {
name := cfgmap.ObjectMeta.Name name := cfgmap.Name
if object, ok := mock.objects[name]; ok { if object, ok := mock.objects[name]; ok {
return object, apierrors.NewAlreadyExists(v1.Resource("tests"), name) return object, apierrors.NewAlreadyExists(v1.Resource("tests"), name)
} }
@ -149,7 +149,7 @@ func (mock *MockConfigMapsInterface) Create(_ context.Context, cfgmap *v1.Config
// Update updates a ConfigMap. // Update updates a ConfigMap.
func (mock *MockConfigMapsInterface) Update(_ context.Context, cfgmap *v1.ConfigMap, _ metav1.UpdateOptions) (*v1.ConfigMap, error) { func (mock *MockConfigMapsInterface) Update(_ context.Context, cfgmap *v1.ConfigMap, _ metav1.UpdateOptions) (*v1.ConfigMap, error) {
name := cfgmap.ObjectMeta.Name name := cfgmap.Name
if _, ok := mock.objects[name]; !ok { if _, ok := mock.objects[name]; !ok {
return nil, apierrors.NewNotFound(v1.Resource("tests"), name) return nil, apierrors.NewNotFound(v1.Resource("tests"), name)
} }
@ -216,7 +216,7 @@ func (mock *MockSecretsInterface) List(_ context.Context, opts metav1.ListOption
} }
for _, secret := range mock.objects { for _, secret := range mock.objects {
if labelSelector.Matches(kblabels.Set(secret.ObjectMeta.Labels)) { if labelSelector.Matches(kblabels.Set(secret.Labels)) {
list.Items = append(list.Items, *secret) list.Items = append(list.Items, *secret)
} }
} }
@ -225,7 +225,7 @@ func (mock *MockSecretsInterface) List(_ context.Context, opts metav1.ListOption
// Create creates a new Secret. // Create creates a new Secret.
func (mock *MockSecretsInterface) Create(_ context.Context, secret *v1.Secret, _ metav1.CreateOptions) (*v1.Secret, error) { func (mock *MockSecretsInterface) Create(_ context.Context, secret *v1.Secret, _ metav1.CreateOptions) (*v1.Secret, error) {
name := secret.ObjectMeta.Name name := secret.Name
if object, ok := mock.objects[name]; ok { if object, ok := mock.objects[name]; ok {
return object, apierrors.NewAlreadyExists(v1.Resource("tests"), name) return object, apierrors.NewAlreadyExists(v1.Resource("tests"), name)
} }
@ -235,7 +235,7 @@ func (mock *MockSecretsInterface) Create(_ context.Context, secret *v1.Secret, _
// Update updates a Secret. // Update updates a Secret.
func (mock *MockSecretsInterface) Update(_ context.Context, secret *v1.Secret, _ metav1.UpdateOptions) (*v1.Secret, error) { func (mock *MockSecretsInterface) Update(_ context.Context, secret *v1.Secret, _ metav1.UpdateOptions) (*v1.Secret, error) {
name := secret.ObjectMeta.Name name := secret.Name
if _, ok := mock.objects[name]; !ok { if _, ok := mock.objects[name]; !ok {
return nil, apierrors.NewNotFound(v1.Resource("tests"), name) return nil, apierrors.NewNotFound(v1.Resource("tests"), name)
} }

@ -72,7 +72,7 @@ func (secrets *Secrets) Get(key string) (*rspb.Release, error) {
} }
// found the secret, decode the base64 data string // found the secret, decode the base64 data string
r, err := decodeRelease(string(obj.Data["release"])) r, err := decodeRelease(string(obj.Data["release"]))
r.Labels = filterSystemLabels(obj.ObjectMeta.Labels) r.Labels = filterSystemLabels(obj.Labels)
return r, errors.Wrapf(err, "get: failed to decode data %q", key) return r, errors.Wrapf(err, "get: failed to decode data %q", key)
} }
@ -99,7 +99,7 @@ func (secrets *Secrets) List(filter func(*rspb.Release) bool) ([]*rspb.Release,
continue continue
} }
rls.Labels = item.ObjectMeta.Labels rls.Labels = item.Labels
if filter(rls) { if filter(rls) {
results = append(results, rls) results = append(results, rls)
@ -137,7 +137,7 @@ func (secrets *Secrets) Query(labels map[string]string) ([]*rspb.Release, error)
slog.Debug("failed to decode release", "key", item.Name, slog.Any("error", err)) slog.Debug("failed to decode release", "key", item.Name, slog.Any("error", err))
continue continue
} }
rls.Labels = item.ObjectMeta.Labels rls.Labels = item.Labels
results = append(results, rls) results = append(results, rls)
} }
return results, nil return results, nil

@ -88,14 +88,14 @@ func (s *Storage) Delete(name string, version int) (*rspb.Release, error) {
// storage backend fails to retrieve the releases. // storage backend fails to retrieve the releases.
func (s *Storage) ListReleases() ([]*rspb.Release, error) { func (s *Storage) ListReleases() ([]*rspb.Release, error) {
slog.Debug("listing all releases in storage") slog.Debug("listing all releases in storage")
return s.Driver.List(func(_ *rspb.Release) bool { return true }) return s.List(func(_ *rspb.Release) bool { return true })
} }
// ListUninstalled returns all releases with Status == UNINSTALLED. An error is returned // ListUninstalled returns all releases with Status == UNINSTALLED. An error is returned
// if the storage backend fails to retrieve the releases. // if the storage backend fails to retrieve the releases.
func (s *Storage) ListUninstalled() ([]*rspb.Release, error) { func (s *Storage) ListUninstalled() ([]*rspb.Release, error) {
slog.Debug("listing uninstalled releases in storage") slog.Debug("listing uninstalled releases in storage")
return s.Driver.List(func(rls *rspb.Release) bool { return s.List(func(rls *rspb.Release) bool {
return relutil.StatusFilter(rspb.StatusUninstalled).Check(rls) return relutil.StatusFilter(rspb.StatusUninstalled).Check(rls)
}) })
} }
@ -104,7 +104,7 @@ func (s *Storage) ListUninstalled() ([]*rspb.Release, error) {
// if the storage backend fails to retrieve the releases. // if the storage backend fails to retrieve the releases.
func (s *Storage) ListDeployed() ([]*rspb.Release, error) { func (s *Storage) ListDeployed() ([]*rspb.Release, error) {
slog.Debug("listing all deployed releases in storage") slog.Debug("listing all deployed releases in storage")
return s.Driver.List(func(rls *rspb.Release) bool { return s.List(func(rls *rspb.Release) bool {
return relutil.StatusFilter(rspb.StatusDeployed).Check(rls) return relutil.StatusFilter(rspb.StatusDeployed).Check(rls)
}) })
} }
@ -133,7 +133,7 @@ func (s *Storage) Deployed(name string) (*rspb.Release, error) {
func (s *Storage) DeployedAll(name string) ([]*rspb.Release, error) { func (s *Storage) DeployedAll(name string) ([]*rspb.Release, error) {
slog.Debug("getting deployed releases", "name", name) slog.Debug("getting deployed releases", "name", name)
ls, err := s.Driver.Query(map[string]string{ ls, err := s.Query(map[string]string{
"name": name, "name": name,
"owner": "helm", "owner": "helm",
"status": "deployed", "status": "deployed",
@ -152,7 +152,7 @@ func (s *Storage) DeployedAll(name string) ([]*rspb.Release, error) {
func (s *Storage) History(name string) ([]*rspb.Release, error) { func (s *Storage) History(name string) ([]*rspb.Release, error) {
slog.Debug("getting release history", "name", name) slog.Debug("getting release history", "name", name)
return s.Driver.Query(map[string]string{"name": name, "owner": "helm"}) return s.Query(map[string]string{"name": name, "owner": "helm"})
} }
// removeLeastRecent removes items from history until the length number of releases // removeLeastRecent removes items from history until the length number of releases

@ -41,7 +41,7 @@ func Now() Time {
} }
func (t Time) MarshalJSON() ([]byte, error) { func (t Time) MarshalJSON() ([]byte, error) {
if t.Time.IsZero() { if t.IsZero() {
return []byte(emptyString), nil return []byte(emptyString), nil
} }

Loading…
Cancel
Save