Skip to content

Commit

Permalink
backport of commit 17e72c8
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Jan 3, 2023
1 parent 7d831c4 commit 7d4e161
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
5 changes: 2 additions & 3 deletions command/agent/csi_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,8 @@ func parseCSISecrets(req *http.Request) structs.CSISecrets {
secrets := map[string]string{}
secretkvs := strings.Split(secretsHeader, ",")
for _, secretkv := range secretkvs {
kv := strings.SplitN(secretkv, "=", 2)
if len(kv) == 2 {
secrets[kv[0]] = kv[1]
if key, value, found := strings.Cut(secretkv, "="); found {
secrets[key] = value
}
}
if len(secrets) == 0 {
Expand Down
5 changes: 2 additions & 3 deletions command/volume_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ func (c *VolumeDeleteCommand) Run(args []string) int {

secrets := api.CSISecrets{}
for _, kv := range secretsArgs {
s := strings.SplitN(kv, "=", 2)
if len(s) == 2 {
secrets[s[0]] = s[1]
if key, value, found := strings.Cut(kv, "="); found {
secrets[key] = value
} else {
c.Ui.Error("Secret must be in the format: -secret key=value")
return 1
Expand Down
10 changes: 4 additions & 6 deletions command/volume_snapshot_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ func (c *VolumeSnapshotCreateCommand) Run(args []string) int {

secrets := api.CSISecrets{}
for _, kv := range secretsArgs {
s := strings.SplitN(kv, "=", 2)
if len(s) == 2 {
secrets[s[0]] = s[1]
if key, value, found := strings.Cut(kv, "="); found {
secrets[key] = value
} else {
c.Ui.Error("Secret must be in the format: -secret key=value")
return 1
Expand All @@ -128,9 +127,8 @@ func (c *VolumeSnapshotCreateCommand) Run(args []string) int {

params := map[string]string{}
for _, kv := range parametersArgs {
p := strings.SplitN(kv, "=", 2)
if len(p) == 2 {
params[p[0]] = p[1]
if key, value, found := strings.Cut(kv, "="); found {
params[key] = value
}
}

Expand Down
5 changes: 2 additions & 3 deletions command/volume_snapshot_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ func (c *VolumeSnapshotDeleteCommand) Run(args []string) int {

secrets := api.CSISecrets{}
for _, kv := range secretsArgs {
s := strings.SplitN(kv, "=", 2)
if len(s) == 2 {
secrets[s[0]] = s[1]
if key, value, found := strings.Cut(kv, "="); found {
secrets[key] = value
} else {
c.Ui.Error("Secret must be in the format: -secret key=value")
return 1
Expand Down
5 changes: 2 additions & 3 deletions command/volume_snapshot_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ func (c *VolumeSnapshotListCommand) Run(args []string) int {

secrets := api.CSISecrets{}
for _, kv := range secretsArgs {
s := strings.SplitN(kv, "=", 2)
if len(s) == 2 {
secrets[s[0]] = s[1]
if key, value, found := strings.Cut(kv, "="); found {
secrets[key] = value
} else {
c.Ui.Error("Secret must be in the format: -secret key=value")
return 1
Expand Down

0 comments on commit 7d4e161

Please sign in to comment.