Skip to content

Commit

Permalink
Fix NPE when registering Tenants (#1921)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvaldivia committed Dec 28, 2023
1 parent 8471e33 commit 6a99fbf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions api/operator_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/minio/operator/api/operations/operator_api"
"github.com/minio/operator/models"
miniov2 "github.com/minio/operator/pkg/apis/minio.min.io/v2"
v2 "github.com/minio/operator/pkg/apis/minio.min.io/v2"
xhttp "github.com/minio/operator/pkg/http"
"github.com/minio/operator/pkg/subnet"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -154,7 +153,7 @@ func getTenantsToRegister(ctx context.Context, session *models.Principal, k8sCli
if err != nil {
return nil, err
}
tenantStructs := make([]tenantInterface, len(tenantList.Items))
var tenantStructs []tenantInterface
for _, tenant := range tenantList.Items {
svcURL := tenant.GetTenantServiceURL()
mAdmin, err := getTenantAdminClient(ctx, k8sClient, &tenant, svcURL)
Expand All @@ -168,7 +167,7 @@ func getTenantsToRegister(ctx context.Context, session *models.Principal, k8sCli

func registerTenants(ctx context.Context, k8sClient K8sClientI, tenants []tenantInterface, apiKey string) (*models.OperatorSubnetRegisterAPIKeyResponse, *models.Error) {
for _, tenant := range tenants {
if err := registerTenant(ctx, k8sClient, tenant.mAdminClient, tenant.tenant, apiKey); err != nil {
if err := registerTenant(ctx, tenant.mAdminClient, apiKey); err != nil {
return nil, ErrorWithContext(ctx, err)
}
}
Expand Down Expand Up @@ -202,7 +201,7 @@ func SubnetRegisterWithAPIKey(ctx context.Context, minioClient MinioAdmin, apiKe
return true, nil
}

func registerTenant(ctx context.Context, k8sClient K8sClientI, adminClient MinioAdmin, tenant v2.Tenant, apiKey string) error {
func registerTenant(ctx context.Context, adminClient MinioAdmin, apiKey string) error {
_, err := SubnetRegisterWithAPIKey(ctx, adminClient, apiKey)
return err
}
Expand Down

0 comments on commit 6a99fbf

Please sign in to comment.