|
@@ -2,6 +2,7 @@ package helper
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"github.com/docker/docker-credential-helpers/credentials"
|
|
"github.com/docker/docker-credential-helpers/credentials"
|
|
|
|
|
+ api "github.com/porter-dev/porter/api/client"
|
|
|
"github.com/porter-dev/porter/cli/cmd/config"
|
|
"github.com/porter-dev/porter/cli/cmd/config"
|
|
|
"github.com/porter-dev/porter/cli/cmd/docker"
|
|
"github.com/porter-dev/porter/cli/cmd/docker"
|
|
|
)
|
|
)
|
|
@@ -21,11 +22,19 @@ func NewPorterHelper(debug bool) *PorterHelper {
|
|
|
cliConfig := config.InitAndLoadNewConfig()
|
|
cliConfig := config.InitAndLoadNewConfig()
|
|
|
cache := docker.NewFileCredentialsCache()
|
|
cache := docker.NewFileCredentialsCache()
|
|
|
|
|
|
|
|
|
|
+ var client *api.Client
|
|
|
|
|
+
|
|
|
|
|
+ if token := cliConfig.Token; token != "" {
|
|
|
|
|
+ client = api.NewClientWithToken(cliConfig.Host+"/api", token)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ client = api.NewClient(cliConfig.Host+"/api", "cookie.json")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return &PorterHelper{
|
|
return &PorterHelper{
|
|
|
Debug: debug,
|
|
Debug: debug,
|
|
|
ProjectID: cliConfig.Project,
|
|
ProjectID: cliConfig.Project,
|
|
|
AuthGetter: &docker.AuthGetter{
|
|
AuthGetter: &docker.AuthGetter{
|
|
|
- Client: config.GetAPIClient(),
|
|
|
|
|
|
|
+ Client: client,
|
|
|
Cache: cache,
|
|
Cache: cache,
|
|
|
ProjectID: cliConfig.Project,
|
|
ProjectID: cliConfig.Project,
|
|
|
},
|
|
},
|