Skip to content

Commit 9ba9d1b

Browse files
authored
Make packages for general utils code
This commit breaks up the utils/utils.go file into smaller packages in Trident.
1 parent 42d5277 commit 9ba9d1b

File tree

129 files changed

+4310
-4487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+4310
-4487
lines changed

cli/cmd/install.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2025 NetApp, Inc. All Rights Reserved.
22

33
package cmd
44

@@ -24,10 +24,10 @@ import (
2424
"github.com/netapp/trident/cli/api"
2525
k8sclient "github.com/netapp/trident/cli/k8s_client"
2626
tridentconfig "github.com/netapp/trident/config"
27+
"github.com/netapp/trident/internal/crypto"
2728
"github.com/netapp/trident/internal/nodeprep/protocol"
2829
. "github.com/netapp/trident/logging"
29-
"github.com/netapp/trident/utils"
30-
"github.com/netapp/trident/utils/crypto"
30+
"github.com/netapp/trident/pkg/network"
3131
"github.com/netapp/trident/utils/errors"
3232
versionutils "github.com/netapp/trident/utils/version"
3333
)
@@ -343,7 +343,7 @@ func discoverInstallationEnvironment() error {
343343

344344
// Override registry only if using the default Trident image name and an alternate registry was supplied
345345
if imageRegistry != "" {
346-
tridentImage = utils.ReplaceImageRegistry(tridentImage, imageRegistry)
346+
tridentImage = network.ReplaceImageRegistry(tridentImage, imageRegistry)
347347
}
348348
}
349349
Log().Debugf("Trident image: %s", tridentImage)
@@ -352,7 +352,7 @@ func discoverInstallationEnvironment() error {
352352
autosupportImage = tridentconfig.DefaultAutosupportImage
353353

354354
if imageRegistry != "" {
355-
autosupportImage = utils.ReplaceImageRegistry(autosupportImage, imageRegistry)
355+
autosupportImage = network.ReplaceImageRegistry(autosupportImage, imageRegistry)
356356
}
357357
}
358358
Log().Debugf("Autosupport image: %s", autosupportImage)
@@ -427,7 +427,7 @@ func validateInstallationArguments() error {
427427
labelFormat := "a DNS-1123 label must consist of lower case alphanumeric characters or '-', " +
428428
"and must start and end with an alphanumeric character"
429429

430-
if !utils.DNS1123LabelRegex.MatchString(TridentPodNamespace) {
430+
if !network.DNS1123LabelRegex.MatchString(TridentPodNamespace) {
431431
return fmt.Errorf("'%s' is not a valid namespace name; %s", TridentPodNamespace, labelFormat)
432432
}
433433

cli/cmd/uninstall.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2025 NetApp, Inc. All Rights Reserved.
22

33
package cmd
44

@@ -11,7 +11,7 @@ import (
1111
k8sclient "github.com/netapp/trident/cli/k8s_client"
1212
tridentconfig "github.com/netapp/trident/config"
1313
. "github.com/netapp/trident/logging"
14-
"github.com/netapp/trident/utils"
14+
"github.com/netapp/trident/pkg/network"
1515
)
1616

1717
func init() {
@@ -88,7 +88,7 @@ func discoverTrident() (installed bool, err error) {
8888
}
8989

9090
func validateUninstallationArguments() error {
91-
if !utils.DNS1123LabelRegex.MatchString(TridentPodNamespace) {
91+
if !network.DNS1123LabelRegex.MatchString(TridentPodNamespace) {
9292
return fmt.Errorf("%s is not a valid namespace name; a DNS-1123 label must consist "+
9393
"of lower case alphanumeric characters or '-', and must start and end with an alphanumeric "+
9494
"character", TridentPodNamespace)

cli/cmd/update_node.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2025 NetApp, Inc. All Rights Reserved.
22

33
package cmd
44

@@ -13,7 +13,7 @@ import (
1313

1414
"github.com/netapp/trident/cli/api"
1515
"github.com/netapp/trident/frontend/rest"
16-
"github.com/netapp/trident/utils"
16+
"github.com/netapp/trident/pkg/convert"
1717
"github.com/netapp/trident/utils/errors"
1818
"github.com/netapp/trident/utils/models"
1919
)
@@ -45,13 +45,13 @@ var updateNodeCmd = &cobra.Command{
4545
var ready, adminReady, cleaned *bool
4646
var err error
4747
if cmd.Flags().Changed("orchestratorReady") {
48-
ready = utils.Ptr(orchestratorReady)
48+
ready = convert.ToPtr(orchestratorReady)
4949
}
5050
if cmd.Flags().Changed("administratorReady") {
51-
adminReady = utils.Ptr(administratorReady)
51+
adminReady = convert.ToPtr(administratorReady)
5252
}
5353
if cmd.Flags().Changed("provisionerReady") {
54-
cleaned = utils.Ptr(provisionerReady)
54+
cleaned = convert.ToPtr(provisionerReady)
5555
}
5656

5757
if OperatingMode == ModeTunnel {

cli/k8s_client/yaml_factory.go

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2025 NetApp, Inc. All Rights Reserved.
22

33
package k8sclient
44

@@ -10,7 +10,8 @@ import (
1010

1111
commonconfig "github.com/netapp/trident/config"
1212
. "github.com/netapp/trident/logging"
13-
"github.com/netapp/trident/utils"
13+
"github.com/netapp/trident/pkg/collection"
14+
"github.com/netapp/trident/pkg/yaml"
1415
)
1516

1617
const (
@@ -59,8 +60,8 @@ func GetServiceAccountYAML(
5960
}
6061

6162
saYAML = strings.ReplaceAll(saYAML, "{NAME}", serviceAccountName)
62-
saYAML = utils.ReplaceMultilineYAMLTag(saYAML, "LABELS", constructLabels(labels))
63-
saYAML = utils.ReplaceMultilineYAMLTag(saYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
63+
saYAML = yaml.ReplaceMultilineTag(saYAML, "LABELS", constructLabels(labels))
64+
saYAML = yaml.ReplaceMultilineTag(saYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
6465

6566
// Log().service account YAML before the secrets are added.
6667
Log().WithField("yaml", saYAML).Trace("Service account YAML.")
@@ -99,8 +100,8 @@ func GetClusterRoleYAML(clusterRoleName string, labels, controllingCRDetails map
99100

100101
clusterRoleYAML := controllerClusterRoleCSIYAMLTemplate
101102
clusterRoleYAML = strings.ReplaceAll(clusterRoleYAML, "{CLUSTER_ROLE_NAME}", clusterRoleName)
102-
clusterRoleYAML = utils.ReplaceMultilineYAMLTag(clusterRoleYAML, "LABELS", constructLabels(labels))
103-
clusterRoleYAML = utils.ReplaceMultilineYAMLTag(clusterRoleYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
103+
clusterRoleYAML = yaml.ReplaceMultilineTag(clusterRoleYAML, "LABELS", constructLabels(labels))
104+
clusterRoleYAML = yaml.ReplaceMultilineTag(clusterRoleYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
104105
Log().WithField("yaml", clusterRoleYAML).Trace("Cluster role YAML.")
105106
return clusterRoleYAML
106107
}
@@ -191,8 +192,8 @@ func GetRoleYAML(namespace, roleName string, labels, controllingCRDetails map[st
191192

192193
roleYAML = strings.ReplaceAll(roleYAML, "{ROLE_NAME}", roleName)
193194
roleYAML = strings.ReplaceAll(roleYAML, "{NAMESPACE}", namespace)
194-
roleYAML = utils.ReplaceMultilineYAMLTag(roleYAML, "LABELS", constructLabels(labels))
195-
roleYAML = utils.ReplaceMultilineYAMLTag(roleYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
195+
roleYAML = yaml.ReplaceMultilineTag(roleYAML, "LABELS", constructLabels(labels))
196+
roleYAML = yaml.ReplaceMultilineTag(roleYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
196197

197198
return roleYAML
198199
}
@@ -235,8 +236,8 @@ func GetRoleBindingYAML(namespace, name string, labels, controllingCRDetails map
235236
rbYAML := roleBindingKubernetesV1YAMLTemplate
236237
rbYAML = strings.ReplaceAll(rbYAML, "{NAMESPACE}", namespace)
237238
rbYAML = strings.ReplaceAll(rbYAML, "{NAME}", name)
238-
rbYAML = utils.ReplaceMultilineYAMLTag(rbYAML, "LABELS", constructLabels(labels))
239-
rbYAML = utils.ReplaceMultilineYAMLTag(rbYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
239+
rbYAML = yaml.ReplaceMultilineTag(rbYAML, "LABELS", constructLabels(labels))
240+
rbYAML = yaml.ReplaceMultilineTag(rbYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
240241
return rbYAML
241242
}
242243

@@ -274,8 +275,8 @@ func GetClusterRoleBindingYAML(
274275

275276
crbYAML = strings.ReplaceAll(crbYAML, "{NAMESPACE}", namespace)
276277
crbYAML = strings.ReplaceAll(crbYAML, "{NAME}", name)
277-
crbYAML = utils.ReplaceMultilineYAMLTag(crbYAML, "LABELS", constructLabels(labels))
278-
crbYAML = utils.ReplaceMultilineYAMLTag(crbYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
278+
crbYAML = yaml.ReplaceMultilineTag(crbYAML, "LABELS", constructLabels(labels))
279+
crbYAML = yaml.ReplaceMultilineTag(crbYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
279280

280281
Log().WithField("yaml", crbYAML).Trace("Cluster role binding YAML.")
281282
return crbYAML
@@ -308,8 +309,8 @@ func GetCSIServiceYAML(serviceName string, labels, controllingCRDetails map[stri
308309

309310
serviceYAML := strings.ReplaceAll(serviceYAMLTemplate, "{LABEL_APP}", labels[TridentAppLabelKey])
310311
serviceYAML = strings.ReplaceAll(serviceYAML, "{SERVICE_NAME}", serviceName)
311-
serviceYAML = utils.ReplaceMultilineYAMLTag(serviceYAML, "LABELS", constructLabels(labels))
312-
serviceYAML = utils.ReplaceMultilineYAMLTag(serviceYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
312+
serviceYAML = yaml.ReplaceMultilineTag(serviceYAML, "LABELS", constructLabels(labels))
313+
serviceYAML = yaml.ReplaceMultilineTag(serviceYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
313314

314315
Log().WithField("yaml", serviceYAML).Trace("CSI Service YAML.")
315316
return serviceYAML
@@ -347,8 +348,8 @@ func GetResourceQuotaYAML(resourceQuotaName, namespace string, labels, controlli
347348

348349
resourceQuotaYAML := strings.ReplaceAll(resourceQuotaYAMLTemplate, "{RESOURCEQUOTA_NAME}", resourceQuotaName)
349350
resourceQuotaYAML = strings.ReplaceAll(resourceQuotaYAML, "{NAMESPACE}", namespace)
350-
resourceQuotaYAML = utils.ReplaceMultilineYAMLTag(resourceQuotaYAML, "LABELS", constructLabels(labels))
351-
resourceQuotaYAML = utils.ReplaceMultilineYAMLTag(resourceQuotaYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
351+
resourceQuotaYAML = yaml.ReplaceMultilineTag(resourceQuotaYAML, "LABELS", constructLabels(labels))
352+
resourceQuotaYAML = yaml.ReplaceMultilineTag(resourceQuotaYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
352353

353354
Log().WithField("yaml", resourceQuotaYAML).Trace("Resource Quota YAML.")
354355
return resourceQuotaYAML
@@ -498,18 +499,18 @@ func GetCSIDeploymentYAML(args *DeploymentYAMLArguments) string {
498499
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{HTTP_REQUEST_TIMEOUT}", args.HTTPRequestTimeout)
499500
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{SERVICE_ACCOUNT}", args.ServiceAccountName)
500501
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{IMAGE_PULL_POLICY}", args.ImagePullPolicy)
501-
deploymentYAML = utils.ReplaceMultilineYAMLTag(deploymentYAML, "LABELS", constructLabels(args.Labels))
502-
deploymentYAML = utils.ReplaceMultilineYAMLTag(deploymentYAML, "OWNER_REF", constructOwnerRef(args.ControllingCRDetails))
503-
deploymentYAML = utils.ReplaceMultilineYAMLTag(deploymentYAML, "NODE_SELECTOR", constructNodeSelector(args.NodeSelector))
504-
deploymentYAML = utils.ReplaceMultilineYAMLTag(deploymentYAML, "NODE_TOLERATIONS", constructTolerations(args.Tolerations))
502+
deploymentYAML = yaml.ReplaceMultilineTag(deploymentYAML, "LABELS", constructLabels(args.Labels))
503+
deploymentYAML = yaml.ReplaceMultilineTag(deploymentYAML, "OWNER_REF", constructOwnerRef(args.ControllingCRDetails))
504+
deploymentYAML = yaml.ReplaceMultilineTag(deploymentYAML, "NODE_SELECTOR", constructNodeSelector(args.NodeSelector))
505+
deploymentYAML = yaml.ReplaceMultilineTag(deploymentYAML, "NODE_TOLERATIONS", constructTolerations(args.Tolerations))
505506
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{ENABLE_FORCE_DETACH}", strconv.FormatBool(args.EnableForceDetach))
506507
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{ENABLE_ACP}", enableACP)
507508
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{K8S_API_CLIENT_TRIDENT_THROTTLE}", K8sAPITridentThrottle)
508509
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{K8S_API_CLIENT_SIDECAR_THROTTLE}", K8sAPISidecarThrottle)
509510

510511
// Log before secrets are inserted into YAML.
511512
Log().WithField("yaml", deploymentYAML).Trace("CSI Deployment YAML.")
512-
deploymentYAML = utils.ReplaceMultilineYAMLTag(deploymentYAML, "IMAGE_PULL_SECRETS",
513+
deploymentYAML = yaml.ReplaceMultilineTag(deploymentYAML, "IMAGE_PULL_SECRETS",
513514
constructImagePullSecrets(args.ImagePullSecrets))
514515

515516
return deploymentYAML
@@ -804,13 +805,13 @@ func GetCSIDaemonSetYAMLWindows(args *DaemonsetYAMLArguments) string {
804805
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{HTTP_REQUEST_TIMEOUT}", args.HTTPRequestTimeout)
805806
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{SERVICE_ACCOUNT}", args.ServiceAccountName)
806807
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{IMAGE_PULL_POLICY}", args.ImagePullPolicy)
807-
daemonSetYAML = utils.ReplaceMultilineYAMLTag(daemonSetYAML, "NODE_SELECTOR", constructNodeSelector(args.NodeSelector))
808-
daemonSetYAML = utils.ReplaceMultilineYAMLTag(daemonSetYAML, "NODE_TOLERATIONS", constructTolerations(tolerations))
809-
daemonSetYAML = utils.ReplaceMultilineYAMLTag(daemonSetYAML, "LABELS", constructLabels(args.Labels))
810-
daemonSetYAML = utils.ReplaceMultilineYAMLTag(daemonSetYAML, "OWNER_REF", constructOwnerRef(args.ControllingCRDetails))
808+
daemonSetYAML = yaml.ReplaceMultilineTag(daemonSetYAML, "NODE_SELECTOR", constructNodeSelector(args.NodeSelector))
809+
daemonSetYAML = yaml.ReplaceMultilineTag(daemonSetYAML, "NODE_TOLERATIONS", constructTolerations(tolerations))
810+
daemonSetYAML = yaml.ReplaceMultilineTag(daemonSetYAML, "LABELS", constructLabels(args.Labels))
811+
daemonSetYAML = yaml.ReplaceMultilineTag(daemonSetYAML, "OWNER_REF", constructOwnerRef(args.ControllingCRDetails))
811812
// Log before secrets are inserted into YAML.
812813
Log().WithField("yaml", daemonSetYAML).Trace("CSI Daemonset Windows YAML.")
813-
daemonSetYAML = utils.ReplaceMultilineYAMLTag(daemonSetYAML, "IMAGE_PULL_SECRETS",
814+
daemonSetYAML = yaml.ReplaceMultilineTag(daemonSetYAML, "IMAGE_PULL_SECRETS",
814815
constructImagePullSecrets(args.ImagePullSecrets))
815816

816817
return daemonSetYAML
@@ -882,14 +883,14 @@ func GetCSIDaemonSetYAMLLinux(args *DaemonsetYAMLArguments) string {
882883
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{IMAGE_PULL_POLICY}", args.ImagePullPolicy)
883884
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{ISCSI_SELF_HEALING_INTERVAL}", args.ISCSISelfHealingInterval)
884885
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{ISCSI_SELF_HEALING_WAIT_TIME}", args.ISCSISelfHealingWaitTime)
885-
daemonSetYAML = utils.ReplaceMultilineYAMLTag(daemonSetYAML, "NODE_SELECTOR", constructNodeSelector(args.NodeSelector))
886-
daemonSetYAML = utils.ReplaceMultilineYAMLTag(daemonSetYAML, "NODE_TOLERATIONS", constructTolerations(tolerations))
887-
daemonSetYAML = utils.ReplaceMultilineYAMLTag(daemonSetYAML, "LABELS", constructLabels(args.Labels))
888-
daemonSetYAML = utils.ReplaceMultilineYAMLTag(daemonSetYAML, "OWNER_REF", constructOwnerRef(args.ControllingCRDetails))
886+
daemonSetYAML = yaml.ReplaceMultilineTag(daemonSetYAML, "NODE_SELECTOR", constructNodeSelector(args.NodeSelector))
887+
daemonSetYAML = yaml.ReplaceMultilineTag(daemonSetYAML, "NODE_TOLERATIONS", constructTolerations(tolerations))
888+
daemonSetYAML = yaml.ReplaceMultilineTag(daemonSetYAML, "LABELS", constructLabels(args.Labels))
889+
daemonSetYAML = yaml.ReplaceMultilineTag(daemonSetYAML, "OWNER_REF", constructOwnerRef(args.ControllingCRDetails))
889890

890891
// Log before secrets are inserted into YAML.
891892
Log().WithField("yaml", daemonSetYAML).Trace("CSI Daemonset Linux YAML.")
892-
daemonSetYAML = utils.ReplaceMultilineYAMLTag(daemonSetYAML, "IMAGE_PULL_SECRETS",
893+
daemonSetYAML = yaml.ReplaceMultilineTag(daemonSetYAML, "IMAGE_PULL_SECRETS",
893894
constructImagePullSecrets(args.ImagePullSecrets))
894895

895896
return daemonSetYAML
@@ -1409,13 +1410,13 @@ func GetTridentVersionPodYAML(args *TridentVersionPodYAMLArguments) string {
14091410
versionPodYAML := strings.ReplaceAll(tridentVersionPodYAML, "{NAME}", args.TridentVersionPodName)
14101411
versionPodYAML = strings.ReplaceAll(versionPodYAML, "{TRIDENT_IMAGE}", args.TridentImage)
14111412
versionPodYAML = strings.ReplaceAll(versionPodYAML, "{SERVICE_ACCOUNT}", args.ServiceAccountName)
1412-
versionPodYAML = utils.ReplaceMultilineYAMLTag(versionPodYAML, "LABELS", constructLabels(args.Labels))
1413-
versionPodYAML = utils.ReplaceMultilineYAMLTag(versionPodYAML, "OWNER_REF", constructOwnerRef(args.ControllingCRDetails))
1414-
versionPodYAML = utils.ReplaceMultilineYAMLTag(versionPodYAML, "NODE_TOLERATIONS", constructTolerations(args.Tolerations))
1413+
versionPodYAML = yaml.ReplaceMultilineTag(versionPodYAML, "LABELS", constructLabels(args.Labels))
1414+
versionPodYAML = yaml.ReplaceMultilineTag(versionPodYAML, "OWNER_REF", constructOwnerRef(args.ControllingCRDetails))
1415+
versionPodYAML = yaml.ReplaceMultilineTag(versionPodYAML, "NODE_TOLERATIONS", constructTolerations(args.Tolerations))
14151416

14161417
// Log before secrets are inserted into YAML.
14171418
Log().WithField("yaml", versionPodYAML).Trace("Trident Version Pod YAML.")
1418-
versionPodYAML = utils.ReplaceMultilineYAMLTag(versionPodYAML, "IMAGE_PULL_SECRETS",
1419+
versionPodYAML = yaml.ReplaceMultilineTag(versionPodYAML, "IMAGE_PULL_SECRETS",
14191420
constructImagePullSecrets(args.ImagePullSecrets))
14201421
versionPodYAML = strings.ReplaceAll(versionPodYAML, "{IMAGE_PULL_POLICY}", args.ImagePullPolicy)
14211422

@@ -1471,8 +1472,8 @@ func GetOpenShiftSCCYAML(
14711472
sccYAML = strings.ReplaceAll(sccYAML, "{SCC}", sccName)
14721473
sccYAML = strings.ReplaceAll(sccYAML, "{NAMESPACE}", namespace)
14731474
sccYAML = strings.ReplaceAll(sccYAML, "{USER}", user)
1474-
sccYAML = utils.ReplaceMultilineYAMLTag(sccYAML, "LABELS", constructLabels(labels))
1475-
sccYAML = utils.ReplaceMultilineYAMLTag(sccYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
1475+
sccYAML = yaml.ReplaceMultilineTag(sccYAML, "LABELS", constructLabels(labels))
1476+
sccYAML = yaml.ReplaceMultilineTag(sccYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
14761477

14771478
Log().WithField("yaml", sccYAML).Trace("OpenShift SCC YAML.")
14781479
return sccYAML
@@ -1592,8 +1593,8 @@ func GetSecretYAML(
15921593

15931594
secretYAML := strings.ReplaceAll(secretYAMLTemplate, "{SECRET_NAME}", secretName)
15941595
secretYAML = strings.ReplaceAll(secretYAML, "{NAMESPACE}", namespace)
1595-
secretYAML = utils.ReplaceMultilineYAMLTag(secretYAML, "LABELS", constructLabels(labels))
1596-
secretYAML = utils.ReplaceMultilineYAMLTag(secretYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
1596+
secretYAML = yaml.ReplaceMultilineTag(secretYAML, "LABELS", constructLabels(labels))
1597+
secretYAML = yaml.ReplaceMultilineTag(secretYAML, "OWNER_REF", constructOwnerRef(controllingCRDetails))
15971598

15981599
// Log before actual secrets are inserted into YAML.
15991600
Log().WithField("yaml", secretYAML).Trace("(Redacted) Secret YAML.")
@@ -2560,8 +2561,8 @@ func GetCSIDriverYAML(name string, labels, controllingCRDetails map[string]strin
25602561
defer func() { Log().Trace("<<<< GetCSIDriverYAML") }()
25612562

25622563
csiDriver := strings.ReplaceAll(CSIDriverYAMLv1, "{NAME}", name)
2563-
csiDriver = utils.ReplaceMultilineYAMLTag(csiDriver, "LABELS", constructLabels(labels))
2564-
csiDriver = utils.ReplaceMultilineYAMLTag(csiDriver, "OWNER_REF", constructOwnerRef(controllingCRDetails))
2564+
csiDriver = yaml.ReplaceMultilineTag(csiDriver, "LABELS", constructLabels(labels))
2565+
csiDriver = yaml.ReplaceMultilineTag(csiDriver, "OWNER_REF", constructOwnerRef(controllingCRDetails))
25652566

25662567
Log().WithField("yaml", csiDriver).Trace("CSI Driver YAML")
25672568
return csiDriver
@@ -2612,7 +2613,7 @@ func constructTolerations(tolerations []map[string]string) string {
26122613
toleration += fmt.Sprintf(" tolerationSeconds: %s\n", t["tolerationSeconds"])
26132614
}
26142615
if toleration != "" {
2615-
toleration, _ = utils.ReplaceAtIndex(toleration, '-', 0)
2616+
toleration, _ = collection.ReplaceAtIndex(toleration, '-', 0)
26162617
tolerationsString += toleration
26172618
}
26182619
}

config/config.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2025 NetApp, Inc. All Rights Reserved.
22

33
package config
44

@@ -145,6 +145,10 @@ const (
145145
Windows = "windows"
146146
Darwin = "darwin"
147147

148+
// Path separators
149+
WindowsPathSeparator = `\`
150+
UnixPathSeparator = "/"
151+
148152
// Minimum and maximum supported Kubernetes versions
149153
KubernetesVersionMin = "v1.25"
150154
KubernetesVersionMax = "v1.31"
@@ -180,6 +184,9 @@ const (
180184

181185
// NVMeSelfHealingInterval is an interval with which the NVMe self-healing thread is called periodically
182186
NVMeSelfHealingInterval = 300 * time.Second
187+
188+
// REDACTED is replacement text for sensitive information that would otherwise be exposed by HTTP logging, etc.
189+
REDACTED = "<REDACTED>"
183190
)
184191

185192
var (

0 commit comments

Comments
 (0)