sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/plugins/common/kustomize/v1/create.go (about) 1 /* 2 Copyright 2022 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 //go:deprecated This package has been deprecated in favor of v2 18 package v1 19 20 import ( 21 "strconv" 22 23 "github.com/spf13/pflag" 24 25 "sigs.k8s.io/kubebuilder/v3/pkg/config" 26 "sigs.k8s.io/kubebuilder/v3/pkg/model/resource" 27 ) 28 29 type createSubcommand struct { 30 config config.Config 31 resource *resource.Resource 32 33 flagSet *pflag.FlagSet 34 35 // force indicates whether to scaffold files even if they exist. 36 force bool 37 } 38 39 func (p *createSubcommand) BindFlags(fs *pflag.FlagSet) { p.flagSet = fs } 40 41 func (p *createSubcommand) InjectConfig(c config.Config) error { 42 p.config = c 43 return nil 44 } 45 46 func (p *createSubcommand) InjectResource(res *resource.Resource) error { 47 p.resource = res 48 return nil 49 } 50 51 func (p *createSubcommand) configure() (err error) { 52 if forceFlag := p.flagSet.Lookup("force"); forceFlag != nil { 53 if p.force, err = strconv.ParseBool(forceFlag.Value.String()); err != nil { 54 return err 55 } 56 57 } 58 return nil 59 }