Skip to content

Commit 314e66a

Browse files
authored
Merge pull request kubernetes-sigs#11 from monopole/dropMinusFFromDiff
drop unnecessary -f from diff
2 parents 00cb01a + 6662bb6 commit 314e66a

File tree

3 files changed

+19
-40
lines changed

3 files changed

+19
-40
lines changed

demos/ldap/integration_test.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@
2828

2929
set -x
3030

31-
target=$1
32-
33-
echo Kustomizing: \"$target\"
34-
ls $target
35-
36-
tmpDir=$(mktemp -d)
37-
3831
function configureCluster {
3932
kustomize build $target > $tmpDir/my.yaml
4033
[[ $? -eq 0 ]] || { exitWith "Failed to kustomize build"; }
@@ -115,6 +108,13 @@ function deleteAddedUser {
115108
"cn=The Postmaster,dc=example,dc=org"
116109
}
117110

111+
target=$1
112+
113+
echo Kustomizing: \"$target\"
114+
ls $target
115+
116+
tmpDir=$(mktemp -d)
117+
118118
configureCluster
119119

120120
podName=`getPodField '{.items[0].metadata.name}'`

pkg/commands/build.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ limitations under the License.
1717
package commands
1818

1919
import (
20-
"fmt"
2120
"io"
22-
"os"
2321
"path/filepath"
2422

2523
"github.com/spf13/cobra"
@@ -46,17 +44,12 @@ func newCmdBuild(out, errOut io.Writer, fs fs.FileSystem) *cobra.Command {
4644
Short: "Print current configuration per contents of " + constants.KustomizationFileName,
4745
Example: "Use the file somedir/" + constants.KustomizationFileName +
4846
" to generate a set of api resources:\nbuild somedir/",
49-
Run: func(cmd *cobra.Command, args []string) {
47+
RunE: func(cmd *cobra.Command, args []string) error {
5048
err := o.Validate(args)
5149
if err != nil {
52-
fmt.Fprintf(errOut, "error: %v\n", err)
53-
os.Exit(1)
54-
}
55-
err = o.RunBuild(out, errOut, fs)
56-
if err != nil {
57-
fmt.Fprintf(errOut, "error: %v\n", err)
58-
os.Exit(1)
50+
return err
5951
}
52+
return o.RunBuild(out, errOut, fs)
6053
},
6154
}
6255
return cmd

pkg/commands/diff.go

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,43 +40,29 @@ func newCmdDiff(out, errOut io.Writer, fs fs.FileSystem) *cobra.Command {
4040
var o diffOptions
4141

4242
cmd := &cobra.Command{
43-
Use: "diff",
44-
Short: "diff between transformed resources and untransformed resources",
45-
Long: "diff between transformed resources and untransformed resources and the subpackages are all transformed.",
46-
Example: `diff -f .`,
43+
Use: "diff [path]",
44+
Short: "diff between customized resources and uncustomized resources",
4745
RunE: func(cmd *cobra.Command, args []string) error {
4846
err := o.Validate(cmd, args)
4947
if err != nil {
5048
return err
5149
}
52-
err = o.Complete(cmd, args)
53-
if err != nil {
54-
return err
55-
}
5650
return o.RunDiff(out, errOut, fs)
5751
},
5852
}
59-
60-
cmd.Flags().StringVarP(
61-
&o.kustomizationPath,
62-
"filename",
63-
"f",
64-
"",
65-
"Specify a directory containing "+constants.KustomizationFileName)
66-
cmd.MarkFlagRequired("filename")
6753
return cmd
6854
}
6955

7056
// Validate validates diff command.
7157
func (o *diffOptions) Validate(cmd *cobra.Command, args []string) error {
72-
if len(args) > 0 {
73-
return errors.New("The diff command takes no arguments.")
58+
if len(args) > 1 {
59+
return errors.New("specify one path to " + constants.KustomizationFileName)
7460
}
75-
return nil
76-
}
77-
78-
// Complete completes diff command.
79-
func (o *diffOptions) Complete(cmd *cobra.Command, args []string) error {
61+
if len(args) == 0 {
62+
o.kustomizationPath = "./"
63+
return nil
64+
}
65+
o.kustomizationPath = args[0]
8066
return nil
8167
}
8268

0 commit comments

Comments
 (0)