File tree 1 file changed +9
-1
lines changed
docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1/scaffolds
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ limitations under the License.
16
16
package scaffolds
17
17
18
18
import (
19
+ "fmt"
20
+
19
21
"v1/scaffolds/internal/templates/api"
20
22
21
23
"github.com/spf13/pflag"
@@ -54,7 +56,13 @@ func ApiCmd(pr *external.PluginRequest) external.PluginResponse {
54
56
// Here is an example of parsing a flag from a Kubebuilder external plugin request
55
57
flags := pflag .NewFlagSet ("apiFlags" , pflag .ContinueOnError )
56
58
flags .Int ("number" , 1 , "set a number to be added in the scaffolded apiFile.txt" )
57
- flags .Parse (pr .Args )
59
+ if err := flags .Parse (pr .Args ); err != nil {
60
+ pluginResponse .Error = true
61
+ pluginResponse .ErrorMsgs = []string {
62
+ fmt .Sprintf ("failed to parse flags: %s" , err .Error ()),
63
+ }
64
+ return pluginResponse
65
+ }
58
66
number , _ := flags .GetInt ("number" )
59
67
60
68
apiFile := api .NewApiFile (api .WithNumber (number ))
You can’t perform that action at this time.
0 commit comments