Skip to content

Commit

Permalink
Merge pull request #292 from projectsyn/feat/compile-pipeline-reconci…
Browse files Browse the repository at this point in the history
…liation

Reconcile managed compile pipeline configuration
  • Loading branch information
HappyTetrahedron authored Jul 26, 2024
2 parents 704dc7d + 1daf931 commit c678f7e
Show file tree
Hide file tree
Showing 18 changed files with 1,597 additions and 5 deletions.
9 changes: 9 additions & 0 deletions api/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type ClusterSpec struct {
// Adopt: will create a new external resource or will adopt and manage an already existing resource
// +kubebuilder:validation:Enum=Create;Adopt
CreationPolicy CreationPolicy `json:"creationPolicy,omitempty"`
// EnableCompilePipeline determines whether the gitops compile pipeline should be set up for this cluster
EnableCompilePipeline bool `json:"enableCompilePipeline,omitempty"`
}

// BootstrapToken this key is used only once for Steward to register.
Expand Down Expand Up @@ -131,6 +133,9 @@ func init() {

// GetGitTemplate returns the git repository template
func (c *Cluster) GetGitTemplate() *GitRepoTemplate {
if c.Spec.GitRepoTemplate == nil {
return &GitRepoTemplate{}
}
return c.Spec.GitRepoTemplate
}

Expand Down Expand Up @@ -171,3 +176,7 @@ func (c *Cluster) GetMeta() metav1.ObjectMeta {
func (c *Cluster) GetStatus() interface{} {
return c.Status
}

func (c *Cluster) GetEnableCompilePipeline() bool {
return c.Spec.EnableCompilePipeline
}
5 changes: 3 additions & 2 deletions api/v1alpha1/constants.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package v1alpha1

const (
LabelNameTenant = "syn.tools/tenant"
FinalizerName = "cluster.lieutenant.syn.tools"
LabelNameTenant = "syn.tools/tenant"
FinalizerName = "cluster.lieutenant.syn.tools"
PipelineFinalizerName = "cluster.lieutenant.syn.tools/pipelines"

// DeleteProtectionAnnotation defines the delete protection annotation name
DeleteProtectionAnnotation = "syn.tools/protected-delete"
Expand Down
33 changes: 32 additions & 1 deletion api/v1alpha1/tenant_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ type TenantSpec struct {
// The fields within this can use Go templating.
// See https://syn.tools/lieutenant-operator/explanations/templating.html for details.
ClusterTemplate *ClusterSpec `json:"clusterTemplate,omitempty"`
// CompilePipeline contains the configuration for the automatically configured compile pipelines on this tenant
CompilePipeline *CompilePipelineSpec `json:"compilePipeline,omitempty"`
}

// TenantStatus defines the observed state of Tenant
type TenantStatus struct {
// TBD
// CompilePipeline contains the status of the automatically configured compile pipelines on this tenant
CompilePipeline *CompilePipelineStatus `json:"compilePipeline,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -68,6 +71,18 @@ type TenantList struct {
Items []Tenant `json:"items"`
}

type CompilePipelineSpec struct {
// Enabled enables or disables the compile pipeline for this tenant
Enabled bool `json:"enabled,omitempty"`
// Pipelines contains a map of filenames and file contents, specifying files which are added to the GitRepoTemplate in order to set up the automatically configured compile pipeline
PipelineFiles map[string]string `json:"pipelineFiles,omitempty"`
}

type CompilePipelineStatus struct {
// Clusters contains the list of all clusters for which the automatically configured compile pipeline is enabled
Clusters []string `json:"clusters,omitempty"`
}

func init() {
SchemeBuilder.Register(&Tenant{}, &TenantList{})
}
Expand All @@ -80,6 +95,22 @@ func (t *Tenant) GetGitTemplate() *GitRepoTemplate {
return t.Spec.GitRepoTemplate
}

// GetCompilePipelineStatus returns the compile pipeline status
func (t *Tenant) GetCompilePipelineStatus() *CompilePipelineStatus {
if t.Status.CompilePipeline == nil {
return &CompilePipelineStatus{}
}
return t.Status.CompilePipeline
}

// GetCompilePipelineSpec returns the compile pipeline spec
func (t *Tenant) GetCompilePipelineSpec() *CompilePipelineSpec {
if t.Spec.CompilePipeline == nil {
return &CompilePipelineSpec{}
}
return t.Spec.CompilePipeline
}

// GetTenantRef returns the tenant of this CR
func (t *Tenant) GetTenantRef() corev1.LocalObjectReference {
return corev1.LocalObjectReference{Name: t.GetName()}
Expand Down
54 changes: 53 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 4 additions & 0 deletions config/crd/bases/syn.tools_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ spec:
description: DisplayName of cluster which could be different from
metadata.name. Allows cluster renaming should it be needed.
type: string
enableCompilePipeline:
description: EnableCompilePipeline determines whether the gitops compile
pipeline should be set up for this cluster
type: boolean
facts:
additionalProperties:
type: string
Expand Down
32 changes: 32 additions & 0 deletions config/crd/bases/syn.tools_tenants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ spec:
description: DisplayName of cluster which could be different from
metadata.name. Allows cluster renaming should it be needed.
type: string
enableCompilePipeline:
description: EnableCompilePipeline determines whether the gitops
compile pipeline should be set up for this cluster
type: boolean
facts:
additionalProperties:
type: string
Expand Down Expand Up @@ -291,6 +295,22 @@ spec:
description: TokenLifetime set the token lifetime
type: string
type: object
compilePipeline:
description: CompilePipeline contains the configuration for the automatically
configured compile pipelines on this tenant
properties:
enabled:
description: Enabled enables or disables the compile pipeline
for this tenant
type: boolean
pipelineFiles:
additionalProperties:
type: string
description: Pipelines contains a map of filenames and file contents,
specifying files which are added to the GitRepoTemplate in order
to set up the automatically configured compile pipeline
type: object
type: object
creationPolicy:
description: |-
CreationPolicy defines how the external resources should be treated upon CR creation.
Expand Down Expand Up @@ -501,6 +521,18 @@ spec:
type: object
status:
description: TenantStatus defines the observed state of Tenant
properties:
compilePipeline:
description: CompilePipeline contains the status of the automatically
configured compile pipelines on this tenant
properties:
clusters:
description: Clusters contains the list of all clusters for which
the automatically configured compile pipeline is enabled
items:
type: string
type: array
type: object
type: object
type: object
served: true
Expand Down
20 changes: 20 additions & 0 deletions config/crd/bases/syn.tools_tenanttemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ spec:
description: DisplayName of cluster which could be different from
metadata.name. Allows cluster renaming should it be needed.
type: string
enableCompilePipeline:
description: EnableCompilePipeline determines whether the gitops
compile pipeline should be set up for this cluster
type: boolean
facts:
additionalProperties:
type: string
Expand Down Expand Up @@ -291,6 +295,22 @@ spec:
description: TokenLifetime set the token lifetime
type: string
type: object
compilePipeline:
description: CompilePipeline contains the configuration for the automatically
configured compile pipelines on this tenant
properties:
enabled:
description: Enabled enables or disables the compile pipeline
for this tenant
type: boolean
pipelineFiles:
additionalProperties:
type: string
description: Pipelines contains a map of filenames and file contents,
specifying files which are added to the GitRepoTemplate in order
to set up the automatically configured compile pipeline
type: object
type: object
creationPolicy:
description: |-
CreationPolicy defines how the external resources should be treated upon CR creation.
Expand Down
Loading

0 comments on commit c678f7e

Please sign in to comment.