Skip to content

Commit b3ad66d

Browse files
DragonDMNagaRajuPasunuri
authored andcommitted
Added - Support for Fleet Application Management Service v1.2
1 parent 643286b commit b3ad66d

File tree

107 files changed

+15856
-2464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+15856
-2464
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
variable "tenancy_ocid" {
3+
# default = ""
4+
}
5+
6+
variable "ssh_public_key" {
7+
# default = ""
8+
}
9+
10+
variable "region" {
11+
default = "us-ashburn-1"
12+
}
13+
14+
variable "compartment_id" {
15+
# default = ""
16+
}
17+
18+
variable "compliance_policy_id" {
19+
# default = ""
20+
}
21+
22+
data "oci_fleet_apps_management_compliance_policies" "test_compliance_policies" {
23+
compartment_id = "${var.compartment_id}"
24+
}
25+
26+
resource "oci_fleet_apps_management_compliance_policy_rule" "test_compliance_policy_rule" {
27+
compartment_id = "${var.compartment_id}"
28+
compliance_policy_id = "${var.compliance_policy_id}"
29+
display_name = "displayName"
30+
freeform_tags = {
31+
"Department" = "Finance"
32+
}
33+
grace_period = "gracePeriod2"
34+
patch_selection {
35+
days_since_release = "0"
36+
patch_level = "LATEST"
37+
selection_type = "PATCH_LEVEL"
38+
}
39+
patch_type = ["Security"]
40+
product_version {
41+
is_applicable_for_all_higher_versions = "false"
42+
version = "9"
43+
}
44+
severity = ["LOW"]
45+
}

examples/fleet_apps_management/fleet/fleet.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ variable "fleet_state" {
8888
default = "NEEDS_ATTENTION"
8989
}
9090

