Skip to content

Commit 089321f

Browse files
Add additional keys to adopted resource spec (#13)
Issue #, if available: aws-controllers-k8s/community#766 Some resources require more than an ARN/Name/ID to describe a single resource. This PR adds an `additionalKeys` field to the `AWSIdentifiers` to allow for arbitrary identifiers as needed by any resources. Generator code to support this change: aws-controllers-k8s/code-generator#62
1 parent 3d52b06 commit 089321f

File tree

4 files changed

+36
-19
lines changed

4 files changed

+36
-19
lines changed

apis/core/v1alpha1/identifiers.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ type AWSIdentifiers struct {
2020
ARN *AWSResourceName `json:"arn,omitempty"`
2121
// NameOrId is a user-supplied string identifier for the resource. It may
2222
// or may not be globally unique, depending on the type of resource.
23-
NameOrID *string `json:"nameOrID,omitempty"`
23+
NameOrID string `json:"nameOrID,omitempty"`
24+
// AdditionalKeys represents any additional arbitrary identifiers used when
25+
// describing the target resource.
26+
AdditionalKeys map[string]string `json:"additionalKeys,omitempty"`
2427
}
2528

2629
// TargetKubernetesResource provides all the values necessary to identify a given ACK type
2730
// and override any metadata values when creating a resource of that type.
2831
type TargetKubernetesResource struct {
2932
// +kubebuilder:validation:Required
30-
Group *string `json:"group"`
33+
Group string `json:"group"`
3134
// +kubebuilder:validation:Required
32-
Kind *string `json:"kind"`
35+
Kind string `json:"kind"`
3336
Metadata *PartialObjectMeta `json:"metadata,omitempty"`
3437
}

apis/core/v1alpha1/zz_generated.deepcopy.go

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

config/crd/bases/services.k8s.aws_adoptedresources.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ spec:
4040
description: AWSIdentifiers provide all unique ways to reference an
4141
AWS resource.
4242
properties:
43+
additionalKeys:
44+
additionalProperties:
45+
type: string
46+
description: AdditionalKeys represents any additional arbitrary
47+
identifiers used when describing the target resource.
48+
type: object
4349
arn:
4450
description: ARN is the AWS Resource Name for the resource. It
4551
is a globally unique identifier.

pkg/runtime/adoption_reconciler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ func (r *adoptionReconciler) getTargetResourceGroupKind(
337337
res *ackv1alpha1.AdoptedResource,
338338
) schema.GroupKind {
339339
return schema.GroupKind{
340-
Group: *res.Spec.Kubernetes.Group,
341-
Kind: *res.Spec.Kubernetes.Kind,
340+
Group: res.Spec.Kubernetes.Group,
341+
Kind: res.Spec.Kubernetes.Kind,
342342
}
343343
}
344344

0 commit comments

Comments
 (0)