sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/plugins/external/edit.go (about) 1 /* 2 Copyright 2021 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package external 18 19 import ( 20 "github.com/spf13/pflag" 21 22 "sigs.k8s.io/kubebuilder/v3/pkg/machinery" 23 "sigs.k8s.io/kubebuilder/v3/pkg/plugin" 24 "sigs.k8s.io/kubebuilder/v3/pkg/plugin/external" 25 ) 26 27 var _ plugin.EditSubcommand = &editSubcommand{} 28 29 type editSubcommand struct { 30 Path string 31 Args []string 32 } 33 34 func (p *editSubcommand) UpdateMetadata(_ plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) { 35 setExternalPluginMetadata("edit", p.Path, subcmdMeta) 36 } 37 38 func (p *editSubcommand) BindFlags(fs *pflag.FlagSet) { 39 bindExternalPluginFlags(fs, "edit", p.Path, p.Args) 40 } 41 42 func (p *editSubcommand) Scaffold(fs machinery.Filesystem) error { 43 req := external.PluginRequest{ 44 APIVersion: defaultAPIVersion, 45 Command: "edit", 46 Args: p.Args, 47 } 48 49 err := handlePluginResponse(fs, req, p.Path) 50 if err != nil { 51 return err 52 } 53 54 return nil 55 }