Skip to content

Commit 2a67b2a

Browse files
committed
Added release notes for 1.1.1
1 parent a4fa5b8 commit 2a67b2a

File tree

6 files changed

+130
-50
lines changed

6 files changed

+130
-50
lines changed

pkg/evergreen/evg_yaml.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ type Configuration struct {
1010
BuildVariants []BuildVariant `yaml:"buildvariants"`
1111
Tasks []Task `yaml:"tasks"`
1212
TaskGroups []TaskGroup `yaml:"task_groups"`
13+
Parameters []Parameter `yaml:"parameters"`
14+
}
15+
16+
type Parameter struct {
17+
Key string
18+
Value string
19+
Description string
1320
}
1421

1522
type Task struct {

pkg/evgprompt/completer.go

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func (c *Completer) createPatchSuggestions(d prompt.Document) []prompt.Suggest {
6666
return c.getBuildVariantSuggestions(d)
6767
}
6868

69+
if getLastWord(d) == "--param" {
70+
return c.getParamSuggestions()
71+
}
72+
6973
if getLastWord(d) == "--description" {
7074
return nil
7175
}
@@ -124,9 +128,18 @@ func (c *Completer) createPatchSuggestions(d prompt.Document) []prompt.Suggest {
124128
Description: "Specify the name of an existing evergreen project",
125129
})
126130
}
131+
132+
// it's possible to add multiple params to a single command, so the field
133+
// already existing doesn't mean we shouldn't show it.
134+
suggestions = append(suggestions, prompt.Suggest{
135+
Text: "--param",
136+
Description: "Specify a parameter for the evergreen patch",
137+
})
138+
127139
return prompt.FilterFuzzy(suggestions, d.GetWordBeforeCursor(), true)
128140

129141
}
142+
130143
func (c *Completer) patchSuggestions(d prompt.Document) []prompt.Suggest {
131144

132145
text := d.TextBeforeCursor()
@@ -209,37 +222,51 @@ func (c *Completer) getBuildVariantSuggestions(d prompt.Document) []prompt.Sugge
209222
return prompt.FilterFuzzy(suggestions, d.GetWordBeforeCursor(), true)
210223
}
211224

