Commit 6ebb956
Add --config-file flag to addon enable command
This commit implements the feature requested in issue #501 by adding
a --config-file flag to the addon enable command. The flag allows
users to specify addon configurations that will be applied to the
cluster and referenced in the ManagedClusterAddOn resource.
Changes:
- Added ConfigFile field to Options struct
- Added --config-file flag to the enable command
- Implemented applyConfigFileAndBuildReferences() function that:
- Reads configuration resources from a YAML file
- Applies the resources to the cluster using ResourceReader
- Uses REST mapper to discover GVR (Group/Version/Resource)
- Builds AddOnConfig references with proper group, resource,
namespace, and name
- Updated NewClusterAddonInfo() to accept configs as a parameter
- Updated runWithClient() to apply config file before creating addons
- Updated ApplyAddon() to handle configs when updating existing addons
- Added comprehensive integration tests for the new functionality
- Added TestClientGetter helper for test setup
The config file should contain actual Kubernetes resources (e.g.,
AddOnDeploymentConfig) in YAML format. Multiple resources can be
separated by '---'. The implementation automatically discovers the
resource type and builds proper references that are set in the
ManagedClusterAddOn.Spec.Configs field.
Example usage:
clusteradm addon enable --names my-addon --clusters cluster1 \
--config-file addon-config.yaml
Fixes #501
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: Jian Qiu <[email protected]>1 parent ea3fc6d commit 6ebb956
File tree
6 files changed
+369
-3
lines changed- pkg/cmd/addon
- disable
- enable
6 files changed
+369
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
| |||
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| 78 | + | |
73 | 79 | | |
74 | 80 | | |
75 | 81 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
12 | 14 | | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
27 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
28 | 115 | | |
29 | 116 | | |
30 | 117 | | |
| |||
51 | 138 | | |
52 | 139 | | |
53 | 140 | | |
| 141 | + | |
54 | 142 | | |
55 | 143 | | |
56 | 144 | | |
| |||
115 | 203 | | |
116 | 204 | | |
117 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
118 | 212 | | |
119 | 213 | | |
120 | 214 | | |
| |||
125 | 219 | | |
126 | 220 | | |
127 | 221 | | |
128 | | - | |
| 222 | + | |
129 | 223 | | |
130 | 224 | | |
131 | 225 | | |
| |||
155 | 249 | | |
156 | 250 | | |
157 | 251 | | |
| 252 | + | |
158 | 253 | | |
159 | 254 | | |
160 | 255 | | |
0 commit comments