Skip to content

Commit

Permalink
Add -filter to CLI listing and website docs (#967)
Browse files Browse the repository at this point in the history
* Add -filter to CLI listing.

This doesn't include docs/Changelog yet, that will come shortly.

* Add changelog

* Add website docs and fix a curl output bug
  • Loading branch information
jefferai authored Mar 1, 2021
1 parent a4005b0 commit 519efa6
Show file tree
Hide file tree
Showing 26 changed files with 199 additions and 20 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ All of these changes are from [PR

### New and Improved

* list filtering: Listing now supports filtering results before being returned
to the user. The filtering takes place server side and uses boolean
expressions against the JSON representation of returned items. See [the
documentation](https://www.boundaryproject.io/docs/concepts/filtering/resource-listing)
for more details. ([PR](https://github.com/hashicorp/boundary/pull/952))
([PR](https://github.com/hashicorp/boundary/pull/957))
([PR](https://github.com/hashicorp/boundary/pull/967))
* server: Officially support reloading TLS parameters on `SIGHUP`. (This likely
worked before but wasn't fully tested.)
([PR](https://github.com/hashicorp/boundary/pull/959))
Expand Down
7 changes: 4 additions & 3 deletions api/output_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,19 @@ func (d *OutputStringError) parseRequest() {
h = fmt.Sprintf("Bearer $(boundary config get-token -keyring-type %s -token-name %s)", keyringType, tokenName)
}
}
d.parsedCurlString = fmt.Sprintf("%s-H \"%s: %s\" ", d.parsedCurlString, k, h)
d.parsedCurlString = fmt.Sprintf("%s-H \"%s: %s\"", d.parsedCurlString, k, h)
}
}

if len(body) > 0 {
// We need to escape single quotes since that's what we're using to
// quote the body
escapedBody := strings.Replace(string(body), "'", "'\"'\"'", -1)
d.parsedCurlString = fmt.Sprintf("%s-d '%s' ", d.parsedCurlString, escapedBody)
d.parsedCurlString = fmt.Sprintf(" %s-d '%s'", d.parsedCurlString, escapedBody)
}

d.parsedCurlString = fmt.Sprintf("%s%s", d.parsedCurlString, d.Request.URL.String())
// Filters can have shell characters so we use single quotes to surround the URL
d.parsedCurlString = fmt.Sprintf("%s '%s'", d.parsedCurlString, d.Request.URL.String())
}

func (d *OutputStringError) CurlString() string {
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type Command struct {
FlagHostCatalogId string
FlagVersion int
FlagRecursive bool
FlagFilter string

client *api.Client
}
Expand Down
6 changes: 5 additions & 1 deletion internal/cmd/commands/accountscmd/accounts.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions internal/cmd/commands/accountscmd/password_accounts.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion internal/cmd/commands/authmethodscmd/authmethods.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion internal/cmd/commands/authtokenscmd/authtokens.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion internal/cmd/commands/groupscmd/groups.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion internal/cmd/commands/hostcatalogscmd/hostcatalogs.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion internal/cmd/commands/hostscmd/hosts.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions internal/cmd/commands/hostscmd/static_hosts.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion internal/cmd/commands/hostsetscmd/hostsets.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions internal/cmd/commands/hostsetscmd/static_hostsets.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion internal/cmd/commands/rolescmd/roles.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion internal/cmd/commands/scopescmd/scopes.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/cmd/commands/server/listener_reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ func TestServer_ReloadListener(t *testing.T) {
// Setup initial certs
inBytes, err := ioutil.ReadFile(wd + "bundle1.pem")
require.NoError(err)
require.NoError(ioutil.WriteFile(td+"/bundle.pem", inBytes, 0777))
require.NoError(ioutil.WriteFile(td+"/bundle.pem", inBytes, 0o777))

relHcl := fmt.Sprintf(reloadConfig, cmd.DatabaseUrl, controllerKey, workerAuthKey, recoveryKey, td, td)
require.NoError(ioutil.WriteFile(td+"/reload.hcl", []byte(relHcl), 0777))
require.NoError(ioutil.WriteFile(td+"/reload.hcl", []byte(relHcl), 0o777))

// Populate CA pool
inBytes, _ = ioutil.ReadFile(td + "/bundle.pem")
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestServer_ReloadListener(t *testing.T) {

inBytes, err = ioutil.ReadFile(wd + "bundle2.pem")
require.NoError(err)
require.NoError(ioutil.WriteFile(td+"/bundle.pem", inBytes, 0777))
require.NoError(ioutil.WriteFile(td+"/bundle.pem", inBytes, 0o777))

cmd.SighupCh <- struct{}{}
select {
Expand Down
6 changes: 5 additions & 1 deletion internal/cmd/commands/sessionscmd/sessions.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion internal/cmd/commands/targetscmd/targets.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions internal/cmd/commands/targetscmd/tcp_targets.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion internal/cmd/commands/userscmd/users.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions internal/cmd/common/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ func PopulateCommonFlags(c *base.Command, f *base.FlagSet, resourceType string,
Target: &c.FlagRecursive,
Usage: "If set, the list operation will be applied recursively into child scopes, if supported by the type.",
})
case "filter":
f.StringVar(&base.StringVar{
Name: "filter",
Target: &c.FlagFilter,
Usage: "If set, the list operation will be filtered before being returned. The filter operates against each item in the list. Using single quotes is recommended as filters contain double quotes. See https://www.boundaryproject.io/docs/concepts/filtering/resource-listing for details.",
})
}
}
}
Loading

0 comments on commit 519efa6

Please sign in to comment.