diff --git a/README.md b/README.md index ae9e214f..ee144796 100644 --- a/README.md +++ b/README.md @@ -358,6 +358,7 @@ The following resources are available in the InSpec GCP Profile | [google_resourcemanager_folder](docs/resources/google_resourcemanager_folder.md) | [google_resourcemanager_folders](docs/resources/google_resourcemanager_folders.md) | | [google_resourcemanager_folder_iam_binding](docs/resources/google_resourcemanager_folder_iam_binding.md) | No Plural Resource | | [google_resourcemanager_folder_iam_policy](docs/resources/google_resourcemanager_folder_iam_policy.md) | No Plural Resource | +| [google_run_job](docs/resources/google_run_job.md) | [google_run_jobs](docs/resources/google_run_jobs.md) | | [google_run_service](docs/resources/google_run_service.md) | [google_run_services](docs/resources/google_run_services.md) | | [google_runtime_config_config](docs/resources/google_runtime_config_config.md) | [google_runtime_config_configs](docs/resources/google_runtime_config_configs.md) | | [google_runtime_config_config_iam_binding](docs/resources/google_runtime_config_config_iam_binding.md) | No Plural Resource | diff --git a/docs/resources/google_run_job.md b/docs/resources/google_run_job.md index 2bba7978..f8a0e8f9 100644 --- a/docs/resources/google_run_job.md +++ b/docs/resources/google_run_job.md @@ -23,7 +23,7 @@ A `google_run_job` is used to test a Google Job resource ## Examples ``` -describe google_run_job(name: ' value_name') do +describe google_run_job(name: 'projects/{project}/locations/{location}/jobs/{value_name}') do it { should exist } its('name') { should cmp 'value_name' } its('uid') { should cmp 'value_uid' } @@ -41,10 +41,9 @@ describe google_run_job(name: ' value_name') do its('start_execution_token') { should cmp 'value_startexecutiontoken' } its('run_execution_token') { should cmp 'value_runexecutiontoken' } its('etag') { should cmp 'value_etag' } - end -describe google_run_job(name: "does_not_exit") do +describe google_run_job(name: "projects/{project}/locations/{location}/jobs/{does_not_exit}") do it { should_not exist } end ``` @@ -64,11 +63,11 @@ Properties that can be accessed from the `google_run_job` resource: * `labels`: Unstructured key value map that can be used to organize and categorize objects. User-provided labels are shared with Google's billing system, so they can be used to filter, or break down billing charges by team, component, environment, state, etc. For more information, visit https://cloud.google.com/resource-manager/docs/creating-managing-labels or https://cloud.google.com/run/docs/configuring/labels. Cloud Run API v2 does not support labels with `run.googleapis.com`, `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` namespaces, and they will be rejected. All system labels in v1 now have a corresponding field in v2 Job. - * `additional_properties`: + * `additional_properties`: * `annotations`: Unstructured key value map that may be set by external tools to store and arbitrary metadata. They are not queryable and should be preserved when modifying objects. Cloud Run API v2 does not support annotations with `run.googleapis.com`, `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` namespaces, and they will be rejected on new resources. All system annotations in v1 now have a corresponding field in v2 Job. This field follows Kubernetes annotations' namespacing, limits, and rules. - * `additional_properties`: + * `additional_properties`: * `create_time`: Output only. The creation time. @@ -109,11 +108,11 @@ Properties that can be accessed from the `google_run_job` resource: * `labels`: Unstructured key value map that can be used to organize and categorize objects. User-provided labels are shared with Google's billing system, so they can be used to filter, or break down billing charges by team, component, environment, state, etc. For more information, visit https://cloud.google.com/resource-manager/docs/creating-managing-labels or https://cloud.google.com/run/docs/configuring/labels. Cloud Run API v2 does not support labels with `run.googleapis.com`, `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` namespaces, and they will be rejected. All system labels in v1 now have a corresponding field in v2 ExecutionTemplate. - * `additional_properties`: + * `additional_properties`: * `annotations`: Unstructured key value map that may be set by external tools to store and arbitrary metadata. They are not queryable and should be preserved when modifying objects. Cloud Run API v2 does not support annotations with `run.googleapis.com`, `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` namespaces, and they will be rejected. All system annotations in v1 now have a corresponding field in v2 ExecutionTemplate. This field follows Kubernetes annotations' namespacing, limits, and rules. - * `additional_properties`: + * `additional_properties`: * `parallelism`: Specifies the maximum desired number of tasks the execution should run at given time. Must be <= task_count. When the job is run, if this field is 0 or unset, the maximum possible value will be used for that execution. The actual number of tasks running in steady state will be less than this number when there are fewer tasks waiting to be completed remaining, i.e. when the work left to do is less than max parallelism. @@ -149,7 +148,7 @@ Properties that can be accessed from the `google_run_job` resource: * `limits`: Only `memory` and `cpu` keys in the map are supported. Notes: * The only supported values for CPU are '1', '2', '4', and '8'. Setting 4 CPU requires at least 2Gi of memory. For more information, go to https://cloud.google.com/run/docs/configuring/cpu. * For supported 'memory' values and syntax, go to https://cloud.google.com/run/docs/configuring/memory-limits - * `additional_properties`: + * `additional_properties`: * `cpu_idle`: Determines whether CPU is only allocated during requests (true by default). However, if ResourceRequirements is set, the caller must explicitly set this field to true to preserve the default behavior. diff --git a/docs/resources/google_run_jobs.md b/docs/resources/google_run_jobs.md index 2427fb49..fc968557 100644 --- a/docs/resources/google_run_jobs.md +++ b/docs/resources/google_run_jobs.md @@ -23,8 +23,10 @@ A `google_run_jobs` is used to test a Google Job resource ## Examples ``` - describe google_run_jobs(parent: ' value_parent') do + describe google_run_jobs(parent: 'projects/{project}/locations/{location}') do it { should exist } + its('names') { should include 'value_name' } + its('creators') { should include 'value_creator' } end ``` diff --git a/libraries/google_run_job.rb b/libraries/google_run_job.rb index 46642ceb..c238b43e 100644 --- a/libraries/google_run_job.rb +++ b/libraries/google_run_job.rb @@ -104,7 +104,7 @@ def exists? end def to_s - "Job #{@params[:]}" + "Job #{@params[:name]}" end private @@ -114,6 +114,6 @@ def product_url(_ = nil) end def resource_base_url - '{{+name}}' + '{{name}}' end end diff --git a/libraries/google_run_jobs.rb b/libraries/google_run_jobs.rb index 80081dd7..b6764b93 100644 --- a/libraries/google_run_jobs.rb +++ b/libraries/google_run_jobs.rb @@ -124,6 +124,6 @@ def product_url(_ = nil) end def resource_base_url - '{{+parent}}/jobs' + '{{parent}}/jobs' end end diff --git a/test/integration/build/gcp-mm.tf b/test/integration/build/gcp-mm.tf index 385a181d..0866db18 100644 --- a/test/integration/build/gcp-mm.tf +++ b/test/integration/build/gcp-mm.tf @@ -266,7 +266,9 @@ variable "dataproc_metastore_federation" { variable "data_fusion_instance" { type = any } - +variable "cloud_run_jobs" { + type = any +} resource "google_compute_ssl_policy" "custom-ssl-policy" { name = var.ssl_policy["name"] min_tls_version = var.ssl_policy["min_tls_version"] @@ -2228,3 +2230,18 @@ resource "google_data_fusion_instance" "data_fusion_instance" { region = var.data_fusion_instance.location type = var.data_fusion_instance.type } + +resource "google_cloud_run_v2_job" "default" { + name = var.cloud_run_jobs.name + location = var.cloud_run_jobs.location + deletion_protection = var.cloud_run_jobs.deletion_protection + project = var.gcp_project_id + + template { + template { + containers { + image = var.cloud_run_jobs.image + } + } + } +} diff --git a/test/integration/configuration/mm-attributes.yml b/test/integration/configuration/mm-attributes.yml index 538260f1..ab0626a0 100644 --- a/test/integration/configuration/mm-attributes.yml +++ b/test/integration/configuration/mm-attributes.yml @@ -745,3 +745,9 @@ data_fusion_instance: name: "inspec-instance" location: "us-central1" type: "DEVELOPER" + +cloud_run_jobs: + name: "inspec-tutorial1-20230915-182543" + location: "us-central1" + deletion_protection: "false" + image: "us-central1-docker.pkg.dev/ppradhan/nas/balasubs_tutorial1_20230915_182543:latest" diff --git a/test/integration/verify/controls/google_run_job.rb b/test/integration/verify/controls/google_run_job.rb index 9e06ec4e..f4cdff3a 100644 --- a/test/integration/verify/controls/google_run_job.rb +++ b/test/integration/verify/controls/google_run_job.rb @@ -17,20 +17,20 @@ gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') job = input('job', value: { - "name": "value_name", - "parent": "value_parent", - "uid": "value_uid", - "generation": "value_generation", - "create_time": "value_createtime", + "name": "projects/ppradhan/locations/us-central1/jobs/inspec-tutorial1-20230915-182543", + "parent": "projects/ppradhan/locations/us-central1", + "uid": "605bd3e1-4bf0-4a9d-85ea-23eae08f51dc", + "generation": "1", + "create_time": "2024-10-10T13:34:58.675033Z", + "client": "cloud-console", "update_time": "value_updatetime", "delete_time": "value_deletetime", "expire_time": "value_expiretime", "creator": "value_creator", "last_modifier": "value_lastmodifier", - "client": "value_client", "client_version": "value_clientversion", - "launch_stage": "value_launchstage", - "observed_generation": "value_observedgeneration", + "launch_stage": "GA", + "observed_generation": "1", "start_execution_token": "value_startexecutiontoken", "run_execution_token": "value_runexecutiontoken", "etag": "value_etag" diff --git a/test/integration/verify/controls/google_run_jobs.rb b/test/integration/verify/controls/google_run_jobs.rb index 28a25eb5..bff5d293 100644 --- a/test/integration/verify/controls/google_run_jobs.rb +++ b/test/integration/verify/controls/google_run_jobs.rb @@ -16,21 +16,21 @@ gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') - job = input('job', value: { - "name": "value_name", - "parent": "value_parent", - "uid": "value_uid", - "generation": "value_generation", - "create_time": "value_createtime", +job = input('job', value: { + "name": "projects/ppradhan/locations/us-central1/jobs/inspec-tutorial1-20230915-182543", + "parent": "projects/ppradhan/locations/us-central1", + "uid": "605bd3e1-4bf0-4a9d-85ea-23eae08f51dc", + "generation": "1", + "create_time": "2024-10-10T13:34:58.675033Z", + "client": "cloud-console", "update_time": "value_updatetime", "delete_time": "value_deletetime", "expire_time": "value_expiretime", "creator": "value_creator", "last_modifier": "value_lastmodifier", - "client": "value_client", "client_version": "value_clientversion", - "launch_stage": "value_launchstage", - "observed_generation": "value_observedgeneration", + "launch_stage": "GA", + "observed_generation": "1", "start_execution_token": "value_startexecutiontoken", "run_execution_token": "value_runexecutiontoken", "etag": "value_etag" @@ -39,7 +39,7 @@ impact 1.0 title 'google_run_jobs resource test' - describe google_run_jobs(parent: job['parent']) do + describe google_run_jobs(parent: job['parent']) do it { should exist } end end