Skip to content

Commit 86972ac

Browse files
committed
manual:
* fix test inputs * TODO: revert: Change log levels in controller * Since we have a server assigned id, adjust NewContactIdentity
1 parent 19da704 commit 86972ac

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

apis/essentialcontacts/v1alpha1/contact_identity.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ func NewContactIdentity(ctx context.Context, reader client.Reader, obj *Essentia
126126
}
127127
}
128128
if actualResourceID != resourceID {
129-
return nil, fmt.Errorf("cannot reset `metadata.name` or `spec.resourceID` to %s, since it has already assigned to %s",
130-
resourceID, actualResourceID)
129+
// This is expected in the case of EssentialContactsContact. The actual resource ID is set by the GCP API.
130+
resourceID = actualResourceID
131131
}
132132
}
133133
return &ContactIdentity{

pkg/controller/direct/essentialcontacts/contact_controller.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ var _ directbase.Adapter = &contactAdapter{}
104104
// Return a non-nil error requeues the requests.
105105
func (a *contactAdapter) Find(ctx context.Context) (bool, error) {
106106
log := klog.FromContext(ctx)
107-
log.V(2).Info("getting essential contact", "name", a.id)
107+
log.Info("getting essential contact", "name", a.id)
108108

109109
// Use the calculated name if available (from status), otherwise construct from ID
110110
name := direct.ValueOf(a.desired.Status.ExternalRef)
@@ -128,7 +128,7 @@ func (a *contactAdapter) Find(ctx context.Context) (bool, error) {
128128
// Create creates the resource in GCP based on `spec` and update the Config Connector object `status` based on the GCP response.
129129
func (a *contactAdapter) Create(ctx context.Context, createOp *directbase.CreateOperation) error {
130130
log := klog.FromContext(ctx)
131-
log.V(2).Info("creating essential contact", "name", a.id)
131+
log.Info("creating essential contact", "name", a.id)
132132
mapCtx := &direct.MapContext{}
133133

134134
desired := a.desired.DeepCopy()
@@ -145,7 +145,7 @@ func (a *contactAdapter) Create(ctx context.Context, createOp *directbase.Create
145145
if err != nil {
146146
return fmt.Errorf("creating essential contact %s: %w", a.id, err)
147147
}
148-
log.V(2).Info("successfully created essential contact", "name", a.id)
148+
log.Info("successfully created essential contact", "name", a.id)
149149

150150
status := &krm.EssentialContactsContactStatus{}
151151
status.ObservedState = EssentialContactsContactObservedState_FromProto(mapCtx, created)
@@ -159,7 +159,7 @@ func (a *contactAdapter) Create(ctx context.Context, createOp *directbase.Create
159159
// Update updates the resource in GCP based on `spec` and update the Config Connector object `status` based on the GCP response.
160160
func (a *contactAdapter) Update(ctx context.Context, updateOp *directbase.UpdateOperation) error {
161161
log := klog.FromContext(ctx)
162-
log.V(2).Info("updating essential contact", "name", a.id)
162+
log.Info("updating essential contact", "name", a.id)
163163
mapCtx := &direct.MapContext{}
164164

165165
desired := a.desired.DeepCopy()
@@ -179,7 +179,7 @@ func (a *contactAdapter) Update(ctx context.Context, updateOp *directbase.Update
179179

180180
var updated *pb.Contact
181181
if len(paths) == 0 {
182-
log.V(2).Info("no field needs update", "name", a.id)
182+
log.Info("no field needs update", "name", a.id)
183183
updated = a.actual
184184
} else {
185185
req := &pb.UpdateContactRequest{
@@ -191,7 +191,7 @@ func (a *contactAdapter) Update(ctx context.Context, updateOp *directbase.Update
191191
if err != nil {
192192
return fmt.Errorf("updating essential contact %s: %w", a.id, err)
193193
}
194-
log.V(2).Info("successfully updated essential contact", "name", a.id)
194+
log.Info("successfully updated essential contact", "name", a.id)
195195
}
196196

197197
status := &krm.EssentialContactsContactStatus{}
@@ -259,19 +259,19 @@ func (a *contactAdapter) Export(ctx context.Context) (*unstructured.Unstructured
259259
// Delete the resource from GCP service when the corresponding Config Connector resource is deleted.
260260
func (a *contactAdapter) Delete(ctx context.Context, deleteOp *directbase.DeleteOperation) (bool, error) {
261261
log := klog.FromContext(ctx)
262-
log.V(2).Info("deleting essential contact", "name", a.actual.Name)
262+
log.Info("deleting essential contact", "name", a.actual.Name)
263263

264264
req := &pb.DeleteContactRequest{Name: a.actual.Name}
265265
err := a.gcpClient.DeleteContact(ctx, req)
266266
if err != nil {
267267
if direct.IsNotFound(err) {
268268
// Return success if not found (assume it was already deleted).
269-
log.V(2).Info("skipping delete for non-existent essential contact, assuming it was already deleted", "name", a.actual.Name)
269+
log.Info("skipping delete for non-existent essential contact, assuming it was already deleted", "name", a.actual.Name)
270270
return true, nil
271271
}
272272
return false, fmt.Errorf("deleting essential contact %s: %w", a.actual.Name, err)
273273
}
274-
log.V(2).Info("successfully deleted essential contact", "name", a.actual.Name)
274+
log.Info("successfully deleted essential contact", "name", a.actual.Name)
275275

276276
return true, nil
277277
}

pkg/test/resourcefixture/testdata/basic/essentialcontacts/v1alpha1/essentialcontactscontact/essentialcontactscontact-minimal/create.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ metadata:
1919
spec:
2020
projectRef:
2121
external: ${projectId}
22-
location: us-central1
23-
description: "Initial description"
22+
languageTag: en
23+
notificationCategorySubscriptions:
24+
- BILLING
25+

pkg/test/resourcefixture/testdata/basic/essentialcontacts/v1alpha1/essentialcontactscontact/essentialcontactscontact-minimal/update.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ metadata:
1919
spec:
2020
projectRef:
2121
external: ${projectId}
22-
location: us-central1
23-
description: "Updated description"
22+
languageTag: en
23+
notificationCategorySubscriptions:
24+
- ALL
25+

0 commit comments

Comments
 (0)