Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/nelm/release_plan_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func newReleasePlanInstallCommand(ctx context.Context, afterAllCommandsBuiltFunc
cfg.Chart = args[0]
}

if err := action.ReleasePlanInstall(ctx, cfg.ReleaseName, cfg.ReleaseNamespace, cfg.ReleasePlanInstallOptions); err != nil {
if _, err := action.ReleasePlanInstall(ctx, cfg.ReleaseName, cfg.ReleaseNamespace, cfg.ReleasePlanInstallOptions); err != nil {
return fmt.Errorf("release plan install: %w", err)
}

Expand Down
11 changes: 6 additions & 5 deletions pkg/plan/plan_artifact.go → pkg/action/plan_artifact.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plan
package action

import (
"compress/gzip"
Expand All @@ -10,6 +10,7 @@
"time"

"github.com/samber/lo"
"github.com/werf/nelm/pkg/plan"

Check failure on line 13 in pkg/action/plan_artifact.go

View workflow job for this annotation

GitHub Actions / lint / _

File is not properly formatted (gci)

"github.com/werf/common-go/pkg/secrets_manager"
"github.com/werf/nelm/pkg/common"
Expand All @@ -32,11 +33,11 @@

type PlanArtifactData struct {
Options common.ReleaseInstallRuntimeOptions `json:"options"`
Changes []*ResourceChange `json:"changes"`
Plan *Plan `json:"plan"`
Changes []*plan.ResourceChange `json:"changes"`
Plan *plan.Plan `json:"plan"`
Release *helmrelease.Release `json:"release"`
InstallableResourceInfos []*InstallableResourceInfo `json:"installableResourceInfos"`
ReleaseInfos []*ReleaseInfo `json:"releaseInfos"`
InstallableResourceInfos []*plan.InstallableResourceInfo `json:"installableResourceInfos"`
ReleaseInfos []*plan.ReleaseInfo `json:"releaseInfos"`
}

type PlanArtifactRelease struct {
Expand Down
19 changes: 13 additions & 6 deletions pkg/action/release_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ type ReleaseInstallOptions struct {
// LegacyLogRegistryStreamOut is the output writer for Helm registry client logs.
// Defaults to io.Discard if not set. Used for debugging registry operations.
LegacyLogRegistryStreamOut io.Writer
// LegacyPlanArtifact provides plan artifact as a result of the release plan install action.
LegacyPlanArtifact *PlanArtifact
// LegacyProgressReportCh, when non-nil, receives ProgressReport snapshots during deployment.
// Must be a buffered channel with capacity >= 1. The caller owns the channel and is responsible
// for its lifecycle. Intermediate reports may be dropped if the consumer is slow; the final
Expand Down Expand Up @@ -165,8 +167,6 @@ func ReleaseInstall(ctx context.Context, releaseName, releaseNamespace string, o
}

func releaseInstall(ctx context.Context, ctxCancelFn context.CancelCauseFunc, releaseName, releaseNamespace string, opts ReleaseInstallOptions) error {
usePlan := opts.PlanArtifactPath != ""

currentDir, err := os.Getwd()
if err != nil {
return fmt.Errorf("get current working directory: %w", err)
Expand All @@ -186,20 +186,27 @@ func releaseInstall(ctx context.Context, ctxCancelFn context.CancelCauseFunc, re
lo.Must0(os.Setenv("WERF_SECRET_KEY", opts.SecretKey))
}

var planArtifact *plan.PlanArtifact
if usePlan {
var planArtifact *PlanArtifact

if opts.PlanArtifactPath != "" {
log.Default.Info(ctx, "Using %s plan artifact", opts.PlanArtifactPath)

log.Default.Debug(ctx, "Read plan artifact")

planArtifact, err = plan.ReadPlanArtifact(ctx, opts.PlanArtifactPath, opts.SecretKey, opts.SecretWorkDir)
planArtifact, err = ReadPlanArtifact(ctx, opts.PlanArtifactPath, opts.SecretKey, opts.SecretWorkDir)
if err != nil {
return fmt.Errorf("read plan artifact from %s: %w", opts.PlanArtifactPath, err)
}
} else {
planArtifact = opts.LegacyPlanArtifact
}

usePlan := planArtifact != nil

if usePlan {
log.Default.Debug(ctx, "Validate plan artifact")

if err := plan.ValidatePlanArtifact(planArtifact, opts.PlanArtifactLifetime); err != nil {
if err := ValidatePlanArtifact(planArtifact, opts.PlanArtifactLifetime); err != nil {
return fmt.Errorf("validate plan artifact: %w", err)
}

Expand Down
Loading
Loading