Skip to content

Commit

Permalink
feedback PR meeting
Browse files Browse the repository at this point in the history
  • Loading branch information
threadproc committed Sep 19, 2023
1 parent 4482809 commit 3c231f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions pkg/controller/servicecatalog/provisionedproduct/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ func (c *custom) Update(ctx context.Context, mg resource.Managed) (managed.Exter
return managed.ExternalUpdate{}, errors.New(errUnexpectedObject)
}

// TODO: move this to preUpdate

// We want to check if we are in a state where we can actually update it
ppStatus := pointer.StringDeref(cr.Status.AtProvider.Status, "")
if ppStatus == "" || ppStatus == string(svcapitypes.ProvisionedProductStatus_SDK_UNDER_CHANGE) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/servicecatalog/provisionedproduct/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const (
acceptLanguageEnglish = "en"
)

// TODO: merge utils and lifecycle.go into this file

type customConnector struct {
kube client.Client
}
Expand Down Expand Up @@ -88,6 +90,8 @@ func SetupProvisionedProduct(mgr ctrl.Manager, o controller.Options) error {
}

func (c *customConnector) Connect(ctx context.Context, mg resource.Managed) (managed.ExternalClient, error) {
// TODO: remove custom connector and move code from Update method to preUpdate

cr, ok := mg.(*svcapitypes.ProvisionedProduct)
if !ok {
return nil, errors.New(errUnexpectedObject)
Expand Down
10 changes: 3 additions & 7 deletions pkg/controller/servicecatalog/provisionedproduct/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,10 @@ func provisioningParamsAreChanged(cfStackParams []cfsdkv2types.Parameter, curren

// productOrArtifactAreChanged will attempt to determine whether or not the currently requested SC product and provisioning artifact IDs have changed when using names instead of IDs
func (c *custom) productOrArtifactAreChanged(ds *svcapitypes.ProvisionedProductParameters, resp *svcsdk.ProvisionedProductDetail) (bool, error) { // nolint:gocyclo
var productID, artifactID string
productID := pointer.StringDeref(ds.ProductID, "")
artifactID := pointer.StringDeref(ds.ProvisioningArtifactID, "")

if ds.ProductID != nil {
productID = pointer.StringDeref(ds.ProductID, "")
}
if ds.ProvisioningArtifactID != nil {
artifactID = pointer.StringDeref(ds.ProvisioningArtifactID, "")
}
// TODO: write tests for this function before any refactoring

if productID == "" || artifactID == "" {
// If we are using names for either the product or artifact, we should
Expand Down

0 comments on commit 3c231f6

Please sign in to comment.