Skip to content

Commit

Permalink
Start livestatereporter on pipedv1 (#5457)
Browse files Browse the repository at this point in the history
* Start livestateerporter on pipedv1

Signed-off-by: Yoshiki Fujikane <[email protected]>

* Add plugin field in the model application

Signed-off-by: Yoshiki Fujikane <[email protected]>

* Implement ListByPluginName

Signed-off-by: Yoshiki Fujikane <[email protected]>

* Fix for lint

Signed-off-by: Yoshiki Fujikane <[email protected]>

* Update for gen/code

Signed-off-by: Yoshiki Fujikane <[email protected]>

* Remove ListByPlatformProvider

Signed-off-by: Yoshiki Fujikane <[email protected]>

* Fix to use plugins

Signed-off-by: Yoshiki Fujikane <[email protected]>

---------

Signed-off-by: Yoshiki Fujikane <[email protected]>
  • Loading branch information
ffjlabo authored Jan 24, 2025
1 parent 90170ba commit f50cc80
Show file tree
Hide file tree
Showing 27 changed files with 1,649 additions and 773 deletions.
21 changes: 0 additions & 21 deletions pkg/app/pipedv1/apistore/applicationstore/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ type Lister interface {
// List lists all applications that should be handled by this piped.
// All disabled applications will be ignored.
List() []*model.Application
// ListByPlatformProvider lists all applications for a given cloud provider name.
ListByPlatformProvider(name string) []*model.Application
// Get retrieves a specifiec deployment for the given id.
Get(id string) (*model.Application, bool)
}
Expand Down Expand Up @@ -127,25 +125,6 @@ func (s *store) List() []*model.Application {
return apps.([]*model.Application)
}

// ListByPlatformProvider lists all applications for a given platform provider name.
func (s *store) ListByPlatformProvider(name string) []*model.Application {
list := s.applicationList.Load()
if list == nil {
return nil
}

var (
apps = list.([]*model.Application)
out = make([]*model.Application, 0, len(apps))
)
for _, app := range apps {
if app.PlatformProvider == name {
out = append(out, app)
}
}
return out
}

// Get retrieves a specific deployment for the given id.
func (s *store) Get(id string) (*model.Application, bool) {
apps := s.applicationMap.Load()
Expand Down
22 changes: 12 additions & 10 deletions pkg/app/pipedv1/cmd/piped/piped.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,23 +375,25 @@ func (p *piped) run(ctx context.Context, input cli.Input) (runErr error) {
return err
}

// Start running application live state reporter.
{
// TODO: Implement the live state reporter controller.
}

// Start running application application drift detector.
{
// TODO: Implement the drift detector controller.
}

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

// Start running application live state reporter.
// Currently, this feature is disabled beucause many errors are showed up if the app.pipecd.yaml is not migrated.
// {
// r, err := livestatereporter.NewReporter(applicationLister, apiClient, gitClient, pluginRegistry, cfg, decrypter, input.Logger)
// if err != nil {
// input.Logger.Error("failed to create live state reporter", zap.Error(err))
// }
// group.Go(func() error {
// return r.Run(ctx)
// })
// }

// Start running deployment controller.
{
c := controller.NewController(
Expand Down
5 changes: 3 additions & 2 deletions pkg/app/pipedv1/controller/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
config "github.com/pipe-cd/pipecd/pkg/configv1"
"github.com/pipe-cd/pipecd/pkg/model"
pluginapi "github.com/pipe-cd/pipecd/pkg/plugin/api/v1alpha1"
"github.com/pipe-cd/pipecd/pkg/plugin/api/v1alpha1/common"
"github.com/pipe-cd/pipecd/pkg/plugin/api/v1alpha1/deployment"
"github.com/pipe-cd/pipecd/pkg/regexpool"
)
Expand Down Expand Up @@ -181,7 +182,7 @@ func (p *planner) Run(ctx context.Context) error {
}()

// Prepare running deploy source and target deploy source.
var runningDS, targetDS *deployment.DeploymentSource
var runningDS, targetDS *common.DeploymentSource

repoCfg := config.PipedRepository{
RepoID: p.deployment.GitPath.Repo.Id,
Expand Down Expand Up @@ -248,7 +249,7 @@ func (p *planner) Run(ctx context.Context) error {
// - CommitMatcher ensure pipeline/quick sync based on the commit message
// - Force quick sync if there is no previous deployment (aka. this is the first deploy)
// - Based on PlannerService.DetermineStrategy returned by plugins
func (p *planner) buildPlan(ctx context.Context, runningDS, targetDS *deployment.DeploymentSource) (*plannerOutput, error) {
func (p *planner) buildPlan(ctx context.Context, runningDS, targetDS *common.DeploymentSource) (*plannerOutput, error) {
out := &plannerOutput{}

input := &deployment.PlanPluginInput{
Expand Down
5 changes: 3 additions & 2 deletions pkg/app/pipedv1/controller/planner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
config "github.com/pipe-cd/pipecd/pkg/configv1"
"github.com/pipe-cd/pipecd/pkg/model"
pluginapi "github.com/pipe-cd/pipecd/pkg/plugin/api/v1alpha1"
"github.com/pipe-cd/pipecd/pkg/plugin/api/v1alpha1/common"
"github.com/pipe-cd/pipecd/pkg/plugin/api/v1alpha1/deployment"
)

Expand Down Expand Up @@ -1070,7 +1071,7 @@ func TestPlanner_BuildPlan(t *testing.T) {
planner.lastSuccessfulCommitHash = "123"
}

runningDS := &deployment.DeploymentSource{}
runningDS := &common.DeploymentSource{}

type genericConfig struct {
Kind config.Kind `json:"kind"`
Expand All @@ -1085,7 +1086,7 @@ func TestPlanner_BuildPlan(t *testing.T) {
})

require.NoError(t, err)
targetDS := &deployment.DeploymentSource{
targetDS := &common.DeploymentSource{
ApplicationConfig: jsonBytes,
}
out, err := planner.buildPlan(context.TODO(), runningDS, targetDS)
Expand Down
6 changes: 3 additions & 3 deletions pkg/app/pipedv1/deploysource/deploysource.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/sourceprocesser"
config "github.com/pipe-cd/pipecd/pkg/configv1"
"github.com/pipe-cd/pipecd/pkg/model"
"github.com/pipe-cd/pipecd/pkg/plugin/api/v1alpha1/deployment"
"github.com/pipe-cd/pipecd/pkg/plugin/api/v1alpha1/common"
)

type DeploySource struct {
Expand All @@ -37,8 +37,8 @@ type DeploySource struct {
ApplicationConfigFilename string
}

func (d *DeploySource) ToPluginDeploySource() *deployment.DeploymentSource {
return &deployment.DeploymentSource{
func (d *DeploySource) ToPluginDeploySource() *common.DeploymentSource {
return &common.DeploymentSource{
ApplicationDirectory: d.AppDir,
CommitHash: d.Revision,
ApplicationConfig: d.ApplicationConfig,
Expand Down
Loading

0 comments on commit f50cc80

Please sign in to comment.