Skip to content

Commit 75829c6

Browse files
committed
Added - Container Instance : Remoed unsupported COMMAND
1 parent 298d0e4 commit 75829c6

File tree

5 files changed

+50
-99
lines changed

5 files changed

+50
-99
lines changed

internal/integrationtest/container_instances_container_instance_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,19 @@ func TestContainerInstancesContainerInstanceResource_basic(t *testing.T) {
436436
resource.TestCheckResourceAttr(resourceName, "containers.0.display_name", "displayName"),
437437
resource.TestCheckResourceAttr(resourceName, "containers.0.environment_variables.%", "1"),
438438
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.#", "1"),
439+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.failure_action", "KILL"),
440+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.failure_threshold", "10"),
441+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.headers.#", "1"),
442+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.headers.0.name", "name"),
443+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.headers.0.value", "value"),
444+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.health_check_type", "HTTP"),
445+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.initial_delay_in_seconds", "10"),
446+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.interval_in_seconds", "10"),
447+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.name", "name"),
448+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.path", "path"),
449+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.port", "10"),
450+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.success_threshold", "1"),
451+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.timeout_in_seconds", "10"),
439452
resource.TestCheckResourceAttr(resourceName, "containers.0.image_url", "busybox"),
440453
resource.TestCheckResourceAttr(resourceName, "containers.0.is_resource_principal_disabled", "false"),
441454
resource.TestCheckResourceAttr(resourceName, "containers.0.resource_config.#", "1"),
@@ -516,6 +529,19 @@ func TestContainerInstancesContainerInstanceResource_basic(t *testing.T) {
516529
resource.TestCheckResourceAttr(resourceName, "containers.0.display_name", "displayName"),
517530
resource.TestCheckResourceAttr(resourceName, "containers.0.environment_variables.%", "1"),
518531
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.#", "1"),
532+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.failure_action", "KILL"),
533+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.failure_threshold", "10"),
534+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.headers.#", "1"),
535+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.headers.0.name", "name"),
536+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.headers.0.value", "value"),
537+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.health_check_type", "HTTP"),
538+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.initial_delay_in_seconds", "10"),
539+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.interval_in_seconds", "10"),
540+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.name", "name"),
541+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.path", "path"),
542+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.port", "10"),
543+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.success_threshold", "1"),
544+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.timeout_in_seconds", "10"),
519545
resource.TestCheckResourceAttr(resourceName, "containers.0.image_url", "busybox"),
520546
resource.TestCheckResourceAttr(resourceName, "containers.0.is_resource_principal_disabled", "false"),
521547
resource.TestCheckResourceAttr(resourceName, "containers.0.resource_config.#", "1"),
@@ -591,6 +617,19 @@ func TestContainerInstancesContainerInstanceResource_basic(t *testing.T) {
591617
resource.TestCheckResourceAttr(resourceName, "containers.0.display_name", "displayName2"),
592618
resource.TestCheckResourceAttr(resourceName, "containers.0.environment_variables.%", "1"),
593619
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.#", "1"),
620+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.failure_action", "KILL"),
621+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.failure_threshold", "10"),
622+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.headers.#", "1"),
623+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.headers.0.name", "name"),
624+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.headers.0.value", "value"),
625+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.health_check_type", "HTTP"),
626+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.initial_delay_in_seconds", "10"),
627+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.interval_in_seconds", "10"),
628+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.name", "name"),
629+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.path", "path"),
630+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.port", "10"),
631+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.success_threshold", "1"),
632+
resource.TestCheckResourceAttr(resourceName, "containers.0.health_checks.0.timeout_in_seconds", "10"),
594633
resource.TestCheckResourceAttr(resourceName, "containers.0.image_url", "busybox"),
595634
resource.TestCheckResourceAttr(resourceName, "containers.0.is_resource_principal_disabled", "false"),
596635
resource.TestCheckResourceAttr(resourceName, "containers.0.resource_config.#", "1"),

internal/service/container_instances/container_instances_container_instance_resource.go

Lines changed: 5 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,17 @@ func ContainerInstancesContainerInstanceResource() *schema.Resource {
118118
ForceNew: true,
119119
DiffSuppressFunc: tfresource.EqualIgnoreCaseSuppressDiff,
120120
ValidateFunc: validation.StringInSlice([]string{
121-
"COMMAND",
122121
"HTTP",
123122
"TCP",
124123
}, true),
125124
},
126-
127-
// Optional
128-
"command": {
129-
Type: schema.TypeList,
130-
Optional: true,
131-
Computed: true,
125+
"port": {
126+
Type: schema.TypeInt,
127+
Required: true,
132128
ForceNew: true,
133-
Elem: &schema.Schema{
134-
Type: schema.TypeString,
135-
},
136129
},
130+
131+
// Optional
137132
"failure_action": {
138133
Type: schema.TypeString,
139134
Optional: true,
@@ -197,12 +192,6 @@ func ContainerInstancesContainerInstanceResource() *schema.Resource {
197192
Computed: true,
198193
ForceNew: true,
199194
},
200-
"port": {
201-
Type: schema.TypeInt,
202-
Optional: true,
203-
Computed: true,
204-
ForceNew: true,
205-
},
206195
"status": {
207196
Type: schema.TypeString,
208197
Optional: true,
@@ -1962,48 +1951,6 @@ func (s *ContainerInstancesContainerInstanceResourceCrud) mapToCreateContainerHe
19621951
healthCheckType = "" // default value
19631952
}
19641953
switch strings.ToLower(healthCheckType) {
1965-
case strings.ToLower("COMMAND"):
1966-
details := oci_container_instances.CreateContainerCommandHealthCheckDetails{}
1967-
if command, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "command")); ok {
1968-
interfaces := command.([]interface{})
1969-
tmp := make([]string, len(interfaces))
1970-
for i := range interfaces {
1971-
if interfaces[i] != nil {
1972-
tmp[i] = interfaces[i].(string)
1973-
}
1974-
}
1975-
if len(tmp) != 0 || s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "command")) {
1976-
details.Command = tmp
1977-
}
1978-
}
1979-
if failureAction, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "failure_action")); ok {
1980-
details.FailureAction = oci_container_instances.ContainerHealthCheckFailureActionEnum(failureAction.(string))
1981-
}
1982-
if failureThreshold, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "failure_threshold")); ok {
1983-
tmp := failureThreshold.(int)
1984-
details.FailureThreshold = &tmp
1985-
}
1986-
if initialDelayInSeconds, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "initial_delay_in_seconds")); ok {
1987-
tmp := initialDelayInSeconds.(int)
1988-
details.InitialDelayInSeconds = &tmp
1989-
}
1990-
if intervalInSeconds, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "interval_in_seconds")); ok {
1991-
tmp := intervalInSeconds.(int)
1992-
details.IntervalInSeconds = &tmp
1993-
}
1994-
if name, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "name")); ok {
1995-
tmp := name.(string)
1996-
details.Name = &tmp
1997-
}
1998-
if successThreshold, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "success_threshold")); ok {
1999-
tmp := successThreshold.(int)
2000-
details.SuccessThreshold = &tmp
2001-
}
2002-
if timeoutInSeconds, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "timeout_in_seconds")); ok {
2003-
tmp := timeoutInSeconds.(int)
2004-
details.TimeoutInSeconds = &tmp
2005-
}
2006-
baseObject = details
20071954
case strings.ToLower("HTTP"):
20081955
details := oci_container_instances.CreateContainerHttpHealthCheckDetails{}
20091956
if headers, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "headers")); ok {
@@ -2101,42 +2048,6 @@ func (s *ContainerInstancesContainerInstanceResourceCrud) mapToCreateContainerHe
21012048
func ContainerHealthCheckToMap(obj oci_container_instances.ContainerHealthCheck) map[string]interface{} {
21022049
result := map[string]interface{}{}
21032050
switch v := (obj).(type) {
2104-
case oci_container_instances.ContainerCommandHealthCheck:
2105-
result["health_check_type"] = "COMMAND"
2106-
2107-
result["command"] = v.Command
2108-
2109-
result["failure_action"] = string(v.FailureAction)
2110-
2111-
if v.FailureThreshold != nil {
2112-
result["failure_threshold"] = int(*v.FailureThreshold)
2113-
}
2114-
2115-
if v.InitialDelayInSeconds != nil {
2116-
result["initial_delay_in_seconds"] = int(*v.InitialDelayInSeconds)
2117-
}
2118-
2119-
if v.IntervalInSeconds != nil {
2120-
result["interval_in_seconds"] = int(*v.IntervalInSeconds)
2121-
}
2122-
2123-
if v.Name != nil {
2124-
result["name"] = string(*v.Name)
2125-
}
2126-
2127-
result["status"] = string(v.Status)
2128-
2129-
if v.StatusDetails != nil {
2130-
result["status_details"] = string(*v.StatusDetails)
2131-
}
2132-
2133-
if v.SuccessThreshold != nil {
2134-
result["success_threshold"] = int(*v.SuccessThreshold)
2135-
}
2136-
2137-
if v.TimeoutInSeconds != nil {
2138-
result["timeout_in_seconds"] = int(*v.TimeoutInSeconds)
2139-
}
21402051
case oci_container_instances.ContainerHttpHealthCheck:
21412052
result["health_check_type"] = "HTTP"
21422053

website/docs/d/container_instances_container_instance.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ The following attributes are exported:
6262
* `processor_description` - A short description of the container instance's processor (CPU).
6363
* `state` - The current state of the container instance.
6464
* `system_tags` - Usage of system tag keys. These predefined keys are scoped to namespaces. Example: `{"orcl-cloud.free-tier-retained": "true"}`.
65+
* `tenant_id` - TenantId id of the container instance.
6566
* `time_created` - The time the container instance was created, in the format defined by [RFC 3339](https://tools.ietf.org/rfc/rfc3339).
6667
* `time_updated` - The time the container instance was updated, in the format defined by [RFC 3339](https://tools.ietf.org/rfc/rfc3339).
6768
* `vnics` - The virtual networks available to the containers in the container instance.

website/docs/d/container_instances_container_instances.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ The following attributes are exported:
7777
* `processor_description` - A short description of the container instance's processor (CPU).
7878
* `state` - The current state of the container instance.
7979
* `system_tags` - Usage of system tag keys. These predefined keys are scoped to namespaces. Example: `{"orcl-cloud.free-tier-retained": "true"}`.
80+
* `tenant_id` - TenantId id of the container instance.
8081
* `time_created` - The time the container instance was created, in the format defined by [RFC 3339](https://tools.ietf.org/rfc/rfc3339).
8182
* `time_updated` - The time the container instance was updated, in the format defined by [RFC 3339](https://tools.ietf.org/rfc/rfc3339).
8283
* `vnics` - The virtual networks available to the containers in the container instance.

website/docs/r/container_instances_container_instance.html.markdown

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ resource "oci_container_instances_container_instance" "test_container_instance"
3434
health_checks {
3535
#Required
3636
health_check_type = var.container_instance_containers_health_checks_health_check_type
37+
port = var.container_instance_containers_health_checks_port
3738
3839
#Optional
39-
command = var.container_instance_containers_health_checks_command
4040
failure_action = var.container_instance_containers_health_checks_failure_action
4141
failure_threshold = var.container_instance_containers_health_checks_failure_threshold
4242
headers {
@@ -49,7 +49,6 @@ resource "oci_container_instances_container_instance" "test_container_instance"
4949
interval_in_seconds = var.container_instance_containers_health_checks_interval_in_seconds
5050
name = var.container_instance_containers_health_checks_name
5151
path = var.container_instance_containers_health_checks_path
52-
port = var.container_instance_containers_health_checks_port
5352
success_threshold = var.container_instance_containers_health_checks_success_threshold
5453
timeout_in_seconds = var.container_instance_containers_health_checks_timeout_in_seconds
5554
}
@@ -172,8 +171,7 @@ The following arguments are supported:
172171

173172
The total size of all environment variables combined, name and values, must be 64 KB or smaller.
174173
* `freeform_tags` - (Optional) Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`
175-
* `health_checks` - (Optional) list of container health checks to check container status and take appropriate action if container status is failed. There are three types of health checks that we currently support HTTP, TCP, and Command.
176-
* `command` - (Required when health_check_type=COMMAND) The list of strings that will be simplified to a single command for checking the status of the container.
174+
* `health_checks` - (Optional) list of container health checks to check container status and take appropriate action if container status is failed. There are two types of health checks that we currently support HTTP and TCP.
177175
* `failure_action` - (Optional) The action will be triggered when the container health check fails. There are two types of action: KILL or NONE. The default action is KILL. If failure action is KILL, the container will be subject to the container restart policy.
178176
* `failure_threshold` - (Optional) Number of consecutive failures at which we consider the check failed.
179177
* `headers` - (Applicable when health_check_type=HTTP) Container health check HTTP headers.
@@ -184,7 +182,7 @@ The following arguments are supported:
184182
* `interval_in_seconds` - (Optional) Number of seconds between two consecutive runs for checking container health.
185183
* `name` - (Optional) Health check name.
186184
* `path` - (Required when health_check_type=HTTP) Container health check HTTP path.
187-
* `port` - (Required when health_check_type=HTTP | TCP) Container health check HTTP port.
185+
* `port` - (Required) Container health check HTTP port.
188186
* `success_threshold` - (Optional) Number of consecutive successes at which we consider the check succeeded again after it was in failure state.
189187
* `timeout_in_seconds` - (Optional) Length of waiting time in seconds before marking health check failed.
190188
* `image_url` - (Required) A URL identifying the image that the container runs in, such as docker.io/library/busybox:latest. If you do not provide a tag, the tag will default to latest.
@@ -301,6 +299,7 @@ The following attributes are exported:
301299
* `processor_description` - A short description of the container instance's processor (CPU).
302300
* `state` - The current state of the container instance.
303301
* `system_tags` - Usage of system tag keys. These predefined keys are scoped to namespaces. Example: `{"orcl-cloud.free-tier-retained": "true"}`.
302+
* `tenant_id` - TenantId id of the container instance.
304303
* `time_created` - The time the container instance was created, in the format defined by [RFC 3339](https://tools.ietf.org/rfc/rfc3339).
305304
* `time_updated` - The time the container instance was updated, in the format defined by [RFC 3339](https://tools.ietf.org/rfc/rfc3339).
306305
* `vnics` - The virtual networks available to the containers in the container instance.

0 commit comments

Comments
 (0)