Skip to content

Commit 6385821

Browse files
authored
✨ add --bundle-version-overrides flag; update default bundle to OCM v0.16.1 (#488)
* chore: support v0.16.1 bundle Signed-off-by: Tyler Gillson <[email protected]> * feat: configurable version bundle Signed-off-by: Tyler Gillson <[email protected]> * refactor: override component versions Signed-off-by: Tyler Gillson <[email protected]> * chore: minimize diff Signed-off-by: Tyler Gillson <[email protected]> * chore: add unit tests Signed-off-by: Tyler Gillson <[email protected]> --------- Signed-off-by: Tyler Gillson <[email protected]>
1 parent 1687026 commit 6385821

File tree

21 files changed

+164
-15
lines changed

21 files changed

+164
-15
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,28 @@ Enable specific add-on(s) agent deployment to the given managed clusters of the
146146
Create and deploy a sample Argo CD ApplicationSet
147147

148148
`clusteradm create sampleapp sample-appset`
149+
150+
## Version Bundles
151+
152+
By default, clusteradm uses a built-in version bundle that defines the versions of all OCM components to be installed. You can request a specific version bundle using the `--bundle-version` flag. You can override individual component versions within the selected version bundle using the `--bundle-version-overrides` flag:
153+
154+
```bash
155+
# Override component versions within the default version bundle:
156+
clusteradm init --bundle-version-overrides /path/to/bundle-overrides.json
157+
158+
# Override component versions within a specific version bundle:
159+
clusteradm init --bundle-version v0.16.0 --bundle-version-overrides /path/to/bundle-overrides.json
160+
```
161+
162+
The version bundle override file must be a JSON file containing one or more OCM component versions. Example:
163+
164+
```json
165+
{
166+
"ocm": "v0.16.1",
167+
"app_addon": "v0.16.0",
168+
"policy_addon": "v0.16.0",
169+
"multicluster_controlplane": "v0.7.0"
170+
}
171+
```
172+
173+
This is useful when you need to use specific versions of components or when working with custom builds.

pkg/cmd/init/cmd.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,12 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream
7474
"The credential file is the docker config json file and will be filled into the default image pull secret named open-cluster-management-image-pull-credentials.")
7575
cmd.Flags().StringVar(&o.bundleVersion, "bundle-version", "default",
7676
"The version of predefined compatible image versions (e.g. v0.6.0). Defaults to the latest released version. You can also set \"latest\" to install the latest development version.")
77+
cmd.Flags().StringVar(&o.versionBundleFile, "bundle-version-overrides", "",
78+
"Path to a file containing version bundle overrides. Optional. If provided, overrides component versions within the selected version bundle.")
7779
clusterManagerSet.BoolVar(&o.useBootstrapToken, "use-bootstrap-token", false, "If set then the bootstrap token will used instead of a service account token")
7880
_ = clusterManagerSet.SetAnnotation("image-registry", "clusterManagerSet", []string{})
7981
_ = clusterManagerSet.SetAnnotation("bundle-version", "clusterManagerSet", []string{})
82+
_ = clusterManagerSet.SetAnnotation("bundle-version-file", "clusterManagerSet", []string{})
8083
_ = clusterManagerSet.SetAnnotation("use-bootstrap-token", "clusterManagerSet", []string{})
8184
cmd.Flags().AddFlagSet(clusterManagerSet)
8285

pkg/cmd/init/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
5959
}
6060
})
6161

62-
bundleVersion, err := version.GetVersionBundle(o.bundleVersion)
62+
bundleVersion, err := version.GetVersionBundle(o.bundleVersion, o.versionBundleFile)
6363
if err != nil {
6464
return err
6565
}

pkg/cmd/init/options.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type Options struct {
2828

2929
// version of predefined compatible image versions
3030
bundleVersion string
31+
// Path to a file containing version bundle configuration
32+
versionBundleFile string
3133

3234
// If set, deploy the singleton controlplane
3335
singleton bool

pkg/cmd/install/hubaddon/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream
5353
cmd.Flags().StringVar(&o.outputFile, "output-file", "", "The generated resources will be copied in the specified file")
5454
cmd.Flags().StringVar(&o.bundleVersion, "bundle-version", "default",
5555
"The image version tag to use when deploying the hub add-on(s) (e.g. v0.6.0). Defaults to the latest released version. You can also set \"latest\" to install the latest development version.")
56+
cmd.Flags().StringVar(&o.versionBundleFile, "bundle-version-overrides", "",
57+
"Path to a file containing version bundle overrides. Optional. If provided, overrides component versions within the selected version bundle.")
5658

5759
return cmd
5860
}

pkg/cmd/install/hubaddon/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (o *Options) validate() (err error) {
5252
}
5353
}
5454

55-
versionBundle, err := version.GetVersionBundle(o.bundleVersion)
55+
versionBundle, err := version.GetVersionBundle(o.bundleVersion, o.versionBundleFile)
5656
if err != nil {
5757
return err
5858
}

pkg/cmd/install/hubaddon/exec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var _ = ginkgo.Describe("install hub-addon", func() {
4141
}
4242

4343
var err error
44-
ocmBundleVersion, err = version.GetVersionBundle(ocmVersion)
44+
ocmBundleVersion, err = version.GetVersionBundle(ocmVersion, "")
4545
gomega.Expect(err).ToNot(gomega.HaveOccurred())
4646
})
4747

pkg/cmd/install/hubaddon/options.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ type Options struct {
1717
outputFile string
1818
values scenario.Values
1919
bundleVersion string
20+
// Path to a file containing version bundle configuration
21+
versionBundleFile string
2022

2123
Streams genericiooptions.IOStreams
2224

pkg/cmd/join/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream
6363
"The credential file is the docker config json file and will be filled into the default image pull secret named open-cluster-management-image-pull-credentials.")
6464
cmd.Flags().StringVar(&o.bundleVersion, "bundle-version", "default",
6565
"The version of predefined compatible image versions (e.g. v0.6.0). Defaults to the latest released version. You can also set \"latest\" to install the latest development version.")
66+
cmd.Flags().StringVar(&o.versionBundleFile, "bundle-version-overrides", "",
67+
"Path to a file containing version bundle overrides. Optional. If provided, overrides component versions within the selected version bundle.")
6668
cmd.Flags().BoolVar(&o.forceHubInClusterEndpointLookup, "force-internal-endpoint-lookup", false,
6769
"If true, the installed klusterlet agent will be starting the cluster registration process by "+
6870
"looking for the internal endpoint from the public cluster-info in the hub cluster instead of from --hub-apiserver.")

pkg/cmd/join/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
9696
ClusterName: o.clusterName,
9797
}
9898

99-
bundleVersion, err := version.GetVersionBundle(o.bundleVersion)
99+
bundleVersion, err := version.GetVersionBundle(o.bundleVersion, o.versionBundleFile)
100100
if err != nil {
101101
return err
102102
}

0 commit comments

Comments
 (0)