Skip to content

Commit

Permalink
Merge pull request hashicorp#8 from sl1pm4t/revision-history-limit
Browse files Browse the repository at this point in the history
Add `revision_history_limit` to Deployment
  • Loading branch information
sl1pm4t authored Mar 28, 2018
2 parents fcc8e8d + 1cea547 commit 29a93a3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ test-compile:
targets: $(TARGETS)

$(TARGETS):
GOOS=$@ GOARCH=amd64 go build -o "dist/$@/terraform-provider-tfstate_${TRAVIS_TAG}_x4"
zip -j dist/terraform-provider-tfstate_${TRAVIS_TAG}_$@_amd64.zip dist/$@/terraform-provider-tfstate_${TRAVIS_TAG}_x4
GOOS=$@ GOARCH=amd64 go build -o "dist/$@/terraform-provider-kubernetes_${TRAVIS_TAG}_x4"
zip -j dist/terraform-provider-kubernetes_${TRAVIS_TAG}_$@_amd64.zip dist/$@/terraform-provider-kubernetes_${TRAVIS_TAG}_x4

.PHONY: build test testacc vet fmt fmtcheck errcheck vendor-status test-compile targets $(TARGETS)

6 changes: 6 additions & 0 deletions kubernetes/resource_kubernetes_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ func resourceKubernetesDeployment() *schema.Resource {
Optional: true,
Default: 1,
},
"revision_history_limit": {
Type: schema.TypeInt,
Description: "The number of old ReplicaSets to retain to allow rollback. Defaults to 10.",
Optional: true,
Default: 10,
},
"selector": {
Type: schema.TypeMap,
Description: "A label query over pods that should match the Replicas count. If Selector is empty, it is defaulted to the labels present on the Pod template. Label keys and values that must match in order to be controlled by this deployment, if empty defaulted to labels on Pod template. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors",
Expand Down
4 changes: 3 additions & 1 deletion kubernetes/resource_kubernetes_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func TestAccKubernetesDeployment_basic(t *testing.T) {
resource.TestCheckResourceAttr("kubernetes_deployment.test", "spec.0.template.0.spec.0.container.0.name", "tf-acc-test"),
resource.TestCheckResourceAttr("kubernetes_deployment.test", "spec.0.paused", "true"),
resource.TestCheckResourceAttr("kubernetes_deployment.test", "spec.0.progress_deadline_seconds", "30"),
resource.TestCheckResourceAttr("kubernetes_deployment.test", "spec.0.revision_history_limit", "4"),
),
},
{
Expand Down Expand Up @@ -364,7 +365,8 @@ resource "kubernetes_deployment" "test" {
}
spec {
paused = true
progress_deadline_seconds = "30"
progress_deadline_seconds = 30
revision_history_limit = 4
selector {
TestLabelOne = "one"
TestLabelTwo = "two"
Expand Down
10 changes: 10 additions & 0 deletions kubernetes/structures_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@ func flattenDeploymentSpec(in v1beta1.DeploymentSpec, d *schema.ResourceData) ([
att["paused"] = in.Paused
if in.ProgressDeadlineSeconds != nil {
att["progress_deadline_seconds"] = int(*in.ProgressDeadlineSeconds)
} else {
// nil pointer means the this is set to the default value (600)
att["progress_deadline_seconds"] = 600
}

if in.Replicas != nil {
att["replicas"] = *in.Replicas
}

if in.RevisionHistoryLimit != nil {
att["revision_history_limit"] = *in.RevisionHistoryLimit
} else {
// nil pointer means the this is set to the default value (10)
att["revision_history_limit"] = 10
}

att["selector"] = in.Selector.MatchLabels
att["strategy"] = flattenDeploymentStrategy(in.Strategy)

Expand Down
8 changes: 8 additions & 0 deletions scripts/runtests_mk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

export TF_ACC=1
export KUBE_CTX=minikube
export KUBE_CTX_CLUSTER=minikube
export KUBE_CTX_AUTH_INFO=minikube

/usr/local/bin/go test -v -parallel 1 -timeout 3600s github.com/sl1pm4t/terraform-provider-kubernetes/kubernetes -run "^TestAccKubernetes.*"

0 comments on commit 29a93a3

Please sign in to comment.