-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from usual2970/feat/deploy_group
添加部署变量、部署授权组的支持
- Loading branch information
Showing
29 changed files
with
2,173 additions
and
575 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
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,30 @@ | ||
package variables | ||
|
||
import "strings" | ||
|
||
// Parse2Map 将变量赋值字符串解析为map | ||
func Parse2Map(str string) map[string]string { | ||
|
||
m := make(map[string]string) | ||
|
||
lines := strings.Split(str, ";") | ||
|
||
for _, line := range lines { | ||
|
||
line = strings.TrimSpace(line) | ||
|
||
if line == "" { | ||
continue | ||
} | ||
|
||
kv := strings.Split(line, "=") | ||
|
||
if len(kv) != 2 { | ||
continue | ||
} | ||
|
||
m[kv[0]] = kv[1] | ||
} | ||
|
||
return m | ||
} |
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,56 @@ | ||
package variables | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestParse2Map(t *testing.T) { | ||
type args struct { | ||
str string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want map[string]string | ||
}{ | ||
{ | ||
name: "test1", | ||
args: args{ | ||
str: "a=1;b=2;c=3", | ||
}, | ||
want: map[string]string{ | ||
"a": "1", | ||
"b": "2", | ||
"c": "3", | ||
}, | ||
}, | ||
{ | ||
name: "test2", | ||
args: args{ | ||
str: `a=1; | ||
b=2; | ||
c=`, | ||
}, | ||
want: map[string]string{ | ||
"a": "1", | ||
"b": "2", | ||
"c": "", | ||
}, | ||
}, | ||
{ | ||
name: "test3", | ||
args: args{ | ||
str: "1", | ||
}, | ||
want: map[string]string{}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := Parse2Map(tt.args.str); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("Parse2Map() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.