Skip to content

Commit

Permalink
add requireVerifiedChromeOs as optional (#4758) (#9071)
Browse files Browse the repository at this point in the history
* add requireVerifiedChromeOs as optional

see https://cloud.google.com/access-context-manager/docs/access-level-attributes

* add to tests

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored May 4, 2021
1 parent 541be33 commit 1cc487a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/4758.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
accesscontextmanager: added support for `require_verified_chrome_os` in basic access levels.
```
25 changes: 23 additions & 2 deletions google/resource_access_context_manager_access_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ An empty list allows all types and all versions.`,
of this OS satisfies the constraint.
Format: "major.minor.patch" such as "10.5.301", "9.2.1".`,
},
"require_verified_chrome_os": {
Type: schema.TypeBool,
Optional: true,
Description: `If you specify DESKTOP_CHROME_OS for osType, you can optionally include requireVerifiedChromeOs to require Chrome Verified Access.`,
},
},
},
},
Expand Down Expand Up @@ -695,8 +700,9 @@ func flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstrai
continue
}
transformed = append(transformed, map[string]interface{}{
"minimum_version": flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsMinimumVersion(original["minimumVersion"], d, config),
"os_type": flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsOsType(original["osType"], d, config),
"minimum_version": flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsMinimumVersion(original["minimumVersion"], d, config),
"require_verified_chrome_os": flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsRequireVerifiedChromeOs(original["requireVerifiedChromeOs"], d, config),
"os_type": flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsOsType(original["osType"], d, config),
})
}
return transformed
Expand All @@ -705,6 +711,10 @@ func flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstrai
return v
}

func flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsRequireVerifiedChromeOs(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsOsType(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}
Expand Down Expand Up @@ -967,6 +977,13 @@ func expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstrain
transformed["minimumVersion"] = transformedMinimumVersion
}

transformedRequireVerifiedChromeOs, err := expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsRequireVerifiedChromeOs(original["require_verified_chrome_os"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedRequireVerifiedChromeOs); val.IsValid() && !isEmptyValue(val) {
transformed["requireVerifiedChromeOs"] = transformedRequireVerifiedChromeOs
}

transformedOsType, err := expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsOsType(original["os_type"], d, config)
if err != nil {
return nil, err
Expand All @@ -983,6 +1000,10 @@ func expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstrain
return v, nil
}

func expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsRequireVerifiedChromeOs(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandAccessContextManagerAccessLevelBasicConditionsDevicePolicyOsConstraintsOsType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ resource "google_access_context_manager_access_level" "test-access" {
require_screen_lock = true
os_constraints {
os_type = "DESKTOP_CHROME_OS"
require_verified_chrome_os = true
}
}
regions = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ resource "google_access_context_manager_access_level" "test-access" {
require_corp_owned = true
os_constraints {
os_type = "DESKTOP_CHROME_OS"
require_verified_chrome_os = true
}
}
regions = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ The `os_constraints` block supports:
of this OS satisfies the constraint.
Format: "major.minor.patch" such as "10.5.301", "9.2.1".

* `require_verified_chrome_os` -
(Optional)
If you specify DESKTOP_CHROME_OS for osType, you can optionally include requireVerifiedChromeOs to require Chrome Verified Access.

* `os_type` -
(Required)
The operating system type of the device.
Expand Down

0 comments on commit 1cc487a

Please sign in to comment.