Skip to content

Commit

Permalink
Addressing review comments - 4
Browse files Browse the repository at this point in the history
  • Loading branch information
nb-goog committed Oct 23, 2024
1 parent 7db151f commit c86273e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions apis/kms/v1alpha1/autokeyconfig_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ refsv1beta1.ExternalNormalizer = &KMSAutokeyConfigRef{}
// holds the GCP identifier for the KRM object.
type KMSAutokeyConfigRef struct {
// A reference to an externally managed KMSAutokeyConfig resource.
// Should be in the format "projects/<projectID>/locations/<location>/autokeyconfigs/<autokeyconfigID>".
// Should be in the format "folders/<folderID>/autokeyConfig".
External string `json:"external,omitempty"`

// The name of a KMSAutokeyConfig resource.
Expand Down Expand Up @@ -136,7 +136,6 @@ func (r *KMSAutokeyConfigRef) Parent() (*KMSAutokeyConfigParent, error) {

type KMSAutokeyConfigParent struct {
FolderID string
Location string
}

func (p *KMSAutokeyConfigParent) String() string {
Expand All @@ -151,7 +150,7 @@ func ParseKMSAutokeyConfigExternal(external string) (parent *KMSAutokeyConfigPar
external = strings.TrimPrefix(external, "/")
tokens := strings.Split(external, "/")
if len(tokens) != 3 || tokens[0] != "folders" || tokens[2] != "autokeyConfig" {
return nil, fmt.Errorf("format of KMSAutokeyConfig external=%q was not known (use projects/<projectId>/locations/<location>/autokeyconfigs/<autokeyconfigID>)", external)
return nil, fmt.Errorf("format of KMSAutokeyConfig external=%q was not known (use folders/<folderID>/autokeyConfig)", external)
}
parent = &KMSAutokeyConfigParent{
FolderID: tokens[1],
Expand Down
6 changes: 3 additions & 3 deletions apis/kms/v1alpha1/kmsautokeyconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ type KMSAutokeyConfigSpec struct {
// NOTE: ResourceID field is not required for AutokeyConfig as its ID has the format folders/<folderID>/autokeyConfig i.e., it doesnt have any unique ID of its own and relies on folderID for uniqueness.

// Immutable. The folder that this resource belongs to.
// +required
FolderRef *refs.FolderRef `json:"folderRef"`

// +optional
KeyProject *refs.ProjectRef `json:"keyProject,omitempty"`
KeyProjectRef *refs.ProjectRef `json:"keyProject,omitempty"`
}

// KMSAutokeyConfigStatus defines the config connector machine state of KMSAutokeyConfig
Expand All @@ -47,8 +48,6 @@ type KMSAutokeyConfigStatus struct {

// ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource.
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`
//KeyProject *refs.ProjectRef `json:"projectRef,omitempty"`
//State *string `json:"state,omitempty"`

// A unique specifier for the KMSAutokeyConfig resource in GCP.
ExternalRef *string `json:"externalRef,omitempty"`
Expand All @@ -67,6 +66,7 @@ type KMSAutokeyConfigObservedState struct {

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:categories=gcp,shortName=gcpkmsautokeyconfig;gcpkmsautokeyconfigs
// +kubebuilder:resource:categories=gcp
// +kubebuilder:subresource:status
// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/system=true"
Expand Down
4 changes: 2 additions & 2 deletions apis/kms/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func (m *model) AdapterForObject(ctx context.Context, reader client.Reader, u *u
return nil, fmt.Errorf("unable to resolve folder for autokeyConfig name: %s", obj.GetName())
}
var keyProject *refs.Project
if obj.Spec.KeyProject != nil {
if obj.Spec.KeyProjectRef != nil {
var err error
keyProject, err = refs.ResolveProject(ctx, reader, obj, obj.Spec.KeyProject)
keyProject, err = refs.ResolveProject(ctx, reader, obj, obj.Spec.KeyProjectRef)
if err != nil {
return nil, fmt.Errorf("unable to resolve key project for autokeyConfig naem: %s", obj.GetName())
}
Expand Down Expand Up @@ -221,7 +221,7 @@ func (a *Adapter) Export(ctx context.Context) (*unstructured.Unstructured, error
// Delete implements the Adapter interface.
// Note: Delete operation is not supported for GCP AutokeyConfig resource.
// However in KCC, the user has full flexibility to delete the KCC AutokeyConfig resource.
// To make this KKCC operation effective, as part of KCC AutokeyConfig deletion we will update the AutokeyConfig resource in GCP with empty key_project which will prevent further use of AutokeyConfig.
// To make this KCC operation effective, as part of KCC AutokeyConfig deletion we will update the AutokeyConfig resource in GCP with empty key_project which will prevent further use of AutokeyConfig.
// Because of the above decision we will update the observedstate for AutokeyConfig with state = UNINITIALIZED
func (a *Adapter) Delete(ctx context.Context, deleteOp *directbase.DeleteOperation) (bool, error) {
log := klog.FromContext(ctx).WithName(ctrlName)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c86273e

Please sign in to comment.