Skip to content

Commit 44d7c38

Browse files
committed
External-ccm: Fix go formatting
Go source files are currently not properly formatted, making `make gofmt` fail. This PR addresses that. Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
1 parent d845dcf commit 44d7c38

21 files changed

Lines changed: 151 additions & 160 deletions

File tree

cmd/oci-csi-controller-driver/csi-controller-driver/oci-csi-controller-driver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
)
2525

2626
const (
27-
bvCsiDriver = "BV"
28-
lustreCsiDriver = "Lustre"
27+
bvCsiDriver = "BV"
28+
lustreCsiDriver = "Lustre"
2929
)
3030

3131
// StartControllerDriver main function to start CSI Controller Driver

cmd/oci-csi-controller-driver/csioptions/csioptions.go

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import (
2323
)
2424

2525
const (
26-
fssAddressSuffix = "-fss.sock"
27-
fssVolumeNameAppendedPrefix = "-fss"
26+
fssAddressSuffix = "-fss.sock"
27+
fssVolumeNameAppendedPrefix = "-fss"
2828

2929
lustreAddressSuffix = "-lustre.sock"
3030
lustreVolumeNameAppendedPrefix = "-lustre"
3131

3232
CrossNamespaceVolumeDataSource = "CrossNamespaceVolumeDataSource"
33-
VolumeAttributesClass = "VolumeAttributesClass"
33+
VolumeAttributesClass = "VolumeAttributesClass"
3434
)
3535

