Skip to content
Open
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
38 changes: 22 additions & 16 deletions apis/actions.github.com/v1alpha1/autoscalinglistener_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,37 @@ import (

// AutoscalingListenerSpec defines the desired state of AutoscalingListener
type AutoscalingListenerSpec struct {
// Required
// +optional
GitHubConfigURL string `json:"githubConfigUrl,omitempty"`

// Required
// +optional
GitHubConfigSecret string `json:"githubConfigSecret,omitempty"`

// Required
// +optional
// +kubebuilder:validation:Minimum=1
RunnerScaleSetID int `json:"runnerScaleSetId,omitempty"`
Comment thread
Copilot marked this conversation as resolved.

// Required
// +optional
AutoscalingRunnerSetNamespace string `json:"autoscalingRunnerSetNamespace,omitempty"`

// Required
// +optional
AutoscalingRunnerSetName string `json:"autoscalingRunnerSetName,omitempty"`

// Required
// +optional
EphemeralRunnerSetName string `json:"ephemeralRunnerSetName,omitempty"`

// Required
// +kubebuilder:validation:Minimum:=0
MaxRunners int `json:"maxRunners,omitempty"`
// +kubebuilder:validation:Minimum=0
// +optional
MaxRunners int `json:"maxRunners"`

// Required
// +kubebuilder:validation:Minimum:=0
MinRunners int `json:"minRunners,omitempty"`
// +kubebuilder:validation:Minimum=0
// +optional
MinRunners int `json:"minRunners"`

// Required
// +optional
Image string `json:"image,omitempty"`

// Required
// +optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`

// +optional
Expand Down Expand Up @@ -99,17 +100,22 @@ type AutoscalingListenerStatus struct{}

// AutoscalingListener is the Schema for the autoscalinglisteners API
type AutoscalingListener struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AutoscalingListenerSpec `json:"spec,omitempty"`
// +optional
Spec AutoscalingListenerSpec `json:"spec,omitempty"`
// +optional
Status AutoscalingListenerStatus `json:"status,omitempty"`
}

// AutoscalingListenerList is a list of AutoscalingListener resources
// +kubebuilder:object:root=true
// AutoscalingListenerList contains a list of AutoscalingListener
type AutoscalingListenerList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
Items []AutoscalingListener `json:"items"`
}
Expand Down
54 changes: 23 additions & 31 deletions apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,26 @@ import (
// +kubebuilder:printcolumn:JSONPath=".status.phase",name=Phase,type=string
// +kubebuilder:printcolumn:JSONPath=".status.pendingEphemeralRunners",name=Pending Runners,type=integer
// +kubebuilder:printcolumn:JSONPath=".status.runningEphemeralRunners",name=Running Runners,type=integer
// +kubebuilder:printcolumn:JSONPath=".status.finishedEphemeralRunners",name=Finished Runners,type=integer
// +kubebuilder:printcolumn:JSONPath=".status.deletingEphemeralRunners",name=Deleting Runners,type=integer
// +kubebuilder:printcolumn:JSONPath=".status.failedEphemeralRunners",name=Failed Runners,type=integer

// AutoscalingRunnerSet is the Schema for the autoscalingrunnersets API
type AutoscalingRunnerSet struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AutoscalingRunnerSetSpec `json:"spec,omitempty"`
// +optional
Spec AutoscalingRunnerSetSpec `json:"spec,omitempty"`
// +optional
Status AutoscalingRunnerSetStatus `json:"status,omitempty"`
}

