This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Nutanix CSI credentials Secret creation
The existing code created a ClusterResourceSet with the user provided Secret. However, that won't work unless that Secret has an embedded Secret in it.
- Loading branch information
Showing
9 changed files
with
341 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2023 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package utils | ||
|
||
import ( | ||
storagev1 "k8s.io/api/storage/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/utils/ptr" | ||
|
||
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/v1alpha1" | ||
) | ||
|
||
const ( | ||
kindStorageClass = "StorageClass" | ||
) | ||
|
||
func CreateStorageClass( | ||
storageConfig v1alpha1.StorageClassConfig, | ||
provisionerName v1alpha1.StorageProvisioner, | ||
isDefault bool, | ||
defaultParameters map[string]string, | ||
) *storagev1.StorageClass { | ||
parameters := make(map[string]string) | ||
// set the defaults first so that user provided parameters can override them | ||
for k, v := range defaultParameters { | ||
parameters[k] = v | ||
} | ||
// set user provided parameters, overriding any defaults with the same key | ||
for k, v := range storageConfig.Parameters { | ||
parameters[k] = v | ||
} | ||
|
||
sc := storagev1.StorageClass{ | ||
TypeMeta: metav1.TypeMeta{ | ||
Kind: kindStorageClass, | ||
APIVersion: storagev1.SchemeGroupVersion.String(), | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: storageConfig.Name, | ||
}, | ||
Provisioner: string(provisionerName), | ||
Parameters: parameters, | ||
VolumeBindingMode: ptr.To(storageConfig.VolumeBindingMode), | ||
ReclaimPolicy: ptr.To(storageConfig.ReclaimPolicy), | ||
AllowVolumeExpansion: ptr.To(storageConfig.AllowExpansion), | ||
} | ||
if isDefault { | ||
sc.ObjectMeta.Annotations = defaultStorageClassMap | ||
} | ||
return &sc | ||
} |
Oops, something went wrong.