Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add useful next step links to compute deploy #8

Merged
merged 3 commits into from
Mar 20, 2020
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
41 changes: 41 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 this 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 All @@ -544,6 +574,7 @@ func TestDeploy(t *testing.T) {
args: []string{"compute", "deploy", "-t", "123", "-p", "pkg/package.tar.gz", "-s", "123", "--version", "2"},
api: mock.API{
ActivateVersionFn: activateVersionOk,
ListDomainsFn: listDomainsOk,
},
client: codeClient{http.StatusOK},
manifestIncludes: "version = 2",
Expand Down Expand Up @@ -1043,6 +1074,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 this 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