From 92e6e693f5280abfd6e6858ea062248da514b355 Mon Sep 17 00:00:00 2001 From: Tihomir Jovicic Date: Mon, 2 Aug 2021 09:35:33 +0200 Subject: [PATCH] fix linting issues Signed-off-by: Tihomir Jovicic --- cmd/dagger/cmd/mod/file.go | 17 +++++++---------- cmd/dagger/cmd/mod/repo.go | 2 +- cmd/dagger/cmd/mod/root.go | 2 -- cmd/dagger/cmd/root.go | 2 +- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/cmd/dagger/cmd/mod/file.go b/cmd/dagger/cmd/mod/file.go index 29474951..33be4a68 100644 --- a/cmd/dagger/cmd/mod/file.go +++ b/cmd/dagger/cmd/mod/file.go @@ -45,7 +45,7 @@ type require struct { version string } -func (r *require) cloneUrl() string { +func (r *require) cloneURL() string { return fmt.Sprintf("%s%s", r.prefix, r.repo) } @@ -122,10 +122,7 @@ func parseArgument(arg string) (*require, error) { return nil, err } - repoPath, version, err := parseGithubRepoVersion(suffix) - if err != nil { - return nil, err - } + repoPath, version := parseGithubRepoVersion(suffix) return &require{ prefix: "https://", @@ -151,17 +148,17 @@ func parseGithubRepoName(arg string) (string, string, error) { return repoMatches[1], repoMatches[2], nil } -func parseGithubRepoVersion(repoSuffix string) (string, string, error) { +func parseGithubRepoVersion(repoSuffix string) (string, string) { if repoSuffix == "" { - return "", "", nil + return "", "" } i := strings.LastIndexAny(repoSuffix, "@:") if i == -1 { - return repoSuffix, "", nil + return repoSuffix, "" } - return repoSuffix[:i], repoSuffix[i+1:], nil + return repoSuffix[:i], repoSuffix[i+1:] } func readModFile() (*file, error) { @@ -179,7 +176,7 @@ func readModFile() (*file, error) { } func writeModFile(f *file) error { - return ioutil.WriteFile("./cue.mod/module.cue", f.contents().Bytes(), 0644) + return ioutil.WriteFile("./cue.mod/module.cue", f.contents().Bytes(), 0600) } func move(r *require, sourceRepoPath, destBasePath string) error { diff --git a/cmd/dagger/cmd/mod/repo.go b/cmd/dagger/cmd/mod/repo.go index 4970c914..36630001 100644 --- a/cmd/dagger/cmd/mod/repo.go +++ b/cmd/dagger/cmd/mod/repo.go @@ -18,7 +18,7 @@ type repo struct { func clone(require *require, dir string) (*repo, error) { r, err := git.PlainClone(dir, false, &git.CloneOptions{ - URL: require.cloneUrl(), + URL: require.cloneURL(), }) if err != nil { return nil, err diff --git a/cmd/dagger/cmd/mod/root.go b/cmd/dagger/cmd/mod/root.go index 1f12ca18..87d934ab 100644 --- a/cmd/dagger/cmd/mod/root.go +++ b/cmd/dagger/cmd/mod/root.go @@ -2,7 +2,6 @@ package mod import "github.com/spf13/cobra" - // Cmd exposes the top-level command var Cmd = &cobra.Command{ Use: "mod", @@ -14,4 +13,3 @@ func init() { getCmd, ) } - diff --git a/cmd/dagger/cmd/root.go b/cmd/dagger/cmd/root.go index 705630c5..988bc481 100644 --- a/cmd/dagger/cmd/root.go +++ b/cmd/dagger/cmd/root.go @@ -1,7 +1,6 @@ package cmd import ( - "go.dagger.io/dagger/cmd/dagger/cmd/mod" "os" "strings" @@ -9,6 +8,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" "go.dagger.io/dagger/cmd/dagger/cmd/input" + "go.dagger.io/dagger/cmd/dagger/cmd/mod" "go.dagger.io/dagger/cmd/dagger/cmd/output" "go.dagger.io/dagger/cmd/dagger/logger" "go.dagger.io/dagger/keychain"