Skip to content

Commit 1356c4a

Browse files
committed
Updates controller-runtime version to v0.8.1
This involved bumping the code-gen version to 0.20 because the signature of the function had been updated. Required regenerating the conversion code. Also updated the types containing slice of pointers of custom object types to slice of custom objects to avoid conversion errors. Update the v1a3 -> v1a4 upgrade docs to record this requirement. Signed-off-by: Sagar Muchhal <[email protected]>
1 parent c615219 commit 1356c4a

File tree

24 files changed

+592
-329
lines changed

24 files changed

+592
-329
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,13 @@ generate-go-core: $(CONTROLLER_GEN) $(CONVERSION_GEN)
234234
$(MAKE) clean-generated-conversions SRC_DIRS="./api/v1alpha3,./$(EXP_DIR)/api/v1alpha3,./$(EXP_DIR)/addons/api/v1alpha3"
235235
$(CONVERSION_GEN) \
236236
--input-dirs=./api/v1alpha3 \
237+
--build-tag=ignore_autogenerated_core_v1alpha3 \
238+
--output-file-base=zz_generated.conversion \
239+
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
240+
$(CONVERSION_GEN) \
237241
--input-dirs=./$(EXP_DIR)/api/v1alpha3 \
238242
--input-dirs=./$(EXP_DIR)/addons/api/v1alpha3 \
239-
--build-tag=ignore_autogenerated_core_v1alpha3 \
243+
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1alpha3 \
240244
--output-file-base=zz_generated.conversion \
241245
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
242246

cmd/clusterctl/client/cluster/inventory_managementgroup_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ func fakeProvider(name string, providerType clusterctlv1.ProviderType, version,
171171
Kind: "Provider",
172172
},
173173
ObjectMeta: metav1.ObjectMeta{
174-
Namespace: targetNamespace,
175-
Name: clusterctlv1.ManifestLabel(name, providerType),
174+
ResourceVersion: "1",
175+
Namespace: targetNamespace,
176+
Name: clusterctlv1.ManifestLabel(name, providerType),
176177
Labels: map[string]string{
177178
clusterctlv1.ClusterctlLabelName: "",
178179
clusterv1.ProviderLabelName: clusterctlv1.ManifestLabel(name, providerType),

cmd/clusterctl/client/cluster/inventory_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func Test_inventoryClient_EnsureCustomResourceDefinitions(t *testing.T) {
7777
}
7878
}
7979

80-
var fooProvider = clusterctlv1.Provider{ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "ns1"}}
80+
var fooProvider = clusterctlv1.Provider{ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "ns1", ResourceVersion: "1"}}
8181

8282
func Test_inventoryClient_List(t *testing.T) {
8383
type fields struct {
@@ -127,6 +127,8 @@ func Test_inventoryClient_Create(t *testing.T) {
127127
m clusterctlv1.Provider
128128
}
129129
providerV2 := fakeProvider("infra", clusterctlv1.InfrastructureProviderType, "v0.2.0", "", "")
130+
// since this test object is used in a Create request, wherein setting ResourceVersion should no be set
131+
providerV2.ResourceVersion = ""
130132
providerV3 := fakeProvider("infra", clusterctlv1.InfrastructureProviderType, "v0.3.0", "", "")
131133

132134
tests := []struct {

cmd/clusterctl/internal/test/fake_proxy.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ func (f *FakeProxy) WithProviderInventory(name string, providerType clusterctlv1
149149
Kind: "Provider",
150150
},
151151
ObjectMeta: metav1.ObjectMeta{
152-
Namespace: targetNamespace,
153-
Name: clusterctlv1.ManifestLabel(name, providerType),
152+
ResourceVersion: "1",
153+
Namespace: targetNamespace,
154+
Name: clusterctlv1.ManifestLabel(name, providerType),
154155
Labels: map[string]string{
155156
clusterctlv1.ClusterctlLabelName: "",
156157
clusterv1.ProviderLabelName: clusterctlv1.ManifestLabel(name, providerType),

controllers/external/util_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ func TestGetResourceFound(t *testing.T) {
4444
testResourceName := "greenTemplate"
4545
testResourceKind := "GreenTemplate"
4646
testResourceAPIVersion := "green.io/v1"
47+
testResourceVersion := "1"
4748

4849
testResource := &unstructured.Unstructured{}
4950
testResource.SetKind(testResourceKind)
5051
testResource.SetAPIVersion(testResourceAPIVersion)
5152
testResource.SetName(testResourceName)
5253
testResource.SetNamespace(namespace)
54+
testResource.SetResourceVersion(testResourceVersion)
5355

5456
testResourceReference := &corev1.ObjectReference{
5557
Kind: testResourceKind,

docs/book/src/developer/providers/v1alpha3-to-v1alpha4.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@ see [Multi-tenancy](../architecture/controllers/multi-tenancy.md) and [Support m
5454
more details.
5555

5656
Specific changes related to this topic will be detailed in this document.
57+
58+
## Change types with arrays of pointers to custom objects
59+
60+
The conversion-gen code from the `1.20.x` release onward generates incorrect conversion functions for types having arrays of pointers to custom objects. Change the existing types to contain objects instead of pointer references.

exp/addons/api/v1alpha3/zz_generated.conversion.go

Lines changed: 45 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exp/addons/api/v1alpha3/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exp/api/v1alpha3/zz_generated.conversion.go

Lines changed: 25 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exp/api/v1alpha3/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)