Skip to content

Commit

Permalink
refactor!: fold promotion policies into project crd (#1417)
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Rancourt <kent.rancourt@gmail.com>
  • Loading branch information
krancour authored Feb 1, 2024
1 parent 79d788d commit f492e47
Show file tree
Hide file tree
Showing 43 changed files with 1,623 additions and 4,156 deletions.
1 change: 0 additions & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ k8s_resource(
objects = [
'freights.kargo.akuity.io:customresourcedefinition',
'projects.kargo.akuity.io:customresourcedefinition',
'promotionpolicies.kargo.akuity.io:customresourcedefinition',
'promotions.kargo.akuity.io:customresourcedefinition',
'stages.kargo.akuity.io:customresourcedefinition',
'warehouses.kargo.akuity.io:customresourcedefinition'
Expand Down
58 changes: 1 addition & 57 deletions api/service/v1alpha1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,12 @@ service KargoService {
rpc GetPromotion(GetPromotionRequest) returns (GetPromotionResponse);
rpc WatchPromotion(WatchPromotionRequest) returns (stream WatchPromotionResponse);

/* PromotionPolicy APIs */

rpc SetAutoPromotionForStage(SetAutoPromotionForStageRequest) returns (SetAutoPromotionForStageResponse);
rpc CreatePromotionPolicy(CreatePromotionPolicyRequest) returns (CreatePromotionPolicyResponse);
rpc ListPromotionPolicies(ListPromotionPoliciesRequest) returns (ListPromotionPoliciesResponse);
rpc GetPromotionPolicy(GetPromotionPolicyRequest) returns (GetPromotionPolicyResponse);
rpc UpdatePromotionPolicy(UpdatePromotionPolicyRequest) returns (UpdatePromotionPolicyResponse);
rpc DeletePromotionPolicy(DeletePromotionPolicyRequest) returns (DeletePromotionPolicyResponse);

/* Project APIs */

rpc CreateProject(CreateProjectRequest) returns (CreateProjectResponse);
rpc ListProjects(ListProjectsRequest) returns (ListProjectsResponse);
rpc DeleteProject(DeleteProjectRequest) returns (DeleteProjectResponse);
rpc SetAutoPromotionForStage(SetAutoPromotionForStageRequest) returns (SetAutoPromotionForStageResponse);

/* Freight APIs */

Expand Down Expand Up @@ -334,54 +326,6 @@ message SetAutoPromotionForStageRequest {
}

message SetAutoPromotionForStageResponse {
git.luolix.top.akuity.kargo.pkg.api.v1alpha1.PromotionPolicy promotion_policy = 1;
}

message CreatePromotionPolicyRequest {
oneof promotion_policy {
TypedPromotionPolicySpec typed = 1;
string yaml = 2;
}
}

message CreatePromotionPolicyResponse {
git.luolix.top.akuity.kargo.pkg.api.v1alpha1.PromotionPolicy promotion_policy = 1;
}

message ListPromotionPoliciesRequest {
string project = 1;
}

message ListPromotionPoliciesResponse {
repeated git.luolix.top.akuity.kargo.pkg.api.v1alpha1.PromotionPolicy promotion_policies = 1;
}

message GetPromotionPolicyRequest {
string project = 1;
string name = 2;
}

message GetPromotionPolicyResponse {
git.luolix.top.akuity.kargo.pkg.api.v1alpha1.PromotionPolicy promotion_policy = 1;
}

message UpdatePromotionPolicyRequest {
oneof promotion_policy {
TypedPromotionPolicySpec typed = 1;
string yaml = 2;
}
}

message UpdatePromotionPolicyResponse {
git.luolix.top.akuity.kargo.pkg.api.v1alpha1.PromotionPolicy promotion_policy = 1;
}

message DeletePromotionPolicyRequest {
string project = 1;
string name = 2;
}

message DeletePromotionPolicyResponse {
/* explicitly empty */
}

Expand Down
2 changes: 0 additions & 2 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&ProjectList{},
&Promotion{},
&PromotionList{},
&PromotionPolicy{},
&PromotionPolicyList{},
&Warehouse{},
&WarehouseList{},
)
Expand Down
20 changes: 19 additions & 1 deletion api/v1alpha1/project_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,25 @@ func (p *Project) GetStatus() *ProjectStatus {

// ProjectSpec describes a Project.
type ProjectSpec struct {
// TODO: Figure out the attributes of a ProjectSpec.
// PromotionPolicies defines policies governing the promotion of Freight to
// specific Stages within this Project.
PromotionPolicies []PromotionPolicy `json:"promotionPolicies,omitempty"`
}

// PromotionPolicy defines policies governing the promotion of Freight to a
// specific Stage.
type PromotionPolicy struct {
//+kubebuilder:validation:MinLength=1
//+kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
Stage string `json:"stage"`
// AutoPromotionEnabled indicates whether new Freight can automatically be
// promoted into the Stage referenced by the Stage field. Note: There are may
// be other conditions also required for an auto-promotion to occur. This
// field defaults to false, but is commonly set to true for Stages that
// subscribe to Warehouses instead of other, upstream Stages. This allows
// users to define Stages that are automatically updated as soon as new
// artifacts are detected.
AutoPromotionEnabled bool `json:"autoPromotionEnabled,omitempty"`
}

// ProjectStatus describes a Project's current status.
Expand Down
32 changes: 0 additions & 32 deletions api/v1alpha1/promotion_policy_helpers.go

This file was deleted.

64 changes: 0 additions & 64 deletions api/v1alpha1/promotion_policy_helpers_test.go

This file was deleted.

40 changes: 0 additions & 40 deletions api/v1alpha1/promotionpolicy_types.go

This file was deleted.

10 changes: 1 addition & 9 deletions api/v1alpha1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,8 @@ message PromotionMechanisms {
}

message PromotionPolicy {
string api_version = 1 [json_name = "apiVersion"];
string kind = 2 [json_name = "kind"];
git.luolix.top.akuity.kargo.pkg.api.metav1.ObjectMeta metadata = 3 [json_name = "metadata"];
string stage = 4 [json_name = "stage"];
bool enable_auto_promotion = 5 [json_name = "enableAutoPromotion"];
}

message PromotionPolicyList {
git.luolix.top.akuity.kargo.pkg.api.metav1.ListMeta metadata = 1 [json_name = "metadata"];
repeated PromotionPolicy items = 2 [json_name = "items"];
bool auto_promotion_enabled = 5 [json_name = "autoPromotionEnabled"];
}

message PromotionSpec {
Expand Down
49 changes: 6 additions & 43 deletions api/v1alpha1/zz_generated.deepcopy.go

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

26 changes: 26 additions & 0 deletions charts/kargo/crds/kargo.akuity.io_projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,32 @@ spec:
type: object
spec:
description: Spec describes a Project.
properties:
promotionPolicies:
description: PromotionPolicies defines policies governing the promotion
of Freight to specific Stages within this Project.
items:
description: PromotionPolicy defines policies governing the promotion
of Freight to a specific Stage.
properties:
autoPromotionEnabled:
description: 'AutoPromotionEnabled indicates whether new Freight
can automatically be promoted into the Stage referenced by
the Stage field. Note: There are may be other conditions also
required for an auto-promotion to occur. This field defaults
to false, but is commonly set to true for Stages that subscribe
to Warehouses instead of other, upstream Stages. This allows
users to define Stages that are automatically updated as soon
as new artifacts are detected.'
type: boolean
stage:
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
required:
- stage
type: object
type: array
type: object
status:
description: Status describes the Project's current status.
Expand Down
Loading

0 comments on commit f492e47

Please sign in to comment.