3636
// CSIOptions structure which contains flag values
@@ -43,9 +43,9 @@ type CSIOptions struct {
4343
FssEndpoint string
4444
VolumeNamePrefix string
4545
FssVolumeNamePrefix string
46-
LustreCsiAddress string
47-
LustreEndpoint string
48-
LustreVolumeNamePrefix string
46+
LustreCsiAddress string
47+
LustreEndpoint string
48+
LustreVolumeNamePrefix string
4949
VolumeNameUUIDLength int
5050
ShowVersion bool
5151
RetryIntervalStart time.Duration
@@ -71,44 +71,42 @@ type CSIOptions struct {
7171
DefaultFSType string
7272
GroupSnapshotNamePrefix string
7373
GroupSnapshotNameUUIDLength int
74-
7574
}
7675

7776
// NewCSIOptions initializes the flag
7877
func NewCSIOptions() *CSIOptions {
7978
csioptions := CSIOptions{
80-
Master: *flag.String("master", "", "kube master"),
81-
Kubeconfig: *flag.String("kubeconfig", "", "cluster kube config"),
82-
CsiAddress: *flag.String("csi-address", "/run/csi/socket", "Address of the CSI BV driver socket."),
83-
Endpoint: *flag.String("csi-endpoint", "unix://tmp/csi.sock", "CSI BV endpoint"),
84-
FssCsiAddress: *flag.String("fss-csi-address", "/run/fss/socket", "Address of the CSI FSS driver socket."),
85-
FssEndpoint: *flag.String("fss-csi-endpoint", "unix://tmp/csi-fss.sock", "CSI FSS endpoint"),
86-
VolumeNamePrefix: *flag.String("csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a created volume."),
87-
FssVolumeNamePrefix: *flag.String("fss-csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a volume created for FSS."),
88-
LustreCsiAddress: *flag.String("lustre-csi-address", "/run/lustre/socket", "Address of the CSI Lustre driver socket."),
89-
LustreEndpoint: *flag.String("lustre-csi-endpoint", "unix://tmp/csi-lustre.sock", "CSI Lustre endpoint"),
90-
LustreVolumeNamePrefix: *flag.String("lustre-csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a volume created for Lustre."),
91-
VolumeNameUUIDLength: *flag.Int("csi-volume-name-uuid-length", -1, "Truncates generated UUID of a created volume to this length. Defaults behavior is to NOT truncate."),
92-
ShowVersion: *flag.Bool("csi-version", false, "Show version."),
93-
RetryIntervalStart: *flag.Duration("csi-retry-interval-start", time.Second, "Initial retry interval of failed provisioning or deletion. It doubles with each failure, up to retry-interval-max."),
94-
RetryIntervalMax: *flag.Duration("csi-retry-interval-max", 5*time.Minute, "Maximum retry interval of failed provisioning or deletion."),
95-
WorkerThreads: *flag.Uint("csi-worker-threads", 100, "Number of provisioner worker threads, in other words nr. of simultaneous CSI calls."),
96-
OperationTimeout: *flag.Duration("csi-op-timeout", 10*time.Second, "Timeout for waiting for creation or deletion of a volume"),
97-
EnableLeaderElection: *flag.Bool("csi-enable-leader-election", false, "Enables leader election. If leader election is enabled, additional RBAC rules are required. Please refer to the Kubernetes CSI documentation for instructions on setting up these RBAC rules."),
98-
LeaderElectionType: *flag.String("csi-leader-election-type", "endpoints", "the type of leader election, options are 'endpoints' (default) or 'leases' (strongly recommended). The 'endpoints' option is deprecated in favor of 'leases'."),
99-
LeaderElectionNamespace: *flag.String("csi-leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set."),
100-
StrictTopology: *flag.Bool("csi-strict-topology", false, "Passes only selected node topology to CreateVolume Request, unlike default behavior of passing aggregated cluster topologies that match with topology keys of the selected node."),
101-
Resync: *flag.Duration("csi-resync", 10*time.Minute, "Resync interval of the controller."),
102-
Timeout: *flag.Duration("csi-timeout", 15*time.Second, "Timeout for waiting for attaching or detaching the volume."),
103-
FinalizerThreads: *flag.Uint("cloning-protection-threads", 1, "Number of simultaniously running threads, handling cloning finalizer removal"),
104-
MetricsAddress: *flag.String("metrics-address", "", "The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled."),
105-
MetricsPath: *flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`."),
106-
ExtraCreateMetadata: *flag.Bool("extra-create-metadata", false, "If set, add pv/pvc metadata to plugin create requests as parameters."),
107-
ReconcileSync: *flag.Duration("reconcile-sync", 1*time.Minute, "Resync interval of the VolumeAttachment reconciler."),
108-
EnableResizer: *flag.Bool("csi-bv-expansion-enabled", false, "Enables go routine csi-resizer."),
109-
GroupSnapshotNamePrefix: *flag.String("groupsnapshot-name-prefix", "groupsnapshot", "Prefix to apply to the name of a created group snapshot"),
79+
Master: *flag.String("master", "", "kube master"),
80+
Kubeconfig: *flag.String("kubeconfig", "", "cluster kube config"),
81+
CsiAddress: *flag.String("csi-address", "/run/csi/socket", "Address of the CSI BV driver socket."),
82+
Endpoint: *flag.String("csi-endpoint", "unix://tmp/csi.sock", "CSI BV endpoint"),
83+
FssCsiAddress: *flag.String("fss-csi-address", "/run/fss/socket", "Address of the CSI FSS driver socket."),
84+
FssEndpoint: *flag.String("fss-csi-endpoint", "unix://tmp/csi-fss.sock", "CSI FSS endpoint"),
85+
VolumeNamePrefix: *flag.String("csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a created volume."),
86+
FssVolumeNamePrefix: *flag.String("fss-csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a volume created for FSS."),
87+
LustreCsiAddress: *flag.String("lustre-csi-address", "/run/lustre/socket", "Address of the CSI Lustre driver socket."),
88+
LustreEndpoint: *flag.String("lustre-csi-endpoint", "unix://tmp/csi-lustre.sock", "CSI Lustre endpoint"),
89+
LustreVolumeNamePrefix: *flag.String("lustre-csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a volume created for Lustre."),
90+
VolumeNameUUIDLength: *flag.Int("csi-volume-name-uuid-length", -1, "Truncates generated UUID of a created volume to this length. Defaults behavior is to NOT truncate."),
91+
ShowVersion: *flag.Bool("csi-version", false, "Show version."),
92+
RetryIntervalStart: *flag.Duration("csi-retry-interval-start", time.Second, "Initial retry interval of failed provisioning or deletion. It doubles with each failure, up to retry-interval-max."),
93+
RetryIntervalMax: *flag.Duration("csi-retry-interval-max", 5*time.Minute, "Maximum retry interval of failed provisioning or deletion."),
94+
WorkerThreads: *flag.Uint("csi-worker-threads", 100, "Number of provisioner worker threads, in other words nr. of simultaneous CSI calls."),
95+
OperationTimeout: *flag.Duration("csi-op-timeout", 10*time.Second, "Timeout for waiting for creation or deletion of a volume"),
96+
EnableLeaderElection: *flag.Bool("csi-enable-leader-election", false, "Enables leader election. If leader election is enabled, additional RBAC rules are required. Please refer to the Kubernetes CSI documentation for instructions on setting up these RBAC rules."),
97+
LeaderElectionType: *flag.String("csi-leader-election-type", "endpoints", "the type of leader election, options are 'endpoints' (default) or 'leases' (strongly recommended). The 'endpoints' option is deprecated in favor of 'leases'."),
98+
LeaderElectionNamespace: *flag.String("csi-leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set."),
99+
StrictTopology: *flag.Bool("csi-strict-topology", false, "Passes only selected node topology to CreateVolume Request, unlike default behavior of passing aggregated cluster topologies that match with topology keys of the selected node."),
100+
Resync: *flag.Duration("csi-resync", 10*time.Minute, "Resync interval of the controller."),
101+
Timeout: *flag.Duration("csi-timeout", 15*time.Second, "Timeout for waiting for attaching or detaching the volume."),
102+
FinalizerThreads: *flag.Uint("cloning-protection-threads", 1, "Number of simultaniously running threads, handling cloning finalizer removal"),
103+
MetricsAddress: *flag.String("metrics-address", "", "The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled."),
104+
MetricsPath: *flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`."),
105+
ExtraCreateMetadata: *flag.Bool("extra-create-metadata", false, "If set, add pv/pvc metadata to plugin create requests as parameters."),
106+
ReconcileSync: *flag.Duration("reconcile-sync", 1*time.Minute, "Resync interval of the VolumeAttachment reconciler."),
107+
EnableResizer: *flag.Bool("csi-bv-expansion-enabled", false, "Enables go routine csi-resizer."),
108+
GroupSnapshotNamePrefix: *flag.String("groupsnapshot-name-prefix", "groupsnapshot", "Prefix to apply to the name of a created group snapshot"),
110109
GroupSnapshotNameUUIDLength: *flag.Int("groupsnapshot-name-uuid-length", -1, "Length in characters for the generated uuid of a created group snapshot. Defaults behavior is to NOT truncate."),
111-
112110
}
113111
return &csioptions
114112
}

cmd/oci-csi-node-driver/nodedriver/nodedriver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"go.uber.org/zap"
2222
)
2323

