Skip to content

Commit

Permalink
Update linter options
Browse files Browse the repository at this point in the history
Signed-off-by: Radu M <root@radu.sh>
  • Loading branch information
Radu M committed Mar 5, 2020
1 parent 4bd3e04 commit 1cd7bda
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
run: |
export GOPATH=$HOME/go && export GOBIN=$(go env GOPATH)/bin && export PATH=$PATH:$GOPATH&& export PATH=$PATH:$GOBIN && mkdir -p $GOBIN
make bootstrap build test lint
make bootstrap build test
2 changes: 1 addition & 1 deletion golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ linters:
- golint
- gosimple
- ineffassign
- misspell
# - misspell
- unused
- deadcode
- govet
Expand Down
57 changes: 27 additions & 30 deletions pkg/tuf/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"runtime"
"strings"
"time"

"github.com/docker/cli/cli/config"
configtypes "github.com/docker/cli/cli/config/types"
"github.com/docker/distribution/registry/client/auth"
"github.com/docker/distribution/registry/client/auth/challenge"
Expand All @@ -38,8 +35,8 @@ const (
// DockerNotaryServer is the default Notary server associated with Docker Hub
DockerNotaryServer = "https://notary.docker.io"

configFileDir = ".docker"
defaultIndexServer = "https://index.docker.io/v1/"
// configFileDir = ".docker"
// defaultIndexServer = "https://index.docker.io/v1/"
)

func makeTransport(server, gun, tlsCaCert, timeout string) (http.RoundTripper, error) {
Expand Down Expand Up @@ -227,36 +224,36 @@ func getPassphraseRetriever() notary.PassRetriever {
}
}

func getAuth(server string) (configtypes.AuthConfig, error) {
s, err := url.Parse(server)
if err != nil {
return configtypes.AuthConfig{}, fmt.Errorf("cannot parse trust server URL: %v", err)
}
// func getAuth(server string) (configtypes.AuthConfig, error) {
// s, err := url.Parse(server)
// if err != nil {
// return configtypes.AuthConfig{}, fmt.Errorf("cannot parse trust server URL: %v", err)
// }

cfg, err := config.Load(defaultCfgDir())
if err != nil {
return configtypes.AuthConfig{}, err
}
// cfg, err := config.Load(defaultCfgDir())
// if err != nil {
// return configtypes.AuthConfig{}, err
// }

auth, ok := cfg.AuthConfigs[s.Hostname()]
if !ok {
if s.Hostname() == DockerNotaryServer {
return cfg.AuthConfigs[defaultIndexServer], nil
}
return configtypes.AuthConfig{}, fmt.Errorf("authentication not found for trust server %v", server)
}
// auth, ok := cfg.AuthConfigs[s.Hostname()]
// if !ok {
// if s.Hostname() == DockerNotaryServer {
// return cfg.AuthConfigs[defaultIndexServer], nil
// }
// return configtypes.AuthConfig{}, fmt.Errorf("authentication not found for trust server %v", server)
// }

return auth, nil
}
// return auth, nil
// }

func defaultCfgDir() string {
homeEnvPath := os.Getenv("HOME")
if homeEnvPath == "" && runtime.GOOS == "windows" {
homeEnvPath = os.Getenv("USERPROFILE")
}
// func defaultCfgDir() string {
// homeEnvPath := os.Getenv("HOME")
// if homeEnvPath == "" && runtime.GOOS == "windows" {
// homeEnvPath = os.Getenv("USERPROFILE")
// }

return filepath.Join(homeEnvPath, configFileDir)
}
// return filepath.Join(homeEnvPath, configFileDir)
// }

type simpleCredentialStore struct {
auth configtypes.AuthConfig
Expand Down

0 comments on commit 1cd7bda

Please sign in to comment.