-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor constructing containers and support checkout certain git refs (
#382)
- Loading branch information
Showing
24 changed files
with
542 additions
and
307 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
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
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
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,60 @@ | ||
package container | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/oam-dev/terraform-controller/api/types" | ||
v1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/resource" | ||
) | ||
|
||
func (a *Assembler) ApplyContainer(executionType types.TerraformExecutionType, resourceQuota types.ResourceQuota) v1.Container { | ||
|
||
c := v1.Container{ | ||
Name: types.TerraformContainerName, | ||
Image: a.TerraformImage, | ||
ImagePullPolicy: v1.PullIfNotPresent, | ||
Command: []string{ | ||
"bash", | ||
"-c", | ||
fmt.Sprintf("terraform %s -lock=false -auto-approve", executionType), | ||
}, | ||
VolumeMounts: []v1.VolumeMount{ | ||
{ | ||
Name: a.Name, | ||
MountPath: types.WorkingVolumeMountPath, | ||
}, | ||
{ | ||
Name: types.InputTFConfigurationVolumeName, | ||
MountPath: types.InputTFConfigurationVolumeMountPath, | ||
}, | ||
}, | ||
Env: a.Envs, | ||
} | ||
|
||
if resourceQuota.ResourcesLimitsCPU != "" || resourceQuota.ResourcesLimitsMemory != "" || | ||
resourceQuota.ResourcesRequestsCPU != "" || resourceQuota.ResourcesRequestsMemory != "" { | ||
resourceRequirements := v1.ResourceRequirements{} | ||
if resourceQuota.ResourcesLimitsCPU != "" || resourceQuota.ResourcesLimitsMemory != "" { | ||
resourceRequirements.Limits = map[v1.ResourceName]resource.Quantity{} | ||
if resourceQuota.ResourcesLimitsCPU != "" { | ||
resourceRequirements.Limits["cpu"] = resourceQuota.ResourcesLimitsCPUQuantity | ||
} | ||
if resourceQuota.ResourcesLimitsMemory != "" { | ||
resourceRequirements.Limits["memory"] = resourceQuota.ResourcesLimitsMemoryQuantity | ||
} | ||
} | ||
if resourceQuota.ResourcesRequestsCPU != "" || resourceQuota.ResourcesLimitsMemory != "" { | ||
resourceRequirements.Requests = map[v1.ResourceName]resource.Quantity{} | ||
if resourceQuota.ResourcesRequestsCPU != "" { | ||
resourceRequirements.Requests["cpu"] = resourceQuota.ResourcesRequestsCPUQuantity | ||
} | ||
if resourceQuota.ResourcesRequestsMemory != "" { | ||
resourceRequirements.Requests["memory"] = resourceQuota.ResourcesRequestsMemoryQuantity | ||
} | ||
} | ||
c.Resources = resourceRequirements | ||
} | ||
|
||
return c | ||
} |
Oops, something went wrong.