Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(render): add --kube-version flag
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
  • Loading branch information
ilya-lesikov committed Aug 16, 2023
1 parent 7f0f5eb commit bc48dd0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions cmd/werf/bundle/render/render.go
Expand Up @@ -93,6 +93,8 @@ func NewCmd(ctx context.Context) *cobra.Command {
common.SetupRelease(&commonCmdData, cmd)
common.SetupNamespace(&commonCmdData, cmd)

common.SetupKubeVersion(&commonCmdData, cmd)

defaultTag := os.Getenv("WERF_TAG")
if defaultTag == "" {
defaultTag = "latest"
Expand Down Expand Up @@ -244,6 +246,7 @@ func runRender(ctx context.Context) error {
},
Validate: &cmdData.Validate,
IncludeCrds: &cmdData.IncludeCRDs,
KubeVersion: commonCmdData.KubeVersion,
})

if err := helmTemplateCmd.RunE(helmTemplateCmd, []string{releaseName, bundleDir}); err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/werf/common/cmd_data.go
Expand Up @@ -72,6 +72,7 @@ type CmdData struct {
DryRun *bool
KeepStagesBuiltWithinLastNHours *uint64
WithoutKube *bool
KubeVersion *string

LooseGiterminism *bool
Dev *bool
Expand Down
5 changes: 5 additions & 0 deletions cmd/werf/common/common.go
Expand Up @@ -827,6 +827,11 @@ The mode allows restarting the command on a new commit.
In development mode (--dev), werf restarts the command on any changes (including untracked files) in the git repository worktree`)
}

func SetupKubeVersion(cmdData *CmdData, cmd *cobra.Command) {
cmdData.KubeVersion = new(string)
cmd.Flags().StringVarP(cmdData.KubeVersion, "kube-version", "", "", "Set specific Capabilities.KubeVersion (default $WERF_KUBE_VERSION)")
}

func allStagesNames() []string {
var stageNames []string
for _, stageName := range stage.AllStages {
Expand Down
3 changes: 3 additions & 0 deletions cmd/werf/render/render.go
Expand Up @@ -150,6 +150,8 @@ func NewCmd(ctx context.Context) *cobra.Command {
common.SetupRequireBuiltImages(&commonCmdData, cmd)
commonCmdData.SetupPlatform(cmd)

common.SetupKubeVersion(&commonCmdData, cmd)

cmd.Flags().BoolVarP(&cmdData.Validate, "validate", "", util.GetBoolEnvironmentDefaultFalse("WERF_VALIDATE"), "Validate your manifests against the Kubernetes cluster you are currently pointing at (default $WERF_VALIDATE)")
cmd.Flags().BoolVarP(&cmdData.IncludeCRDs, "include-crds", "", util.GetBoolEnvironmentDefaultTrue("WERF_INCLUDE_CRDS"), "Include CRDs in the templated output (default $WERF_INCLUDE_CRDS)")

Expand Down Expand Up @@ -455,6 +457,7 @@ func runRender(ctx context.Context, imagesToProcess build.ImagesToProcess) error
},
Validate: &cmdData.Validate,
IncludeCrds: &cmdData.IncludeCRDs,
KubeVersion: commonCmdData.KubeVersion,
}

fullChartDir := filepath.Join(giterminismManager.ProjectDir(), chartDir)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -348,6 +348,6 @@ replace (
github.com/helm/helm-2to3 => github.com/werf/3p-helm-2to3 v0.0.0-20230313155428-cf9dd655c0e3 // switch back to upstream when merged: https://github.com/helm/helm-2to3/pull/224
github.com/jaguilar/vt100 => github.com/tonistiigi/vt100 v0.0.0-20190402012908-ad4c4a574305 // upstream not maintained
github.com/maorfr/helm-plugin-utils => github.com/werf/3p-helm-plugin-utils v0.6.1-0.20230313152239-057595ce9d57 // switch back to upstream when merged: https://github.com/maorfr/helm-plugin-utils/pull/17
helm.sh/helm/v3 => github.com/werf/3p-helm/v3 v3.0.0-20230803130450-84c058aa1f4b
helm.sh/helm/v3 => github.com/werf/3p-helm/v3 v3.0.0-20230816141106-869627919887
k8s.io/helm => github.com/werf/helm v0.0.0-20210202111118-81e74d46da0f
)
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -1742,8 +1742,8 @@ github.com/weppos/publicsuffix-go v0.5.0/go.mod h1:z3LCPQ38eedDQSwmsSRW4Y7t2L8Ln
github.com/weppos/publicsuffix-go v0.20.1-0.20221209102050-40d9c30084b3 h1:ypyhoprZWFzU0ydOBv3I5SS7/jLFJ+ujPAU+BD/EVFM=
github.com/werf/3p-helm-2to3 v0.0.0-20230313155428-cf9dd655c0e3 h1:pdKLiuiUoOFswc0HV6GX1+JHgP14HqE035xl2DQJi8A=
github.com/werf/3p-helm-2to3 v0.0.0-20230313155428-cf9dd655c0e3/go.mod h1:lTSQBLomjl67m4HQMbg3BHKWes3pOmjNBg8yygXYugk=
github.com/werf/3p-helm/v3 v3.0.0-20230803130450-84c058aa1f4b h1:5v8Ow+3W+Uqlu63wSPidDxovgpUZeGCdF8uwGH51dYc=
github.com/werf/3p-helm/v3 v3.0.0-20230803130450-84c058aa1f4b/go.mod h1:VOUBLZpCrLMJKLGAQQJ/EoXx1DVN3605V5dkMm8EC9A=
github.com/werf/3p-helm/v3 v3.0.0-20230816141106-869627919887 h1:wIju9FN71HSsHnz+ilkm1fNDkToEWiV6SR6h/2z+EaQ=
github.com/werf/3p-helm/v3 v3.0.0-20230816141106-869627919887/go.mod h1:VOUBLZpCrLMJKLGAQQJ/EoXx1DVN3605V5dkMm8EC9A=
github.com/werf/copy-recurse v0.2.7 h1:3FTOarbJ9uhFLi75oeUCioK9zxZwuV7o28kuUBPDZPM=
github.com/werf/copy-recurse v0.2.7/go.mod h1:6Ypb+qN+hRBJgoCgEkX1vpbqcQ+8q69BQ3hi8s8Y6Qc=
github.com/werf/helm v0.0.0-20210202111118-81e74d46da0f h1:81YscYTF9mmTf0ULOsCmm42YWQp+qWDzWi1HjWniZrg=
Expand Down

0 comments on commit bc48dd0

Please sign in to comment.