Skip to content

Commit ea69fb4

Browse files
committed
Small updates based on feedback
1 parent 97f22b0 commit ea69fb4

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"
@@ -168,7 +167,7 @@ func (g *Generator) Render() error {
168167
return err
169168
}
170169
default:
171-
return errors.New(fmt.Sprintf("unexpected operator type [%v]", g.operatorType))
170+
return fmt.Errorf("unexpected operator type [%v]", g.operatorType)
172171
}
173172
return nil
174173
}
@@ -349,7 +348,7 @@ func RenderDeployCrdFile(apiVersion, kind string) error {
349348
GroupName: groupName(apiVersion),
350349
Version: version(apiVersion),
351350
}
352-
crdFilePath := filepath.Join(deployDir, strings.ToLower(kind) + "_crd.yaml")
351+
crdFilePath := filepath.Join(deployDir, strings.ToLower(kind)+"_crd.yaml")
353352
return renderWriteFile(crdFilePath, crdFilePath, crdYamlTmpl, crdTd)
354353
}
355354

0 commit comments

Comments
 (0)