Skip to content

Commit

Permalink
Remove piped config bytes from planner pipedv1 (#5121)
Browse files Browse the repository at this point in the history
Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com>
  • Loading branch information
khanhtc1202 committed Aug 8, 2024
1 parent 304ceff commit 3128bd1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 52 deletions.
45 changes: 0 additions & 45 deletions pkg/app/pipedv1/cmd/piped/piped.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,6 @@ func (p *piped) run(ctx context.Context, input cli.Input) (runErr error) {
// TODO: Implement the drift detector controller.
}

cfgData, err := p.loadConfigByte(ctx)
if err != nil {
input.Logger.Error("failed to load piped configuration", zap.Error(err))
return err
}

// Start running deployment controller.
{
c := controller.NewController(
Expand All @@ -337,7 +331,6 @@ func (p *piped) run(ctx context.Context, input cli.Input) (runErr error) {
notifier,
decrypter,
cfg,
cfgData,
appManifestsCache,
p.gracePeriod,
input.Logger,
Expand Down Expand Up @@ -540,44 +533,6 @@ func (p *piped) loadConfig(ctx context.Context) (*config.PipedSpec, error) {
return nil, fmt.Errorf("one of config-file, config-gcp-secret or config-aws-secret must be set")
}

// loadConfig reads the Piped configuration data from the specified source.
func (p *piped) loadConfigByte(ctx context.Context) ([]byte, error) {
// HACK: When the version of cobra is updated to >=v1.8.0, this should be replaced with https://pkg.go.dev/github.com/spf13/cobra#Command.MarkFlagsMutuallyExclusive.
if err := p.hasTooManyConfigFlags(); err != nil {
return nil, err
}

if p.configFile != "" {
return os.ReadFile(p.configFile)
}

if p.configData != "" {
data, err := base64.StdEncoding.DecodeString(p.configData)
if err != nil {
return nil, fmt.Errorf("the given config-data isn't base64 encoded: %w", err)
}
return data, nil
}

if p.configGCPSecret != "" {
data, err := p.getConfigDataFromSecretManager(ctx)
if err != nil {
return nil, fmt.Errorf("failed to load config from SecretManager (%w)", err)
}
return data, nil
}

if p.configAWSSecret != "" {
data, err := p.getConfigDataFromAWSSecretsManager(ctx)
if err != nil {
return nil, fmt.Errorf("failed to load config from AWS Secrets Manager (%w)", err)
}
return data, nil
}

return nil, fmt.Errorf("one of config-file, config-gcp-secret or config-aws-secret must be set")
}

// TODO: Remove this once the decryption task by plugin call to the plugin service is implemented.
func (p *piped) initializeSecretDecrypter(cfg *config.PipedSpec) (crypto.Decrypter, error) {
sm := cfg.SecretManagement
Expand Down
4 changes: 0 additions & 4 deletions pkg/app/pipedv1/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ type controller struct {
applicationLister applicationLister
analysisResultStore analysisResultStore
notifier notifier
pipedConfig []byte
secretDecrypter secretDecrypter // TODO: Remove this
pipedCfg *config.PipedSpec // TODO: Remove this, use pipedConfig instead
appManifestsCache cache.Cache
Expand Down Expand Up @@ -151,7 +150,6 @@ func NewController(
notifier notifier,
sd secretDecrypter,
pipedCfg *config.PipedSpec,
pipedConfig []byte,
appManifestsCache cache.Cache,
gracePeriod time.Duration,
logger *zap.Logger,
Expand All @@ -173,7 +171,6 @@ func NewController(
secretDecrypter: sd,
appManifestsCache: appManifestsCache,
pipedCfg: pipedCfg,
pipedConfig: pipedConfig,
logPersister: lp,

planners: make(map[string]*planner),
Expand Down Expand Up @@ -480,7 +477,6 @@ func (c *controller) startNewPlanner(ctx context.Context, d *model.Deployment) (
c.apiClient,
c.gitClient,
c.notifier,
c.pipedConfig,
c.logger,
)

Expand Down
3 changes: 0 additions & 3 deletions pkg/app/pipedv1/controller/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ type planner struct {
lastSuccessfulCommitHash string
lastSuccessfulConfigFilename string
workingDir string
pipedConfig []byte

// The plugin clients are used to call plugin that actually
// performs planning deployment.
Expand Down Expand Up @@ -95,7 +94,6 @@ func newPlanner(
apiClient apiClient,
gitClient gitClient,
notifier notifier,
pipedConfig []byte,
logger *zap.Logger,
) *planner {

Expand Down Expand Up @@ -127,7 +125,6 @@ func newPlanner(
gitClient: gitClient,
metadataStore: metadatastore.NewMetadataStore(apiClient, d),
notifier: notifier,
pipedConfig: pipedConfig,
doneDeploymentStatus: d.Status,
cancelledCh: make(chan *model.ReportableCommand, 1),
nowFunc: time.Now,
Expand Down

0 comments on commit 3128bd1

Please sign in to comment.