Skip to content

Commit

Permalink
Support prefix match for list domain command (cadence-workflow#4275)
Browse files Browse the repository at this point in the history
  • Loading branch information
demirkayaender authored Jun 15, 2021
1 parent 6e3a78d commit 407c366
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/cli/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@ func newAdminDomainCommands() []cli.Command {
Name: FlagDeprecatedWithAlias,
Usage: "List deprecated domains only, by default only domains in REGISTERED status are listed",
},
cli.StringFlag{
Name: FlagPrefix,
Usage: "List domains that are matching to the given prefix",
Value: "",
},
cli.BoolFlag{
Name: FlagPrintFullyDetailWithAlias,
Usage: "Print full domain detail",
Expand Down
13 changes: 13 additions & 0 deletions tools/cli/domainCommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ func (d *domainCLIImpl) DescribeDomain(c *cli.Context) {

func (d *domainCLIImpl) ListDomains(c *cli.Context) {
pageSize := c.Int(FlagPageSize)
prefix := c.String(FlagPrefix)
printAll := c.Bool(FlagAll)
printDeprecated := c.Bool(FlagDeprecated)
printFull := c.Bool(FlagPrintFullyDetail)
Expand All @@ -469,6 +470,18 @@ func (d *domainCLIImpl) ListDomains(c *cli.Context) {

domains := d.getAllDomains(c)
var filteredDomains []*types.DescribeDomainResponse

// Only list domains that are matching to the prefix if prefix is provided
if len(prefix) > 0 {
var prefixDomains []*types.DescribeDomainResponse
for _, domain := range domains {
if strings.Index(domain.DomainInfo.Name, prefix) == 0 {
prefixDomains = append(prefixDomains, domain)
}
}
domains = prefixDomains
}

if printAll {
filteredDomains = domains
} else {
Expand Down
1 change: 1 addition & 0 deletions tools/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const (
FlagMore = "more"
FlagMoreWithAlias = FlagMore + ", m"
FlagAll = "all"
FlagPrefix = "prefix"
FlagAllWithAlias = FlagAll + ", a"
FlagDeprecated = "deprecated"
FlagDeprecatedWithAlias = FlagDeprecated + ", dep"
Expand Down

0 comments on commit 407c366

Please sign in to comment.