Skip to content

Commit

Permalink
Merge pull request kubernetes#260 from Liujingfang1/setnameprefix
Browse files Browse the repository at this point in the history
Change command setprefixname to setnameprefix
  • Loading branch information
monopole authored Feb 6, 2018
2 parents c82e0c3 + 932009c commit 4b5663a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cmd/kinflate/kinflate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

func main() {
var c = &cobra.Command{}
c.AddCommand(commands.NewCmdSetPrefixName(os.Stdout, os.Stderr, fs.MakeRealFS()))
c.AddCommand(commands.NewCmdSetNamePrefix(os.Stdout, os.Stderr, fs.MakeRealFS()))
c.AddCommand(commands.NewCmdInflate(os.Stdout, os.Stderr))
c.AddCommand(commands.NewCmdAddResource(os.Stdout, os.Stderr, fs.MakeRealFS()))
c.AddCommand(commands.NewCmdInit(os.Stdout, os.Stderr, fs.MakeRealFS()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ import (
"k8s.io/kubectl/pkg/kinflate/util/fs"
)

type setPrefixNameOptions struct {
type setNamePrefixOptions struct {
prefix string
}

// NewCmdSetPrefixName sets the value of the namePrefix field in the manifest.
func NewCmdSetPrefixName(out, errOut io.Writer, fsys fs.FileSystem) *cobra.Command {
var o setPrefixNameOptions
// NewCmdSetNamePrefix sets the value of the namePrefix field in the manifest.
func NewCmdSetNamePrefix(out, errOut io.Writer, fsys fs.FileSystem) *cobra.Command {
var o setNamePrefixOptions

cmd := &cobra.Command{
Use: "setprefixname",
Use: "setnameprefix",
Short: "Sets the value of the namePrefix field in the manifest.",
Long: "Sets the value of the namePrefix field in the manifest.",
//
Example: `
The command
setprefixname acme-
setnameprefix acme-
will add the field "namePrefix: acme-" to the manifest file if it doesn't exist,
and overwrite the value with "acme-" if the field does exist.
`,
Expand All @@ -57,14 +57,14 @@ and overwrite the value with "acme-" if the field does exist.
if err != nil {
return err
}
return o.RunSetPrefixName(out, errOut, fsys)
return o.RunSetNamePrefix(out, errOut, fsys)
},
}
return cmd
}

// Validate validates setPrefixName command.
func (o *setPrefixNameOptions) Validate(args []string) error {
// Validate validates setNamePrefix command.
func (o *setNamePrefixOptions) Validate(args []string) error {
if len(args) != 1 {
return errors.New("must specify exactly one prefix value")
}
Expand All @@ -73,13 +73,13 @@ func (o *setPrefixNameOptions) Validate(args []string) error {
return nil
}

// Complete completes setPrefixName command.
func (o *setPrefixNameOptions) Complete(cmd *cobra.Command, args []string) error {
// Complete completes setNamePrefix command.
func (o *setNamePrefixOptions) Complete(cmd *cobra.Command, args []string) error {
return nil
}

// RunSetPrefixName runs setPrefixName command (does real work).
func (o *setPrefixNameOptions) RunSetPrefixName(out, errOut io.Writer, fsys fs.FileSystem) error {
// RunSetNamePrefix runs setNamePrefix command (does real work).
func (o *setNamePrefixOptions) RunSetNamePrefix(out, errOut io.Writer, fsys fs.FileSystem) error {
content, err := fsys.ReadFile(constants.KubeManifestFileName)
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ const (
goodPrefixValue = "acme-"
)

func TestSetPrefixNameHappyPath(t *testing.T) {
func TestSetNamePrefixHappyPath(t *testing.T) {
buf := bytes.NewBuffer([]byte{})
fakeFS := fs.MakeFakeFS()
fakeFS.WriteFile(constants.KubeManifestFileName, []byte(manifestTemplate))

cmd := NewCmdSetPrefixName(buf, os.Stderr, fakeFS)
cmd := NewCmdSetNamePrefix(buf, os.Stderr, fakeFS)
args := []string{goodPrefixValue}
err := cmd.RunE(cmd, args)
if err != nil {
Expand All @@ -51,11 +51,11 @@ func TestSetPrefixNameHappyPath(t *testing.T) {
}
}

func TestSetPrefixNameNoArgs(t *testing.T) {
func TestSetNamePrefixNoArgs(t *testing.T) {
buf := bytes.NewBuffer([]byte{})
fakeFS := fs.MakeFakeFS()

cmd := NewCmdSetPrefixName(buf, os.Stderr, fakeFS)
cmd := NewCmdSetNamePrefix(buf, os.Stderr, fakeFS)
err := cmd.Execute()
if err == nil {
t.Errorf("expected error: %v", err)
Expand Down

0 comments on commit 4b5663a

Please sign in to comment.