Skip to content

Commit be35c91

Browse files
Terraform Team AutomationMonica Joshi
authored andcommitted
Added - Support for OS Management Hub: Limit CSS/VCSS content to the latest package versions only
1 parent 261ee01 commit be35c91

File tree

7 files changed

+84
-12
lines changed

7 files changed

+84
-12
lines changed

examples/os_management_hub/software_source/main.tf

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ resource "oci_os_management_hub_software_source" "test_software_source_filter" {
5959
compartment_id = var.compartment_id
6060
display_name = "displayName"
6161
software_source_type = "CUSTOM"
62+
vendor_software_sources {
63+
display_name = "ol8_baseos_latest-x86_64"
64+
id = data.oci_os_management_hub_software_sources.ol8_baseos_latest_x86_64.software_source_collection[0].items[0].id
65+
}
6266
vendor_software_sources {
6367
#Required
6468
display_name = "ol8_appstream-x86_64"
6569
id = data.oci_os_management_hub_software_sources.ol8_appstream_x86_64.software_source_collection[0].items[0].id
6670
}
67-
vendor_software_sources {
68-
display_name = "ol8_baseos_latest-x86_64"
69-
id = data.oci_os_management_hub_software_sources.ol8_baseos_latest_x86_64.software_source_collection[0].items[0].id
70-
}
7171

7272
#Optional
7373
custom_software_source_filter {
@@ -96,22 +96,28 @@ resource "oci_os_management_hub_software_source" "test_software_source_filter" {
9696
is_auto_resolve_dependencies = "false"
9797
is_automatically_updated = "true"
9898
is_created_from_package_list = "false"
99+
is_latest_content_only = "false"
100+
origin_software_source_id = data.oci_os_management_hub_software_sources.ol8_baseos_latest_x86_64.software_source_collection[0].items[0].id
101+
102+
lifecycle {
103+
ignore_changes = [defined_tags]
104+
}
99105
}
100106

101107
resource "oci_os_management_hub_software_source" "test_software_source_list" {
102108
#Required
103109
compartment_id = var.compartment_id
104110
display_name = "displayName"
105111
software_source_type = "CUSTOM"
112+
vendor_software_sources {
113+
display_name = "ol8_baseos_latest-x86_64"
114+
id = data.oci_os_management_hub_software_sources.ol8_baseos_latest_x86_64.software_source_collection[0].items[0].id
115+
}
106116
vendor_software_sources {
107117
#Required
108118
display_name = "ol8_appstream-x86_64"
109119
id = data.oci_os_management_hub_software_sources.ol8_appstream_x86_64.software_source_collection[0].items[0].id
110120
}
111-
vendor_software_sources {
112-
display_name = "ol8_baseos_latest-x86_64"
113-
id = data.oci_os_management_hub_software_sources.ol8_baseos_latest_x86_64.software_source_collection[0].items[0].id
114-
}
115121

116122
#Optional
117123
defined_tags = {"Operations.CostCenter"= "42"}
@@ -120,6 +126,10 @@ resource "oci_os_management_hub_software_source" "test_software_source_list" {
120126
is_auto_resolve_dependencies = "false"
121127
is_automatically_updated = "true"
122128
is_created_from_package_list = "true"
129+
130+
lifecycle {
131+
ignore_changes = [defined_tags]
132+
}
123133
}
124134

125135
# Get software source
@@ -196,7 +206,7 @@ data "oci_os_management_hub_software_package_software_source" "test_software_pac
196206

197207
# Add software package
198208
resource "oci_os_management_hub_software_source_add_packages_management" "test_software_source_add_packages_management" {
199-
packages = ["ModemManager-glib-1.10.4-1.el8.x86_64.rpm"]
209+
packages = ["ModemManager-glib-1.10.4-1.el8.x86_64"]
200210
software_source_id = oci_os_management_hub_software_source.test_software_source_list.id
201211
}
202212

internal/integrationtest/os_management_hub_software_source_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ var (
8787
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
8888
"display_name": acctest.Representation{RepType: acctest.Required, Create: `displayName`, Update: `displayName2`},
8989
"software_source_type": acctest.Representation{RepType: acctest.Required, Create: `CUSTOM`},
90-
"vendor_software_sources": []acctest.RepresentationGroup{{RepType: acctest.Required, Group: OsManagementHubSoftwareSourceVendorSoftwareSourcesRepresentation2}, {RepType: acctest.Required, Group: OsManagementHubSoftwareSourceVendorSoftwareSourcesRepresentation}},
90+
"vendor_software_sources": []acctest.RepresentationGroup{{RepType: acctest.Required, Group: OsManagementHubSoftwareSourceVendorSoftwareSourcesRepresentation}, {RepType: acctest.Required, Group: OsManagementHubSoftwareSourceVendorSoftwareSourcesRepresentation2}},
9191
"custom_software_source_filter": acctest.RepresentationGroup{RepType: acctest.Required, Group: OsManagementHubSoftwareSourceCustomSoftwareSourceFilterRepresentation},
9292
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}},
9393
"is_auto_resolve_dependencies": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `false`},
9494
"is_automatically_updated": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
9595
"is_created_from_package_list": acctest.Representation{RepType: acctest.Optional, Create: `false`},
96+
"is_latest_content_only": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
9697
}
9798

