Skip to content

Commit

Permalink
Merge pull request #103 from modular-magician/trigger-healthcheck-add…
Browse files Browse the repository at this point in the history
…itions

Trigger healthcheck additions
  • Loading branch information
Stuart Paterson authored Jan 30, 2019
2 parents f79effb + ae2bb20 commit aeb68b2
Show file tree
Hide file tree
Showing 25 changed files with 1,090 additions and 11 deletions.
65 changes: 65 additions & 0 deletions docs/resources/google_cloudbuild_trigger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: About the Trigger resource
platform: gcp
---


## Syntax
A `google_cloudbuild_trigger` is used to test a Google Trigger resource

## Examples
```
describe google_cloudbuild_triggers(project: 'chef-gcp-inspec') do
its('count') { should eq 1 }
end
google_cloudbuild_triggers(project: 'chef-gcp-inspec').ids.each do |id|
describe google_cloudbuild_trigger(project: 'chef-gcp-inspec', id: id) do
its('filename') { should eq 'cloudbuild.yaml' }
its('trigger_template.branch_name') { should eq 'trigger-branch' }
its('trigger_template.repo_name') { should eq 'trigger-repo' }
its('trigger_template.project_id') { should eq 'trigger-project' }
end
end
```

## Properties
Properties that can be accessed from the `google_cloudbuild_trigger` resource:

* `id`: The unique identifier for the trigger.

* `description`: Human-readable description of the trigger.

* `disabled`: Whether the trigger is disabled or not. If true, the trigger will never result in a build.

* `create_time`: Time when the trigger was created.

* `substitutions`: Substitutions data for Build resource.

* `filename`: Path, from the source root, to a file whose contents is used for the template.

* `ignored_files`: ignoredFiles and includedFiles are file glob matches using http://godoc/pkg/path/filepath#Match extended with support for `**`. If ignoredFiles and changed files are both empty, then they are not used to determine whether or not to trigger a build. If ignoredFiles is not empty, then we ignore any files that match any of the ignored_file globs. If the change has no files that are outside of the ignoredFiles globs, then we do not trigger a build.

* `included_files`: ignoredFiles and includedFiles are file glob matches using http://godoc/pkg/path/filepath#Match extended with support for `**`. If any of the files altered in the commit pass the ignoredFiles filter and includedFiles is empty, then as far as this filter is concerned, we should trigger the build. If any of the files altered in the commit pass the ignoredFiles filter and includedFiles is not empty, then we make sure that at least one of those files matches a includedFiles glob. If not, then we do not trigger a build.

* `trigger_template`: Template describing the types of source changes to trigger a build. Branch and tag names in trigger templates are interpreted as regular expressions. Any branch or tag change that matches that regular expression will trigger a build.

* `projectId`: ID of the project that owns the Cloud Source Repository. If omitted, the project ID requesting the build is assumed.

* `repoName`: Name of the Cloud Source Repository. If omitted, the name "default" is assumed.

* `dir`: Directory, relative to the source root, in which to run the build. This must be a relative path. If a step's dir is specified and is an absolute path, this value is ignored for that step's execution.

* `branchName`: Name of the branch to build.

* `tagName`: Name of the tag to build.

* `commitSha`: Explicit commit SHA to build.

* `build`: Contents of the build template.

* `tags`: Tags for annotation of a Build. These are not docker tags.

* `images`: A list of images to be pushed upon the successful completion of all build steps. The images are pushed using the builder service account's credentials. The digests of the pushed images will be stored in the Build resource's results field. If any of the images fail to be pushed, the build status is marked FAILURE.

* `steps`: The operations to be performed on the workspace.
43 changes: 43 additions & 0 deletions docs/resources/google_cloudbuild_triggers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: About the Trigger resource
platform: gcp
---


## Syntax
A `google_cloudbuild_triggers` is used to test a Google Trigger resource

## Examples
```
describe google_cloudbuild_triggers(project: 'chef-gcp-inspec') do
its('count') { should eq 1 }
end
google_cloudbuild_triggers(project: 'chef-gcp-inspec').ids.each do |id|
describe google_cloudbuild_trigger(project: 'chef-gcp-inspec', id: id) do
its('filename') { should eq 'cloudbuild.yaml' }
its('trigger_template.branch_name') { should eq 'trigger-branch' }
its('trigger_template.repo_name') { should eq 'trigger-repo' }
its('trigger_template.project_id') { should eq 'trigger-project' }
end
end
```