91-
92-
9391
provider "oci" {
9492
tenancy_ocid = var.tenancy_ocid
9593
user_ocid = var.user_ocid
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
variable "tenancy_ocid" {
3+
# default = ""
4+
}
5+
6+
variable "ssh_public_key" {
7+
# default = ""
8+
}
9+
10+
variable "region" {
11+
default = "us-ashburn-1"
12+
}
13+
14+
variable "compartment_id" {
15+
# default = ""
16+
}
17+
18+
variable "compatible_product_id" {
19+
# default = ""
20+
}
21+
22+
variable "credential_id" {
23+
# default = ""
24+
}
25+
26+
variable "patch_type_id" {
27+
# default = ""
28+
}
29+
30+
resource "oci_fleet_apps_management_platform_configuration" "test_platform_configuration" {
31+
compartment_id = "${var.compartment_id}"
32+
config_category_details {
33+
compatible_products {
34+
id = "${var.compatible_product_id}"
35+
}
36+
components = ["components2"]
37+
config_category = "PRODUCT"
38+
credentials {
39+
id = "${var.credential_id}"
40+
}
41+
patch_types {
42+
id = "${var.patch_type_id}"
43+
}
44+
versions = ["versions2"]
45+
}
46+
description = "description2"
47+
display_name = "displayName2"
48+
}

internal/integrationtest/fleet_apps_management_compliance_policy_rule_test.go

Lines changed: 363 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package integrationtest
5+
6+
import (
7+
"fmt"
8+
"testing"
9+
10+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
11+
12+
"github.com/oracle/terraform-provider-oci/httpreplay"
13+
"github.com/oracle/terraform-provider-oci/internal/acctest"
14+
15+
"github.com/oracle/terraform-provider-oci/internal/utils"
16+
)
17+
18+
var (
19+
FleetAppsManagementCompliancePolicySingularDataSourceRepresentation = map[string]interface{}{
20+
"compliance_policy_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compliance_policy_id}`},
21+
}
22+
23+
FleetAppsManagementCompliancePolicyDataSourceRepresentation = map[string]interface{}{
24+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
25+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`},
26+
"id": acctest.Representation{RepType: acctest.Optional, Create: `${var.compliance_policy_id}`},
27+
"state": acctest.Representation{RepType: acctest.Optional, Create: `AVAILABLE`},
28+
}
29+
30+
FleetAppsManagementCompliancePolicyResourceConfig = ""
31+
)
32+
33+
// issue-routing-tag: fleet_apps_management/default
34+
func TestFleetAppsManagementCompliancePolicyResource_basic(t *testing.T) {
35+
httpreplay.SetScenario("TestFleetAppsManagementCompliancePolicyResource_basic")
36+
defer httpreplay.SaveScenario()
37+
38+
config := acctest.ProviderTestConfig()
39+
40+
compartmentId := utils.GetEnvSettingWithBlankDefault("tenancy_ocid")
41+
compliancePolicyId := utils.GetEnvSettingWithBlankDefault("compliance_policy_id")
42+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
43+
compliancePolicyIdVariableStr := fmt.Sprintf("variable \"compliance_policy_id\" { default = \"%s\" }\n", compliancePolicyId)
44+
45+
datasourceName := "data.oci_fleet_apps_management_compliance_policies.test_compliance_policies"
46+
singularDatasourceName := "data.oci_fleet_apps_management_compliance_policy.test_compliance_policy"
47+
48+
acctest.SaveConfigContent("", "", "", t)
49+
50+
acctest.ResourceTest(t, nil, []resource.TestStep{
51+
// verify datasource
52+
{
53+
Config: config +
54+
acctest.GenerateDataSourceFromRepresentationMap("oci_fleet_apps_management_compliance_policies", "test_compliance_policies", acctest.Required, acctest.Create, FleetAppsManagementCompliancePolicyDataSourceRepresentation) +
55+
compartmentIdVariableStr + compliancePolicyIdVariableStr + FleetAppsManagementCompliancePolicyResourceConfig,
56+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
57+
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
58+
// Below criteria checks collection is returned
59+
resource.TestCheckResourceAttrSet(datasourceName, "compliance_policy_collection.#"),
60+
// Considering at least one compliance rule exists in entire tenancy, below criteria checks collection is non-empty
61+
resource.TestCheckResourceAttr(datasourceName, "compliance_policy_collection.0.%", "1"),
62+
// Verify each entity has total 11 attributes
63+
resource.TestCheckResourceAttr(datasourceName, "compliance_policy_collection.0.items.0.%", "11"),
64+
65+
//Check for some values
66+
resource.TestCheckResourceAttr(datasourceName, "compliance_policy_collection.0.items.0.compartment_id", compartmentId),
67+
resource.TestCheckResourceAttrSet(datasourceName, "compliance_policy_collection.0.items.0.id"),
68+
resource.TestCheckResourceAttrSet(datasourceName, "compliance_policy_collection.0.items.0.display_name"),
69+
resource.TestCheckResourceAttr(datasourceName, "compliance_policy_collection.0.items.0.state", "ACTIVE"),
70+
),
71+
},
72+
// verify singular datasource
73+
{
74+
Config: config +
75+
acctest.GenerateDataSourceFromRepresentationMap("oci_fleet_apps_management_compliance_policy", "test_compliance_policy", acctest.Required, acctest.Create, FleetAppsManagementCompliancePolicySingularDataSourceRepresentation) +
76+
compartmentIdVariableStr + compliancePolicyIdVariableStr + FleetAppsManagementCompliancePolicyResourceConfig,
77+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
78+
resource.TestCheckResourceAttrSet(singularDatasourceName, "compliance_policy_id"),
79+
80+
resource.TestCheckResourceAttrSet(singularDatasourceName, "compartment_id"),
81+
resource.TestCheckResourceAttrSet(singularDatasourceName, "display_name"),
82+
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),
83+
resource.TestCheckResourceAttrSet(singularDatasourceName, "product_id"),
84+
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
85+
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"),
86+
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_updated"),
87+
),
88+
},
89+
})
90+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package integrationtest
5+
6+
import (
7+
"fmt"
8+
"regexp"
9+
"testing"
10+
11+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
12+
13+
"github.com/oracle/terraform-provider-oci/httpreplay"
14+
"github.com/oracle/terraform-provider-oci/internal/acctest"
15+
16+
"github.com/oracle/terraform-provider-oci/internal/utils"
17+
)
18+
19+
var (
20+
FleetAppsManagementComplianceRecordCountDataSourceRepresentation = map[string]interface{}{
21+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
22+
}
23+
24+
FleetAppsManagementComplianceRecordCountResourceConfig = ""
25+
)
26+
27+
// issue-routing-tag: fleet_apps_management/default
28+
func TestFleetAppsManagementComplianceRecordCountResource_basic(t *testing.T) {
29+
httpreplay.SetScenario("TestFleetAppsManagementComplianceRecordCountResource_basic")
30+
defer httpreplay.SaveScenario()
31+
32+
config := acctest.ProviderTestConfig()
33+
34+
compartmentId := utils.GetEnvSettingWithBlankDefault("tenancy_ocid")
35+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
36+
37+
datasourceName := "data.oci_fleet_apps_management_compliance_record_counts.test_compliance_record_counts"
38+
39+
acctest.SaveConfigContent("", "", "", t)
40+
41+
acctest.ResourceTest(t, nil, []resource.TestStep{
42+
// verify datasource
43+
{
44+
Config: config +
45+
acctest.GenerateDataSourceFromRepresentationMap("oci_fleet_apps_management_compliance_record_counts", "test_compliance_record_counts", acctest.Required, acctest.Create, FleetAppsManagementComplianceRecordCountDataSourceRepresentation) +
46+
compartmentIdVariableStr + FleetAppsManagementComplianceRecordCountResourceConfig,
47+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
48+
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
49+
50+
resource.TestCheckResourceAttrSet(datasourceName, "compliance_record_aggregation_collection.#"),
51+
resource.TestMatchResourceAttr(datasourceName, "compliance_record_aggregation_collection.0.items.#",
52+
regexp.MustCompile("[1-9][0-9]*")),
53+
),
54+
},
55+
})
56+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package integrationtest
5+
6+
import (
7+
"fmt"
8+
"regexp"
9+
"testing"
10+
11+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
12+
13+
"github.com/oracle/terraform-provider-oci/httpreplay"
14+
"github.com/oracle/terraform-provider-oci/internal/acctest"
15+
16+
"github.com/oracle/terraform-provider-oci/internal/utils"
17+
)
18+
19+
var (
20+
FleetAppsManagementComplianceRecordDataSourceRepresentation = map[string]interface{}{
21+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
22+
"compliance_state": acctest.Representation{RepType: acctest.Optional, Create: `NON_COMPLIANT`},
23+
"entity_id": acctest.Representation{RepType: acctest.Required, Create: `${var.test_active_fleet}`},
24+
"product_name": acctest.Representation{RepType: acctest.Optional, Create: `Oracle Linux`},
25+
"product_stack": acctest.Representation{RepType: acctest.Optional, Create: `Oracle Linux`},
26+
}
27+
28+
FleetAppsManagementComplianceRecordResourceConfig = ""
29+
)
30+
31+
// issue-routing-tag: fleet_apps_management/default
32+
func TestFleetAppsManagementComplianceRecordResource_basic(t *testing.T) {
33+
httpreplay.SetScenario("TestFleetAppsManagementComplianceRecordResource_basic")
34+
defer httpreplay.SaveScenario()
35+
36+
config := acctest.ProviderTestConfig()
37+
38+
compartmentId := utils.GetEnvSettingWithBlankDefault("tenancy_ocid")
39+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
40+
41+
// Fleet in ACTIVE state. Fleets require a confirmation action call not supported by Terraform to go active.
42+
// Thus, this needs to be created and confirmed manually.
43+
activeFleetId := utils.GetEnvSettingWithBlankDefault("test_active_fleet")
44+
activeFleetStr := fmt.Sprintf("variable \"test_active_fleet\" { default = \"%s\" }\n", activeFleetId)
45+
46+
datasourceName := "data.oci_fleet_apps_management_compliance_records.test_compliance_records"
47+
48+
acctest.SaveConfigContent("", "", "", t)
49+
50+
acctest.ResourceTest(t, nil, []resource.TestStep{
51+
// verify datasource
52+
{
53+
Config: config +
54+
acctest.GenerateDataSourceFromRepresentationMap("oci_fleet_apps_management_compliance_records", "test_compliance_records", acctest.Optional, acctest.Create, FleetAppsManagementComplianceRecordDataSourceRepresentation) +
55+
activeFleetStr + compartmentIdVariableStr + FleetAppsManagementComplianceRecordResourceConfig,
56+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
57+
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
58+
resource.TestCheckResourceAttr(datasourceName, "compliance_state", "NON_COMPLIANT"),
59+
resource.TestCheckResourceAttrSet(datasourceName, "entity_id"),
60+
resource.TestCheckResourceAttr(datasourceName, "product_name", "Oracle Linux"),
61+
resource.TestCheckResourceAttr(datasourceName, "product_stack", "Oracle Linux"),
62+
63+
resource.TestCheckResourceAttrSet(datasourceName, "compliance_record_collection.#"),
64+
resource.TestMatchResourceAttr(datasourceName, "compliance_record_collection.0.items.#",
65+
regexp.MustCompile("[1-9][0-9]*")),
66+
),
67+
},
68+
})
69+
}

0 commit comments

Comments
 (0)