Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
controller: rename secretclient to api since it contains more than se…
Browse files Browse the repository at this point in the history
…cret utils now

Signed-off-by: Muvaffak Onus <me@muvaf.com>
  • Loading branch information
muvaf committed Oct 22, 2021
1 parent b249ad8 commit bc01a67
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/secretclient.go → pkg/controller/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (ac *APICallbacks) Apply(name string) terraform.CallbackFn {
if kErr := ac.kube.Get(ctx, nn, tr); kErr != nil {
return errors.Wrap(kErr, "cannot get Terraformed resource")
}
tr.SetConditions(resource.LastOperationCondition(err))
tr.SetConditions(resource.AsyncOperationCondition(err))
return errors.Wrap(ac.kube.Status().Update(ctx, tr), errStatusUpdate)
}
}
Expand All @@ -95,7 +95,7 @@ func (ac *APICallbacks) Destroy(name string) terraform.CallbackFn {
if kErr := ac.kube.Get(ctx, nn, tr); kErr != nil {
return errors.Wrap(kErr, "cannot get Terraformed resource")
}
tr.SetConditions(resource.LastOperationCondition(err))
tr.SetConditions(resource.AsyncOperationCondition(err))
return errors.Wrap(ac.kube.Status().Update(ctx, tr), errStatusUpdate)
}
}
8 changes: 4 additions & 4 deletions pkg/controller/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ type external struct {
callback CallbackProvider
}

func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed.ExternalObservation, error) {
func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed.ExternalObservation, error) { //nolint:gocyclo
// We skip the gocyclo check because most of the operations are straight-forward
// and serial.
// TODO(muvaf): Look for ways to reduce the cyclomatic complexity without
Expand Down Expand Up @@ -188,7 +188,7 @@ func (e *external) Observe(ctx context.Context, mg xpresource.Managed) (managed.
}

func (e *external) Create(ctx context.Context, mg xpresource.Managed) (managed.ExternalCreation, error) {
if e.callback != nil {
if e.config.UseAsync {
return managed.ExternalCreation{}, errors.Wrap(e.workspace.ApplyAsync(e.callback.Apply(mg.GetName())), errStartAsyncApply)
}
tr, ok := mg.(resource.Terraformed)
Expand All @@ -215,7 +215,7 @@ func (e *external) Create(ctx context.Context, mg xpresource.Managed) (managed.E
}

func (e *external) Update(ctx context.Context, mg xpresource.Managed) (managed.ExternalUpdate, error) {
if e.callback != nil {
if e.config.UseAsync {
return managed.ExternalUpdate{}, errors.Wrap(e.workspace.ApplyAsync(e.callback.Apply(mg.GetName())), errStartAsyncApply)
}
tr, ok := mg.(resource.Terraformed)
Expand All @@ -234,7 +234,7 @@ func (e *external) Update(ctx context.Context, mg xpresource.Managed) (managed.E
}

func (e *external) Delete(ctx context.Context, mg xpresource.Managed) error {
if e.callback != nil {
if e.config.UseAsync {
return errors.Wrap(e.workspace.DestroyAsync(e.callback.Destroy(mg.GetName())), errStartAsyncDestroy)
}
return errors.Wrap(e.workspace.Destroy(ctx), errDestroy)
Expand Down
5 changes: 2 additions & 3 deletions pkg/controller/external_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,8 @@ func TestConnect(t *testing.T) {

func TestObserve(t *testing.T) {
type args struct {
w Workspace
async bool
obj xpresource.Managed
w Workspace
obj xpresource.Managed
}
type want struct {
obs managed.ExternalObservation
Expand Down
4 changes: 2 additions & 2 deletions pkg/resource/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const (
ReasonSuccess xpv1.ConditionReason = "Success"
)

// LastOperationCondition returns the condition depending on the content
// AsyncOperationCondition returns the condition depending on the content
// of the error.
func LastOperationCondition(err error) xpv1.Condition {
func AsyncOperationCondition(err error) xpv1.Condition {
switch {
case err == nil:
return xpv1.Condition{
Expand Down

0 comments on commit bc01a67

Please sign in to comment.