8000 feat(domains): adds description field to domainv1 by nsmethwick-fastly · Pull Request #1483 · fastly/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(domains): adds description field to domainv1 #1483

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

Merged
merged 2 commits into from
Jun 11, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG

## [Unreleased]
- feat(domains): add `description` to `domainv1` endpoints ([#1483](https://github.com/fastly/cli/pull/1483))

### Breaking:

Expand Down
5 changes: 3 additions & 2 deletions pkg/commands/domainv1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
// format.
func printSummary(out io.Writer, data []v1.Data) {
t := text.NewTable(out)
t.AddHeader("FQDN", "DOMAIN ID", "SERVICE ID", "CREATED AT", "UPDATED AT")
t.AddHeader("FQDN", "DOMAIN ID", "SERVICE ID", "CREATED AT", "UPDATED AT", "DESCRIPTION")
for _, d := range data {
var sid string
if d.ServiceID != nil {
sid = *d.ServiceID
}
t.AddLine(d.FQDN, d.DomainID, sid, d.CreatedAt, d.UpdatedAt)
t.AddLine(d.FQDN, d.DomainID, sid, d.CreatedAt, d.UpdatedAt, d.Description)
}
t.Print()
}
Expand All @@ -35,6 +35,7 @@ func printVerbose(out io.Writer, data []v1.Data) {
}
fmt.Fprintf(out, "Created at: %s\n", d.CreatedAt)
fmt.Fprintf(out, "Updated at: %s\n", d.UpdatedAt)
fmt.Fprintf(out, "Description: %s\n", d.Description)
fmt.Fprintf(out, "\n")
}
}
8 changes: 8 additions & 0 deletions pkg/commands/domainv1/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ type CreateCommand struct {
// Required.
fqdn string
serviceID string

// Optional.
description argparser.OptionalString
}

// NewCreateCommand returns a usable command registered under the parent.
Expand All @@ -32,6 +35,7 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman
c.CmdClause = parent.Command("create", "Create a domain").Alias("add")

// Optional.
c.CmdClause.Flag("description", "The description for the domain").Action(c.description.Set).StringVar(&c.description.Value)
c.CmdClause.Flag("fqdn", "The fully qualified domain name").Required().StringVar(&c.fqdn)
c.RegisterFlag(argparser.StringFlagOpts{
Name: argparser.FlagServiceIDName,
Expand All @@ -51,6 +55,10 @@ func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error {
input.ServiceID = &c.serviceID
}

if c.description.WasSet {
input.Description = &c.description.Value
}

fc, ok := c.Globals.APIClient.(*fastly.Client)
if !ok {
return errors.New("failed to convert interface to a fastly client")
Expand Down
16 changes: 10 additions & 6 deletions pkg/commands/domainv1/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ func TestDomainV1List(t *testing.T) {
fqdn := "www.example.com"
sid := "123"
did := "domain-id"
description := "domain description"

resp := testutil.GenJSON(v1.Collection{
Data: []v1.Data{
{
DomainID: did,
FQDN: fqdn,
ServiceID: &sid,
DomainID: did,
FQDN: fqdn,
ServiceID: &sid,
Description: description,
},
},
})
Expand Down Expand Up @@ -137,11 +139,13 @@ func TestDomainV1Describe(t *testing.T) {
fqdn := "www.example.com"
sid := "123"
did := "domain-id"
description := "domain description"

resp := testutil.GenJSON(v1.Data{
DomainID: did,
FQDN: fqdn,
ServiceID: &sid,
DomainID: did,
FQDN: fqdn,
ServiceID: &sid,
Description: description,
})

scenarios := []testutil.CLIScenario{
Expand Down
10 changes: 8 additions & 2 deletions pkg/commands/domainv1/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (
// UpdateCommand calls the Fastly API to update domains.
type UpdateCommand struct {
argparser.Base
domainID string
serviceID string
domainID string
serviceID string
description argparser.OptionalString
}

// NewUpdateCommand returns a usable command registered under the parent.
Expand All @@ -33,6 +34,7 @@ func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateComman
c.CmdClause.Flag("domain-id", "The Domain Identifier (UUID)").Required().StringVar(&c.domainID)

// Optional
c.CmdClause.Flag("description", "The description for the domain").Action(c.description.Set).StringVar(&c.description.Value)
c.CmdClause.Flag("service-id", "The service_id associated with your domain (omit to unset)").StringVar(&c.serviceID)

return &c
Expand All @@ -47,6 +49,10 @@ func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error {
input.ServiceID = &c.serviceID
}

if c.description.WasSet {
input.Description = &c.description.Value
}

fc, ok := c.Globals.APIClient.(*fastly.Client)
if !ok {
return errors.New("failed to convert interface to a fastly client")
Expand Down
0