Skip to content

Commit

Permalink
Add deploy target (#5378)
Browse files Browse the repository at this point in the history
* Add deployTarget to piped config

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

* Add deployTargets to the model

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

* Add plugins field to piped config

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

* Fix for lint/web

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

* Add comment

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

---------

Signed-off-by: Yoshiki Fujikane <[email protected]>
  • Loading branch information
ffjlabo authored Dec 2, 2024
1 parent 55a7cb1 commit b2b9148
Show file tree
Hide file tree
Showing 11 changed files with 413 additions and 245 deletions.
22 changes: 22 additions & 0 deletions pkg/configv1/piped.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ type PipedSpec struct {
CloudProviders []PipedPlatformProvider `json:"cloudProviders,omitempty"`
// List of platform providers can be used by this piped.
PlatformProviders []PipedPlatformProvider `json:"platformProviders,omitempty"`
// List of plugiin configs
Plugins []PipedPlugin `json:"plugins,omitempty"`
// List of analysis providers can be used by this piped.
AnalysisProviders []PipedAnalysisProvider `json:"analysisProviders,omitempty"`
// Sending notification to Slack, Webhook…
Expand Down Expand Up @@ -1288,3 +1290,23 @@ type PipedEventWatcherGitRepo struct {
// This is prioritized if both includes and this one are given.
Excludes []string `json:"excludes,omitempty"`
}

// PipedPlugin defines the plugin configuration for the piped.
type PipedPlugin struct {
// The name of the plugin.
Name string `json:"name"`
// The port which the plugin listens to.
Port int `json:"port"`
// The deploy target names.
DeployTargets []PipedDeployTarget `json:"deployTargets,omitempty"`
}

// PipedDeployTarget defines the deploy target configuration for the piped.
type PipedDeployTarget struct {
// The name of the deploy target.
Name string `json:"name"`
// The labes of the deploy target.
Labels map[string]string `json:"labels,omitempty"`
// The configuration of the deploy target.
Config json.RawMessage `json:"config"`
}
190 changes: 101 additions & 89 deletions pkg/model/application.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pkg/model/application.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ message Application {
// This must be one of the provider names registered in the piped.
// TODO: Add validation for this field.
string platform_provider = 15;
// The names of deploy taget where to deploy this application.
repeated string deploy_targets = 16;
// Additional description about application.
string description = 9;
// Custom attributes to identify applications.
Expand Down
317 changes: 164 additions & 153 deletions pkg/model/deployment.pb.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pkg/model/deployment.proto
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ message Deployment {
// The name of platform provider where to deploy this application.
// This must be one of the provider names registered in the piped.
string platform_provider = 11;

// The names of deploy taget where to deploy this application.
repeated string deploy_targets = 12;
// Custom attributes to identify applications.
map<string, string> labels = 10;

Expand Down
6 changes: 6 additions & 0 deletions web/model/application_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export class Application extends jspb.Message {
getPlatformProvider(): string;
setPlatformProvider(value: string): Application;

getDeployTargetsList(): Array<string>;
setDeployTargetsList(value: Array<string>): Application;
clearDeployTargetsList(): Application;
addDeployTargets(value: string, index?: number): Application;

getDescription(): string;
setDescription(value: string): Application;

Expand Down Expand Up @@ -89,6 +94,7 @@ export namespace Application {
gitPath?: pkg_model_common_pb.ApplicationGitPath.AsObject,
cloudProvider: string,
platformProvider: string,
deployTargetsList: Array<string>,
description: string,
labelsMap: Array<[string, string]>,
mostRecentlySuccessfulDeployment?: ApplicationDeploymentReference.AsObject,
Expand Down
58 changes: 57 additions & 1 deletion web/model/application_pb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions web/model/deployment_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export class Deployment extends jspb.Message {
getPlatformProvider(): string;
setPlatformProvider(value: string): Deployment;

getDeployTargetsList(): Array<string>;
setDeployTargetsList(value: Array<string>): Deployment;
clearDeployTargetsList(): Deployment;
addDeployTargets(value: string, index?: number): Deployment;

getLabelsMap(): jspb.Map<string, string>;
clearLabelsMap(): Deployment;

Expand Down Expand Up @@ -107,6 +112,7 @@ export namespace Deployment {
gitPath?: pkg_model_common_pb.ApplicationGitPath.AsObject,
cloudProvider: string,
platformProvider: string,
deployTargetsList: Array<string>,
labelsMap: Array<[string, string]>,
trigger?: DeploymentTrigger.AsObject,
summary: string,
Expand Down
51 changes: 50 additions & 1 deletion web/model/deployment_pb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions web/src/__fixtures__/dummy-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const dummyApplication: Application.AsObject = {
id: randomUUID(),
cloudProvider: "",
platformProvider: "kubernetes-default",
deployTargetsList: ["kubernetes-default"],
disabled: false,
gitPath: {
configFilename: "",
Expand Down Expand Up @@ -131,6 +132,7 @@ export function createApplicationFromObject(
const app = new Application();
app.setId(o.id);
app.setPlatformProvider(o.platformProvider);
app.setDeployTargetsList(o.deployTargetsList);
app.setDisabled(o.disabled);
app.setKind(o.kind);
app.setName(o.name);
Expand Down
1 change: 1 addition & 0 deletions web/src/__fixtures__/dummy-deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const dummyDeployment: Deployment.AsObject = {
versionsList: [],
cloudProvider: "kube-1",
platformProvider: "kube-1",
deployTargetsList: ["kube-1"],
labelsMap: [],
createdAt: createdAt.unix(),
updatedAt: completedAt.unix(),
Expand Down

0 comments on commit b2b9148

Please sign in to comment.