Skip to content
This repository was archived by the owner on Jul 18, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions cmds/signin/signin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/taskcluster/taskcluster-cli/config"
tcclient "github.com/taskcluster/taskcluster-client-go"
"github.com/taskcluster/taskcluster-client-go/auth"
libUrls "github.com/taskcluster/taskcluster-lib-urls"
graceful "gopkg.in/tylerb/graceful.v1"
)

Expand Down Expand Up @@ -52,9 +53,10 @@ tools using those libraries can also benefit from this signin method.`,
root.Command.AddCommand(cmd)

config.RegisterOptions("signin", map[string]config.OptionDefinition{
"toolsUrl": config.OptionDefinition{
Description: "URL for the tools service.",
Default: "https://tools.taskcluster.net",
"rootUrl": config.OptionDefinition{
Description: "Root URL against which to act",
Default: "https://taskcluster.net",
Env: "TASKCLUSTER_ROOT_URL",
Validate: func(value interface{}) error {
if _, ok := value.(string); !ok {
return errors.New("Must be a string")
Expand Down Expand Up @@ -87,12 +89,15 @@ func cmdSignin(cmd *cobra.Command, _ []string) error {
s.Server.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
qs := r.URL.Query()
csh, _ := cmd.Flags().GetBool("csh")
rootURL := config.Configuration["signin"]["rootUrl"].(string)
if csh {
fmt.Fprintln(cmd.OutOrStdout(), "setenv TASKCLUSTER_CLIENT_ID '"+qs.Get("clientId")+"'")
fmt.Fprintln(cmd.OutOrStdout(), "setenv TASKCLUSTER_ACCESS_TOKEN '"+qs.Get("accessToken")+"'")
fmt.Fprintln(cmd.OutOrStdout(), "setenv TASKCLUSTER_ROOT_URL '"+rootURL+"'")
} else {
fmt.Fprintln(cmd.OutOrStdout(), "export TASKCLUSTER_CLIENT_ID='"+qs.Get("clientId")+"'")
fmt.Fprintln(cmd.OutOrStdout(), "export TASKCLUSTER_ACCESS_TOKEN='"+qs.Get("accessToken")+"'")
fmt.Fprintln(cmd.OutOrStdout(), "export TASKCLUSTER_ROOT_URL='"+rootURL+"'")
}
fmt.Fprintln(cmd.OutOrStderr(), "Credentials output as environment variables")

Expand Down Expand Up @@ -124,7 +129,7 @@ func cmdSignin(cmd *cobra.Command, _ []string) error {
// Construct URL for login service and open it
callbackURL := "http://" + strings.Replace(listener.Addr().String(), "127.0.0.1", "localhost", 1)
description := url.QueryEscape("Temporary client for use on the command line")
loginURL := config.Configuration["signin"]["toolsUrl"].(string) + "/auth/clients/new"
loginURL := libUrls.UI(config.Configuration["signin"]["rootUrl"].(string), "/auth/clients/new")
name, _ := cmd.Flags().GetString("name")
loginURL += "?name=" + url.QueryEscape(name)
loginURL += "&description=" + description
Expand Down
12 changes: 9 additions & 3 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"revisionTime": "2017-03-30T08:48:43Z"
},
{
"checksumSHA1": "GPl+4G/6LSTGEgPtxqlIQhXJ82U=",
"checksumSHA1": "DCjamhJdcLN963jm6/yFoDbJvT4=",
"path": "github.com/shirou/gopsutil/disk",
"revision": "e49a95f3d5f824c3f9875ca49e54e4fef17f82cf",
"revisionTime": "2017-04-06T13:17:56Z"
Expand All @@ -161,7 +161,7 @@
"revisionTime": "2017-04-06T13:17:56Z"
},
{
"checksumSHA1": "rLo31ffS0VeaRYKDTm+WSd8nUQ4=",
"checksumSHA1": "zkNNauN735M7Jghr+MsARbb+/xQ=",
"path": "github.com/shirou/gopsutil/mem",
"revision": "e49a95f3d5f824c3f9875ca49e54e4fef17f82cf",
"revisionTime": "2017-04-06T13:17:56Z"
Expand Down Expand Up @@ -286,6 +286,12 @@
"revision": "d0979b7bd0a8f9c555b9ffca20e95dbf02f0cfce",
"revisionTime": "2017-04-07T13:25:32Z"
},
{
"checksumSHA1": "RRxFQSmAKEqOr0yNyocMTnVfZEo=",
"path": "github.com/taskcluster/taskcluster-lib-urls",
"revision": "fa4efabda5891c53b4885970852eb0d5c487d977",
"revisionTime": "2018-06-01T19:41:51Z"
},
{
"checksumSHA1": "Es6jQ7nOtzvM74kkdt1BTj2CvBY=",
"path": "github.com/taskcluster/taskcluster-worker/engines",
Expand Down Expand Up @@ -383,7 +389,7 @@
"revisionTime": "2016-12-29T22:47:41Z"
},
{
"checksumSHA1": "oBjdFvDUZpioGsB6URqe16hDQUg=",
"checksumSHA1": "aQcK6fcqVIdpOQ7Gw6qkFiDtnrE=",
"origin": "github.com/fatih/color/vendor/golang.org/x/sys/unix",
"path": "golang.org/x/sys/unix",
"revision": "9131ab34cf20d2f6d83fdc67168a5430d1c7dc23",
Expand Down