-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(controllers): Implement the TerraformRun controller (#167)
* chore: wip * feat(tfrun): bootstrap tfrun controller and CRD * test(tfrun): wip writing tests * feat(layer): refactored remediationStrategy * fix(layer): fix test data with remediationStrategy * feat(tfrun): wip: conditions and state handlers * feat(tfrun): minimal working controller * feat(tfrun): add RBAC for tfrun on burrito-controllers * fix(tfrun): initialize controller clock * fix(tfrun): add RBAC for tfrun to plain manifests * feat(tfrun): wip: layer controller creates tfruns * feat(tfrun): layer controller creates tfruns * fix(tfrun): drop tfrun when in terminal state * fix(tfrun): rework condition for last retry * fix(tfrun): make maxRetries an int ptr for merging repo/layer * feat(tfrun): remove from runner failure annotation * test(layer): remove old commented tests * test(tfrun): first tests on nominal case * test(tfrun): tests on error cases * feat(tfrun): define maxRetries in config * feat(tfrun): make Retries column integer * chore(docs): update documentation for tfrun * style: changing logrus -> log --------- Co-authored-by: Alan <alanl@padok.fr>
- Loading branch information
1 parent
006165a
commit 93a6cd3
Showing
55 changed files
with
2,387 additions
and
597 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,9 @@ Dockerfile.cross | |
*.swp | ||
*.swo | ||
*~ | ||
|
||
# Python virtual environment (for mkdocs) | ||
.env | ||
.venv | ||
env/ | ||
venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
Copyright 2022. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
// TerraformRunSpec defines the desired state of TerraformRun | ||
type TerraformRunSpec struct { | ||
Action string `json:"action,omitempty"` | ||
Layer TerraformRunLayer `json:"layer,omitempty"` | ||
} | ||
|
||
type TerraformRunLayer struct { | ||
Name string `json:"name,omitempty"` | ||
Namespace string `json:"namespace,omitempty"` | ||
} | ||
|
||
// TerraformRunStatus defines the observed state of TerraformRun | ||
type TerraformRunStatus struct { | ||
Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
State string `json:"state,omitempty"` | ||
Retries int `json:"retries"` | ||
LastRun string `json:"lastRun,omitempty"` | ||
RunnerPod string `json:"runnerPod,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:resource:shortName=runs;run;tfruns;tfrun; | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state` | ||
// +kubebuilder:printcolumn:name="Retries",type=integer,JSONPath=`.status.retries` | ||
// +kubebuilder:printcolumn:name="Created On",type=string,JSONPath=`.metadata.creationTimestamp` | ||
// +kubebuilder:printcolumn:name="Runner Pod",type=string,JSONPath=`.status.runnerPod` | ||
// TerraformRun is the Schema for the terraformRuns API | ||
type TerraformRun struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec TerraformRunSpec `json:"spec,omitempty"` | ||
Status TerraformRunStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// TerraformRunList contains a list of TerraformRun | ||
type TerraformRunList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []TerraformRun `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&TerraformRun{}, &TerraformRunList{}) | ||
} | ||
|
||
// Associated functions | ||
|
||
// Workaround needed for envtest which does not populate the TypeMeta structure | ||
// See https://github.com/kubernetes-sigs/controller-runtime/issues/1870 | ||
func (run *TerraformRun) GetAPIVersion() string { | ||
if run.APIVersion == "" { | ||
return "config.terraform.padok.cloud/v1alpha1" | ||
} | ||
return run.APIVersion | ||
} | ||
|
||
// Same as above | ||
func (run *TerraformRun) GetKind() string { | ||
if run.Kind == "" { | ||
return "TerraformRun" | ||
} | ||
return run.Kind | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../../manifests/crds/config.terraform.padok.cloud_terraformruns.yaml |
Oops, something went wrong.