Merge pull request #11 from monopole/dropMinusFFromDiff

drop unnecessary -f from diff
This commit is contained in:
Jeff Regan
2018-05-18 11:36:32 -07:00
committed by GitHub
3 changed files with 19 additions and 40 deletions

View File

@@ -28,13 +28,6 @@
set -x set -x
target=$1
echo Kustomizing: \"$target\"
ls $target
tmpDir=$(mktemp -d)
function configureCluster { function configureCluster {
kustomize build $target > $tmpDir/my.yaml kustomize build $target > $tmpDir/my.yaml
[[ $? -eq 0 ]] || { exitWith "Failed to kustomize build"; } [[ $? -eq 0 ]] || { exitWith "Failed to kustomize build"; }
@@ -115,6 +108,13 @@ function deleteAddedUser {
"cn=The Postmaster,dc=example,dc=org" "cn=The Postmaster,dc=example,dc=org"
} }
target=$1
echo Kustomizing: \"$target\"
ls $target
tmpDir=$(mktemp -d)
configureCluster configureCluster
podName=`getPodField '{.items[0].metadata.name}'` podName=`getPodField '{.items[0].metadata.name}'`

View File

@@ -17,9 +17,7 @@ limitations under the License.
package commands package commands
import ( import (
"fmt"
"io" "io"
"os"
"path/filepath" "path/filepath"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@@ -46,17 +44,12 @@ func newCmdBuild(out, errOut io.Writer, fs fs.FileSystem) *cobra.Command {
Short: "Print current configuration per contents of " + constants.KustomizationFileName, Short: "Print current configuration per contents of " + constants.KustomizationFileName,
Example: "Use the file somedir/" + constants.KustomizationFileName + Example: "Use the file somedir/" + constants.KustomizationFileName +
" to generate a set of api resources:\nbuild somedir/", " to generate a set of api resources:\nbuild somedir/",
Run: func(cmd *cobra.Command, args []string) { RunE: func(cmd *cobra.Command, args []string) error {
err := o.Validate(args) err := o.Validate(args)
if err != nil { if err != nil {
fmt.Fprintf(errOut, "error: %v\n", err) return err
os.Exit(1)
}
err = o.RunBuild(out, errOut, fs)
if err != nil {
fmt.Fprintf(errOut, "error: %v\n", err)
os.Exit(1)
} }
return o.RunBuild(out, errOut, fs)
}, },
} }
return cmd return cmd

View File

@@ -40,43 +40,29 @@ func newCmdDiff(out, errOut io.Writer, fs fs.FileSystem) *cobra.Command {
var o diffOptions var o diffOptions
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "diff", Use: "diff [path]",
Short: "diff between transformed resources and untransformed resources", Short: "diff between customized resources and uncustomized resources",
Long: "diff between transformed resources and untransformed resources and the subpackages are all transformed.",
Example: `diff -f .`,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
err := o.Validate(cmd, args) err := o.Validate(cmd, args)
if err != nil { if err != nil {
return err return err
} }
err = o.Complete(cmd, args)
if err != nil {
return err
}
return o.RunDiff(out, errOut, fs) return o.RunDiff(out, errOut, fs)
}, },
} }
cmd.Flags().StringVarP(
&o.kustomizationPath,
"filename",
"f",
"",
"Specify a directory containing "+constants.KustomizationFileName)
cmd.MarkFlagRequired("filename")
return cmd return cmd
} }
// Validate validates diff command. // Validate validates diff command.
func (o *diffOptions) Validate(cmd *cobra.Command, args []string) error { func (o *diffOptions) Validate(cmd *cobra.Command, args []string) error {
if len(args) > 0 { if len(args) > 1 {
return errors.New("The diff command takes no arguments.") return errors.New("specify one path to " + constants.KustomizationFileName)
} }
return nil if len(args) == 0 {
} o.kustomizationPath = "./"
return nil
// Complete completes diff command. }
func (o *diffOptions) Complete(cmd *cobra.Command, args []string) error { o.kustomizationPath = args[0]
return nil return nil
} }