Commit edc0b2a
Add --config-file flag to addon enable command (#512)
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)
Signed-off-by: Jian Qiu <[email protected]>
Co-authored-by: Claude <[email protected]>1 parent ea3fc6d commit edc0b2a
File tree
6 files changed
+379
-3
lines changed- pkg/cmd/addon
- disable
- enable
6 files changed
+379
-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 | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
7 | 12 | | |
8 | 13 | | |
9 | 14 | | |
10 | 15 | | |
11 | 16 | | |
| 17 | + | |
12 | 18 | | |
| 19 | + | |
13 | 20 | | |
14 | 21 | | |
15 | 22 | | |
| |||
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
27 | | - | |
| 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 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
28 | 123 | | |
29 | 124 | | |
30 | 125 | | |
| |||
51 | 146 | | |
52 | 147 | | |
53 | 148 | | |
| 149 | + | |
54 | 150 | | |
55 | 151 | | |
56 | 152 | | |
| |||
115 | 211 | | |
116 | 212 | | |
117 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
118 | 220 | | |
119 | 221 | | |
120 | 222 | | |
| |||
125 | 227 | | |
126 | 228 | | |
127 | 229 | | |
128 | | - | |
| 230 | + | |
129 | 231 | | |
130 | 232 | | |
131 | 233 | | |
| |||
155 | 257 | | |
156 | 258 | | |
157 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
158 | 263 | | |
159 | 264 | | |
160 | 265 | | |
0 commit comments