Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alper Rifat Ulucinar <[email protected]>
  • Loading branch information
ulucinar committed Nov 1, 2023
1 parent 1bad32b commit 4aeb57e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
1 change: 1 addition & 0 deletions pkg/config/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func TestDefaultResource(t *testing.T) {
cmpopts.IgnoreFields(Sensitive{}, "fieldPaths", "AdditionalConnectionDetailsFn"),
cmpopts.IgnoreFields(LateInitializer{}, "ignoredCanonicalFieldPaths"),
cmpopts.IgnoreFields(ExternalName{}, "SetIdentifierArgumentFn", "GetExternalNameFn", "GetIDFn"),
cmpopts.IgnoreFields(Resource{}, "useNoForkClient"),
}

for name, tc := range cases {
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func WithMainTemplate(template string) ProviderOption {
// NewProvider builds and returns a new Provider from provider
// tfjson schema, that is generated using Terraform CLI with:
// `terraform providers schema --json`
func NewProvider(schema []byte, prefix string, modulePath string, metadata []byte, opts ...ProviderOption) *Provider { // nolint:gocyclo
func NewProvider(schema []byte, prefix string, modulePath string, metadata []byte, opts ...ProviderOption) *Provider { //nolint:gocyclo
ps := tfjson.ProviderSchemas{}
if err := ps.UnmarshalJSON(schema); err != nil {
panic(err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/external_nofork.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (c *NoForkConnector) processParamsWithStateFunc(schemaMap map[string]*schem
return params
}

func (c *NoForkConnector) applyStateFuncToParam(sc *schema.Schema, param any) any {
func (c *NoForkConnector) applyStateFuncToParam(sc *schema.Schema, param any) any { //nolint:gocyclo
switch sc.Type {
case schema.TypeMap:
if sc.Elem == nil {
Expand Down Expand Up @@ -301,7 +301,7 @@ func deleteInstanceDiffAttribute(instanceDiff *tf.InstanceDiff, paramKey string)
return nil
}

func filterInitExclusiveDiffs(tr resource.Terraformed, instanceDiff *tf.InstanceDiff) error {
func filterInitExclusiveDiffs(tr resource.Terraformed, instanceDiff *tf.InstanceDiff) error { //nolint:gocyclo
if instanceDiff == nil || instanceDiff.Empty() {
return nil
}
Expand Down Expand Up @@ -373,7 +373,7 @@ func (n *noForkExternal) getResourceDataDiff(tr resource.Terraformed, ctx contex
return instanceDiff, nil
}

func (n *noForkExternal) Observe(ctx context.Context, mg xpresource.Managed) (managed.ExternalObservation, error) {
func (n *noForkExternal) Observe(ctx context.Context, mg xpresource.Managed) (managed.ExternalObservation, error) { //nolint:gocyclo
n.logger.Debug("Observing the external resource")

if meta.WasDeleted(mg) && n.opTracker.IsDeleted() {
Expand Down
6 changes: 0 additions & 6 deletions pkg/controller/nofork_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ func (a *AsyncTracker) GetTfID() string {
return a.tfState.ID
}

func (a *AsyncTracker) SetTfID(tfId string) {
//a.mu.Lock()
//defer a.mu.Unlock()
a.tfID = tfId
}

// IsDeleted returns whether the associated external resource
// has logically been deleted.
func (a *AsyncTracker) IsDeleted() bool {
Expand Down
2 changes: 1 addition & 1 deletion pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (r *MetricRecorder) ObserveReconcileDelay(gvk schema.GroupVersionKind, name
if o == nil || !o.(*Observations).observeReconcileDelay || o.(*Observations).expectedReconcileTime == nil {
return
}
d := time.Now().Sub(*o.(*Observations).expectedReconcileTime)
d := time.Since(*o.(*Observations).expectedReconcileTime)
if d < 0 {
d = 0
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/types/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import (
"sort"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/pkg/errors"
"k8s.io/utils/ptr"

"github.com/crossplane/upjet/pkg"
"github.com/crossplane/upjet/pkg/config"
"github.com/crossplane/upjet/pkg/types/comments"
"github.com/crossplane/upjet/pkg/types/name"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/pkg/errors"
"k8s.io/utils/ptr"
)

var parentheses = regexp.MustCompile(`\(([^)]+)\)`)
Expand Down Expand Up @@ -213,7 +214,7 @@ func NewReferenceField(g *Builder, cfg *config.Resource, r *resource, sch *schem
}

// AddToResource adds built field to the resource.
func (f *Field) AddToResource(g *Builder, r *resource, typeNames *TypeNames, addToObservation bool) {
func (f *Field) AddToResource(g *Builder, r *resource, typeNames *TypeNames, addToObservation bool) { //nolint:gocyclo
if f.Comment.UpjetOptions.FieldJSONTag != nil {
f.JSONTag = *f.Comment.UpjetOptions.FieldJSONTag
}
Expand Down

0 comments on commit 4aeb57e

Please sign in to comment.