Skip to content

Commit

Permalink
Add useful next step links to compute deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
phamann committed Mar 19, 2020
1 parent 00f47c4 commit 14c4453
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
40 changes: 40 additions & 0 deletions pkg/compute/compute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,13 +484,37 @@ func TestDeploy(t *testing.T) {
"Activating version...",
},
},
{
name: "list domains error",
args: []string{"compute", "deploy", "-t", "123"},
api: mock.API{
LatestVersionFn: latestVersionActiveOk,
CloneVersionFn: cloneVersionOk,
ActivateVersionFn: activateVersionOk,
ListDomainsFn: listDomainsError,
},
client: codeClient{http.StatusOK},
manifest: "name = \"package\"\nservice_id = \"123\"\n",
wantOutput: []string{
"Reading package manifest...",
"Validating package...",
"Fetching latest version...",
"Cloning latest version...",
"Uploading package...",
"Activating version...",
"Manage this service at:",
"https://manage.fastly.com/configure/services/123",
"Deployed package (service 123, version 2)",
},
},
{
name: "success",
args: []string{"compute", "deploy", "-t", "123"},
api: mock.API{
LatestVersionFn: latestVersionActiveOk,
CloneVersionFn: cloneVersionOk,
ActivateVersionFn: activateVersionOk,
ListDomainsFn: listDomainsOk,
},
client: codeClient{http.StatusOK},
manifest: "name = \"package\"\nservice_id = \"123\"\n",
Expand All @@ -501,6 +525,10 @@ func TestDeploy(t *testing.T) {
"Cloning latest version...",
"Uploading package...",
"Activating version...",
"Manage this service at:",
"https://manage.fastly.com/configure/services/123",
"View the service at:",
"https://directly-careful-coyote.edgecompute.app",
"Deployed package (service 123, version 2)",
},
},
Expand All @@ -511,6 +539,7 @@ func TestDeploy(t *testing.T) {
LatestVersionFn: latestVersionActiveOk,
CloneVersionFn: cloneVersionOk,
ActivateVersionFn: activateVersionOk,
ListDomainsFn: listDomainsOk,
},
client: codeClient{http.StatusOK},
wantOutput: []string{
Expand All @@ -529,6 +558,7 @@ func TestDeploy(t *testing.T) {
LatestVersionFn: latestVersionInactiveOk,
CloneVersionFn: cloneVersionOk,
ActivateVersionFn: activateVersionOk,
ListDomainsFn: listDomainsOk,
},
client: codeClient{http.StatusOK},
wantOutput: []string{
Expand Down Expand Up @@ -1043,6 +1073,16 @@ func activateVersionError(i *fastly.ActivateVersionInput) (*fastly.Version, erro
return nil, errTest
}

func listDomainsOk(i *fastly.ListDomainsInput) ([]*fastly.Domain, error) {
return []*fastly.Domain{
&fastly.Domain{Name: "https://directly-careful-coyote.edgecompute.app"},
}, nil
}

func listDomainsError(i *fastly.ListDomainsInput) ([]*fastly.Domain, error) {
return nil, errTest
}

type errorClient struct {
err error
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/compute/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ func (c *DeployCommand) Exec(in io.Reader, out io.Writer) (err error) {
}

progress.Done()

text.Break(out)

text.Description(out, "Manage this service at", fmt.Sprintf("%s%s", manageServiceBaseURL, serviceID))

if domains, err := c.Globals.Client.ListDomains(&fastly.ListDomainsInput{
Service: serviceID,
Version: c.version,
}); err == nil {
text.Description(out, "View the service at", fmt.Sprintf("https://%s", domains[0].Name))
}

text.Success(out, "Deployed package (service %s, version %v)", serviceID, c.version)
return nil
}
Expand Down

0 comments on commit 14c4453

Please sign in to comment.