Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduler pipedv1 init logic #5321

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions pkg/app/pipedv1/cmd/piped/piped.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import (
"sigs.k8s.io/yaml"

"github.com/pipe-cd/pipecd/pkg/admin"
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/apistore/analysisresultstore"
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/apistore/applicationstore"
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/apistore/commandstore"
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/apistore/deploymentstore"
Expand All @@ -61,7 +60,6 @@ import (
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/statsreporter"
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/trigger"
"github.com/pipe-cd/pipecd/pkg/app/server/service/pipedservice"
"github.com/pipe-cd/pipecd/pkg/cache/memorycache"
"github.com/pipe-cd/pipecd/pkg/cli"
"github.com/pipe-cd/pipecd/pkg/config"
"github.com/pipe-cd/pipecd/pkg/crypto"
Expand Down Expand Up @@ -291,11 +289,6 @@ func (p *piped) run(ctx context.Context, input cli.Input) (runErr error) {
eventLister = store.Lister()
}

analysisResultStore := analysisresultstore.NewStore(apiClient, input.Logger)

// Create memory caches.
appManifestsCache := memorycache.NewTTLCache(ctx, time.Hour, time.Minute)

// Start running application live state reporter.
{
// TODO: Implement the live state reporter controller.
Expand All @@ -320,12 +313,6 @@ func (p *piped) run(ctx context.Context, input cli.Input) (runErr error) {
})
}

decrypter, err := p.initializeSecretDecrypter(cfg)
if err != nil {
input.Logger.Error("failed to initialize secret decrypter", zap.Error(err))
return err
}

// Start running application application drift detector.
{
// TODO: Implement the drift detector controller.
Expand All @@ -338,12 +325,7 @@ func (p *piped) run(ctx context.Context, input cli.Input) (runErr error) {
gitClient,
deploymentLister,
commandLister,
applicationLister,
analysisResultStore,
notifier,
decrypter,
cfg,
appManifestsCache,
p.gracePeriod,
input.Logger,
tracerProvider,
Expand Down
64 changes: 14 additions & 50 deletions pkg/app/pipedv1/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/controller/controllermetrics"
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/logpersister"
"github.com/pipe-cd/pipecd/pkg/app/server/service/pipedservice"
"github.com/pipe-cd/pipecd/pkg/cache"
"github.com/pipe-cd/pipecd/pkg/config"
"github.com/pipe-cd/pipecd/pkg/git"
"github.com/pipe-cd/pipecd/pkg/model"
)
Expand Down Expand Up @@ -74,23 +72,10 @@
ListStageCommands(deploymentID, stageID string) []model.ReportableCommand
}

type applicationLister interface {
Get(id string) (*model.Application, bool)
}

type analysisResultStore interface {
GetLatestAnalysisResult(ctx context.Context, applicationID string) (*model.AnalysisResult, error)
PutLatestAnalysisResult(ctx context.Context, applicationID string, analysisResult *model.AnalysisResult) error
}

type notifier interface {
Notify(event model.NotificationEvent)
}

type secretDecrypter interface {
Decrypt(string) (string, error)
}

type DeploymentController interface {
Run(ctx context.Context) error
}
Expand All @@ -101,18 +86,13 @@
)

type controller struct {
apiClient apiClient
pluginRegistry PluginRegistry
gitClient gitClient
deploymentLister deploymentLister
commandLister commandLister
applicationLister applicationLister
analysisResultStore analysisResultStore
notifier notifier
secretDecrypter secretDecrypter // TODO: Remove this
pipedCfg *config.PipedSpec // TODO: Remove this, use pipedConfig instead
appManifestsCache cache.Cache
logPersister logpersister.Persister
apiClient apiClient
pluginRegistry PluginRegistry
gitClient gitClient
deploymentLister deploymentLister
commandLister commandLister
notifier notifier
logPersister logpersister.Persister

// Map from application ID to the planner
// of a pending deployment of that application.
Expand Down Expand Up @@ -147,12 +127,7 @@
gitClient gitClient,
deploymentLister deploymentLister,
commandLister commandLister,
applicationLister applicationLister,
analysisResultStore analysisResultStore,
notifier notifier,
sd secretDecrypter,
pipedCfg *config.PipedSpec,
appManifestsCache cache.Cache,
gracePeriod time.Duration,
logger *zap.Logger,
tracerProvider trace.TracerProvider,
Expand All @@ -163,18 +138,13 @@
lg = logger.Named("controller")
)
return &controller{
apiClient: apiClient,
pluginRegistry: DefaultPluginRegistry(),
gitClient: gitClient,
deploymentLister: deploymentLister,
commandLister: commandLister,
applicationLister: applicationLister,
analysisResultStore: analysisResultStore,
notifier: notifier,
secretDecrypter: sd,
appManifestsCache: appManifestsCache,
pipedCfg: pipedCfg,
logPersister: lp,
apiClient: apiClient,
pluginRegistry: DefaultPluginRegistry(),
gitClient: gitClient,
deploymentLister: deploymentLister,
commandLister: commandLister,
notifier: notifier,
logPersister: lp,

Check warning on line 147 in pkg/app/pipedv1/controller/controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/pipedv1/controller/controller.go#L141-L147

Added lines #L141 - L147 were not covered by tests

planners: make(map[string]*planner),
donePlanners: make(map[string]time.Time),
Expand Down Expand Up @@ -617,14 +587,8 @@
workingDir,
c.apiClient,
c.gitClient,
c.commandLister,
c.applicationLister,
c.analysisResultStore,
c.logPersister,
c.notifier,
c.secretDecrypter,
c.pipedCfg,
c.appManifestsCache,
c.logger,
c.tracerProvider,
)
Expand Down
Loading
Loading