From 2788f5e9b60f7cf86686e3f2148acaefa2477249 Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Thu, 22 Dec 2022 18:44:52 -0800 Subject: [PATCH] Upgrade dcl (#7012) * Upgrade dcl * Add new basic test * Simplify tests * Fix yaml * Use other zone * Update tests * Simplify tests * Remove sample tests, use handwritten * Rename test * Test in separate project, add back docs-only sample * Add test changes too * Add a couple fields --- mmv1/third_party/terraform/go.mod.erb | 2 +- mmv1/third_party/terraform/go.sum | 6 + ...os_config_os_policy_assignment_test.go.erb | 198 +++++++++++++++ .../samples/fixed.os_policy_assignment.json | 179 -------------- .../samples/fixed_os_policy_assignment.yaml | 5 - .../samples/percent.os_policy_assignment.json | 218 ----------------- .../samples/percent_os_policy_assignment.yaml | 32 --- .../update_fixed.os_policy_assignment.json | 220 ----------------- .../update_percent.os_policy_assignment.json | 229 ------------------ tpgtools/go.mod | 2 +- tpgtools/go.sum | 8 +- .../samples/ospolicyassignment/meta.yaml | 2 + 12 files changed, 210 insertions(+), 891 deletions(-) create mode 100644 mmv1/third_party/terraform/tests/resource_os_config_os_policy_assignment_test.go.erb delete mode 100755 tpgtools/api/osconfig/samples/percent.os_policy_assignment.json delete mode 100755 tpgtools/api/osconfig/samples/percent_os_policy_assignment.yaml delete mode 100755 tpgtools/api/osconfig/samples/update_fixed.os_policy_assignment.json delete mode 100755 tpgtools/api/osconfig/samples/update_percent.os_policy_assignment.json diff --git a/mmv1/third_party/terraform/go.mod.erb b/mmv1/third_party/terraform/go.mod.erb index 3b19c3ca80fc..100e2a8e5412 100644 --- a/mmv1/third_party/terraform/go.mod.erb +++ b/mmv1/third_party/terraform/go.mod.erb @@ -5,7 +5,7 @@ go 1.18 require ( cloud.google.com/go/bigtable v1.17.0 - github.com/GoogleCloudPlatform/declarative-resource-client-library v1.28.0 + github.com/GoogleCloudPlatform/declarative-resource-client-library v1.30.0 github.com/apparentlymart/go-cidr v1.1.0 github.com/client9/misspell v0.3.4 github.com/davecgh/go-spew v1.1.1 diff --git a/mmv1/third_party/terraform/go.sum b/mmv1/third_party/terraform/go.sum index 0d5a67b44454..a3128c4e733e 100644 --- a/mmv1/third_party/terraform/go.sum +++ b/mmv1/third_party/terraform/go.sum @@ -1289,3 +1289,9 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8 rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.29.0 h1:RmGDbvUWkRLYyWngSad04GR4LAnqflbXvzI1iBO2+rU= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.29.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.29.1-0.20221217025133-b2d522d3684b h1:RgZjFUQKRCJV61R5emEFGhDOX84D0BPZG+p/E0hilSk= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.29.1-0.20221217025133-b2d522d3684b/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.30.0 h1:1DMSUzQO2osKXy03/xZmr5n8bMlW3RyMhHR2JpkkVzY= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.30.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k= diff --git a/mmv1/third_party/terraform/tests/resource_os_config_os_policy_assignment_test.go.erb b/mmv1/third_party/terraform/tests/resource_os_config_os_policy_assignment_test.go.erb new file mode 100644 index 000000000000..776f2b469b27 --- /dev/null +++ b/mmv1/third_party/terraform/tests/resource_os_config_os_policy_assignment_test.go.erb @@ -0,0 +1,198 @@ +<% autogen_exception -%> + +package google + +import ( + "context" + "fmt" + dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" + osconfig "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/osconfig<%= dcl_version(version) -%>" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "strings" + "testing" +) + +func TestAccOsConfigOsPolicyAssignment_basicOsPolicyAssignment(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "project_name": getTestProjectFromEnv(), + "zone": getTestZoneFromEnv(), + "random_suffix": randString(t, 10), + "org_id": getTestOrgFromEnv(t), + "billing_act": getTestBillingAccountFromEnv(t), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckOsConfigOsPolicyAssignmentDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccOsConfigOsPolicyAssignment_PercentOsPolicyAssignment(context), + }, + { + ResourceName: "google_os_config_os_policy_assignment.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"rollout.0.min_wait_duration"}, + }, + }, + }) +} + +func testAccOsConfigOsPolicyAssignment_PercentOsPolicyAssignment(context map[string]interface{}) string { + return Nprintf(` +resource "google_project" "project" { + project_id = "tf-test%{random_suffix}" + name = "tf-test%{random_suffix}" + org_id = "%{org_id}" + billing_account = "%{billing_act}" +} + +resource "google_project_service" "compute" { + project = google_project.project.project_id + service = "compute.googleapis.com" +} + +resource "google_project_service" "osconfig" { + project = google_project.project.project_id + service = "osconfig.googleapis.com" + depends_on = [google_project_service.compute] +} + +resource "google_os_config_os_policy_assignment" "primary" { + instance_filter { + all = false + exclusion_labels { + labels = { + label-two = "value-two" + } + } + inclusion_labels { + labels = { + label-one = "value-one" + } + } + inventories { + os_short_name = "centos" + os_version = "8.*" + } + } + + location = "%{zone}" + name = "tf-test-assignment%{random_suffix}" + + os_policies { + id = "policy" + mode = "VALIDATION" + + resource_groups { + resources { + id = "apt-to-yum" + + repository { + apt { + archive_type = "DEB" + components = ["doc"] + distribution = "debian" + uri = "https://atl.mirrors.clouvider.net/debian" + gpg_key = ".gnupg/pubring.kbx" + } + } + } + inventory_filters { + os_short_name = "centos" + os_version = "8.*" + } + + resources { + id = "exec1" + exec { + validate { + interpreter = "SHELL" + args = ["arg1"] + file { + local_path = "$HOME/script.sh" + } + output_file_path = "$HOME/out" + } + enforce { + interpreter = "SHELL" + args = ["arg1"] + file { + allow_insecure = true + remote { + uri = "https://www.example.com/script.sh" + sha256_checksum = "c7938fed83afdccbb0e86a2a2e4cad7d5035012ca3214b4a61268393635c3063" + } + } + output_file_path = "$HOME/out" + } + } + } + } + allow_no_resource_group_match = false + description = "A test os policy" + } + + rollout { + disruption_budget { + percent = 100 + } + + min_wait_duration = "3s" + } + + description = "A test os policy assignment" + project = google_project.project.project_id + depends_on = [google_project_service.compute, google_project_service.osconfig] +} + + +`, context) +} + +func testAccCheckOsConfigOsPolicyAssignmentDestroyProducer(t *testing.T) func(s *terraform.State) error { + return func(s *terraform.State) error { + for name, rs := range s.RootModule().Resources { + if rs.Type != "rs.google_os_config_os_policy_assignment" { + continue + } + if strings.HasPrefix(name, "data.") { + continue + } + + config := googleProviderConfig(t) + + billingProject := "" + if config.BillingProject != "" { + billingProject = config.BillingProject + } + + obj := &osconfig.OSPolicyAssignment{ + Location: dcl.String(rs.Primary.Attributes["location"]), + Name: dcl.String(rs.Primary.Attributes["name"]), + Description: dcl.String(rs.Primary.Attributes["description"]), + Project: dcl.StringOrNil(rs.Primary.Attributes["project"]), + SkipAwaitRollout: dcl.Bool(rs.Primary.Attributes["skip_await_rollout"] == "true"), + Baseline: dcl.Bool(rs.Primary.Attributes["baseline"] == "true"), + Deleted: dcl.Bool(rs.Primary.Attributes["deleted"] == "true"), + Etag: dcl.StringOrNil(rs.Primary.Attributes["etag"]), + Reconciling: dcl.Bool(rs.Primary.Attributes["reconciling"] == "true"), + RevisionCreateTime: dcl.StringOrNil(rs.Primary.Attributes["revision_create_time"]), + RevisionId: dcl.StringOrNil(rs.Primary.Attributes["revision_id"]), + RolloutState: osconfig.OSPolicyAssignmentRolloutStateEnumRef(rs.Primary.Attributes["rollout_state"]), + Uid: dcl.StringOrNil(rs.Primary.Attributes["uid"]), + } + + client := NewDCLOsConfigClient(config, config.userAgent, billingProject, 0) + _, err := client.GetOSPolicyAssignment(context.Background(), obj) + if err == nil { + return fmt.Errorf("google_os_config_os_policy_assignment still exists %v", obj) + } + } + return nil + } +} diff --git a/tpgtools/api/osconfig/samples/fixed.os_policy_assignment.json b/tpgtools/api/osconfig/samples/fixed.os_policy_assignment.json index 5974c3936ef9..d4beb5178ed1 100755 --- a/tpgtools/api/osconfig/samples/fixed.os_policy_assignment.json +++ b/tpgtools/api/osconfig/samples/fixed.os_policy_assignment.json @@ -25,185 +25,6 @@ "name": "bazel" } } - }, - { - "id": "deb1", - "pkg": { - "desiredState": "INSTALLED", - "deb": { - "source": { - "localPath": "$HOME/package.deb" - } - } - } - }, - { - "id": "deb2", - "pkg": { - "desiredState": "INSTALLED", - "deb": { - "pullDeps": true, - "source": { - "allowInsecure": true, - "remote": { - "uri": "ftp.us.debian.org/debian/package.deb", - "sha256Checksum": "3bbfd1043cd7afdb78cf9afec36c0c5370d2fea98166537b4e67f3816f256025" - } - } - } - } - }, - { - "id": "deb3", - "pkg": { - "desiredState": "INSTALLED", - "deb": { - "pullDeps": true, - "source": { - "gcs": { - "bucket": "test-bucket", - "object": "test-object", - "generation": 1 - } - } - } - } - }, - { - "id": "yum", - "pkg": { - "desiredState": "INSTALLED", - "yum": { - "name": "gstreamer-plugins-base-devel.x86_64" - } - } - }, - { - "id": "zypper", - "pkg": { - "desiredState": "INSTALLED", - "zypper": { - "name": "gcc" - } - } - }, - { - "id": "rpm1", - "pkg": { - "desiredState": "INSTALLED", - "rpm": { - "pullDeps": true, - "source": { - "localPath": "$HOME/package.rpm" - } - } - } - }, - { - "id": "rpm2", - "pkg": { - "desiredState": "INSTALLED", - "rpm": { - "source": { - "allowInsecure": true, - "remote": { - "uri": "https://mirror.jaleco.com/centos/8.3.2011/BaseOS/x86_64/os/Packages/efi-filesystem-3-2.el8.noarch.rpm", - "sha256Checksum": "3bbfd1043cd7afdb78cf9afec36c0c5370d2fea98166537b4e67f3816f256025" - } - } - } - } - }, - { - "id": "rpm3", - "pkg": { - "desiredState": "INSTALLED", - "rpm": { - "source": { - "gcs": { - "bucket": "test-bucket", - "object": "test-object", - "generation": 1 - } - } - } - } - } - ] - }, - { - "resources": [ - { - "id": "apt-to-deb", - "pkg": { - "desiredState": "INSTALLED", - "apt": { - "name": "bazel" - } - } - }, - { - "id": "deb-local-path-to-gcs", - "pkg": { - "desiredState": "INSTALLED", - "deb": { - "source": { - "localPath": "$HOME/package.deb" - } - } - } - }, - { - "id": "googet", - "pkg": { - "desiredState": "INSTALLED", - "googet": { - "name": "gcc" - } - } - }, - { - "id": "msi1", - "pkg": { - "desiredState": "INSTALLED", - "msi": { - "source": { - "localPath": "$HOME/package.msi" - }, - "properties": ["REBOOT=ReallySuppress"] - } - } - }, - { - "id": "msi2", - "pkg": { - "desiredState": "INSTALLED", - "msi": { - "source": { - "allowInsecure": true, - "remote": { - "uri": "https://remote.uri.com/package.msi", - "sha256Checksum": "3bbfd1043cd7afdb78cf9afec36c0c5370d2fea98166537b4e67f3816f256025" - }, - "sha256Checksum": "3bbfd1043cd7afdb78cf9afec36c0c5370d2fea98166537b4e67f3816f256025" - } - } - } - }, - { - "id": "msi3", - "pkg": { - "desiredState": "INSTALLED", - "msi": { - "source": { - "gcs": { - "bucket": "test-bucket", - "object": "test-object", - "generation": 1 - } - } - } - } } ] } diff --git a/tpgtools/api/osconfig/samples/fixed_os_policy_assignment.yaml b/tpgtools/api/osconfig/samples/fixed_os_policy_assignment.yaml index 621e5c03cac5..0565f7dd85e6 100755 --- a/tpgtools/api/osconfig/samples/fixed_os_policy_assignment.yaml +++ b/tpgtools/api/osconfig/samples/fixed_os_policy_assignment.yaml @@ -20,11 +20,6 @@ versions: - beta - alpha resource: samples/fixed.os_policy_assignment.json -updates: -- resource: samples/update_fixed.os_policy_assignment.json - dependencies: [] -- resource: samples/percent.os_policy_assignment.json - dependencies: [] variables: - name: assignment type: resource_name diff --git a/tpgtools/api/osconfig/samples/percent.os_policy_assignment.json b/tpgtools/api/osconfig/samples/percent.os_policy_assignment.json deleted file mode 100755 index ab0b00ea5165..000000000000 --- a/tpgtools/api/osconfig/samples/percent.os_policy_assignment.json +++ /dev/null @@ -1,218 +0,0 @@ -{ - "name": "{{assignment}}", - "project": "{{project}}", - "location": "{{zone}}", - "description": "A test os policy assignment", - "osPolicies": [ - { - "id": "policy", - "mode": "VALIDATION", - "resourceGroups": [ - { - "resources": [ - { - "id": "apt-to-yum", - "repository": { - "apt": { - "archiveType": "DEB", - "uri": "https://atl.mirrors.clouvider.net/debian", - "distribution": "debian", - "components": ["doc"], - "gpgKey": ".gnupg/pubring.kbx" - } - } - }, - { - "id": "yum", - "repository": { - "yum": { - "id": "yum", - "displayName": "yum", - "baseUrl": "http://centos.s.uw.edu/centos/", - "gpgKeys": ["RPM-GPG-KEY-CentOS-7"] - } - } - }, - { - "id": "zypper", - "repository": { - "zypper": { - "id": "zypper", - "displayName": "zypper", - "baseUrl": "http://mirror.dal10.us.leaseweb.net/opensuse", - "gpgKeys": ["sample-key-uri"] - } - } - }, - { - "id": "goo", - "repository": { - "goo": { - "name": "goo", - "url": "https://foo.com/googet/bar" - } - } - }, - { - "id": "exec1", - "exec": { - "validate": { - "args": ["arg1"], - "interpreter": "SHELL", - "outputFilePath": "$HOME/out", - "file": { - "localPath": "$HOME/script.sh" - } - }, - "enforce": { - "args": ["arg1"], - "interpreter": "SHELL", - "outputFilePath": "$HOME/out", - "file": { - "allowInsecure": true, - "remote": { - "uri": "https://www.example.com/script.sh", - "sha256Checksum": "c7938fed83afdccbb0e86a2a2e4cad7d5035012ca3214b4a61268393635c3063" - } - } - } - } - }, - { - "id": "exec2", - "exec": { - "validate": { - "args": ["arg1"], - "interpreter": "SHELL", - "outputFilePath": "$HOME/out", - "file": { - "allowInsecure": true, - "remote": { - "uri": "https://www.example.com/script.sh", - "sha256Checksum": "c7938fed83afdccbb0e86a2a2e4cad7d5035012ca3214b4a61268393635c3063" - } - } - }, - "enforce": { - "args": ["arg1"], - "interpreter": "SHELL", - "outputFilePath": "$HOME/out", - "file": { - "localPath": "$HOME/script.sh" - } - } - } - }, - { - "id": "exec3", - "exec": { - "validate": { - "interpreter": "SHELL", - "outputFilePath": "$HOME/out", - "file": { - "allowInsecure": true, - "gcs": { - "bucket": "test-bucket", - "object": "test-object", - "generation": 1 - } - } - }, - "enforce": { - "interpreter": "SHELL", - "outputFilePath": "$HOME/out", - "script": "pwd" - } - } - }, - { - "id": "exec4", - "exec": { - "validate": { - "interpreter": "SHELL", - "outputFilePath": "$HOME/out", - "script": "pwd" - }, - "enforce": { - "interpreter": "SHELL", - "outputFilePath": "$HOME/out", - "file": { - "allowInsecure": true, - "gcs": { - "bucket": "test-bucket", - "object": "test-object", - "generation": 1 - } - } - } - } - }, - { - "id": "file1", - "file": { - "path": "$HOME/file", - "state": "PRESENT", - "file": { - "localPath": "$HOME/file" - } - } - } - ] - }, - { - "resources": [ - { - "id": "file2", - "file": { - "path": "$HOME/file", - "state": "PRESENT", - "permissions": "755", - "file": { - "allowInsecure": true, - "remote": { - "uri": "https://www.example.com/file", - "sha256Checksum": "c7938fed83afdccbb0e86a2a2e4cad7d5035012ca3214b4a61268393635c3063" - } - } - } - }, - { - "id": "file3", - "file": { - "path": "$HOME/file", - "state": "PRESENT", - "file": { - "gcs": { - "bucket": "test-bucket", - "object": "test-object", - "generation": 1 - } - } - } - }, - { - "id": "file4", - "file": { - "path": "$HOME/file", - "state": "PRESENT", - "content": "sample-content" - } - } - ] - } - ] - } - ], - "instanceFilter": { - "all": true, - "inclusionLabels": [], - "exclusionLabels": [], - "inventories": [] - }, - "rollout": { - "disruptionBudget": { - "percent": 1 - }, - "minWaitDuration": "3.5s" - } -} diff --git a/tpgtools/api/osconfig/samples/percent_os_policy_assignment.yaml b/tpgtools/api/osconfig/samples/percent_os_policy_assignment.yaml deleted file mode 100755 index 111974d27f9f..000000000000 --- a/tpgtools/api/osconfig/samples/percent_os_policy_assignment.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2021 Google LLC. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -name: percent_os_policy_assignment -description: An example of an osconfig os policy assignment with percent rollout disruption - budget -type: os_policy_assignment -versions: -- ga -- beta -- alpha -resource: samples/percent.os_policy_assignment.json -updates: -- resource: samples/update_percent.os_policy_assignment.json - dependencies: [] -variables: -- name: assignment - type: resource_name -- name: project - type: project -- name: zone - type: zone diff --git a/tpgtools/api/osconfig/samples/update_fixed.os_policy_assignment.json b/tpgtools/api/osconfig/samples/update_fixed.os_policy_assignment.json deleted file mode 100755 index 88fd1edc3373..000000000000 --- a/tpgtools/api/osconfig/samples/update_fixed.os_policy_assignment.json +++ /dev/null @@ -1,220 +0,0 @@ -{ - "name": "{{assignment}}", - "project": "{{project}}", - "location": "{{zone}}", - "description": "An updated test os policy assignment", - "osPolicies": [ - { - "id": "policy", - "description": "An updated test os policy", - "mode": "ENFORCEMENT", - "resourceGroups": [ - { - "inventoryFilters": [ - { - "osShortName": "", - "osVersion": "9.*" - } - ], - "resources": [ - { - "id": "apt", - "pkg": { - "desiredState": "INSTALLED", - "apt": { - "name": "firefox" - } - } - }, - { - "id": "new-deb1", - "pkg": { - "desiredState": "REMOVED", - "deb": { - "source": { - "localPath": "$HOME/new-package.deb" - } - } - } - }, - { - "id": "new-deb2", - "pkg": { - "desiredState": "REMOVED", - "deb": { - "pullDeps": false, - "source": { - "allowInsecure": false, - "remote": { - "uri": "ftp.us.debian.org/debian/new-package.deb", - "sha256Checksum": "9f8e5818ccb47024d01000db713c0a333679b64678ff5fe2d9bea0a23014dd54" - } - } - } - } - }, - { - "id": "new-yum", - "pkg": { - "desiredState": "REMOVED", - "yum": { - "name": "vlc.x86_64" - } - } - }, - { - "id": "new-zypper", - "pkg": { - "desiredState": "REMOVED", - "zypper": { - "name": "ModemManager" - } - } - }, - { - "id": "new-rpm1", - "pkg": { - "desiredState": "REMOVED", - "rpm": { - "pullDeps": false, - "source": { - "localPath": "$HOME/new-package.rpm" - } - } - } - }, - { - "id": "new-rpm2", - "pkg": { - "desiredState": "REMOVED", - "rpm": { - "source": { - "allowInsecure": false, - "remote": { - "uri": "https://mirror.jaleco.com/centos/8.3.2011/BaseOS/x86_64/os/Packages/NetworkManager-adsl-1.26.0-12.el8_3.x86_64.rpm", - "sha256Checksum": "9f8e5818ccb47024d01000db713c0a333679b64678ff5fe2d9bea0a23014dd54" - } - } - } - } - }, - { - "id": "new-rpm3", - "pkg": { - "desiredState": "REMOVED", - "rpm": { - "source": { - "gcs": { - "bucket": "new-test-bucket", - "object": "new-test-object", - "generation": 2 - } - } - } - } - } - ] - }, - { - "resources": [ - { - "id": "apt-to-deb", - "pkg": { - "desiredState": "REMOVED", - "deb": { - "source": { - "localPath": "$HOME/new-package.deb" - } - } - } - }, - { - "id": "deb-local-path-to-gcs", - "pkg": { - "desiredState": "REMOVED", - "deb": { - "source": { - "gcs": { - "bucket": "new-test-bucket", - "object": "new-test-object", - "generation": 2 - } - } - } - } - }, - { - "id": "new-googet", - "pkg": { - "desiredState": "REMOVED", - "googet": { - "name": "julia" - } - } - }, - { - "id": "new-msi1", - "pkg": { - "desiredState": "REMOVED", - "msi": { - "source": { - "localPath": "$HOME/new-package.msi" - }, - "properties": ["ACTION=INSTALL"] - } - } - }, - { - "id": "new-msi2", - "pkg": { - "desiredState": "REMOVED", - "msi": { - "source": { - "allowInsecure": false, - "remote": { - "uri": "https://remote.uri.com/new-package.msi", - "sha256Checksum": "9f8e5818ccb47024d01000db713c0a333679b64678ff5fe2d9bea0a23014dd54" - } - } - } - } - }, - { - "id": "new-msi3", - "pkg": { - "desiredState": "REMOVED", - "msi": { - "source": { - "gcs": { - "bucket": "new-test-bucket", - "object": "new-test-object", - "generation": 2 - } - } - } - } - } - ] - } - ], - "allowNoResourceGroupMatch": true - } - ], - "instanceFilter": { - "all": false, - "inclusionLabels": [], - "exclusionLabels": [], - "inventories": [ - { - "osShortName": "", - "osVersion": "9.*" - } - ] - }, - "rollout": { - "disruptionBudget": { - "fixed": 2 - }, - "minWaitDuration": "7.5s" - } -} diff --git a/tpgtools/api/osconfig/samples/update_percent.os_policy_assignment.json b/tpgtools/api/osconfig/samples/update_percent.os_policy_assignment.json deleted file mode 100755 index a228aa61eac1..000000000000 --- a/tpgtools/api/osconfig/samples/update_percent.os_policy_assignment.json +++ /dev/null @@ -1,229 +0,0 @@ -{ - "name": "{{assignment}}", - "project": "{{project}}", - "location": "{{zone}}", - "description": "A test os policy assignment", - "osPolicies": [ - { - "id": "new-policy", - "mode": "VALIDATION", - "resourceGroups": [ - { - "resources": [ - { - "id": "apt-to-yum", - "repository": { - "yum": { - "id": "new-yum", - "displayName": "new-yum", - "baseUrl": "http://mirrors.rcs.alaska.edu/centos/", - "gpgKeys": ["RPM-GPG-KEY-CentOS-Debug-7"] - } - } - }, - { - "id": "new-yum", - "repository": { - "yum": { - "id": "new-yum", - "displayName": "new-yum", - "baseUrl": "http://mirrors.rcs.alaska.edu/centos/", - "gpgKeys": ["RPM-GPG-KEY-CentOS-Debug-7"] - } - } - }, - { - "id": "new-zypper", - "repository": { - "zypper": { - "id": "new-zypper", - "displayName": "new-zypper", - "baseUrl": "http://mirror.vtti.vt.edu/opensuse/", - "gpgKeys": ["new-sample-key-uri"] - } - } - }, - { - "id": "new-goo", - "repository": { - "goo": { - "name": "new-goo", - "url": "https://foo.com/googet/baz" - } - } - }, - { - "id": "new-exec1", - "exec": { - "validate": { - "args": ["arg2"], - "interpreter": "POWERSHELL", - "outputFilePath": "$HOME/out", - "file": { - "localPath": "$HOME/script.bat" - } - }, - "enforce": { - "args": ["arg2"], - "interpreter": "POWERSHELL", - "outputFilePath": "$HOME/out", - "file": { - "allowInsecure": false, - "remote": { - "uri": "https://www.example.com/script.bat", - "sha256Checksum": "9f8e5818ccb47024d01000db713c0a333679b64678ff5fe2d9bea0a23014dd54" - } - } - } - } - }, - { - "id": "new-exec2", - "exec": { - "validate": { - "args": ["arg2"], - "interpreter": "POWERSHELL", - "outputFilePath": "$HOME/out", - "file": { - "allowInsecure": false, - "remote": { - "uri": "https://www.example.com/script.bat", - "sha256Checksum": "9f8e5818ccb47024d01000db713c0a333679b64678ff5fe2d9bea0a23014dd54" - } - } - }, - "enforce": { - "args": ["arg2"], - "interpreter": "POWERSHELL", - "outputFilePath": "$HOME/out", - "file": { - "localPath": "$HOME/script.bat" - } - } - } - }, - { - "id": "new-exec3", - "exec": { - "validate": { - "interpreter": "POWERSHELL", - "outputFilePath": "$HOME/out", - "file": { - "allowInsecure": false, - "gcs": { - "bucket": "new-test-bucket", - "object": "new-test-object", - "generation": 2 - } - } - }, - "enforce": { - "interpreter": "POWERSHELL", - "outputFilePath": "$HOME/out", - "script": "dir" - } - } - }, - { - "id": "new-exec4", - "exec": { - "validate": { - "interpreter": "POWERSHELL", - "outputFilePath": "$HOME/out", - "script": "dir" - }, - "enforce": { - "interpreter": "POWERSHELL", - "outputFilePath": "$HOME/out", - "file": { - "allowInsecure": false, - "gcs": { - "bucket": "new-test-bucket", - "object": "new-test-object", - "generation": 2 - } - } - } - } - }, - { - "id": "new-file1", - "file": { - "path": "$HOME/new-file", - "state": "PRESENT", - "file": { - "localPath": "$HOME/new-file" - } - } - } - ] - }, - { - "resources": [ - { - "id": "new-file2", - "file": { - "path": "$HOME/new-file", - "state": "CONTENTS_MATCH", - "permissions": "655", - "file": { - "allowInsecure": false, - "remote": { - "uri": "https://www.example.com/new-file", - "sha256Checksum": "9f8e5818ccb47024d01000db713c0a333679b64678ff5fe2d9bea0a23014dd54" - } - } - } - }, - { - "id": "new-file3", - "file": { - "path": "$HOME/new-file", - "state": "CONTENTS_MATCH", - "file": { - "gcs": { - "bucket": "new-test-bucket", - "object": "new-test-object", - "generation": 2 - } - } - } - }, - { - "id": "new-file4", - "file": { - "path": "$HOME/new-file", - "state": "CONTENTS_MATCH", - "content": "new-sample-content" - } - } - ] - } - ] - } - ], - "instanceFilter": { - "all": false, - "osShortNames": ["centos"], - "inclusionLabels": [ - { - "labels": { - "label-one": "value-one" - } - } - ], - "exclusionLabels": [ - { - "labels": { - "label-two": "value-two" - } - } - ] - }, - "rollout": { - "disruptionBudget": { - "percent": 2 - }, - "minWaitDuration": "3.5s" - } -} diff --git a/tpgtools/go.mod b/tpgtools/go.mod index 30b84458391b..28e73de39cca 100644 --- a/tpgtools/go.mod +++ b/tpgtools/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( bitbucket.org/creachadair/stringset v0.0.9 - github.com/GoogleCloudPlatform/declarative-resource-client-library v1.28.0 + github.com/GoogleCloudPlatform/declarative-resource-client-library v1.30.0 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/hashicorp/errwrap v1.0.0 github.com/hashicorp/hcl v1.0.0 diff --git a/tpgtools/go.sum b/tpgtools/go.sum index 59ba8701a7ed..a9a931e98891 100644 --- a/tpgtools/go.sum +++ b/tpgtools/go.sum @@ -35,12 +35,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.26.4 h1:nP8L2TqVbGehmlt6sfYiu4BKE0lJrGW1RrtP9/+FwfY= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.26.4/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.27.1 h1:cjRzz6gP7oxlYq+GEEhOU5HCNlG4Wc+jKxllKFayJBA= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.27.1/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.28.0 h1:QRloCSdH4JGX5H4wie8D4WeM4/TaqniVf/d/hnkrqLo= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.28.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.30.0 h1:1DMSUzQO2osKXy03/xZmr5n8bMlW3RyMhHR2JpkkVzY= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.30.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= diff --git a/tpgtools/overrides/osconfig/samples/ospolicyassignment/meta.yaml b/tpgtools/overrides/osconfig/samples/ospolicyassignment/meta.yaml index 7c8ca5f00e4c..9b21dde14383 100644 --- a/tpgtools/overrides/osconfig/samples/ospolicyassignment/meta.yaml +++ b/tpgtools/overrides/osconfig/samples/ospolicyassignment/meta.yaml @@ -1,2 +1,4 @@ ignore_read: - "rollout.0.min_wait_duration" +test_hide: + - fixed_os_policy_assignment.yaml \ No newline at end of file