Commit 3f6e80a
authored
Make CRD version configurable (#266)
- Fixes #1089
- Adds config.ResourceConfig.APIVersion to be able to
override the generated version for a CRD
Issue #, if available: [#1089](aws-controllers-k8s/community#1089)
Description of changes:
This PR proposes a new configuration field named `APIVersion` (JSON-serialized name `api_version`) in `config.ResourceConfig` that allows overriding versions of specific CRDs generated by the Crossplane codegen pipeline. If a specific version string is not configured for a CRD-type, the default version specified with the `--version` command-line argument is used for backwards-compatibility. An [example configuration](https://github.com/crossplane/provider-aws/blob/master/apis/cloudfront/v1alpha1/generator-config.yaml) overriding the version for the CloudFront Distribution resource is as follows:
```
resources:
"Distribution":
api_versions:
- name: "v1beta1"
storage: true
ignore:
resource_names:
- FieldLevelEncryptionProfile
- Invalidation
- KeyGroup
- OriginRequestPolicy
- PublicKey
- StreamingDistribution
- RealtimeLogConfig
- MonitoringSubscription
- FieldLevelEncryptionConfig
field_paths:
- DistributionConfig.CallerReference
- Origins.Quantity
- OriginAccessIdentityConfig.CallerReference
```
**This PR now introduces a backward-incompatible behavior change in the Crossplane pipeline:**
Because the generator configuration is per API group (service) and because we may now have resources belonging to different API versions in a single group, this PR changes the default path of the `generator-config.yaml` file from:
`apis/<API group>/<API version>/generator-config.yaml`
to
`apis/<API group>/generator-config.yaml`
An example invocation `ack-generate crossplane cloudfront --output <output path> --generator-config-path generator-config.yaml` using the above configuration yields the following file structure:
```console
❯ tree
.
├── apis
│ └── cloudfront
│ ├── v1alpha1
│ │ ├── zz_cache_policy.go
│ │ ├── zz_cloud_front_origin_access_identity.go [0/941]
│ │ ├── zz_doc.go
│ │ ├── zz_enums.go
│ │ ├── zz_function.go
│ │ ├── zz_groupversion_info.go
│ │ ├── zz_response_headers_policy.go
│ │ └── zz_types.go
│ └── v1beta1
│ ├── zz_distribution.go
│ ├── zz_doc.go
│ ├── zz_enums.go
│ ├── zz_groupversion_info.go
│ └── zz_types.go
├── generator-config.yaml
├── go.mod
├── go.sum
└── pkg
└── controller
└── cloudfront
├── cachepolicy
│ ├── zz_controller.go
│ └── zz_conversions.go
├── cloudfrontoriginaccessidentity
│ ├── zz_controller.go
│ └── zz_conversions.go
├── distribution
│ ├── zz_controller.go
│ └── zz_conversions.go
├── function
│ ├── zz_controller.go
│ └── zz_conversions.go
└── responseheaderspolicy
├── zz_controller.go
└── zz_conversions.go
12 directories, 26 files
```
Without the `resources` configuration block, all resources are under `v1alpha1` version as expected:
```console
❯ tree .
.
├── apis [0/1036]
│ └── cloudfront
│ └── v1alpha1
│ ├── zz_cache_policy.go
│ ├── zz_cloud_front_origin_access_identity.go
│ ├── zz_distribution.go
│ ├── zz_doc.go
│ ├── zz_enums.go
│ ├── zz_function.go
│ ├── zz_groupversion_info.go
│ ├── zz_response_headers_policy.go
│ └── zz_types.go
├── generator-config.yaml
├── go.mod
├── go.sum
└── pkg
└── controller
└── cloudfront
├── cachepolicy
│ ├── zz_controller.go
│ └── zz_conversions.go
├── cloudfrontoriginaccessidentity
│ ├── zz_controller.go
│ └── zz_conversions.go
├── distribution
│ ├── zz_controller.go
│ └── zz_conversions.go
├── function
│ ├── zz_controller.go
│ └── zz_conversions.go
└── responseheaderspolicy
├── zz_controller.go
└── zz_conversions.go
11 directories, 22 files
```
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.1 parent 4c88d33 commit 3f6e80a
File tree
5 files changed
+91
-16
lines changed- cmd/ack-generate/command
- pkg
- generate
- config
- crossplane
- model
5 files changed
+91
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
81 | 87 | | |
82 | 88 | | |
83 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
138 | 146 | | |
139 | 147 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
154 | 165 | | |
155 | 166 | | |
156 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
157 | 172 | | |
158 | | - | |
| 173 | + | |
159 | 174 | | |
160 | 175 | | |
161 | 176 | | |
162 | 177 | | |
163 | 178 | | |
164 | 179 | | |
| 180 | + | |
165 | 181 | | |
166 | 182 | | |
167 | 183 | | |
| |||
177 | 193 | | |
178 | 194 | | |
179 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
180 | 199 | | |
181 | 200 | | |
182 | 201 | | |
| |||
188 | 207 | | |
189 | 208 | | |
190 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
191 | 213 | | |
192 | 214 | | |
193 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
99 | 116 | | |
100 | 117 | | |
101 | 118 | | |
| |||
0 commit comments