Move version.go to commands dir.

This commit is contained in:
Jeffrey Regan
2018-06-12 13:08:23 -07:00
parent f98bc42cbb
commit 2fb69db685
2 changed files with 10 additions and 11 deletions

View File

@@ -23,7 +23,6 @@ import (
"os" "os"
"github.com/kubernetes-sigs/kustomize/pkg/fs" "github.com/kubernetes-sigs/kustomize/pkg/fs"
"github.com/kubernetes-sigs/kustomize/version"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@@ -46,7 +45,7 @@ See https://github.com/kubernetes-sigs/kustomize
newCmdBuild(stdOut, stdErr, fsys), newCmdBuild(stdOut, stdErr, fsys),
newCmdDiff(stdOut, stdErr, fsys), newCmdDiff(stdOut, stdErr, fsys),
newCmdEdit(stdOut, stdErr, fsys), newCmdEdit(stdOut, stdErr, fsys),
version.NewCmdVersion(stdOut), newCmdVersion(stdOut),
) )
c.PersistentFlags().AddGoFlagSet(flag.CommandLine) c.PersistentFlags().AddGoFlagSet(flag.CommandLine)

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package version package commands
import ( import (
"fmt" "fmt"
@@ -32,8 +32,8 @@ var (
buildDate = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') buildDate = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
) )
// Version represens kustomize version. // version returns the version of kustomize.
type Version struct { type version struct {
// KustomizeVersion is a kustomize binary version. // KustomizeVersion is a kustomize binary version.
KustomizeVersion string `json:"kustomizeVersion"` KustomizeVersion string `json:"kustomizeVersion"`
// GitCommit is a git commit // GitCommit is a git commit
@@ -46,9 +46,9 @@ type Version struct {
GoArch string `json:"goArch"` GoArch string `json:"goArch"`
} }
// GetVersion returns version. // getVersion returns version.
func GetVersion() Version { func getVersion() version {
return Version{ return version{
kustomizeVersion, kustomizeVersion,
gitCommit, gitCommit,
buildDate, buildDate,
@@ -58,18 +58,18 @@ func GetVersion() Version {
} }
// Print prints version. // Print prints version.
func (v Version) Print(w io.Writer) { func (v version) Print(w io.Writer) {
fmt.Fprintf(w, "Version: %+v\n", v) fmt.Fprintf(w, "Version: %+v\n", v)
} }
// NewCmdVersion makes version command. // NewCmdVersion makes version command.
func NewCmdVersion(w io.Writer) *cobra.Command { func newCmdVersion(w io.Writer) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "version", Use: "version",
Short: "Prints the kustomize version", Short: "Prints the kustomize version",
Example: `kustomize version`, Example: `kustomize version`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
GetVersion().Print(w) getVersion().Print(w)
}, },
} }
} }