9899
OsManagementHubSoftwareSourceCustomRepresentation = map[string]interface{}{
@@ -101,7 +102,7 @@ var (
101102
"description": acctest.Representation{RepType: acctest.Optional, Create: `tf-custom-ss`, Update: `tf-custom-ss2`},
102103
"display_name": acctest.Representation{RepType: acctest.Required, Create: `tf-custom-ss`, Update: `tf-custom-ss2`},
103104
"software_source_type": acctest.Representation{RepType: acctest.Required, Create: `CUSTOM`},
104-
"vendor_software_sources": []acctest.RepresentationGroup{{RepType: acctest.Required, Group: OsManagementHubSoftwareSourceVendorSoftwareSourcesRepresentation2}, {RepType: acctest.Required, Group: OsManagementHubSoftwareSourceVendorSoftwareSourcesRepresentation}},
105+
"vendor_software_sources": []acctest.RepresentationGroup{{RepType: acctest.Required, Group: OsManagementHubSoftwareSourceVendorSoftwareSourcesRepresentation}, {RepType: acctest.Required, Group: OsManagementHubSoftwareSourceVendorSoftwareSourcesRepresentation2}},
105106
"is_auto_resolve_dependencies": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `false`},
106107
"is_automatically_updated": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
107108
"is_created_from_package_list": acctest.Representation{RepType: acctest.Required, Create: `true`},
@@ -206,6 +207,7 @@ func TestOsManagementHubSoftwareSourceResource_basic(t *testing.T) {
206207
resource.TestCheckResourceAttr(resourceName, "is_auto_resolve_dependencies", "false"),
207208
resource.TestCheckResourceAttr(resourceName, "is_automatically_updated", "false"),
208209
resource.TestCheckResourceAttr(resourceName, "is_created_from_package_list", "false"),
210+
resource.TestCheckResourceAttr(resourceName, "is_latest_content_only", "false"),
209211
resource.TestCheckResourceAttrSet(resourceName, "os_family"),
210212
resource.TestCheckResourceAttrSet(resourceName, "package_count"),
211213
resource.TestCheckResourceAttrSet(resourceName, "repo_id"),
@@ -261,14 +263,15 @@ func TestOsManagementHubSoftwareSourceResource_basic(t *testing.T) {
261263
resource.TestCheckResourceAttr(resourceName, "is_auto_resolve_dependencies", "false"),
262264
resource.TestCheckResourceAttr(resourceName, "is_automatically_updated", "false"),
263265
resource.TestCheckResourceAttr(resourceName, "is_created_from_package_list", "false"),
266+
resource.TestCheckResourceAttr(resourceName, "is_latest_content_only", "false"),
264267
resource.TestCheckResourceAttrSet(resourceName, "os_family"),
265268
resource.TestCheckResourceAttr(resourceName, "packages.#", "0"),
266269
resource.TestCheckResourceAttrSet(resourceName, "repo_id"),
267270
resource.TestCheckResourceAttr(resourceName, "software_source_type", "CUSTOM"),
268271
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
269272
resource.TestCheckResourceAttrSet(resourceName, "url"),
270273
resource.TestCheckResourceAttr(resourceName, "vendor_software_sources.#", "2"),
271-
resource.TestCheckResourceAttr(resourceName, "vendor_software_sources.0.display_name", "ol8_baseos_latest-x86_64"),
274+
resource.TestCheckResourceAttrSet(resourceName, "vendor_software_sources.0.display_name"),
272275
resource.TestCheckResourceAttrSet(resourceName, "vendor_software_sources.0.id"),
273276

274277
func(s *terraform.State) (err error) {
@@ -308,6 +311,7 @@ func TestOsManagementHubSoftwareSourceResource_basic(t *testing.T) {
308311
resource.TestCheckResourceAttr(resourceName, "is_auto_resolve_dependencies", "false"),
309312
resource.TestCheckResourceAttr(resourceName, "is_automatically_updated", "true"),
310313
resource.TestCheckResourceAttr(resourceName, "is_created_from_package_list", "false"),
314+
resource.TestCheckResourceAttr(resourceName, "is_latest_content_only", "true"),
311315
resource.TestCheckResourceAttrSet(resourceName, "os_family"),
312316
resource.TestCheckResourceAttr(resourceName, "packages.#", "0"),
313317
resource.TestCheckResourceAttrSet(resourceName, "repo_id"),

internal/service/os_management_hub/os_management_hub_software_source_data_source.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ func (s *OsManagementHubSoftwareSourceDataSourceCrud) SetData() error {
8989
s.D.Set("is_created_from_package_list", *v.IsCreatedFromPackageList)
9090
}
9191

92+
if v.IsLatestContentOnly != nil {
93+
s.D.Set("is_latest_content_only", *v.IsLatestContentOnly)
94+
}
95+
9296
s.D.Set("packages", v.Packages)
9397

9498
vendorSoftwareSources := []interface{}{}
@@ -263,6 +267,10 @@ func (s *OsManagementHubSoftwareSourceDataSourceCrud) SetData() error {
263267
s.D.Set("is_created_from_package_list", *v.IsCreatedFromPackageList)
264268
}
265269

270+
if v.IsLatestContentOnly != nil {
271+
s.D.Set("is_latest_content_only", *v.IsLatestContentOnly)
272+
}
273+
266274
s.D.Set("packages", v.Packages)
267275

268276
if v.SoftwareSourceVersion != nil {

internal/service/os_management_hub/os_management_hub_software_source_resource.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ func OsManagementHubSoftwareSourceResource() *schema.Resource {
200200
Computed: true,
201201
ForceNew: true,
202202
},
203+
"is_latest_content_only": {
204+
Type: schema.TypeBool,
205+
Optional: true,
206+
Computed: true,
207+
},
203208
"origin_software_source_id": {
204209
Type: schema.TypeString,
205210
Optional: true,
@@ -618,6 +623,10 @@ func (s *OsManagementHubSoftwareSourceResourceCrud) SetData() error {
618623
s.D.Set("is_created_from_package_list", *v.IsCreatedFromPackageList)
619624
}
620625

626+
if v.IsLatestContentOnly != nil {
627+
s.D.Set("is_latest_content_only", *v.IsLatestContentOnly)
628+
}
629+
621630
s.D.Set("packages", v.Packages)
622631

623632
vendorSoftwareSources := []interface{}{}
@@ -796,6 +805,10 @@ func (s *OsManagementHubSoftwareSourceResourceCrud) SetData() error {
796805
s.D.Set("is_created_from_package_list", *v.IsCreatedFromPackageList)
797806
}
798807

808+
if v.IsLatestContentOnly != nil {
809+
s.D.Set("is_latest_content_only", *v.IsLatestContentOnly)
810+
}
811+
799812
s.D.Set("packages", v.Packages)
800813

801814
if v.SoftwareSourceVersion != nil {
@@ -1169,6 +1182,10 @@ func (s *OsManagementHubSoftwareSourceResourceCrud) populateTopLevelPolymorphicC
11691182
tmp := isCreatedFromPackageList.(bool)
11701183
details.IsCreatedFromPackageList = &tmp
11711184
}
1185+
if isLatestContentOnly, ok := s.D.GetOkExists("is_latest_content_only"); ok {
1186+
tmp := isLatestContentOnly.(bool)
1187+
details.IsLatestContentOnly = &tmp
1188+
}
11721189
if packages, ok := s.D.GetOkExists("packages"); ok {
11731190
interfaces := packages.([]interface{})
11741191
tmp := make([]string, len(interfaces))
@@ -1269,6 +1286,10 @@ func (s *OsManagementHubSoftwareSourceResourceCrud) populateTopLevelPolymorphicC
12691286
tmp := isCreatedFromPackageList.(bool)
12701287
details.IsCreatedFromPackageList = &tmp
12711288
}
1289+
if isLatestContentOnly, ok := s.D.GetOkExists("is_latest_content_only"); ok {
1290+
tmp := isLatestContentOnly.(bool)
1291+
details.IsLatestContentOnly = &tmp
1292+
}
12721293
if packages, ok := s.D.GetOkExists("packages"); ok {
12731294
interfaces := packages.([]interface{})
12741295
tmp := make([]string, len(interfaces))
@@ -1360,6 +1381,10 @@ func (s *OsManagementHubSoftwareSourceResourceCrud) populateTopLevelPolymorphicU
13601381
tmp := isAutomaticallyUpdated.(bool)
13611382
details.IsAutomaticallyUpdated = &tmp
13621383
}
1384+
if isLatestContentOnly, ok := s.D.GetOkExists("is_latest_content_only"); ok {
1385+
tmp := isLatestContentOnly.(bool)
1386+
details.IsLatestContentOnly = &tmp
1387+
}
13631388
if vendorSoftwareSources, ok := s.D.GetOkExists("vendor_software_sources"); ok {
13641389
interfaces := vendorSoftwareSources.([]interface{})
13651390
tmp := make([]oci_os_management_hub.Id, len(interfaces))

website/docs/d/os_management_hub_software_source.html.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ The following attributes are exported:
6262
* `is_auto_resolve_dependencies` - Indicates whether the service should automatically resolve package dependencies when including specific packages in the software source.
6363
* `is_automatically_updated` - Indicates whether the service should automatically update the custom software source to use the latest package versions available. The service reviews packages levels once a day.
6464
* `is_created_from_package_list` - Indicates whether the service should create the software source from a list of packages provided by the user.
65+
* `is_latest_content_only` - Indicates whether the software source will include only the latest versions of content from vendor software sources, while accounting for other constraints set in the custom or versioned custom software source (such as a package list or filters).
66+
* For a module filter that does not specify a stream, this will include all available streams, and within each stream only the latest version of packages.
67+
* For a module filter that does specify a stream, this will include only the latest version of packages for the specified stream.
68+
* For a package filter that does not specify a version, this will include only the latest available version of the package.
69+
* For a package filter that does specify a version, this will include only the specified version of the package (the isLatestContentOnly attribute is ignored).
70+
* For a package list, this will include only the specified version of packages and modules in the list (the isLatestContentOnly attribute is ignored).
6571
* `is_mandatory_for_autonomous_linux` - Indicates whether the software source is required for the Autonomous Linux service.
6672
* `origin_software_source_id` - This property applies only to replicated vendor software sources. This is the [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the vendor software source in the root compartment.
6773
* `os_family` - The OS family the software source belongs to.

website/docs/d/os_management_hub_software_sources.html.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ The following attributes are exported:
9797
* `is_auto_resolve_dependencies` - Indicates whether the service should automatically resolve package dependencies when including specific packages in the software source.
9898
* `is_automatically_updated` - Indicates whether the service should automatically update the custom software source to use the latest package versions available. The service reviews packages levels once a day.
9999
* `is_created_from_package_list` - Indicates whether the service should create the software source from a list of packages provided by the user.
100+
* `is_latest_content_only` - Indicates whether the software source will include only the latest versions of content from vendor software sources, while accounting for other constraints set in the custom or versioned custom software source (such as a package list or filters).
101+
* For a module filter that does not specify a stream, this will include all available streams, and within each stream only the latest version of packages.
102+
* For a module filter that does specify a stream, this will include only the latest version of packages for the specified stream.
103+
* For a package filter that does not specify a version, this will include only the latest available version of the package.
104+
* For a package filter that does specify a version, this will include only the specified version of the package (the isLatestContentOnly attribute is ignored).
105+
* For a package list, this will include only the specified version of packages and modules in the list (the isLatestContentOnly attribute is ignored).
100106
* `is_mandatory_for_autonomous_linux` - Indicates whether the software source is required for the Autonomous Linux service.
101107
* `origin_software_source_id` - This property applies only to replicated vendor software sources. This is the [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the vendor software source in the root compartment.
102108
* `os_family` - The OS family the software source belongs to.

0 commit comments

Comments
 (0)