Skip to content

Commit ca3f560

Browse files
committed
feat(promotion-windows): add promotion windows for auto-promotion
Signed-off-by: Kristoffer Fagerbekk <fagerbekk@hotmail.com>
1 parent de6d9c0 commit ca3f560

19 files changed

+3331
-1289
lines changed

api/v1alpha1/generated.pb.go

Lines changed: 2251 additions & 1264 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/generated.proto

Lines changed: 60 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/groupversion_info.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
4545
&PromotionTaskList{},
4646
&Warehouse{},
4747
&WarehouseList{},
48+
&PromotionWindow{},
49+
&PromotionWindowList{},
4850
)
4951
metav1.AddToGroupVersion(scheme, GroupVersion)
5052
return nil

api/v1alpha1/project_config_types.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,19 @@ type PromotionPolicy struct {
8383
Stage string `json:"stage,omitempty" protobuf:"bytes,1,opt,name=stage"`
8484
// StageSelector is a selector that matches the Stage resource to which
8585
// this policy applies.
86-
StageSelector *PromotionPolicySelector `json:"stageSelector,omitempty" protobuf:"bytes,3,opt,name=stageSelector"`
86+
StageSelector *PromotionPolicySelector `json:"stageSelector,omitempty" protobuf:"bytes,2,opt,name=stageSelector"`
8787
// AutoPromotionEnabled indicates whether new Freight can automatically be
8888
// promoted into the Stage referenced by the Stage field. Note: There are may
8989
// be other conditions also required for an auto-promotion to occur. This
9090
// field defaults to false, but is commonly set to true for Stages that
9191
// subscribe to Warehouses instead of other, upstream Stages. This allows
9292
// users to define Stages that are automatically updated as soon as new
9393
// artifacts are detected.
94-
AutoPromotionEnabled bool `json:"autoPromotionEnabled,omitempty" protobuf:"varint,2,opt,name=autoPromotionEnabled"`
94+
AutoPromotionEnabled bool `json:"autoPromotionEnabled,omitempty" protobuf:"varint,3,opt,name=autoPromotionEnabled"`
95+
// PromotionWindows defines time windows during which automatic promotions
96+
// are allowed to occur. If not specified, automatic promotions can occur at
97+
// any time.
98+
PromotionWindows []PromotionWindowReference `json:"promotionWindows,omitempty" protobuf:"bytes,4,rep,name=promotionWindows"`
9599
}
96100

