forked from argoproj/argo-workflows
-
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(controller): Include global params when using withParam (argoproj…
- Loading branch information
Showing
12 changed files
with
160 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package common | ||
|
||
// Parameters extends string map with useful methods. | ||
type Parameters map[string]string | ||
|
||
// Merge merges given parameteres. | ||
func (ps Parameters) Merge(args ...Parameters) Parameters { | ||
newParams := ps.DeepCopy() | ||
for _, params := range args { | ||
for k, v := range params { | ||
newParams[k] = v | ||
} | ||
} | ||
return newParams | ||
} | ||
|
||
// DeepCopy returns a new instance which has the same parameters as the receiver. | ||
func (ps Parameters) DeepCopy() Parameters { | ||
newParams := make(Parameters) | ||
for k, v := range ps { | ||
newParams[k] = v | ||
} | ||
return newParams | ||
} |
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,23 @@ | ||
package common | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// TestParamsMerge ensures Merge of Parameters works correctly. | ||
func TestParamsMerge(t *testing.T) { | ||
params := Parameters{"foo": "1"} | ||
newParams := params.Merge(Parameters{"foo": "2", "bar": "1"}, Parameters{"wow": "1"}) | ||
assert.Equal(t, Parameters{"foo": "2", "bar": "1", "wow": "1"}, newParams) | ||
assert.NotSame(t, ¶ms, &newParams) | ||
} | ||
|
||
// TestParamsClone ensures Clone of Parameters works correctly. | ||
func TestParamsClone(t *testing.T) { | ||
params := Parameters{"foo": "1"} | ||
newParams := params.DeepCopy() | ||
assert.Equal(t, params, newParams) | ||
assert.NotSame(t, ¶ms, &newParams) | ||
} |
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
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