File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1/scaffolds Expand file tree Collapse file tree 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.
1616package scaffolds
1717
1818import (
19+ "fmt"
20+
1921 "v1/scaffolds/internal/templates/api"
2022
2123 "github.com/spf13/pflag"
@@ -54,7 +56,13 @@ func ApiCmd(pr *external.PluginRequest) external.PluginResponse {
5456 // Here is an example of parsing a flag from a Kubebuilder external plugin request
5557 flags := pflag .NewFlagSet ("apiFlags" , pflag .ContinueOnError )
5658 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+ }
5866 number , _ := flags .GetInt ("number" )
5967
6068 apiFile := api .NewApiFile (api .WithNumber (number ))
You can’t perform that action at this time.
0 commit comments