Skip to content

Commit 615240f

Browse files
authored
Merge pull request #531 from cnvergence/fix-helm-defaults-dev
Always resolve the latest release version for chart and image default
2 parents 7386fd6 + 02d21db commit 615240f

1 file changed

Lines changed: 20 additions & 21 deletions

File tree

cli/pkg/kubectl/dev/plugin/create.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ type DevOptions struct {
7171
}
7272

7373
// fallbackAssetVersion is used when unable to fetch the latest version
74-
const fallbackAssetVersion = "0.6.0"
74+
const fallbackAssetVersion = "0.7.1"
7575

7676
// gitHubRelease represents a GitHub release response
7777
type gitHubRelease struct {
@@ -88,7 +88,6 @@ func NewDevOptions(streams genericclioptions.IOStreams) *DevOptions {
8888
ProviderClusterName: "kind-provider",
8989
ConsumerClusterName: "kind-consumer",
9090
ChartPath: "oci://ghcr.io/kube-bind/charts/backend",
91-
ChartVersion: fallbackAssetVersion,
9291
}
9392
}
9493

@@ -101,33 +100,28 @@ func (o *DevOptions) AddCmdFlags(cmd *cobra.Command) {
101100
cmd.Flags().StringVar(&o.ConsumerClusterName, "consumer-cluster-name", "kind-consumer", "Name of the consumer cluster in dev mode")
102101
cmd.Flags().DurationVar(&o.WaitForReadyTimeout, "wait-for-ready-timeout", 2*time.Minute, "Timeout for waiting for the cluster to be ready")
103102
cmd.Flags().StringVar(&o.ChartPath, "chart-path", o.ChartPath, "Helm chart path or OCI registry URL")
104-
cmd.Flags().StringVar(&o.ChartVersion, "chart-version", o.ChartVersion, "The version of the Helm chart to use")
103+
cmd.Flags().StringVar(&o.ChartVersion, "chart-version", "", "The version of the Helm chart to use")
105104
cmd.Flags().StringVar(&o.BackendImage, "backend-image", "ghcr.io/kube-bind/backend", "The name of kube-bind backend to use in dev mode")
106105
cmd.Flags().StringVar(&o.BackendTag, "backend-tag", "", "The tag of the kube-bind backend image to use in dev mode")
107106
cmd.Flags().StringVar(&o.KindNetwork, "kind-network", "kube-bind-dev", "The name of the kind network to use in dev mode")
108107
}
109108

110109
// Complete completes the options
111110
func (o *DevOptions) Complete(args []string) error {
112-
// Only fetch the latest version if tag is not set
113-
var assetVersion string
114-
if o.BackendTag == "" {
115-
version, err := fetchLatestRelease()
116-
if err != nil {
117-
// Log the error but continue with fallback version
118-
fmt.Fprintf(o.Streams.ErrOut, "Warning: Failed to fetch latest release version: %v. Using fallback version %s\n", err, fallbackAssetVersion)
119-
assetVersion = fallbackAssetVersion
120-
} else {
121-
assetVersion = version
122-
}
111+
assetVersion := fallbackAssetVersion
112+
version, err := fetchLatestRelease()
113+
if err != nil {
114+
fmt.Fprintf(o.Streams.ErrOut, "Warning: Failed to fetch latest release version: %v. Using fallback version %s\n", err, fallbackAssetVersion)
115+
} else {
116+
assetVersion = version
117+
}
123118

124-
// Update options with the resolved version
125-
if o.ChartVersion == "" || o.ChartVersion == fallbackAssetVersion {
126-
o.ChartVersion = assetVersion
127-
}
128-
if o.BackendTag == "" || o.BackendTag == "v"+fallbackAssetVersion {
129-
o.BackendTag = "v" + assetVersion
130-
}
119+
if o.ChartVersion == "" {
120+
o.ChartVersion = assetVersion
121+
}
122+
123+
if o.BackendTag == "" {
124+
o.BackendTag = "v" + assetVersion
131125
}
132126

133127
return nil
@@ -391,6 +385,11 @@ func (o *DevOptions) installHelmChart(_ context.Context, restConfig *rest.Config
391385
actionConfig.RegistryClient = registryClient
392386

393387
values := map[string]any{
388+
"image": map[string]any{
389+
"repository": o.BackendImage,
390+
"tag": o.BackendTag,
391+
},
392+
394393
"examples": map[string]any{
395394
"enabled": true,
396395
},

0 commit comments

Comments
 (0)