212-
func (c *Completer) abortPatchSuggestions(d prompt.Document) []prompt.Suggest {
225+
func (c *Completer) getParamSuggestions() []prompt.Suggest {
213226
var suggestions []prompt.Suggest
214-
if getLastWord(d) == "abort" {
215-
suggestions = append(suggestions,
216-
prompt.Suggest{
217-
Text: "--patch-id",
218-
Description: "Patch ID of the patch to abort.",
219-
})
220-
return prompt.FilterFuzzy(suggestions, d.GetWordBeforeCursor(), true)
221-
}
222227

223-
patches, err := c.client.GetPatches()
224-
if err != nil {
225-
panic(err)
226-
}
227-
228-
// if we have selected a patch id already,
229-
// we should stop showing other patch ids!
230-
lastWord := getLastWord(d)
231-
for _, p := range patches {
232-
if lastWord == p.PatchId {
233-
return nil
234-
}
235-
}
236-
237-
for _, p := range patches {
228+
for _, param := range c.config.Parameters {
238229
suggestions = append(suggestions, prompt.Suggest{
239-
Text: p.PatchId,
240-
Description: p.Description,
230+
Text: param.Key + "=" + param.Value,
231+
Description: param.Description,
241232
})
242233
}
243234

244-
return prompt.FilterFuzzy(suggestions, d.GetWordBeforeCursor(), true)
235+
return suggestions
245236
}
237+
238+
//
239+
//func (c *Completer) abortPatchSuggestions(d prompt.Document) []prompt.Suggest {
240+
// var suggestions []prompt.Suggest
241+
// if getLastWord(d) == "abort" {
242+
// suggestions = append(suggestions,
243+
// prompt.Suggest{
244+
// Text: "--patch-id",
245+
// Description: "Patch ID of the patch to abort.",
246+
// })
247+
// return prompt.FilterFuzzy(suggestions, d.GetWordBeforeCursor(), true)
248+
// }
249+
//
250+
// patches, err := c.client.GetPatches()
251+
// if err != nil {
252+
// panic(err)
253+
// }
254+
//
255+
// // if we have selected a patch id already,
256+
// // we should stop showing other patch ids!
257+
// lastWord := getLastWord(d)
258+
// for _, p := range patches {
259+
// if lastWord == p.PatchId {
260+
// return nil
261+
// }
262+
// }
263+
//
264+
// for _, p := range patches {
265+
// suggestions = append(suggestions, prompt.Suggest{
266+
// Text: p.PatchId,
267+
// Description: p.Description,
268+
// })
269+
// }
270+
//
271+
// return prompt.FilterFuzzy(suggestions, d.GetWordBeforeCursor(), true)
272+
//}

pkg/evgprompt/executor.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ func (e *Executor) handleEvergreenPatchCreate(s string) {
4747
fmt.Println("Buildvariant must be specified!")
4848
}
4949

50+
// p is expected to be in the form of "Key=Value"
51+
for _, p := range flags.GetAllParams(s) {
52+
args = append(args, "--param", p)
53+
}
54+
5055
args = append(args, "-v", buildvariant)
5156

5257
description := flags.GetDescriptionValue(s)

pkg/util/flags/flags.go

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,58 +19,82 @@ func init() {
1919
}
2020

2121
func GetBuildVariantValue(s string) string {
22-
if bv, ok := extractFlags(s, patchCreate)["--buildvariant"]; ok {
22+
flags := extractFlags(s, patchCreate)
23+
if bv, ok := getValueFromFlagKey("--buildvariant", flags); ok {
2324
return bv
2425
}
2526
return ""
2627
}
2728

2829
func GetTaskValue(s string) string {
29-
if task, ok := extractFlags(s, patchCreate)["--task"]; ok {
30+
flags := extractFlags(s, patchCreate)
31+
if task, ok := getValueFromFlagKey("--task", flags); ok {
3032
return task
3133
}
3234
return ""
3335
}
3436

3537
func GetDescriptionValue(s string) string {
36-
if description, ok := extractFlags(s, patchCreate)["--description"]; ok {
38+
flags := extractFlags(s, patchCreate)
39+
if description, ok := getValueFromFlagKey("--description", flags); ok {
3740
return description
3841
}
3942
return ""
4043
}
4144

4245
func GetPriorityValue(s string) string {
43-
if priority, ok := extractFlags(s, patchCreate)["--priority"]; ok {
46+
flags := extractFlags(s, patchCreate)
47+
if priority, ok := getValueFromFlagKey("--priority", flags); ok {
4448
return priority
4549
}
4650
return ""
4751
}
4852

4953
func GetProjectValue(s string) string {
50-
if project, ok := extractFlags(s, patchCreate)["--project"]; ok {
54+
flags := extractFlags(s, patchCreate)
55+
if project, ok := getValueFromFlagKey("--project", flags); ok {
5156
return project
5257
}
5358
return ""
5459
}
5560

5661
func HasSpecifiedUncommitted(s string) bool {
57-
_, ok := extractFlags(s, patchCreate)["--uncommitted"]
62+
flags := extractFlags(s, patchCreate)
63+
_, ok := getValueFromFlagKey("--uncommitted", flags)
5864
return ok
5965
}
6066

61-
func GetPatchId(s string) string {
62-
if patchId, ok := extractFlags(s, patchAbort)["--patch-id"]; ok {
63-
return patchId
67+
func GetAllParams(s string) []string {
68+
flags := extractFlags(s, patchCreate)
69+
var paramFlags []string
70+
for _, f := range flags {
71+
if f.key == "--param" {
72+
paramFlags = append(paramFlags, f.value)
73+
}
6474
}
65-
return ""
75+
return paramFlags
76+
}
77+
78+
func getValueFromFlagKey(key string, flags []flag) (string, bool) {
79+
for _, f := range flags {
80+
if f.key == key {
81+
return f.value, true
82+
}
83+
}
84+
return "", false
85+
}
86+
87+
type flag struct {
88+
key string
89+
value string
6690
}
6791

6892
// extractFlags converts a string with the given prefix into a map[string]string
6993
// with the keys as the flags and the provided values as the map values.
7094
// if the flag does not require a value, an empty string will be set as the value
7195
// in the map.
72-
func extractFlags(s, prefix string) map[string]string {
73-
flags := map[string]string{}
96+
func extractFlags(s, prefix string) []flag {
97+
var flags []flag
7498

7599
flagsOnly := strings.TrimLeft(s, prefix)
76100
flagsOnly = strings.TrimSpace(flagsOnly)
@@ -100,7 +124,10 @@ func extractFlags(s, prefix string) map[string]string {
100124

101125
// convert every element into a map
102126
for i := 0; i < len(args); i += 2 {
103-
flags[args[i]] = args[i+1]
127+
flags = append(flags, flag{
128+
key: args[i],
129+
value: args[i+1],
130+
})
104131
}
105132

106133
return flags

pkg/util/flags/flags_test.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,41 @@ func TestExtractFlags(t *testing.T) {
4141
input := "patch create --task this_is_my_task --buildvariant this_is_my_bv"
4242
flags := extractFlags(input, patchCreate)
4343

44-
assert.Equal(t, "this_is_my_task", flags["--task"])
45-
assert.Equal(t, "this_is_my_bv", flags["--buildvariant"])
44+
task, _ := getValueFromFlagKey("--task", flags)
45+
assert.Equal(t, "this_is_my_task", task)
46+
47+
bv, _ := getValueFromFlagKey("--buildvariant", flags)
48+
assert.Equal(t, "this_is_my_bv", bv)
4649
})
4750

4851
t.Run("Test with flags that have no value as last item", func(t *testing.T) {
4952
input := "patch create --task this_is_my_task --buildvariant this_is_my_bv --uncommited"
5053
flags := extractFlags(input, patchCreate)
5154

52-
assert.Equal(t, "this_is_my_task", flags["--task"])
53-
assert.Equal(t, "this_is_my_bv", flags["--buildvariant"])
54-
assert.Equal(t, "", flags["--uncommited"])
55+
task, _ := getValueFromFlagKey("--task", flags)
56+
assert.Equal(t, "this_is_my_task", task)
57+
bv, _ := getValueFromFlagKey("--buildvariant", flags)
58+
assert.Equal(t, "this_is_my_bv", bv)
59+
60+
_, ok := getValueFromFlagKey("--uncommited", flags)
61+
assert.Equal(t, true, ok)
5562
})
5663

5764
t.Run("Test with flags that have no value as middle item", func(t *testing.T) {
5865
input := "patch create --task this_is_my_task --buildvariant this_is_my_bv --uncommited --priority 100"
5966
flags := extractFlags(input, patchCreate)
6067

61-
assert.Equal(t, "this_is_my_task", flags["--task"])
62-
assert.Equal(t, "this_is_my_bv", flags["--buildvariant"])
63-
assert.Equal(t, "", flags["--uncommited"])
64-
assert.Equal(t, "100", flags["--priority"])
68+
69+
task, _ := getValueFromFlagKey("--task", flags)
70+
assert.Equal(t, "this_is_my_task", task)
71+
72+
bv, _ := getValueFromFlagKey("--buildvariant", flags)
73+
assert.Equal(t, "this_is_my_bv", bv)
74+
_, ok := getValueFromFlagKey("--uncommited", flags)
75+
assert.Equal(t, true, ok)
76+
77+
priority, _ := getValueFromFlagKey("--priority", flags)
78+
assert.Equal(t, "100", priority)
6579
})
6680

6781
}

release/release.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "1.1.0"
2+
"version": "1.1.1"
33
}

0 commit comments

Comments
 (0)