Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions ovh/resource_cloud_project_kube_nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,28 +154,28 @@ func resourceCloudProjectKubeNodePool() *schema.Resource {
Schema: map[string]*schema.Schema{
"metadata": {
Description: "metadata",
Optional: true,
Required: true,
Type: schema.TypeSet,
MaxItems: 1,
Set: CustomSchemaSetFunc(),
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"finalizers": {
Description: "finalizers",
Optional: true,
Required: true,
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
},
"labels": {
Description: "labels",
Optional: true,
Required: true,
Type: schema.TypeMap,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
},
"annotations": {
Description: "annotations",
Optional: true,
Required: true,
Type: schema.TypeMap,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
Expand All @@ -185,20 +185,20 @@ func resourceCloudProjectKubeNodePool() *schema.Resource {
},
"spec": {
Description: "spec",
Optional: true,
Required: true,
Type: schema.TypeSet,
MaxItems: 1,
Set: CustomSchemaSetFunc(),
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"unschedulable": {
Description: "unschedulable",
Optional: true,
Required: true,
Type: schema.TypeBool,
},
"taints": {
Description: "taints",
Optional: true,
Required: true,
Type: schema.TypeList,
Elem: &schema.Schema{
Type: schema.TypeMap,
Expand Down
169 changes: 95 additions & 74 deletions ovh/resource_cloud_project_kube_nodepool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,100 +75,113 @@ func testSweepCloudProjectKubeNodePool(region string) error {

var testAccCloudProjectKubeNodePoolConfig = `
resource "ovh_cloud_project_kube" "cluster" {
service_name = "%s"
name = "%s"
region = "%s"
version = "%s"
service_name = "%s"
name = "%s"
region = "%s"
version = "%s"
}

resource "ovh_cloud_project_kube_nodepool" "pool" {
service_name = ovh_cloud_project_kube.cluster.service_name
kube_id = ovh_cloud_project_kube.cluster.id
name = ovh_cloud_project_kube.cluster.name
flavor_name = "b2-7"
desired_nodes = 1
min_nodes = 0
max_nodes = 1
template {
metadata {
annotations = {
a1 = "av1"
}
finalizers = ["finalizer.extensions/v1beta1"]
labels = {
l1 = "lv1"
}
}
spec {
unschedulable = false
taints = [
{
effect = "PreferNoSchedule"
key = "t1"
value = "tv1"
}
]
}
}
service_name = ovh_cloud_project_kube.cluster.service_name
kube_id = ovh_cloud_project_kube.cluster.id
name = ovh_cloud_project_kube.cluster.name
flavor_name = "b2-7"
desired_nodes = 1
min_nodes = 0
max_nodes = 1
template {
metadata {
annotations = {
a1 = "av1"
}
finalizers = ["finalizer.extensions/v1beta1"]
labels = {
l1 = "lv1"
}
}
spec {
unschedulable = false
taints = [
{
effect = "PreferNoSchedule"
key = "t1"
value = "tv1"
}
]
}
}
}

`

var testAccCloudProjectKubeNodePoolConfigUpdated = `
resource "ovh_cloud_project_kube" "cluster" {
service_name = "%s"
name = "%s"
region = "%s"
version = "%s"
service_name = "%s"
name = "%s"
region = "%s"
version = "%s"
}

resource "ovh_cloud_project_kube_nodepool" "pool" {
service_name = ovh_cloud_project_kube.cluster.service_name
kube_id = ovh_cloud_project_kube.cluster.id
name = ovh_cloud_project_kube.cluster.name
flavor_name = "b2-7"
desired_nodes = 2
min_nodes = 0
max_nodes = 2
template {
metadata {
annotations = {
a2 = "av2"
}
labels = {
l2 = "lv2"
}
}
}
service_name = ovh_cloud_project_kube.cluster.service_name
kube_id = ovh_cloud_project_kube.cluster.id
name = ovh_cloud_project_kube.cluster.name
flavor_name = "b2-7"
desired_nodes = 2
min_nodes = 0
max_nodes = 2
template {
metadata {
annotations = {
a2 = "av2"
}
finalizers = []
labels = {
l2 = "lv2"
}
}
spec {
unschedulable = false
taints = []
}
}
}

`

var testAccCloudProjectKubeNodePoolConfigUpdatedScaleToZero = `
resource "ovh_cloud_project_kube" "cluster" {
service_name = "%s"
name = "%s"
region = "%s"
version = "%s"
service_name = "%s"
name = "%s"
region = "%s"
version = "%s"
}

resource "ovh_cloud_project_kube_nodepool" "pool" {
service_name = ovh_cloud_project_kube.cluster.service_name
kube_id = ovh_cloud_project_kube.cluster.id
name = ovh_cloud_project_kube.cluster.name
flavor_name = "b2-7"
desired_nodes = 0
min_nodes = 0
max_nodes = 2
template {
metadata {
annotations = {
a2 = "av2"
}
labels = {
l2 = "lv2"
}
}
}
service_name = ovh_cloud_project_kube.cluster.service_name
kube_id = ovh_cloud_project_kube.cluster.id
name = ovh_cloud_project_kube.cluster.name
flavor_name = "b2-7"
desired_nodes = 0
min_nodes = 0
max_nodes = 2
template {
metadata {
annotations = {
a2 = "av2"
}
finalizers = []
labels = {
l2 = "lv2"
}
}
spec {
unschedulable = false
taints = []
}
}
}

`

func TestAccCloudProjectKubeNodePool(t *testing.T) {
Expand Down Expand Up @@ -218,9 +231,11 @@ func TestAccCloudProjectKubeNodePool(t *testing.T) {
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "desired_nodes", "1"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "min_nodes", "0"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "max_nodes", "1"),

resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.annotations.a1", "av1"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.finalizers.0", "finalizer.extensions/v1beta1"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.labels.l1", "lv1"),

resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.0.effect", "PreferNoSchedule"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.0.key", "t1"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.0.value", "tv1"),
Expand All @@ -239,10 +254,13 @@ func TestAccCloudProjectKubeNodePool(t *testing.T) {
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "desired_nodes", "2"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "min_nodes", "0"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "max_nodes", "2"),

resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.annotations.a2", "av2"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.finalizers.#", "0"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.labels.l2", "lv2"),

resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.#", "0"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.unschedulable", "false"),
),
},
{
Expand All @@ -257,10 +275,13 @@ func TestAccCloudProjectKubeNodePool(t *testing.T) {
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "desired_nodes", "0"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "min_nodes", "0"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "max_nodes", "2"),

resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.annotations.a2", "av2"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.finalizers.#", "0"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.metadata.0.labels.l2", "lv2"),

resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.taints.#", "0"),
resource.TestCheckResourceAttr("ovh_cloud_project_kube_nodepool.pool", "template.0.spec.0.unschedulable", "false"),
),
},
{
Expand Down
Loading