Skip to content

Commit d3d0bed

Browse files
committed
Small updates based on feedback
1 parent 74ad2ce commit d3d0bed

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

commands/operator-sdk/cmd/new.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ generates a skeletal app-operator application in $GOPATH/src/github.com/example.
5555
newCmd.MarkFlagRequired("kind")
5656
newCmd.Flags().StringVar(&operatorType, "type", "go", "Type of operator to initialize (e.g \"ansible\")")
5757
newCmd.Flags().BoolVar(&skipGit, "skip-git-init", false, "Do not init the directory as a git repository")
58-
newCmd.Flags().BoolVar(&generatePlaybook, "generate-playbook", false, "Generate a playbook skeleton in watches.yaml. (Only used for --type ansible)")
58+
newCmd.Flags().BoolVar(&generatePlaybook, "generate-playbook", false, "Generate a playbook skeleton. (Only used for --type ansible)")
5959

6060
return newCmd
6161
}
@@ -147,6 +147,9 @@ func verifyFlags() {
147147
if operatorType != goOperatorType && operatorType != ansibleOperatorType {
148148
cmdError.ExitWithError(cmdError.ExitBadArgs, errors.New("--type can only be `go` or `ansible`"))
149149
}
150+
if operatorType != ansibleOperatorType && generatePlaybook {
151+
cmdError.ExitWithError(cmdError.ExitBadArgs, errors.New("--generate-playbook can only be used with --type `ansible`"))
152+
}
150153
kindFirstLetter := string(kind[0])
151154
if kindFirstLetter != strings.ToUpper(kindFirstLetter) {
152155
cmdError.ExitWithError(cmdError.ExitBadArgs, errors.New("--kind must start with an uppercase letter"))

pkg/generator/generator.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package generator
1616

1717
import (
1818
"bytes"
19-
"errors"
2019
"fmt"
2120
"io"
2221
"io/ioutil"
@@ -161,7 +160,7 @@ func (g *Generator) Render() error {
161160
return err
162161
}
163162
default:
164-
return errors.New(fmt.Sprintf("unexpected operator type [%v]", g.operatorType))
163+
return fmt.Errorf("unexpected operator type [%v]", g.operatorType)
165164
}
166165
return nil
167166
}
@@ -342,7 +341,7 @@ func RenderDeployCrdFile(apiVersion, kind string) error {
342341
GroupName: groupName(apiVersion),
343342
Version: version(apiVersion),
344343
}
345-
crdFilePath := filepath.Join(deployDir, strings.ToLower(kind) + "_crd.yaml")
344+
crdFilePath := filepath.Join(deployDir, strings.ToLower(kind)+"_crd.yaml")
346345
return renderWriteFile(crdFilePath, crdFilePath, crdYamlTmpl, crdTd)
347346
}
348347

0 commit comments

Comments
 (0)