Skip to content

Commit

Permalink
Move files to new directories and add persona table (#3526)
Browse files Browse the repository at this point in the history
* Add persona table and move files to new directories
  • Loading branch information
talanknight authored Aug 2, 2023
1 parent 440567c commit c0b6976
Show file tree
Hide file tree
Showing 15 changed files with 632 additions and 137 deletions.
14 changes: 6 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ require (
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/cenkalti/backoff/v4 v4.2.0
github.com/creack/pty v1.1.18
github.com/glebarez/go-sqlite v1.21.1
github.com/glebarez/sqlite v1.8.0
github.com/hashicorp/cap/ldap v0.0.0-20230420150311-6d1e00a6c5e0
github.com/hashicorp/dbassert v0.0.0-20230405175854-2d88acd5134b
github.com/hashicorp/go-kms-wrapping/extras/kms/v2 v2.0.0-20221122211539-47c893099f13
Expand All @@ -100,6 +102,10 @@ require (
github.com/jimlambrt/gldap v0.1.7
github.com/kelseyhightower/envconfig v1.4.0
github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-ps v1.0.0
github.com/seldonio/goven v0.2.1
github.com/sevlyar/go-daemon v0.1.6
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53
golang.org/x/net v0.10.0
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc
Expand Down Expand Up @@ -136,8 +142,6 @@ require (
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
github.com/glebarez/go-sqlite v1.21.1 // indirect
github.com/glebarez/sqlite v1.8.0 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
github.com/go-ldap/ldap/v3 v3.4.4 // indirect
Expand Down Expand Up @@ -169,11 +173,8 @@ require (
github.com/klauspost/compress v1.13.6 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-sqlite3 v2.0.1+incompatible // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
Expand All @@ -189,9 +190,7 @@ require (
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/seldonio/goven v0.2.1 // indirect
github.com/sethvargo/go-diceware v0.3.0 // indirect
github.com/sevlyar/go-daemon v0.1.6 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
Expand All @@ -210,7 +209,6 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/sqlite v1.5.1 // indirect
modernc.org/libc v1.22.3 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
Expand Down
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLe
github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210715191844-86eeefc3e471/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
Expand Down Expand Up @@ -678,8 +679,6 @@ github.com/hashicorp/go-bexpr v0.1.12/go.mod h1:ACktpcSySkFNpcxWSClFrut7wicd9Wzi
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-dbw v0.0.0-20230605211904-d40e5c9d5995 h1:2I5x7ULbjbQVxIvrVhBZU9gXXj/4UcApBuvKf5Rb3Ts=
github.com/hashicorp/go-dbw v0.0.0-20230605211904-d40e5c9d5995/go.mod h1:5bmfUkVf0I4E3tIftLJdBM8vw1Xqe7pmbeYBzdC1cj8=
github.com/hashicorp/go-dbw v0.0.0-20230611160117-87377d5c7f5b h1:czvpsxAjufOAiO2ri2zK0Zb/kNYJfmQNu5y3lfXULxM=
github.com/hashicorp/go-dbw v0.0.0-20230611160117-87377d5c7f5b/go.mod h1:zWbqyuJIlekgoweI8C6nyNRXTdLXkLK6Xqjag5jp0xA=
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
Expand Down Expand Up @@ -1077,6 +1076,7 @@ github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c=
github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
Expand Down Expand Up @@ -1982,12 +1982,8 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/postgres v1.0.8/go.mod h1:4eOzrI1MUfm6ObJU/UcmbXyiHSs8jSwH95G5P5dxcAg=
gorm.io/driver/postgres v1.5.2 h1:ytTDxxEv+MplXOfFe3Lzm7SjG09fcdb3Z/c056DTBx0=
gorm.io/driver/postgres v1.5.2/go.mod h1:fmpX0m2I1PKuR7mKZiEluwrP3hbs+ps7JIGMUBpCgl8=
gorm.io/driver/sqlite v1.5.1 h1:hYyrLkAWE71bcarJDPdZNTLWtr8XrSjOWyjUYI6xdL4=
gorm.io/driver/sqlite v1.5.1/go.mod h1:7MZZ2Z8bqyfSQA1gYEV6MagQWj3cpUkJj9Z+d1HEMEQ=
gorm.io/gorm v1.20.12/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/gorm v1.21.4/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/gorm v1.25.1 h1:nsSALe5Pr+cM3V1qwwQ7rOkw+6UeLrX5O4v3llhHa64=
gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 h1:sC1Xj4TYrLqg1n3AN10w871An7wJM0gzgcm8jkIkECQ=
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
Expand Down
16 changes: 8 additions & 8 deletions internal/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"github.com/hashicorp/boundary/internal/cmd/commands/authenticate"
"github.com/hashicorp/boundary/internal/cmd/commands/authmethodscmd"
"github.com/hashicorp/boundary/internal/cmd/commands/authtokenscmd"
"github.com/hashicorp/boundary/internal/cmd/commands/cache"
"github.com/hashicorp/boundary/internal/cmd/commands/config"
"github.com/hashicorp/boundary/internal/cmd/commands/connect"
"github.com/hashicorp/boundary/internal/cmd/commands/credentiallibrariescmd"
"github.com/hashicorp/boundary/internal/cmd/commands/credentialscmd"
"github.com/hashicorp/boundary/internal/cmd/commands/credentialstorescmd"
"github.com/hashicorp/boundary/internal/cmd/commands/daemon"
"github.com/hashicorp/boundary/internal/cmd/commands/database"
"github.com/hashicorp/boundary/internal/cmd/commands/dev"
"github.com/hashicorp/boundary/internal/cmd/commands/groupscmd"
Expand Down Expand Up @@ -364,13 +364,8 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
}, nil
},

"cache server": func() (cli.Command, error) {
return &cache.ServerCommand{
Command: base.NewCommand(ui),
}, nil
},
"cache search targets": func() (cli.Command, error) {
return &cache.SearchTargetsCommand{
"daemon start": func() (cli.Command, error) {
return &daemon.ServerCommand{
Command: base.NewCommand(ui),
}, nil
},
Expand Down Expand Up @@ -1197,6 +1192,11 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
Func: "set-credential-sources",
}, nil
},
"targets search": func() (cli.Command, error) {
return &daemon.SearchTargetsCommand{
Command: base.NewCommand(ui),
}, nil
},

"users": func() (cli.Command, error) {
return &userscmd.Command{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package cache
package daemon

import (
"context"
Expand Down Expand Up @@ -37,16 +37,16 @@ type ServerCommand struct {
}

func (c *ServerCommand) Synopsis() string {
return "Start a Boundary cache server"
return "Start a Boundary daemon"
}

func (c *ServerCommand) Help() string {
helpText := `
Usage: boundary cache server [options]
Usage: boundary daemon start [options]
Start a cache server:
$ boundary cache server
$ boundary daemon start
For a full list of examples, please see the documentation.
Expand Down Expand Up @@ -80,7 +80,7 @@ func (c *ServerCommand) Flags() *base.FlagSets {
f.Int64Var(&base.Int64Var{
Name: "refresh-interval-seconds",
Target: &c.flagRefreshIntervalSeconds,
Usage: `If set, specifies the number of seconds between cache refreshes`,
Usage: `If set, specifies the number of seconds between cache refreshes. Default: 5 minutes`,
Aliases: []string{"r"},
})
f.UintVar(&base.UintVar{
Expand Down Expand Up @@ -118,7 +118,7 @@ func (c *ServerCommand) AutocompleteFlags() complete.Flags {
}

func (c *ServerCommand) Run(args []string) int {
const op = "cache.(ServerCommand).Run"
const op = "daemon.(ServerCommand).Run"
ctx, cancel := context.WithCancel(c.Context)
c.Context = ctx
c.ContextCancel = cancel
Expand Down Expand Up @@ -162,7 +162,7 @@ func (c *ServerCommand) Run(args []string) int {
const DefaultRefreshIntervalSeconds = 5 * 60

func StartCacheInBackground(ctx context.Context, tokenName string, cmd commander, ui cli.Ui, flagPort uint) error {
const op = "cache.StartCacheInBackground"
const op = "daemon.StartCacheInBackground"

cancelCtx, cancelFunc := context.WithCancel(ctx)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package cache
package daemon

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package cache
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package daemon

import (
"bytes"
Expand Down Expand Up @@ -28,16 +31,16 @@ type SearchTargetsCommand struct {
}

func (c *SearchTargetsCommand) Synopsis() string {
return "Start a Boundary cache server"
return "Start a Boundary daemon"
}

func (c *SearchTargetsCommand) Help() string {
helpText := `
Usage: boundary cache search [options]
Usage: boundary targets search [options]
Search a boundary cache:
Search a boundary target:
$ boundary cache search
$ boundary targets search
For a full list of examples, please see the documentation.
Expand Down Expand Up @@ -80,7 +83,7 @@ func (c *SearchTargetsCommand) AutocompleteFlags() complete.Flags {
}

func (c *SearchTargetsCommand) Run(args []string) int {
const op = "cache.(SearchTargetsCommand).Run"
const op = "daemon.(SearchTargetsCommand).Run"
ctx := c.Context
f := c.Flags()
if err := f.Parse(args); err != nil {
Expand All @@ -93,8 +96,13 @@ func (c *SearchTargetsCommand) Run(args []string) int {
c.UI.Error(err.Error())
return base.CommandUserError
}

client, err := c.Client()
if err != nil {
c.UI.Error(err.Error())
return base.CommandUserError
}
tf := targetFilterBy{
boundaryAddr: client.Addr(),
tokenName: tokenName,
flagNameStartsWith: c.flagNameStartsWith,
flagQuery: c.flagQuery,
Expand Down Expand Up @@ -140,6 +148,7 @@ func (c *SearchTargetsCommand) Run(args []string) int {
}
return base.CommandSuccess
}

func (c *SearchTargetsCommand) printListTable(items []*targets.Target) string {
if len(items) == 0 {
return "No targets found"
Expand Down Expand Up @@ -204,7 +213,7 @@ func (c *SearchTargetsCommand) printListTable(items []*targets.Target) string {
}

func SearchClient(ctx context.Context, addr string, flagOutputCurl bool) (*api.Client, error) {
const op = "cache.SearchClient"
const op = "daemon.SearchClient"
client, err := api.NewClient(nil)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
Expand All @@ -224,10 +233,11 @@ type targetFilterBy struct {
flagNameStartsWith string
flagQuery string
tokenName string
boundaryAddr string
}

func searchTargets(ctx context.Context, filterBy targetFilterBy, flagPort uint, flagOutputCurl bool) (*api.Response, error) {
const op = "cache.searchTargets"
const op = "daemon.searchTargets"
client, err := SearchClient(ctx, fmt.Sprintf("http://localhost:%d", flagPort), flagOutputCurl)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
Expand All @@ -237,6 +247,7 @@ func searchTargets(ctx context.Context, filterBy targetFilterBy, flagPort uint,
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("new client request error: %s", err.Error()))
}
req.Header.Add("token_name", filterBy.tokenName)
req.Header.Add("boundary_addr", filterBy.boundaryAddr)
q := url.Values{}
q.Add("name_starts_with", filterBy.flagNameStartsWith)
q.Add("query", filterBy.flagQuery)
Expand Down
Loading

0 comments on commit c0b6976

Please sign in to comment.