Skip to content

Commit

Permalink
chore(lint): fix gofmt and goimport issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BronzeDeer committed Mar 1, 2023
1 parent ce2b8f8 commit 1a9cd4c
Show file tree
Hide file tree
Showing 20 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/executor/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func exit(err error) {
exitWithCode(err, 1)
}

//exits with the given error and exit code
// exits with the given error and exit code
func exitWithCode(err error, exitCode int) {
fmt.Println(err)
os.Exit(exitCode)
Expand Down
9 changes: 6 additions & 3 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,17 @@ func testGitBuildcontextHelper(t *testing.T, repo string) {

// TestGitBuildcontext explicitly names the main branch
// Example:
// git://github.com/myuser/repo#refs/heads/main
//
// git://github.com/myuser/repo#refs/heads/main
func TestGitBuildcontext(t *testing.T) {
repo := getGitRepo(false)
testGitBuildcontextHelper(t, repo)
}

// TestGitBuildcontextNoRef builds without any commit / branch reference
// Example:
// git://github.com/myuser/repo
//
// git://github.com/myuser/repo
func TestGitBuildcontextNoRef(t *testing.T) {
t.Skip("Docker's behavior is to assume a 'master' branch, which the Kaniko repo doesn't have")
_, _, url := getBranchCommitAndURL()
Expand All @@ -299,7 +301,8 @@ func TestGitBuildcontextNoRef(t *testing.T) {

// TestGitBuildcontextExplicitCommit uses an explicit commit hash instead of named reference
// Example:
// git://github.com/myuser/repo#b873088c4a7b60bb7e216289c58da945d0d771b6
//
// git://github.com/myuser/repo#b873088c4a7b60bb7e216289c58da945d0d771b6
func TestGitBuildcontextExplicitCommit(t *testing.T) {
repo := getGitRepo(true)
testGitBuildcontextHelper(t, repo)
Expand Down
12 changes: 6 additions & 6 deletions pkg/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ type AddCommand struct {

// ExecuteCommand executes the ADD command
// Special stuff about ADD:
// 1. If <src> is a remote file URL:
// - destination will have permissions of 0600
// - If remote file has HTTP Last-Modified header, we set the mtime of the file to that timestamp
// - If dest doesn't end with a slash, the filepath is inferred to be <dest>/<filename>
// 2. If <src> is a local tar archive:
// - it is unpacked at the dest, as 'tar -x' would
// 1. If <src> is a remote file URL:
// - destination will have permissions of 0600
// - If remote file has HTTP Last-Modified header, we set the mtime of the file to that timestamp
// - If dest doesn't end with a slash, the filepath is inferred to be <dest>/<filename>
// 2. If <src> is a local tar archive:
// - it is unpacked at the dest, as 'tar -x' would
func (a *AddCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
replacementEnvs := buildArgs.ReplacementEnvs(config.Env)

Expand Down
1 change: 1 addition & 0 deletions pkg/commands/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 commands

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 commands

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/entrypoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 commands

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 commands

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/onbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type OnBuildCommand struct {
cmd *instructions.OnbuildCommand
}

//ExecuteCommand adds the specified expression in Onbuild to the config
// ExecuteCommand adds the specified expression in Onbuild to the config
func (o *OnBuildCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
logrus.Info("Cmd: ONBUILD")
logrus.Infof("Args: %s", o.cmd.Expression)
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 commands

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 commands

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/stopsignal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 commands

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 commands

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 commands

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/workdir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 commands

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/executor/copy_multistage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 executor

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/snapshot/layered_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 snapshot

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/snapshot/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 snapshot

import (
Expand Down
1 change: 1 addition & 0 deletions pkg/timing/timing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 timing

import (
Expand Down
6 changes: 5 additions & 1 deletion pkg/util/command_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,14 @@ func IsDestDir(path string) bool {

// DestinationFilepath returns the destination filepath from the build context to the image filesystem
// If source is a file:
//
// If dest is a dir, copy it to /dest/relpath
// If dest is a file, copy directly to dest
// If dest is a file, copy directly to dest
//
// If source is a dir:
//
// Assume dest is also a dir, and copy to dest/
//
// If dest is not an absolute filepath, add /cwd to the beginning
func DestinationFilepath(src, dest, cwd string) (string, error) {
_, srcFileName := filepath.Split(src)
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/fs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,9 @@ func AddVolumePathToIgnoreList(path string) {

// DownloadFileToDest downloads the file at rawurl to the given dest for the ADD command
// From add command docs:
// 1. If <src> is a remote file URL:
// - destination will have permissions of 0600
// - If remote file has HTTP Last-Modified header, we set the mtime of the file to that timestamp
// 1. If <src> is a remote file URL:
// - destination will have permissions of 0600
// - If remote file has HTTP Last-Modified header, we set the mtime of the file to that timestamp
func DownloadFileToDest(rawurl, dest string, uid, gid int64) error {
resp, err := http.Get(rawurl)
if err != nil {
Expand Down

0 comments on commit 1a9cd4c

Please sign in to comment.