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

Avoid displaying a wildcard domain #468

Merged
merged 1 commit into from
Nov 10, 2021
Merged
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
23 changes: 16 additions & 7 deletions pkg/commands/compute/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,7 @@ func (c *DeployCommand) Exec(in io.Reader, out io.Writer) (err error) {

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

latestDomains, err := apiClient.ListDomains(&fastly.ListDomainsInput{
ServiceID: serviceID,
ServiceVersion: serviceVersion.Number,
})
if err == nil {
text.Description(out, "View this service at", fmt.Sprintf("https://%s", latestDomains[0].Name))
}
displayDomain(apiClient, serviceID, serviceVersion.Number, out)

text.Success(out, "Deployed package (service %s, version %v)", serviceID, serviceVersion.Number)
return nil
Expand Down Expand Up @@ -731,3 +725,18 @@ func pkgUpload(progress text.Progress, client api.Interface, serviceID string, v

return nil
}

// displayDomain displays a domain from those available in the service.
func displayDomain(apiClient api.Interface, serviceID string, serviceVersion int, out io.Writer) {
latestDomains, err := apiClient.ListDomains(&fastly.ListDomainsInput{
ServiceID: serviceID,
ServiceVersion: serviceVersion,
})
if err == nil {
name := latestDomains[0].Name
if segs := strings.Split(name, "*."); len(segs) > 1 {
name = segs[1]
}
text.Description(out, "View this service at", fmt.Sprintf("https://%s", name))
}
}