fix: properly update 'label' field for helm + render w/ -l flag
@@ -32,6 +32,7 @@ import (
"github.com/blang/semver"
backoff "github.com/cenkalti/backoff/v4"
+ apimachinery "k8s.io/apimachinery/pkg/runtime/schema"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/access"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
@@ -56,6 +57,7 @@ import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/log"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/output"
olog "github.com/GoogleContainerTools/skaffold/pkg/skaffold/output/log"
+ renderutil "github.com/GoogleContainerTools/skaffold/pkg/skaffold/render/renderer/util"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/status"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/sync"
@@ -118,6 +120,9 @@ type Deployer struct {
isMultiConfig bool
// bV is the helm binary version
bV semver.Version
+
+ transformableAllowlist map[apimachinery.GroupKind]latest.ResourceFilter
+ transformableDenylist map[apimachinery.GroupKind]latest.ResourceFilter
}
type Config interface {
@@ -147,6 +152,10 @@ func NewDeployer(ctx context.Context, cfg Config, labeller *label.DefaultLabelle
olog.Entry(context.TODO()).Warn("unable to parse namespaces - deploy might not work correctly!")
}
logger := component.NewLogger(cfg, kubectl, podSelector, &namespaces)
+ transformableAllowlist, transformableDenylist, err := renderutil.ConsolidateTransformConfiguration(cfg)
+ if err != nil {
+ return nil, err
+ }
var ogImages []graph.Artifact
for _, artifact := range artifacts {
ogImages = append(ogImages, graph.Artifact{
@@ -174,6 +183,8 @@ func NewDeployer(ctx context.Context, cfg Config, labeller *label.DefaultLabelle
bV: hv,
enableDebug: cfg.Mode() == config.RunModes.Debug,
isMultiConfig: cfg.IsMultiConfig(),
+ transformableAllowlist: transformableAllowlist,
+ transformableDenylist: transformableDenylist,
}, nil
}
@@ -437,8 +448,17 @@ func (h *Deployer) Render(ctx context.Context, out io.Writer, builds []graph.Art
}
renderedManifests.Write(outBuffer.Bytes())
}
+ manifests, err := manifest.Load(bytes.NewReader(renderedManifests.Bytes()))
+ if err != nil {
+ return err
+ }
+
+ modifiedManifests, err := manifests.SetLabels(h.labels, manifest.NewResourceSelectorLabels(h.transformableAllowlist, h.transformableDenylist))
+ if err != nil {
+ return err
+ }
- return manifest.Write(renderedManifests.String(), filepath, out)
+ return manifest.Write(modifiedManifests.String(), filepath, out)
}
func (h *Deployer) HasRunnableHooks() bool {