## Properties
Properties that can be accessed from the `google_cloudbuild_triggers` resource:

See [google_cloudbuild_trigger.md](google_cloudbuild_trigger.md) for more detailed information
* `ids`: an array of `google_cloudbuild_trigger` id
* `descriptions`: an array of `google_cloudbuild_trigger` description
* `disableds`: an array of `google_cloudbuild_trigger` disabled
* `create_times`: an array of `google_cloudbuild_trigger` create_time
* `substitutions`: an array of `google_cloudbuild_trigger` substitutions
* `filenames`: an array of `google_cloudbuild_trigger` filename
* `ignored_files`: an array of `google_cloudbuild_trigger` ignored_files
* `included_files`: an array of `google_cloudbuild_trigger` included_files
* `trigger_templates`: an array of `google_cloudbuild_trigger` trigger_template
* `builds`: an array of `google_cloudbuild_trigger` build

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
with `where` as a block or a method.
94 changes: 94 additions & 0 deletions docs/resources/google_compute_health_check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
title: About the HealthCheck resource
platform: gcp
---


## Syntax
A `google_compute_health_check` is used to test a Google HealthCheck resource

## Examples
```
describe google_compute_health_check(project: 'chef-gcp-inspec', name: 'inspec-gcp-health-check') do
it { should exist }
its('timeout_sec') { should eq '10' }
its('tcp_health_check.port') { should eq '80' }
end
describe google_compute_health_check(project: 'chef-gcp-inspec', name: 'nonexistent') do
it { should_not exist }
end
```

## Properties
Properties that can be accessed from the `google_compute_health_check` resource:

* `check_interval_sec`: How often (in seconds) to send a health check. The default value is 5 seconds.

* `creation_timestamp`: Creation timestamp in RFC3339 text format.

* `description`: An optional description of this resource. Provide this property when you create the resource.

* `healthy_threshold`: A so-far unhealthy instance will be marked healthy after this many consecutive successes. The default value is 2.

* `id`: The unique identifier for the resource. This identifier is defined by the server.

* `name`: Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

* `timeout_sec`: How long (in seconds) to wait before claiming failure. The default value is 5 seconds. It is invalid for timeoutSec to have greater value than checkIntervalSec.

* `unhealthy_threshold`: A so-far healthy instance will be marked unhealthy after this many consecutive failures. The default value is 2.

* `type`: Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If not specified, the default is TCP. Exactly one of the protocol-specific health check field must be specified, which must match type field.

* `http_health_check`: A nested object resource

* `host`: The value of the host header in the HTTP health check request. If left empty (default value), the public IP on behalf of which this health check is performed will be used.

* `requestPath`: The request path of the HTTP health check request. The default value is /.

* `response`: The bytes to match against the beginning of the response data. If left empty (the default value), any response will indicate health. The response data can only be ASCII.

* `port`: The TCP port number for the HTTP health check request. The default value is 80.

* `portName`: Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name are defined, port takes precedence.

* `proxyHeader`: Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE.

* `https_health_check`: A nested object resource

* `host`: The value of the host header in the HTTPS health check request. If left empty (default value), the public IP on behalf of which this health check is performed will be used.

* `requestPath`: The request path of the HTTPS health check request. The default value is /.

* `response`: The bytes to match against the beginning of the response data. If left empty (the default value), any response will indicate health. The response data can only be ASCII.

* `port`: The TCP port number for the HTTPS health check request. The default value is 443.

* `portName`: Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name are defined, port takes precedence.

* `proxyHeader`: Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE.

* `tcp_health_check`: A nested object resource

* `request`: The application data to send once the TCP connection has been established (default value is empty). If both request and response are empty, the connection establishment alone will indicate health. The request data can only be ASCII.

* `response`: The bytes to match against the beginning of the response data. If left empty (the default value), any response will indicate health. The response data can only be ASCII.

* `port`: The TCP port number for the TCP health check request. The default value is 443.

* `portName`: Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name are defined, port takes precedence.

* `proxyHeader`: Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE.

* `ssl_health_check`: A nested object resource

* `request`: The application data to send once the SSL connection has been established (default value is empty). If both request and response are empty, the connection establishment alone will indicate health. The request data can only be ASCII.

* `response`: The bytes to match against the beginning of the response data. If left empty (the default value), any response will indicate health. The response data can only be ASCII.

