You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Check if there are any remaining parameters (aka ${...}) in the template that was not replaces
64
-
// checkLeftoverParameters()
65
-
unusedParameters, found:=Message.FindLeftovers()
66
-
iffound {
67
-
for_, v:=rangeunusedParameters {
68
-
regex:=strings.NewReplacer("${", "", "}", "")
69
-
log.Errorf("The selected template is using '%s' parameter, but '--%s' flag is not set for this one. Use '-%s %v=\"FOOBAR\"' to fix this.", v, "param", "p", regex.Replace(v))
log.Fatal("Please define this missing parameter properly.")
73
-
} else {
74
-
log.Fatalf("Please define all %v missing parameters properly.", numberOfMissingParameters)
75
-
}
76
-
}
52
+
// Check if there are any remaining placeholders in the template that are not replaced by a parameter
53
+
checkLeftovers()
77
54
78
55
dir:=tempDir()
79
56
defercleanup(dir)
@@ -103,6 +80,22 @@ func init() {
103
80
postCmd.Flags().StringArrayVarP(&templateParams, "param", "p", templateParams, "Specify a key-value pair (eg. -p FOO=BAR) to set/override a parameter value in the template.")
104
81
}
105
82
83
+
// parseUserParameters parse all the '-p FOO=BAR' parameters and checks for syntax errors
84
+
funcparseUserParameters() {
85
+
fork, v:=rangetemplateParams {
86
+
if!strings.Contains(v, "=") {
87
+
log.Fatalf("Wrong syntax of '-p' flag. Please use it like this: '-p FOO=BAR'")
log.Fatalf("Wrong syntax of '-p' flag. Please use it like this: '-p FOO=BAR'")
95
+
}
96
+
}
97
+
}
98
+
106
99
// accessTemplate checks if the provided template is currently accessible and returns an error
107
100
funcaccessTemplate(templatestring) (errerror) {
108
101
@@ -170,6 +163,21 @@ func readTemplate() {
170
163
}
171
164
}
172
165
166
+
funccheckLeftovers() {
167
+
unusedParameters, found:=Message.FindLeftovers()
168
+
iffound {
169
+
for_, v:=rangeunusedParameters {
170
+
regex:=strings.NewReplacer("${", "", "}", "")
171
+
log.Errorf("The selected template is using '%s' parameter, but '--%s' flag is not set for this one. Use '-%s %v=\"FOOBAR\"' to fix this.", v, "param", "p", regex.Replace(v))
0 commit comments