From a7d74422e1a4adcc70d5b1be8463b139209dad22 Mon Sep 17 00:00:00 2001 From: shubhamvernekar Date: Sat, 4 Nov 2023 20:23:36 +0530 Subject: [PATCH] removing key-file from client code flow --- client/client.go | 6 ------ client/monart.go | 4 ---- cmd/dolores/config.go | 1 - cmd/dolores/main.go | 1 - config/config.go | 13 ------------- 5 files changed, 25 deletions(-) diff --git a/client/client.go b/client/client.go index 0473934..0d74096 100644 --- a/client/client.go +++ b/client/client.go @@ -15,7 +15,6 @@ type Client struct { prefix string ctx context.Context //nolint:containedctx log zerolog.Logger - keyFile string } type EncryptedConfig struct { @@ -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 @@ -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 } diff --git a/client/monart.go b/client/monart.go index fc291e4..1c73e3b 100644 --- a/client/monart.go +++ b/client/monart.go @@ -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} diff --git a/cmd/dolores/config.go b/cmd/dolores/config.go index c04495a..c064459 100644 --- a/cmd/dolores/config.go +++ b/cmd/dolores/config.go @@ -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 { diff --git a/cmd/dolores/main.go b/cmd/dolores/main.go index f6cd019..6355cc6 100644 --- a/cmd/dolores/main.go +++ b/cmd/dolores/main.go @@ -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 diff --git a/config/config.go b/config/config.go index 86b836e..9e1c6be 100644 --- a/config/config.go +++ b/config/config.go @@ -33,7 +33,6 @@ type Google struct { ApplicationCredentials string `split_words:"true"` StorageBucket string `split_words:"true"` StoragePrefix string - KeyFile string } type Metadata struct { @@ -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 { @@ -53,10 +51,6 @@ 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 @@ -64,9 +58,6 @@ func (c Client) Valid() error { if c.Google.StorageBucket == "" { return ErrInvalidStorageBucket } - if c.Google.KeyFile == "" { - return ErrInvalidKeyFile - } return nil } @@ -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 }