Skip to content
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
2 changes: 1 addition & 1 deletion envsec/cmd/envsec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"
"os"

"go.jetpack.io/envsec/internal/envcli"
"go.jetpack.io/envsec/pkg/envcli"
)

func main() {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type downloadCmdFlags struct {
format string
}

func downloadCmd() *cobra.Command {
func DownloadCmd() *cobra.Command {
flags := &downloadCmdFlags{}
command := &cobra.Command{
Use: "download <file1>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type execCmdFlags struct {
configFlags
}

func execCmd() *cobra.Command {
func ExecCmd() *cobra.Command {
flags := &execCmdFlags{}
command := &cobra.Command{
Use: "exec <command>",
Expand Down
18 changes: 15 additions & 3 deletions envsec/internal/envcli/flags.go → envsec/pkg/envcli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,16 @@ func (f *configFlags) validateProjectID(orgID typeids.OrganizationID) (string, e
return config.ProjectID.String(), nil
}

type cmdConfig struct {
type CmdConfig struct {
Store envsec.Store
EnvID envsec.EnvID
}

func (f *configFlags) genConfig(ctx context.Context) (*cmdConfig, error) {
func (f *configFlags) genConfig(ctx context.Context) (*CmdConfig, error) {
if bootstrappedConfig != nil {
return bootstrappedConfig, nil
}

var tok *session.Token
var err error

Expand Down Expand Up @@ -128,8 +132,16 @@ func (f *configFlags) genConfig(ctx context.Context) (*cmdConfig, error) {
return nil, errors.WithStack(err)
}

return &cmdConfig{
return &CmdConfig{
Store: store,
EnvID: envid,
}, nil
}

var bootstrappedConfig *CmdConfig

// BootstrapConfig is used to set the config for all commands that use genConfig
// Useful for using envsec programmatically.
func BootstrapConfig(cmdConfig *CmdConfig) {
bootstrappedConfig = cmdConfig
}
File renamed without changes.
2 changes: 1 addition & 1 deletion envsec/internal/envcli/ls.go → envsec/pkg/envcli/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type listCmdFlags struct {
Format string
}

func listCmd() *cobra.Command {
func ListCmd() *cobra.Command {
flags := &listCmdFlags{}

command := &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion envsec/internal/envcli/rm.go → envsec/pkg/envcli/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type removeCmdFlags struct {
configFlags
}

func removeCmd() *cobra.Command {
func RemoveCmd() *cobra.Command {
flags := &removeCmdFlags{}
command := &cobra.Command{
Use: "rm <NAME1> [<NAME2>]...",
Expand Down
12 changes: 6 additions & 6 deletions envsec/internal/envcli/root.go → envsec/pkg/envcli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ func RootCmd(flags *rootCmdFlags) *cobra.Command {
command.Flag("json-errors").Hidden = true

command.AddCommand(authCmd())
command.AddCommand(downloadCmd())
command.AddCommand(execCmd())
command.AddCommand(DownloadCmd())
command.AddCommand(ExecCmd())
command.AddCommand(initCmd())
command.AddCommand(listCmd())
command.AddCommand(removeCmd())
command.AddCommand(setCmd())
command.AddCommand(uploadCmd())
command.AddCommand(ListCmd())
command.AddCommand(RemoveCmd())
command.AddCommand(SetCmd())
command.AddCommand(UploadCmd())
command.SetUsageFunc(UsageFunc)
return command
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion envsec/internal/envcli/set.go → envsec/pkg/envcli/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type setCmdFlags struct {
configFlags
}

func setCmd() *cobra.Command {
func SetCmd() *cobra.Command {
flags := &setCmdFlags{}
command := &cobra.Command{
Use: "set <NAME1>=<value1> [<NAME2>=<value2>]...",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type uploadCmdFlags struct {
format string
}

func uploadCmd() *cobra.Command {
func UploadCmd() *cobra.Command {
flags := &uploadCmdFlags{}
command := &cobra.Command{
Use: "upload <file1> [<fileN>]...",
Expand Down
File renamed without changes.
File renamed without changes.