// AutoscalingRunnerSetSpec defines the desired state of AutoscalingRunnerSet
type AutoscalingRunnerSetSpec struct {
// Required
// +optional
GitHubConfigUrl string `json:"githubConfigUrl,omitempty"`

// Required
// +optional
GitHubConfigSecret string `json:"githubConfigSecret,omitempty"`

// +optional
Expand All @@ -78,7 +80,7 @@ type AutoscalingRunnerSetSpec struct {
// +optional
VaultConfig *VaultConfig `json:"vaultConfig,omitempty"`

// Required
// +optional
Template corev1.PodTemplateSpec `json:"template,omitempty"`

// +optional
Expand Down Expand Up @@ -112,16 +114,16 @@ type AutoscalingRunnerSetSpec struct {
EphemeralRunnerConfigSecretMetadata *ResourceMeta `json:"ephemeralRunnerConfigSecretMetadata,omitempty"`

// +optional
// +kubebuilder:validation:Minimum:=0
// +kubebuilder:validation:Minimum=0
MaxRunners *int `json:"maxRunners,omitempty"`

// +optional
// +kubebuilder:validation:Minimum:=0
// +kubebuilder:validation:Minimum=0
MinRunners *int `json:"minRunners,omitempty"`
}

type TLSConfig struct {
// Required
// +required
CertificateFrom *TLSCertificateSource `json:"certificateFrom,omitempty"`
}

Expand Down Expand Up @@ -158,7 +160,7 @@ func (c *TLSConfig) ToCertPool(keyFetcher func(name, key string) ([]byte, error)
}

type TLSCertificateSource struct {
// Required
// +required
ConfigMapKeyRef *corev1.ConfigMapKeySelector `json:"configMapKeyRef,omitempty"`
}

Expand All @@ -179,9 +181,9 @@ func (c *ProxyConfig) ToHTTPProxyConfig(secretFetcher func(string) (*corev1.Secr
}

if c.HTTP != nil {
u, err := url.Parse(c.HTTP.Url)
u, err := url.Parse(c.HTTP.URL)
if err != nil {
return nil, fmt.Errorf("failed to parse proxy http url %q: %w", c.HTTP.Url, err)
return nil, fmt.Errorf("failed to parse proxy http url %q: %w", c.HTTP.URL, err)
}

if c.HTTP.CredentialSecretRef != "" {
Expand All @@ -204,9 +206,9 @@ func (c *ProxyConfig) ToHTTPProxyConfig(secretFetcher func(string) (*corev1.Secr
}

if c.HTTPS != nil {
u, err := url.Parse(c.HTTPS.Url)
u, err := url.Parse(c.HTTPS.URL)
if err != nil {
return nil, fmt.Errorf("failed to parse proxy https url %q: %w", c.HTTPS.Url, err)
return nil, fmt.Errorf("failed to parse proxy https url %q: %w", c.HTTPS.URL, err)
}

if c.HTTPS.CredentialSecretRef != "" {
Expand Down Expand Up @@ -259,8 +261,8 @@ func (c *ProxyConfig) ProxyFunc(secretFetcher func(string) (*corev1.Secret, erro
}

type ProxyServerConfig struct {
// Required
Url string `json:"url,omitempty"`
// +required
URL string `json:"url,omitempty"`

// +optional
CredentialSecretRef string `json:"credentialSecretRef,omitempty"`
Expand Down Expand Up @@ -315,6 +317,7 @@ type HistogramMetric struct {
// AutoscalingRunnerSetStatus defines the observed state of AutoscalingRunnerSet
type AutoscalingRunnerSetStatus struct {
// +optional
// +kubebuilder:validation:Minimum=0
CurrentRunners int `json:"currentRunners"`

// +optional
Expand All @@ -323,10 +326,13 @@ type AutoscalingRunnerSetStatus struct {
// EphemeralRunner counts separated by the stage ephemeral runners are in, taken from the EphemeralRunnerSet

// +optional
// +kubebuilder:validation:Minimum=0
PendingEphemeralRunners int `json:"pendingEphemeralRunners"`
// +optional
// +kubebuilder:validation:Minimum=0
RunningEphemeralRunners int `json:"runningEphemeralRunners"`
// +optional
// +kubebuilder:validation:Minimum=0
FailedEphemeralRunners int `json:"failedEphemeralRunners"`
}

Expand All @@ -340,20 +346,6 @@ const (
AutoscalingRunnerSetPhaseOutdated AutoscalingRunnerSetPhase = "Outdated"
)

func (ars *AutoscalingRunnerSet) Hash() string {
type data struct {
Spec *AutoscalingRunnerSetSpec
Labels map[string]string
}

d := &data{
Spec: ars.Spec.DeepCopy(),
Labels: ars.Labels,
}

return hash.ComputeTemplateHash(d)
}

func (ars *AutoscalingRunnerSet) ListenerSpecHash() string {
arsSpec := ars.Spec.DeepCopy()
spec := arsSpec
Expand Down
16 changes: 10 additions & 6 deletions apis/actions.github.com/v1alpha1/ephemeralrunner_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ const EphemeralRunnerContainerName = "runner"

// EphemeralRunner is the Schema for the ephemeralrunners API
type EphemeralRunner struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec EphemeralRunnerSpec `json:"spec,omitempty"`
// +optional
Spec EphemeralRunnerSpec `json:"spec,omitempty"`
// +optional
Status EphemeralRunnerStatus `json:"status,omitempty"`
}

Expand Down Expand Up @@ -102,17 +105,17 @@ func (er *EphemeralRunner) VaultProxy() *ProxyConfig {

// EphemeralRunnerSpec defines the desired state of EphemeralRunner
type EphemeralRunnerSpec struct {
// +required
// +optional
GitHubConfigURL string `json:"githubConfigUrl,omitempty"`

// +required
// +optional
GitHubConfigSecret string `json:"githubConfigSecret,omitempty"`

// +optional
GitHubServerTLS *TLSConfig `json:"githubServerTLS,omitempty"`

// +required
RunnerScaleSetID int `json:"runnerScaleSetId,omitempty"`
// +optional
RunnerScaleSetID int `json:"runnerScaleSetId"`

// +optional
Proxy *ProxyConfig `json:"proxy,omitempty"`
Expand All @@ -126,6 +129,7 @@ type EphemeralRunnerSpec struct {
// +optional
EphemeralRunnerConfigSecretMetadata *ResourceMeta `json:"ephemeralRunnerConfigSecretMetadata,omitempty"`

// +optional
corev1.PodTemplateSpec `json:",inline"`
}

Expand Down
15 changes: 13 additions & 2 deletions apis/actions.github.com/v1alpha1/ephemeralrunnerset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ import (
// EphemeralRunnerSetSpec defines the desired state of EphemeralRunnerSet
type EphemeralRunnerSetSpec struct {
// Replicas is the number of desired EphemeralRunner resources in the k8s namespace.
// +optional
Replicas int `json:"replicas,omitempty"`
// PatchID is the unique identifier for the patch issued by the listener app
// +optional
PatchID int `json:"patchID"`
// EphemeralRunnerSpec is the spec of the ephemeral runner
// +optional
EphemeralRunnerSpec EphemeralRunnerSpec `json:"ephemeralRunnerSpec,omitempty"`
// EphemeralRunnerMetadata is the metadata to be applied to all ephemeral runners created by this set.
// If the EphemeralRunnerMetadata is updated, the update applies to new ephemeral runners created after the update,
Expand All @@ -38,12 +41,17 @@ type EphemeralRunnerSetSpec struct {
// EphemeralRunnerSetStatus defines the observed state of EphemeralRunnerSet
type EphemeralRunnerSetStatus struct {
// CurrentReplicas is the number of currently running EphemeralRunner resources being managed by this EphemeralRunnerSet.
// +kubebuilder:validation:Minimum=0
// +optional
CurrentReplicas int `json:"currentReplicas"`
// +optional
// +kubebuilder:validation:Minimum=0
PendingEphemeralRunners int `json:"pendingEphemeralRunners"`
// +optional
// +kubebuilder:validation:Minimum=0
RunningEphemeralRunners int `json:"runningEphemeralRunners"`
// +optional
// +kubebuilder:validation:Minimum=0
FailedEphemeralRunners int `json:"failedEphemeralRunners"`
// +optional
Phase EphemeralRunnerSetPhase `json:"phase"`
Expand Down Expand Up @@ -71,10 +79,13 @@ const (

// EphemeralRunnerSet is the Schema for the ephemeralrunnersets API
type EphemeralRunnerSet struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec EphemeralRunnerSetSpec `json:"spec,omitempty"`
// +optional
Spec EphemeralRunnerSetSpec `json:"spec,omitempty"`
// +optional
Status EphemeralRunnerSetStatus `json:"status,omitempty"`
}

Expand Down
8 changes: 4 additions & 4 deletions apis/actions.github.com/v1alpha1/proxy_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
func TestProxyConfig_ToSecret(t *testing.T) {
config := &v1alpha1.ProxyConfig{
HTTP: &v1alpha1.ProxyServerConfig{
Url: "http://proxy.example.com:8080",
URL: "http://proxy.example.com:8080",
CredentialSecretRef: "my-secret",
},
HTTPS: &v1alpha1.ProxyServerConfig{
Url: "https://proxy.example.com:8080",
URL: "https://proxy.example.com:8080",
CredentialSecretRef: "my-secret",
},
NoProxy: []string{
Expand Down Expand Up @@ -48,11 +48,11 @@ func TestProxyConfig_ToSecret(t *testing.T) {
func TestProxyConfig_ProxyFunc(t *testing.T) {
config := &v1alpha1.ProxyConfig{
HTTP: &v1alpha1.ProxyServerConfig{
Url: "http://proxy.example.com:8080",
URL: "http://proxy.example.com:8080",
CredentialSecretRef: "my-secret",
},
HTTPS: &v1alpha1.ProxyServerConfig{
Url: "https://proxy.example.com:8080",
URL: "https://proxy.example.com:8080",
CredentialSecretRef: "my-secret",
},
NoProxy: []string{
Expand Down
Loading
Loading