* `port`: The TCP port number for the SSL health check request. The default value is 443.

* `portName`: Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name are defined, port takes precedence.

* `proxyHeader`: Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE.
38 changes: 38 additions & 0 deletions docs/resources/google_compute_health_checks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: About the HealthCheck resource
platform: gcp
---


## Syntax
A `google_compute_health_checks` is used to test a Google HealthCheck resource

## Examples
```
describe google_compute_health_checks(project: 'chef-gcp-inspec') do
its('names') { should include 'inspec-gcp-health-check' }
its('timeout_secs') { should include '10' }
end
```

## Properties
Properties that can be accessed from the `google_compute_health_checks` resource:

See [google_compute_health_check.md](google_compute_health_check.md) for more detailed information
* `check_interval_secs`: an array of `google_compute_health_check` check_interval_sec
* `creation_timestamps`: an array of `google_compute_health_check` creation_timestamp
* `descriptions`: an array of `google_compute_health_check` description
* `healthy_thresholds`: an array of `google_compute_health_check` healthy_threshold
* `ids`: an array of `google_compute_health_check` id
* `names`: an array of `google_compute_health_check` name
* `timeout_secs`: an array of `google_compute_health_check` timeout_sec
* `unhealthy_thresholds`: an array of `google_compute_health_check` unhealthy_threshold
* `types`: an array of `google_compute_health_check` type
* `http_health_checks`: an array of `google_compute_health_check` http_health_check
* `https_health_checks`: an array of `google_compute_health_check` https_health_check
* `tcp_health_checks`: an array of `google_compute_health_check` tcp_health_check
* `ssl_health_checks`: an array of `google_compute_health_check` ssl_health_check

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
with `where` as a block or a method.
1 change: 0 additions & 1 deletion docs/resources/google_pubsub_subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ end
describe google_pubsub_subscription(project: 'chef-gcp-inspec', name: 'nonexistent') do
it { should_not exist }
end
```

## Properties
Expand Down
10 changes: 6 additions & 4 deletions docs/resources/google_pubsub_topics.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ A `google_pubsub_topics` is used to test a Google Topic resource
describe google_pubsub_topics(project: 'chef-gcp-inspec') do
it { should exist }
its('names') { should include 'inspec-gcp-topic' }
its('count') { should eq 1 }
its('count') { should be >=1 }
end
google_pubsub_topics(project: 'chef-gcp-inspec').names.each do |topic_name|
describe google_pubsub_topic(project: 'chef-gcp-inspec', name: topic_name) do
its('name') { should eq 'inspec-gcp-topic' }
describe.one do
google_pubsub_topics(project: 'chef-gcp-inspec').names.each do |topic_name|
describe google_pubsub_topic(project: 'chef-gcp-inspec', name: topic_name) do
it { should exist }
end
end
end
```
Expand Down
4 changes: 1 addition & 3 deletions libraries/gcp_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ def fetch_auth
unless @service_account_file.nil?
return Network::Authorization.new.for!(
[
'https://www.googleapis.com/auth/compute.readonly',
'https://www.googleapis.com/auth/pubsub',
'https://www.googleapis.com/auth/ndev.clouddns.readonly',
'https://www.googleapis.com/auth/cloud-platform',
],
).from_service_account_json!(
@service_account_file,
Expand Down
36 changes: 36 additions & 0 deletions libraries/google/cloudbuild/property/trigger_build.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/cloudbuild/property/trigger_steps'
module GoogleInSpec
module CloudBuild
module Property
class TriggerBuild
attr_reader :tags

attr_reader :images

attr_reader :steps

def initialize(args = nil)
return if args.nil?
@tags = args['tags']
@images = args['images']
@steps = GoogleInSpec::CloudBuild::Property::TriggerStepsArray.parse(args['steps'])
end
end
end
end
end
40 changes: 40 additions & 0 deletions libraries/google/cloudbuild/property/trigger_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
module CloudBuild
module Property
class TriggerSteps
attr_reader :name

attr_reader :args

def initialize(args = nil)
return if args.nil?
@name = args['name']
@args = args['args']
end
end

class TriggerStepsArray
def self.parse(value)
return if value.nil?
return TriggerSteps.new(value) unless value.is_a?(::Array)
value.map { |v| TriggerSteps.new(v) }
end
end
end
end
end
Loading

0 comments on commit aeb68b2

Please sign in to comment.