97101
// WebhookReceiverConfig describes the configuration for a single webhook
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package v1alpha1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
)
6+
7+
// +kubebuilder:resource:shortName={promotionwindow,promotionwindows}
8+
// +kubebuilder:object:root=true
9+
// +kubebuilder:printcolumn:name=TimeZone,type=string,JSONPath=`.spec.timeZone`
10+
11+
type PromotionWindow struct {
12+
metav1.TypeMeta `json:",inline"`
13+
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
14+
15+
// Spec describes the composition of an AutoPromotionWindow, including the
16+
// recurring time window and time zone.
17+
//
18+
// +kubebuilder:validation:Required
19+
Spec PromotionWindowSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
20+
}
21+
22+
type PromotionWindowSpec struct {
23+
// Kind is either "deny" or "allow", indicating whether the time window
24+
// represents a period during which promotions are denied or allowed.
25+
//
26+
// +kubebuilder:validation:Enum=deny;allow;
27+
Kind string `json:"kind,omitempty" protobuf:"bytes,1,opt,name=kind"`
28+
// Schedule describes a recurring time window.
29+
// Example: "0 0 * * 1-5" means every weekday at midnight.
30+
//
31+
// +kubebuilder:validation:Required
32+
Schedule string `json:"schedule" protobuf:"bytes,2,opt,name=schedule"`
33+
// Duration is the length of time that the window lasts after the start
34+
// time defined by the Schedule.
35+
//
36+
// +kubebuilder:validation:Required
37+
Duration string `json:"duration,omitempty" protobuf:"bytes,3,opt,name=duration"`
38+
// TimeZone is the IANA time zone name that applies to the time window.
39+
// If not specified, UTC is assumed.
40+
TimeZone string `json:"timeZone,omitempty" protobuf:"bytes,4,opt,name=timeZone"`
41+
}
42+
43+
type PromotionWindowReference struct {
44+
// Name is the name of the time window.
45+
//
46+
// +kubebuilder:validation:Required
47+
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
48+
// Kind is the kind of the time window
49+
//
50+
// +kubebuilder:validation:Enum=PromotionWindow;ClusterPromotionWindow;
51+
Kind string `json:"kind,omitempty" protobuf:"bytes,2,opt,name=kind"`
52+
}
53+
54+
// +kubebuilder:object:root=true
55+
56+
// PromotionWindowList contains a list of PromotionWindows.
57+
type PromotionWindowList struct {
58+
metav1.TypeMeta `json:",inline"`
59+
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
60+
Items []PromotionWindow `json:"items" protobuf:"bytes,2,rep,name=items"`
61+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 93 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/kargo/resources/crds/kargo.akuity.io_projectconfigs.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ spec:
7070
users to define Stages that are automatically updated as soon as new
7171
artifacts are detected.
7272
type: boolean
73+
promotionWindows:
74+
description: |-
75+
PromotionWindows defines time windows during which automatic promotions
76+
are allowed to occur. If not specified, automatic promotions can occur at
77+
any time.
78+
items:
79+
properties:
80+
kind:
81+
description: Kind is the kind of the time window
82+
enum:
83+
- PromotionWindow
84+
- ClusterPromotionWindow
85+
type: string
86+
name:
87+
description: Name is the name of the time window.
88+
type: string
89+
required:
90+
- name
91+
type: object
92+
type: array
7393
stage:
7494
description: |-
7595
Stage is the name of the Stage to which this policy applies.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.19.0
7+
name: promotionwindows.kargo.akuity.io
8+
spec:
9+
group: kargo.akuity.io
10+
names:
11+
kind: PromotionWindow
12+
listKind: PromotionWindowList
13+
plural: promotionwindows
14+
shortNames:
15+
- promotionwindow
16+
- promotionwindows
17+
singular: promotionwindow
18+
scope: Namespaced
19+
versions:
20+
- additionalPrinterColumns:
21+
- jsonPath: .spec.timeZone
22+
name: TimeZone
23+
type: string
24+
name: v1alpha1
25+
schema:
26+
openAPIV3Schema:
27+
properties:
28+
apiVersion:
29+
description: |-
30+
APIVersion defines the versioned schema of this representation of an object.
31+
Servers should convert recognized schemas to the latest internal value, and
32+
may reject unrecognized values.
33+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
34+
type: string
35+
kind:
36+
description: |-
37+
Kind is a string value representing the REST resource this object represents.
38+
Servers may infer this from the endpoint the client submits requests to.
39+
Cannot be updated.
40+
In CamelCase.
41+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
42+
type: string
43+
metadata:
44+
type: object
45+
spec:
46+
description: |-
47+
Spec describes the composition of an AutoPromotionWindow, including the
48+
recurring time window and time zone.
49+
properties:
50+
duration:
51+
description: |-
52+
Duration is the length of time that the window lasts after the start
53+
time defined by the Schedule.
54+
type: string
55+
kind:
56+
description: |-
57+
Kind is either "deny" or "allow", indicating whether the time window
58+
represents a period during which promotions are denied or allowed.
59+
enum:
60+
- deny
61+
- allow
62+
type: string
63+
schedule:
64+
description: |-
65+
Schedule describes a recurring time window.
66+
Example: "0 0 * * 1-5" means every weekday at midnight.
67+
type: string
68+
timeZone:
69+
description: |-
70+
TimeZone is the IANA time zone name that applies to the time window.
71+
If not specified, UTC is assumed.
72+
type: string
73+
required:
74+
- duration
75+
- schedule
76+
type: object
77+
required:
78+
- spec
79+
type: object
80+
served: true
81+
storage: true
82+
subresources: {}

0 commit comments

Comments
 (0)