-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5b809b
commit dcf6297
Showing
8 changed files
with
129 additions
and
475 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package hcpvaultengine | ||
|
||
import "github.com/mitchellh/cli" | ||
|
||
func InitHCPCommand(ui cli.Ui) map[string]cli.CommandFactory { | ||
return map[string]cli.CommandFactory{ | ||
"connect": func() (cli.Command, error) { | ||
return &HCPConnectCommand{ | ||
Ui: ui, | ||
}, nil | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package hcpvaultengine | ||
|
||
// TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package hcpvaultengine | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
|
||
"github.com/mitchellh/cli" | ||
) | ||
|
||
var ( | ||
_ cli.Command = (*HCPConnectCommand)(nil) | ||
) | ||
|
||
type HCPConnectCommand struct { | ||
Ui cli.Ui | ||
|
||
flagNonInteractiveMethod bool | ||
|
||
connectHandler ConnectHandler | ||
} | ||
|
||
func (c *HCPConnectCommand) Help() string { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (c *HCPConnectCommand) Run(args []string) int { | ||
f := c.Flags() | ||
|
||
if err := f.Parse(args); err != nil { | ||
c.Ui.Error(err.Error()) | ||
return 1 | ||
} | ||
|
||
if c.flagNonInteractiveMethod { | ||
c.connectHandler = &nonInteractiveConnectHandler{} | ||
} else { | ||
c.connectHandler = &interactiveConnectHandler{} | ||
} | ||
|
||
authStatus, err := c.connectHandler.Connect(args) | ||
if err != nil { | ||
c.Ui.Error(fmt.Sprintf("Failed to connect to HCP: %s", err)) | ||
return 1 | ||
} | ||
|
||
return 0 | ||
} | ||
|
||
func (c *HCPConnectCommand) Synopsis() string { | ||
return "Authenticate to HCP" | ||
} | ||
|
||
func (c *HCPConnectCommand) Flags() *flag.FlagSet { | ||
mainSet := flag.NewFlagSet("", flag.ContinueOnError) | ||
mainSet.Var(&boolValue{target: &c.flagNonInteractiveMethod}, "non-interactive", "") | ||
return mainSet | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package hcpvaultengine | ||
|
||
type AuthStatus struct { | ||
Token string //should this be encrypted? how? | ||
} | ||
|
||
var ( | ||
_ ConnectHandler = (*interactiveConnectHandler)(nil) | ||
_ ConnectHandler = (*nonInteractiveConnectHandler)(nil) | ||
) | ||
|
||
type ConnectHandler interface { | ||
// should we parse this before [during the Run function common flag parsin] into a struct that's specific to the different handlers? | ||
Connect(args []string) (AuthStatus, error) | ||
} | ||
|
||
type interactiveConnectHandler struct{} | ||
|
||
func (h *interactiveConnectHandler) Connect(args []string) (AuthStatus, error) { | ||
return AuthStatus{}, nil | ||
} | ||
|
||
type nonInteractiveConnectHandler struct{} | ||
|
||
func (h *nonInteractiveConnectHandler) Connect(args []string) (AuthStatus, error) { | ||
return AuthStatus{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package hcpvaultengine | ||
|
||
import "strconv" | ||
|
||
type boolValue struct { | ||
target *bool | ||
} | ||
|
||
func (v *boolValue) String() string { | ||
return strconv.FormatBool(*v.target) | ||
} | ||
|
||
func (v *boolValue) Set(s string) error { | ||
value, err := strconv.ParseBool(s) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
*v.target = value | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,17 @@ | ||
module github.com/hashicorp/vault-plugin-scaffolding | ||
|
||
go 1.20 | ||
go 1.21 | ||
|
||
require ( | ||
github.com/hashicorp/go-hclog v1.5.0 | ||
github.com/hashicorp/vault/api v1.9.2 | ||
github.com/hashicorp/vault/sdk v0.9.1 | ||
) | ||
require github.com/mitchellh/cli v1.0.0 | ||
|
||
require ( | ||
github.com/armon/go-metrics v0.4.1 // indirect | ||
github.com/armon/go-radix v1.0.0 // indirect | ||
github.com/cenkalti/backoff/v3 v3.2.2 // indirect | ||
github.com/bgentry/speakeasy v0.1.0 // indirect | ||
github.com/fatih/color v1.13.0 // indirect | ||
github.com/frankban/quicktest v1.14.2 // indirect | ||
github.com/go-jose/go-jose/v3 v3.0.0 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/golang/snappy v0.0.4 // indirect | ||
github.com/google/go-cmp v0.5.9 // indirect | ||
github.com/hashicorp/errwrap v1.1.0 // indirect | ||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect | ||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect | ||
github.com/hashicorp/go-kms-wrapping/v2 v2.0.8 // indirect | ||
github.com/hashicorp/go-multierror v1.1.1 // indirect | ||
github.com/hashicorp/go-plugin v1.4.8 // indirect | ||
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect | ||
github.com/hashicorp/go-rootcerts v1.0.2 // indirect | ||
github.com/hashicorp/go-secure-stdlib/mlock v0.1.2 // indirect | ||
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect | ||
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect | ||
github.com/hashicorp/go-sockaddr v1.0.2 // indirect | ||
github.com/hashicorp/go-uuid v1.0.3 // indirect | ||
github.com/hashicorp/go-version v1.6.0 // indirect | ||
github.com/hashicorp/golang-lru v0.5.4 // indirect | ||
github.com/hashicorp/hcl v1.0.1-vault-5 // indirect | ||
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.17 // indirect | ||
github.com/mitchellh/copystructure v1.2.0 // indirect | ||
github.com/mitchellh/go-homedir v1.1.0 // indirect | ||
github.com/mitchellh/go-testing-interface v1.14.1 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/mitchellh/reflectwalk v1.0.2 // indirect | ||
github.com/oklog/run v1.1.0 // indirect | ||
github.com/pierrec/lz4 v2.6.1+incompatible // indirect | ||
github.com/rogpeppe/go-internal v1.8.1 // indirect | ||
github.com/ryanuber/go-glob v1.0.0 // indirect | ||
go.uber.org/atomic v1.9.0 // indirect | ||
golang.org/x/crypto v0.6.0 // indirect | ||
golang.org/x/net v0.8.0 // indirect | ||
github.com/posener/complete v1.1.1 // indirect | ||
golang.org/x/sys v0.6.0 // indirect | ||
golang.org/x/text v0.8.0 // indirect | ||
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect | ||
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect | ||
google.golang.org/grpc v1.53.0 // indirect | ||
google.golang.org/protobuf v1.28.1 // indirect | ||
gopkg.in/square/go-jose.v2 v2.6.0 // indirect | ||
) |
Oops, something went wrong.