Skip to content

Commit

Permalink
Add validations
Browse files Browse the repository at this point in the history
  • Loading branch information
mchavez committed Mar 15, 2024
1 parent dc727b0 commit 9c72931
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
14 changes: 14 additions & 0 deletions cmd/baton-vgs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,30 @@ package main

import (
"context"
"errors"

"github.com/conductorone/baton-sdk/pkg/cli"
"github.com/spf13/cobra"
)

// config defines the external configuration required for the connector to run.
type config struct {
cli.BaseConfig `mapstructure:",squash"` // Puts the base config options in the same place as the connector options
Vault string
ClientId string
ClientSecret string
}

// validateConfig is run after the configuration is loaded, and should return an error if it isn't valid.
func validateConfig(ctx context.Context, cfg *config) error {
if cfg.Vault == "" {
return errors.New("vault is required")
}

return nil
}

// cmdFlags sets the cmdFlags required for the connector.
func cmdFlags(cmd *cobra.Command) {
cmd.PersistentFlags().String("vault", "", "The VGS vault. ($BATON_VAULT)")
}
1 change: 1 addition & 0 deletions cmd/baton-vgs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func main() {
}

cmd.Version = version
cmdFlags(cmd)

err = cmd.Execute()
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ services:
image: quay.io/verygoodsecurity/vgs-cli:${VERSION:-latest}
stdin_open: true
tty: true
environment:
VGS_CLIENT_ID: ""
VGS_CLIENT_SECRET: ""
# environment:
# VGS_CLIENT_ID: ""
# VGS_CLIENT_SECRET: ""
entrypoint: bash
env_file:
- .env
Expand Down

0 comments on commit 9c72931

Please sign in to comment.