Skip to content

Commit

Permalink
Remove GetReadOnly from deploysource.Provider interface (#5048)
Browse files Browse the repository at this point in the history
Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com>
  • Loading branch information
khanhtc1202 authored Jul 17, 2024
1 parent 2841574 commit 3bd3a18
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pkg/app/pipedv1/controller/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (s *scheduler) Run(ctx context.Context) error {
*s.deployment.GitPath,
nil,
)
ds, err := configDSP.GetReadOnly(ctx, io.Discard)
ds, err := configDSP.Get(ctx, io.Discard)
if err != nil {
deploymentStatus = model.DeploymentStatus_DEPLOYMENT_FAILURE
statusReason = fmt.Sprintf("Unable to prepare application configuration source data at target commit (%v)", err)
Expand Down
20 changes: 0 additions & 20 deletions pkg/app/pipedv1/deploysource/deploysource.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type DeploySource struct {
type Provider interface {
Revision() string
Get(ctx context.Context, logWriter io.Writer) (*DeploySource, error)
GetReadOnly(ctx context.Context, logWriter io.Writer) (*DeploySource, error)
}

type secretDecrypter interface {
Expand Down Expand Up @@ -106,25 +105,6 @@ func (p *provider) Get(ctx context.Context, lw io.Writer) (*DeploySource, error)
return ds, nil
}

func (p *provider) GetReadOnly(ctx context.Context, lw io.Writer) (*DeploySource, error) {
fmt.Fprintf(lw, "Preparing deploy source at %s commit (%s)\n", p.revisionName, p.revision)

p.mu.Lock()
defer p.mu.Unlock()

if !p.done {
p.source, p.err = p.prepare(ctx, lw)
p.done = true
}

if p.err != nil {
return nil, p.err
}

fmt.Fprintf(lw, "Successfully prepared deploy source at %s commit (%s)\n", p.revisionName, p.revision)
return p.source, nil
}

func (p *provider) prepare(ctx context.Context, lw io.Writer) (*DeploySource, error) {
// Ensure the existence of the working directory.
if err := os.MkdirAll(p.workingDir, 0700); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/pipedv1/executor/cloudrun/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type deployExecutor struct {

func (e *deployExecutor) Execute(sig executor.StopSignal) model.StageStatus {
ctx := sig.Context()
ds, err := e.TargetDSP.GetReadOnly(ctx, e.LogPersister)
ds, err := e.TargetDSP.Get(ctx, e.LogPersister)
if err != nil {
e.LogPersister.Errorf("Failed to prepare target deploy source data (%v)", err)
return model.StageStatus_STAGE_FAILURE
Expand Down Expand Up @@ -152,7 +152,7 @@ func (e *deployExecutor) ensurePromote(ctx context.Context) model.StageStatus {
return model.StageStatus_STAGE_FAILURE
}

runningDS, err := e.RunningDSP.GetReadOnly(ctx, e.LogPersister)
runningDS, err := e.RunningDSP.Get(ctx, e.LogPersister)
if err != nil {
e.LogPersister.Errorf("Failed to prepare running deploy source data (%v)", err)
return model.StageStatus_STAGE_FAILURE
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/pipedv1/executor/cloudrun/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (e *rollbackExecutor) ensureRollback(ctx context.Context) model.StageStatus
return model.StageStatus_STAGE_FAILURE
}

runningDS, err := e.RunningDSP.GetReadOnly(ctx, e.LogPersister)
runningDS, err := e.RunningDSP.Get(ctx, e.LogPersister)
if err != nil {
e.LogPersister.Errorf("Failed to prepare running deploy source data (%v)", err)
return model.StageStatus_STAGE_FAILURE
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/pipedv1/executor/ecs/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type deployExecutor struct {

func (e *deployExecutor) Execute(sig executor.StopSignal) model.StageStatus {
ctx := sig.Context()
ds, err := e.TargetDSP.GetReadOnly(ctx, e.LogPersister)
ds, err := e.TargetDSP.Get(ctx, e.LogPersister)
if err != nil {
e.LogPersister.Errorf("Failed to prepare target deploy source data (%v)", err)
return model.StageStatus_STAGE_FAILURE
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/pipedv1/executor/ecs/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (e *rollbackExecutor) ensureRollback(ctx context.Context) model.StageStatus
return model.StageStatus_STAGE_FAILURE
}

runningDS, err := e.RunningDSP.GetReadOnly(ctx, e.LogPersister)
runningDS, err := e.RunningDSP.Get(ctx, e.LogPersister)
if err != nil {
e.LogPersister.Errorf("Failed to prepare running deploy source data (%v)", err)
return model.StageStatus_STAGE_FAILURE
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/pipedv1/executor/lambda/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type deployExecutor struct {

func (e *deployExecutor) Execute(sig executor.StopSignal) model.StageStatus {
ctx := sig.Context()
ds, err := e.TargetDSP.GetReadOnly(ctx, e.LogPersister)
ds, err := e.TargetDSP.Get(ctx, e.LogPersister)
if err != nil {
e.LogPersister.Errorf("Failed to prepare target deploy source data (%v)", err)
return model.StageStatus_STAGE_FAILURE
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/pipedv1/executor/lambda/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (e *rollbackExecutor) ensureRollback(ctx context.Context) model.StageStatus
return model.StageStatus_STAGE_FAILURE
}

runningDS, err := e.RunningDSP.GetReadOnly(ctx, e.LogPersister)
runningDS, err := e.RunningDSP.Get(ctx, e.LogPersister)
if err != nil {
e.LogPersister.Errorf("Failed to prepare running deploy source data (%v)", err)
return model.StageStatus_STAGE_FAILURE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (ps *PlannerService) QuickSyncPlan(ctx context.Context, in *platform.QuickS
ps.Decrypter,
)

ds, err := p.GetReadOnly(ctx, io.Discard /* TODO */)
ds, err := p.Get(ctx, io.Discard /* TODO */)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 3bd3a18

Please sign in to comment.