Skip to content

Commit

Permalink
Fix nutanix create mgmt new workflow (#7514)
Browse files Browse the repository at this point in the history
* Fix nutanix create mgmt new workflow

* Make method unexported
  • Loading branch information
mitalipaygude authored Feb 7, 2024
1 parent a8a706c commit 36d70e0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/providers/nutanix/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ func (p *Provider) UpdateSecrets(ctx context.Context, cluster *types.Cluster, cl
return fmt.Errorf("loading secrets object: %v", err)
}

return p.updateEKSASecrets(ctx, cluster, clusterSpec)
}

// updateEKSASecrets generates and applies the EKSA secret on the cluster.
func (p *Provider) updateEKSASecrets(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error {
eksaSecretContents, err := p.templateBuilder.GenerateEKSASpecSecret(clusterSpec)
if err != nil {
return err
Expand Down Expand Up @@ -692,7 +697,7 @@ func (p *Provider) InstallCustomProviderComponents(ctx context.Context, kubeconf
}

func (p *Provider) PreCAPIInstallOnBootstrap(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error {
return nil
return p.updateEKSASecrets(ctx, cluster, clusterSpec)
}

func (p *Provider) PostMoveManagementToBootstrap(ctx context.Context, bootstrapCluster *types.Cluster) error {
Expand Down
18 changes: 17 additions & 1 deletion pkg/providers/nutanix/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,12 +1041,28 @@ func TestNutanixProviderInstallCustomProviderComponents(t *testing.T) {
}

func TestNutanixProviderPreCAPIInstallOnBootstrap(t *testing.T) {
provider := testDefaultNutanixProvider(t)
ctrl := gomock.NewController(t)
executable := mockexecutables.NewMockExecutable(ctrl)
executable.EXPECT().ExecuteWithStdin(gomock.Any(), gomock.Any(), gomock.Any()).Return(bytes.Buffer{}, nil)
kubectl := executables.NewKubectl(executable)
mockClient := mocknutanix.NewMockClient(ctrl)
mockCertValidator := mockCrypto.NewMockTlsValidator(ctrl)
mockTransport := mocknutanix.NewMockRoundTripper(ctrl)
mockTransport.EXPECT().RoundTrip(gomock.Any()).Return(&http.Response{}, nil).AnyTimes()
mockHTTPClient := &http.Client{Transport: mockTransport}
mockWriter := filewritermocks.NewMockFileWriter(ctrl)
provider := testNutanixProvider(t, mockClient, kubectl, mockCertValidator, mockHTTPClient, mockWriter)

cluster := &types.Cluster{Name: "eksa-unit-test"}
clusterSpec := test.NewFullClusterSpec(t, "testdata/eksa-cluster.yaml")
err := provider.PreCAPIInstallOnBootstrap(context.Background(), cluster, clusterSpec)
assert.NoError(t, err)

storedMarshal := jsonMarshal
jsonMarshal = fakemarshal
err = provider.PreCAPIInstallOnBootstrap(context.Background(), cluster, clusterSpec)
assert.ErrorContains(t, err, "marshalling failed")
restoremarshal(storedMarshal)
}

func TestNutanixProviderPostMoveManagementToBootstrap(t *testing.T) {
Expand Down

0 comments on commit 36d70e0

Please sign in to comment.