-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix so that TF resources can be reconciled and suspended (#125)
- Loading branch information
Showing
6 changed files
with
169 additions
and
41 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
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,68 @@ | ||
package flux | ||
|
||
import ( | ||
"fmt" | ||
|
||
tf "github.com/flux-iac/tofu-controller/api/v1alpha2" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
type terraformAdapter struct { | ||
*tf.Terraform | ||
} | ||
|
||
func (h terraformAdapter) asClientObject() client.Object { | ||
return h.Terraform | ||
} | ||
|
||
func (h terraformAdapter) deepCopyClientObject() client.Object { | ||
return h.Terraform.DeepCopy() | ||
} | ||
|
||
func (obj terraformAdapter) isSuspended() bool { | ||
return obj.Terraform.Spec.Suspend | ||
} | ||
|
||
func (obj terraformAdapter) setSuspended() { | ||
obj.Terraform.Spec.Suspend = true | ||
} | ||
|
||
func (obj terraformAdapter) setUnsuspended() { | ||
obj.Terraform.Spec.Suspend = false | ||
} | ||
|
||
func (obj terraformAdapter) getObservedGeneration() int64 { | ||
return obj.Terraform.Status.ObservedGeneration | ||
} | ||
|
||
func (obj terraformAdapter) isStatic() bool { | ||
return false | ||
} | ||
|
||
func (obj terraformAdapter) lastHandledReconcileRequest() string { | ||
return obj.Status.LastAttemptedRevision | ||
} | ||
|
||
func (obj terraformAdapter) successMessage() string { | ||
return fmt.Sprintf("fetched revision %s", obj.Status.LastAppliedRevision) | ||
} | ||
|
||
type terraformListAdapter struct { | ||
*tf.TerraformList | ||
} | ||
|
||
func (h terraformListAdapter) asClientList() client.ObjectList { | ||
return h.TerraformList | ||
} | ||
|
||
func (h terraformListAdapter) len() int { | ||
return len(h.TerraformList.Items) | ||
} | ||
|
||
func (a terraformListAdapter) item(i int) suspendable { | ||
return &terraformAdapter{&a.TerraformList.Items[i]} | ||
} | ||
|
||
func (a terraformListAdapter) resumeItem(i int) resumable { | ||
return &terraformAdapter{&a.TerraformList.Items[i]} | ||
} |
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