24-
//RunNodeDriver main function to start node driver
24+
// RunNodeDriver main function to start node driver
2525
func RunNodeDriver(nodeOptions nodedriveroptions.NodeOptions, stopCh <-chan struct{}) error {
2626
logger := logging.Logger().Sugar()
2727
logger.Sync()

cmd/oci-csi-node-driver/nodedriveroptions/nodecsioptions.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414

1515
package nodedriveroptions
1616

17-
//NodeCSIOptions contains details about the flag
17+
// NodeCSIOptions contains details about the flag
1818
type NodeCSIOptions struct {
1919
Endpoint string // Used for Block Volume CSI driver
2020
NodeID string
2121
LogLevel string
2222
Master string
2323
Kubeconfig string
2424

25-
EnableFssDriver bool
26-
FssEndpoint string
25+
EnableFssDriver bool
26+
FssEndpoint string
2727
LustreCsiAddress string
2828
LustreKubeletRegistrationPath string
2929
LustreEndpoint string

pkg/cloudprovider/providers/oci/load_balancer_util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import (
2525
api "k8s.io/api/core/v1"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727

28+
"github.com/oracle/oci-cloud-controller-manager/pkg/oci/client"
2829
"github.com/oracle/oci-go-sdk/v65/common"
2930
"github.com/oracle/oci-go-sdk/v65/loadbalancer"
30-
"github.com/oracle/oci-cloud-controller-manager/pkg/oci/client"
3131
"github.com/stretchr/testify/assert"
3232
)
3333

pkg/csi-util/lustre_lnet_helper.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ type Parameter map[string]interface{}
4242
/*
4343
ValidateLustreVolumeId takes lustreVolumeId as input and returns if its valid or not along with lnetLabel
4444
Ex. volume handle : 10.112.10.6@tcp1:/fsname
45-
volume handle : <MGS NID>[:<MGS NID>]:/<fsname>
45+
46+
volume handle : <MGS NID>[:<MGS NID>]:/<fsname>
4647
*/
4748
func ValidateLustreVolumeId(lusterVolumeId string) (bool, string) {
4849
const minNumOfParamsFromVolumeHandle = 2
@@ -91,9 +92,9 @@ type LnetService struct {
9192

9293
type OCILnetConfigurator struct{}
9394

94-
func NewLnetService() *LnetService{
95+
func NewLnetService() *LnetService {
9596
return &LnetService{
96-
Configurator: &OCILnetConfigurator{},
97+
Configurator: &OCILnetConfigurator{},
9798
}
9899
}
99100

@@ -331,7 +332,7 @@ func (ls *LnetService) IsLnetActive(logger *zap.SugaredLogger, lnetLabel string)
331332
}
332333

333334
func (olc *OCILnetConfigurator) ExecuteCommandOnWorkerNode(args ...string) (string, error) {
334-
335+
335336
command := exec.Command("chroot-bash", args...)
336337

337338
output, err := command.CombinedOutput()
@@ -374,15 +375,15 @@ func isValidShellInput(input string) bool {
374375
return false
375376
}
376377
// List of forbidden characters
377-
forbiddenChars := []string{";", "&", "|", "<", ">", "(", ")", "`", "'", "\"","$","!"}
378+
forbiddenChars := []string{";", "&", "|", "<", ">", "(", ")", "`", "'", "\"", "$", "!"}
378379
for _, char := range forbiddenChars {
379380
if strings.Contains(input, char) {
380381
return false
381382
}
382383
}
383384
return true
384385
}
385-
func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson string) error {
386+
func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson string) error {
386387
if lustreParamsJson == "" {
387388
logger.Debug("No lustre parameters specified.")
388389
return nil
@@ -401,7 +402,7 @@ func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson strin
401402
for key, value := range param {
402403
logger.Infof("Validating lustre param %s=%s", key, fmt.Sprintf("%v", value))
403404
if !isValidShellInput(key) || !isValidShellInput(fmt.Sprintf("%v", value)) {
404-
invalidParams = append(invalidParams, fmt.Sprintf("%v=%v",key, value))
405+
invalidParams = append(invalidParams, fmt.Sprintf("%v=%v", key, value))
405406
}
406407
}
407408
}
@@ -411,4 +412,3 @@ func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson strin
411412
logger.Infof("Successfully validated lustre parameters.")
412413
return nil
413414
}
414-

0 commit comments

Comments
 (0)