github.com/theishshah/operator-sdk@v0.6.0/pkg/scaffold/helm/main.go (about) 1 // Copyright 2019 The Operator-SDK Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package helm 16 17 import ( 18 "path/filepath" 19 20 "github.com/operator-framework/operator-sdk/pkg/scaffold/input" 21 ) 22 23 // Main - main source file for helm operator 24 type Main struct { 25 input.Input 26 } 27 28 func (m *Main) GetInput() (input.Input, error) { 29 if m.Path == "" { 30 m.Path = filepath.Join("cmd", "manager", "main.go") 31 } 32 m.TemplateBody = mainTmpl 33 return m.Input, nil 34 } 35 36 const mainTmpl = `package main 37 38 import ( 39 "os" 40 41 hoflags "github.com/operator-framework/operator-sdk/pkg/helm/flags" 42 "github.com/operator-framework/operator-sdk/pkg/helm" 43 "github.com/operator-framework/operator-sdk/pkg/log/zap" 44 45 "github.com/spf13/pflag" 46 logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" 47 ) 48 49 func main() { 50 hflags := hoflags.AddTo(pflag.CommandLine) 51 pflag.Parse() 52 logf.SetLogger(zap.Logger()) 53 54 if err := helm.Run(hflags); err != nil { 55 logf.Log.WithName("cmd").Error(err, "") 56 os.Exit(1) 57 } 58 } 59 `