From de87136720fa5f7d7ba89b5e6b18266540c03958 Mon Sep 17 00:00:00 2001 From: Prashant Date: Wed, 2 Oct 2019 21:22:26 +0530 Subject: [PATCH 1/3] Kaniko version --- Makefile | 2 +- cmd/executor/cmd/root.go | 32 +++++++++++++++++--------------- cmd/executor/cmd/version.go | 20 ++++++++++++++++++++ 3 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 cmd/executor/cmd/version.go diff --git a/Makefile b/Makefile index e5633bf20..881c55a5d 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,6 @@ VERSION_MINOR ?= 11 VERSION_BUILD ?= 0 VERSION ?= v$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_BUILD) -VERSION_PACKAGE = $(REPOPATH/pkg/version) SHELL := /bin/bash GOOS ?= $(shell go env GOOS) @@ -28,6 +27,7 @@ PROJECT := kaniko REGISTRY?=gcr.io/kaniko-project REPOPATH ?= $(ORG)/$(PROJECT) +VERSION_PACKAGE = $(REPOPATH)/pkg/version GO_FILES := $(shell find . -type f -name '*.go' -not -path "./vendor/*") GO_LDFLAGS := '-extldflags "-static" diff --git a/cmd/executor/cmd/root.go b/cmd/executor/cmd/root.go index 0dd717f86..69a0addc3 100644 --- a/cmd/executor/cmd/root.go +++ b/cmd/executor/cmd/root.go @@ -54,21 +54,23 @@ func init() { var RootCmd = &cobra.Command{ Use: "executor", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - if err := util.ConfigureLogging(logLevel); err != nil { - return err - } - if !opts.NoPush && len(opts.Destinations) == 0 { - return errors.New("You must provide --destination, or use --no-push") - } - if err := cacheFlagsValid(); err != nil { - return errors.Wrap(err, "cache flags invalid") - } - if err := resolveSourceContext(); err != nil { - return errors.Wrap(err, "error resolving source context") - } - if err := resolveDockerfilePath(); err != nil { - return errors.Wrap(err, "error resolving dockerfile path") - } + if cmd.Use == "executor" { + if err := util.ConfigureLogging(logLevel); err != nil { + return err + } + if !opts.NoPush && len(opts.Destinations) == 0 { + return errors.New("You must provide --destination, or use --no-push") + } + if err := cacheFlagsValid(); err != nil { + return errors.Wrap(err, "cache flags invalid") + } + if err := resolveSourceContext(); err != nil { + return errors.Wrap(err, "error resolving source context") + } + if err := resolveDockerfilePath(); err != nil { + return errors.Wrap(err, "error resolving dockerfile path") + } + } return nil }, Run: func(cmd *cobra.Command, args []string) { diff --git a/cmd/executor/cmd/version.go b/cmd/executor/cmd/version.go new file mode 100644 index 000000000..df1880e1a --- /dev/null +++ b/cmd/executor/cmd/version.go @@ -0,0 +1,20 @@ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" + "github.com/GoogleContainerTools/kaniko/pkg/version" +) + +func init() { + RootCmd.AddCommand(versionCmd) +} + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Print the version number of kaniko", + Run: func(cmd *cobra.Command, args []string) { + fmt.Print("Kaniko version : ", version.Version()) + }, +} \ No newline at end of file From f9424d43e75222582f7350b4a5e3ab4b08dfe12c Mon Sep 17 00:00:00 2001 From: Prashant Date: Thu, 3 Oct 2019 21:29:40 +0530 Subject: [PATCH 2/3] fixing lint and minor fix --- cmd/executor/cmd/root.go | 34 +++++++++++++++++----------------- cmd/executor/cmd/version.go | 20 ++++++++++---------- pkg/util/fs_util.go | 3 --- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/cmd/executor/cmd/root.go b/cmd/executor/cmd/root.go index 29ec4162d..07a3d880b 100644 --- a/cmd/executor/cmd/root.go +++ b/cmd/executor/cmd/root.go @@ -54,23 +54,23 @@ func init() { var RootCmd = &cobra.Command{ Use: "executor", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - if cmd.Use == "executor" { - if err := util.ConfigureLogging(logLevel); err != nil { - return err - } - if !opts.NoPush && len(opts.Destinations) == 0 { - return errors.New("You must provide --destination, or use --no-push") - } - if err := cacheFlagsValid(); err != nil { - return errors.Wrap(err, "cache flags invalid") - } - if err := resolveSourceContext(); err != nil { - return errors.Wrap(err, "error resolving source context") - } - if err := resolveDockerfilePath(); err != nil { - return errors.Wrap(err, "error resolving dockerfile path") - } - } + if cmd.Use == "executor" { + if err := util.ConfigureLogging(logLevel); err != nil { + return err + } + if !opts.NoPush && len(opts.Destinations) == 0 { + return errors.New("You must provide --destination, or use --no-push") + } + if err := cacheFlagsValid(); err != nil { + return errors.Wrap(err, "cache flags invalid") + } + if err := resolveSourceContext(); err != nil { + return errors.Wrap(err, "error resolving source context") + } + if err := resolveDockerfilePath(); err != nil { + return errors.Wrap(err, "error resolving dockerfile path") + } + } return nil }, Run: func(cmd *cobra.Command, args []string) { diff --git a/cmd/executor/cmd/version.go b/cmd/executor/cmd/version.go index df1880e1a..65e2bea72 100644 --- a/cmd/executor/cmd/version.go +++ b/cmd/executor/cmd/version.go @@ -1,20 +1,20 @@ package cmd import ( - "fmt" + "fmt" - "github.com/spf13/cobra" - "github.com/GoogleContainerTools/kaniko/pkg/version" + "github.com/GoogleContainerTools/kaniko/pkg/version" + "github.com/spf13/cobra" ) func init() { - RootCmd.AddCommand(versionCmd) + RootCmd.AddCommand(versionCmd) } var versionCmd = &cobra.Command{ - Use: "version", - Short: "Print the version number of kaniko", - Run: func(cmd *cobra.Command, args []string) { - fmt.Print("Kaniko version : ", version.Version()) - }, -} \ No newline at end of file + Use: "version", + Short: "Print the version number of kaniko", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("Kaniko version : ", version.Version()) + }, +} diff --git a/pkg/util/fs_util.go b/pkg/util/fs_util.go index 338caa02a..f56f6bff5 100644 --- a/pkg/util/fs_util.go +++ b/pkg/util/fs_util.go @@ -359,9 +359,6 @@ func RelativeFiles(fp string, root string) ([]string, error) { if CheckWhitelist(path) && !HasFilepathPrefix(path, root, false) { return nil } - if err != nil { - return err - } relPath, err := filepath.Rel(root, path) if err != nil { return err From 9643e0e9a413f751037d837ef6c2c30a37a52f04 Mon Sep 17 00:00:00 2001 From: Tejal Desai Date: Fri, 4 Oct 2019 11:23:41 -0700 Subject: [PATCH 3/3] Add missing boilerplate. Add missing boiler plate. --- cmd/executor/cmd/version.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cmd/executor/cmd/version.go b/cmd/executor/cmd/version.go index 65e2bea72..15a6ec4ef 100644 --- a/cmd/executor/cmd/version.go +++ b/cmd/executor/cmd/version.go @@ -1,3 +1,19 @@ +/* +Copyright 2018 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cmd import (