Skip to content

Commit

Permalink
removing key-file from client code flow
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamvernekar committed Nov 4, 2023
1 parent a40b9a9 commit a7d7442
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 25 deletions.
6 changes: 0 additions & 6 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type Client struct {
prefix string
ctx context.Context //nolint:containedctx
log zerolog.Logger
keyFile string
}

type EncryptedConfig struct {
Expand Down Expand Up @@ -78,10 +77,6 @@ func (c *Client) GetOrgPublicKeys(env string) (OrgPublicKeys, error) {
return OrgPublicKeys{Recipients: recps}, nil
}

func (c *Client) GetKeyFile() string {
return c.keyFile
}

func New(ctx context.Context, cfg config.Client) (*Client, error) {
if err := cfg.Valid(); err != nil {
return nil, err
Expand All @@ -97,7 +92,6 @@ func New(ctx context.Context, cfg config.Client) (*Client, error) {
bucket: cfg.BucketName(),
prefix: cfg.StoragePrefix,
log: log.With().Str("bucket", cfg.BucketName()).Str("prefix", cfg.StoragePrefix).Logger(),
keyFile: cfg.KeyFile(),
}
return cli, nil
}
4 changes: 0 additions & 4 deletions client/monart.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ func (s MonartClient) call(req *http.Request, dest any) (*http.Response, error)
return resp, nil
}

func (s MonartClient) GetKeyFile() string {
return ""
}

func NewMonart(ctx context.Context, cfg *config.Monart) MonartClient {
cred := credentials{APIToken: cfg.APIToken, ID: cfg.ID}
return MonartClient{cli: http.DefaultClient, cred: cred, ctx: ctx}
Expand Down
1 change: 0 additions & 1 deletion cmd/dolores/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func NewConfig(client GetClient) *ConfigCommand {
func (c *ConfigCommand) editAction(ctx *cli.Context) error {
rcli := c.rcli(ctx.Context)
env := ctx.String("environment")
ctx.Set("key-file", rcli.GetKeyFile())
log := c.log.With().Str("cmd", "config.edit").Str("environment", env).Logger()
dcfg, err := parseDecryptConfig(ctx)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion cmd/dolores/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type secretsClient interface {
FetchSecrets(req client.FetchSecretRequest) ([]byte, error)
GetOrgPublicKeys(env string) (client.OrgPublicKeys, error)
Init(ctx context.Context, bucket string, cfg client.Configuration) error
GetKeyFile() string
}

type CtxKey string
Expand Down
13 changes: 0 additions & 13 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type Google struct {
ApplicationCredentials string `split_words:"true"`
StorageBucket string `split_words:"true"`
StoragePrefix string
KeyFile string
}

type Metadata struct {
Expand All @@ -42,7 +41,6 @@ type Metadata struct {
Environment string `json:"environment"`
CreatedAt time.Time `json:"created_at"`
ApplicationCredentials string `json:"application_credentials"`
KeyFile string `json:"key_file"`
}

type Client struct {
Expand All @@ -53,20 +51,13 @@ func (c Client) BucketName() string {
return c.Google.StorageBucket
}

func (c Client) KeyFile() string {
return c.Google.KeyFile
}

func (c Client) Valid() error {
if c.Google.ApplicationCredentials == "" {
return ErrInvalidGoogleCreds
}
if c.Google.StorageBucket == "" {
return ErrInvalidStorageBucket
}
if c.Google.KeyFile == "" {
return ErrInvalidKeyFile
}
return nil
}

Expand Down Expand Up @@ -95,10 +86,6 @@ func LoadClient(ctx context.Context, env string) (Client, error) {
cfg.Google.StoragePrefix = location
}

if keyfile := d.Environments[env].KeyFile; keyfile != "" {
cfg.Google.KeyFile = keyfile
}

if err := cfg.Valid(); err != nil {
return Client{}, err
}
Expand Down

0 comments on commit a7d7442

Please sign in to comment.