Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
Signed-off-by: Wen Zhou <[email protected]>
  • Loading branch information
zdtsw committed Nov 8, 2024
1 parent 008772f commit e03c1c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions pkg/cluster/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
ofapiv2 "github.com/operator-framework/api/pkg/operators/v2"
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -73,10 +74,10 @@ func OperatorExists(ctx context.Context, cli client.Client, operatorPrefix strin
}

// CustomResourceDefinitionExists checks if a CustomResourceDefinition with the given GVK exists.
func CustomResourceDefinitionExists(ctx context.Context, cli client.Client, crdName string) error {
func CustomResourceDefinitionExists(ctx context.Context, cli client.Client, crdGK schema.GroupKind) error {
crd := &apiextv1.CustomResourceDefinition{}
resourceInterval, resourceTimeout := 5*time.Second, 1*time.Minute
name := strings.ToLower(crdName)
resourceInterval, resourceTimeout := 2*time.Second, 5*time.Second
name := strings.ToLower(fmt.Sprintf("%ss.%s", crdGK.Kind, crdGK.Group)) // we need plural form of the kind

err := wait.PollUntilContextTimeout(ctx, resourceInterval, resourceTimeout, false, func(ctx context.Context) (bool, error) {
err := cli.Get(ctx, client.ObjectKey{Name: name}, crd)
Expand Down
2 changes: 1 addition & 1 deletion pkg/feature/servicemesh/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func EnsureServiceMeshOperatorInstalled(ctx context.Context, cli client.Client,
return fmt.Errorf("failed to find the pre-requisite Service Mesh Operator subscription, please ensure Service Mesh Operator is installed. %w", err)
}
// Extra check SMCP CRD is installed and has become active.
if err := cluster.CustomResourceDefinitionExists(ctx, cli, gvk.ServiceMeshControlPlane.GroupKind().String()); err != nil {
if err := cluster.CustomResourceDefinitionExists(ctx, cli, gvk.ServiceMeshControlPlane.GroupKind()); err != nil {
return fmt.Errorf("failed to find the Service Mesh Control Plane CRD, please ensure Service Mesh Operator is installed. %w", err)
}

Expand Down

0 comments on commit e03c1c0

Please sign in to comment.