fix linting issues

Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com>
This commit is contained in:
Tihomir Jovicic 2021-08-02 09:35:33 +02:00
parent 0010609f4d
commit 92e6e693f5
4 changed files with 9 additions and 14 deletions

View File

@ -45,7 +45,7 @@ type require struct {
version string version string
} }
func (r *require) cloneUrl() string { func (r *require) cloneURL() string {
return fmt.Sprintf("%s%s", r.prefix, r.repo) return fmt.Sprintf("%s%s", r.prefix, r.repo)
} }
@ -122,10 +122,7 @@ func parseArgument(arg string) (*require, error) {
return nil, err return nil, err
} }
repoPath, version, err := parseGithubRepoVersion(suffix) repoPath, version := parseGithubRepoVersion(suffix)
if err != nil {
return nil, err
}
return &require{ return &require{
prefix: "https://", prefix: "https://",
@ -151,17 +148,17 @@ func parseGithubRepoName(arg string) (string, string, error) {
return repoMatches[1], repoMatches[2], nil return repoMatches[1], repoMatches[2], nil
} }
func parseGithubRepoVersion(repoSuffix string) (string, string, error) { func parseGithubRepoVersion(repoSuffix string) (string, string) {
if repoSuffix == "" { if repoSuffix == "" {
return "", "", nil return "", ""
} }
i := strings.LastIndexAny(repoSuffix, "@:") i := strings.LastIndexAny(repoSuffix, "@:")
if i == -1 { 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) { func readModFile() (*file, error) {
@ -179,7 +176,7 @@ func readModFile() (*file, error) {
} }
func writeModFile(f *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 { func move(r *require, sourceRepoPath, destBasePath string) error {

View File

@ -18,7 +18,7 @@ type repo struct {
func clone(require *require, dir string) (*repo, error) { func clone(require *require, dir string) (*repo, error) {
r, err := git.PlainClone(dir, false, &git.CloneOptions{ r, err := git.PlainClone(dir, false, &git.CloneOptions{
URL: require.cloneUrl(), URL: require.cloneURL(),
}) })
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -2,7 +2,6 @@ package mod
import "github.com/spf13/cobra" import "github.com/spf13/cobra"
// Cmd exposes the top-level command // Cmd exposes the top-level command
var Cmd = &cobra.Command{ var Cmd = &cobra.Command{
Use: "mod", Use: "mod",
@ -14,4 +13,3 @@ func init() {
getCmd, getCmd,
) )
} }

View File

@ -1,7 +1,6 @@
package cmd package cmd
import ( import (
"go.dagger.io/dagger/cmd/dagger/cmd/mod"
"os" "os"
"strings" "strings"
@ -9,6 +8,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"go.dagger.io/dagger/cmd/dagger/cmd/input" "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/cmd/output"
"go.dagger.io/dagger/cmd/dagger/logger" "go.dagger.io/dagger/cmd/dagger/logger"
"go.dagger.io/dagger/keychain" "go.dagger.io/dagger/keychain"