Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Adding Missing Cloud Build Attributes (#3627) (#426)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Aug 5, 2020
1 parent 64ec4dc commit 660eaf7
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 0 deletions.
42 changes: 42 additions & 0 deletions docs/resources/google_cloudbuild_trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Properties that can be accessed from the `google_cloudbuild_trigger` resource:

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

* `tags`: Tags for annotation of a BuildTrigger

* `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.
Expand Down Expand Up @@ -87,12 +89,52 @@ Properties that can be accessed from the `google_cloudbuild_trigger` resource:

* `build`: Contents of the build template. Either a filename or build template must be provided.

* `source`: The location of the source files to build.

* `storage_source`: Location of the source in an archive file in Google Cloud Storage.

* `bucket`: Google Cloud Storage bucket containing the source.

* `object`: Google Cloud Storage object containing the source. This object must be a gzipped archive file (.tar.gz) containing source to build.

* `generation`: Google Cloud Storage generation for the object. If the generation is omitted, the latest generation will be used

* `repo_source`: Location of the source in a Google Cloud Source Repository.

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

* `repo_name`: Name of the Cloud Source Repository.

* `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.

* `invert_regex`: Only trigger a build if the revision regex does NOT match the revision regex.

* `substitutions`: Substitutions to use in a triggered build. Should only be used with triggers.run

* `branch_name`: Regex matching branches to build. Exactly one a of branch name, tag, or commit SHA must be provided. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax

* `tag_name`: Regex matching tags to build. Exactly one a of branch name, tag, or commit SHA must be provided. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax

* `commit_sha`: Explicit commit SHA to build. Exactly one a of branch name, tag, or commit SHA must be provided.

* `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.

* `substitutions`: Substitutions data for Build resource.

* `queue_ttl`: TTL in queue for this build. If provided and the build is enqueued longer than this value, the build will expire and the build status will be EXPIRED. The TTL starts ticking from createTime. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".

* `logs_bucket`: Google Cloud Storage bucket where logs should be written. Logs file names will be of the format ${logsBucket}/log-${build_id}.txt.

* `timeout`: Amount of time that this build should be allowed to run, to second granularity. If this amount of time elapses, work on the build will cease and the build status will be TIMEOUT. This timeout must be equal to or greater than the sum of the timeouts for build steps within the build. The expected format is the number of seconds followed by s. Default time is ten minutes (600s).

* `secrets`: Secrets to decrypt using Cloud Key Management Service.

* `kms_key_name`: Cloud KMS key name to use to decrypt these envs.

* `secret_env`: Map of environment variable name to its encrypted value. Secret environment variables must be unique across all of a build's secrets, and must be used by at least one build step. Values can be at most 64 KB in size. There can be at most 100 secret values across all of a build's secrets.

* `steps`: The operations to be performed on the workspace.

* `name`: The name of the container image that will run this particular build step. If the image is available in the host's Docker daemon's cache, it will be run directly. If not, the host will attempt to pull the image first, using the builder service account's credentials if necessary. The Docker daemon's cache will already have the latest versions of all of the officially supported build steps (https://github.com/GoogleCloudPlatform/cloud-builders). The Docker daemon will also have cached many of the layers for some popular images, like "ubuntu", "debian", but they will be refreshed at the time you attempt to use them. If you built an image in a previous build step, it will be stored in the host's Docker daemon's cache and is available to use as the name for a later build step.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/google_cloudbuild_triggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ See [google_cloudbuild_trigger.md](google_cloudbuild_trigger.md) for more detail
* `ids`: an array of `google_cloudbuild_trigger` id
* `names`: an array of `google_cloudbuild_trigger` name
* `descriptions`: an array of `google_cloudbuild_trigger` description
* `tags`: an array of `google_cloudbuild_trigger` tags
* `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
Expand Down
19 changes: 19 additions & 0 deletions libraries/google/cloudbuild/property/trigger_build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,44 @@
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/cloudbuild/property/trigger_build_secrets'
require 'google/cloudbuild/property/trigger_build_source'
require 'google/cloudbuild/property/trigger_build_source_repo_source'
require 'google/cloudbuild/property/trigger_build_source_storage_source'
require 'google/cloudbuild/property/trigger_build_steps'
module GoogleInSpec
module CloudBuild
module Property
class TriggerBuild
attr_reader :source

attr_reader :tags

attr_reader :images

attr_reader :substitutions

attr_reader :queue_ttl

attr_reader :logs_bucket

attr_reader :timeout

attr_reader :secrets

attr_reader :steps

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@source = GoogleInSpec::CloudBuild::Property::TriggerBuildSource.new(args['source'], to_s)
@tags = args['tags']
@images = args['images']
@substitutions = args['substitutions']
@queue_ttl = args['queueTtl']
@logs_bucket = args['logsBucket']
@timeout = args['timeout']
@secrets = GoogleInSpec::CloudBuild::Property::TriggerBuildSecretsArray.parse(args['secrets'], to_s)
@steps = GoogleInSpec::CloudBuild::Property::TriggerBuildStepsArray.parse(args['steps'], to_s)
end

Expand Down
45 changes: 45 additions & 0 deletions libraries/google/cloudbuild/property/trigger_build_secrets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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 TriggerBuildSecrets
attr_reader :kms_key_name

attr_reader :secret_env

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@kms_key_name = args['kmsKeyName']
@secret_env = args['secretEnv']
end

def to_s
"#{@parent_identifier} TriggerBuildSecrets"
end
end

class TriggerBuildSecretsArray
def self.parse(value, parent_identifier)
return if value.nil?
return TriggerBuildSecrets.new(value, parent_identifier) unless value.is_a?(::Array)
value.map { |v| TriggerBuildSecrets.new(v, parent_identifier) }
end
end
end
end
end
39 changes: 39 additions & 0 deletions libraries/google/cloudbuild/property/trigger_build_source.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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_build_source_repo_source'
require 'google/cloudbuild/property/trigger_build_source_storage_source'
module GoogleInSpec
module CloudBuild
module Property
class TriggerBuildSource
attr_reader :storage_source

attr_reader :repo_source

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@storage_source = GoogleInSpec::CloudBuild::Property::TriggerBuildSourceStorageSource.new(args['storageSource'], to_s)
@repo_source = GoogleInSpec::CloudBuild::Property::TriggerBuildSourceRepoSource.new(args['repoSource'], to_s)
end

def to_s
"#{@parent_identifier} TriggerBuildSource"
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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 TriggerBuildSourceRepoSource
attr_reader :project_id

attr_reader :repo_name

attr_reader :dir

attr_reader :invert_regex

attr_reader :substitutions

attr_reader :branch_name

attr_reader :tag_name

attr_reader :commit_sha

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@project_id = args['projectId']
@repo_name = args['repoName']
@dir = args['dir']
@invert_regex = args['invertRegex']
@substitutions = args['substitutions']
@branch_name = args['branchName']
@tag_name = args['tagName']
@commit_sha = args['commitSha']
end

def to_s
"#{@parent_identifier} TriggerBuildSourceRepoSource"
end
end
end
end
end
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 TriggerBuildSourceStorageSource
attr_reader :bucket

attr_reader :object

attr_reader :generation

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@bucket = args['bucket']
@object = args['object']
@generation = args['generation']
end

def to_s
"#{@parent_identifier} TriggerBuildSourceStorageSource"
end
end
end
end
end
6 changes: 6 additions & 0 deletions libraries/google_cloudbuild_trigger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
# ----------------------------------------------------------------------------
require 'gcp_backend'
require 'google/cloudbuild/property/trigger_build'
require 'google/cloudbuild/property/trigger_build_secrets'
require 'google/cloudbuild/property/trigger_build_source'
require 'google/cloudbuild/property/trigger_build_source_repo_source'
require 'google/cloudbuild/property/trigger_build_source_storage_source'
require 'google/cloudbuild/property/trigger_build_steps'
require 'google/cloudbuild/property/trigger_github'
require 'google/cloudbuild/property/trigger_github_pull_request'
Expand All @@ -31,6 +35,7 @@ class CloudBuildTrigger < GcpResourceBase
attr_reader :id
attr_reader :name
attr_reader :description
attr_reader :tags
attr_reader :disabled
attr_reader :create_time
attr_reader :substitutions
Expand All @@ -52,6 +57,7 @@ def parse
@id = @fetched['id']
@name = @fetched['name']
@description = @fetched['description']
@tags = @fetched['tags']
@disabled = @fetched['disabled']
@create_time = parse_time_string(@fetched['createTime'])
@substitutions = @fetched['substitutions']
Expand Down
2 changes: 2 additions & 0 deletions libraries/google_cloudbuild_triggers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CloudBuildTriggers < GcpResourceBase
filter_table_config.add(:ids, field: :id)
filter_table_config.add(:names, field: :name)
filter_table_config.add(:descriptions, field: :description)
filter_table_config.add(:tags, field: :tags)
filter_table_config.add(:disableds, field: :disabled)
filter_table_config.add(:create_times, field: :create_time)
filter_table_config.add(:substitutions, field: :substitutions)
Expand Down Expand Up @@ -77,6 +78,7 @@ def transformers
'id' => ->(obj) { return :id, obj['id'] },
'name' => ->(obj) { return :name, obj['name'] },
'description' => ->(obj) { return :description, obj['description'] },
'tags' => ->(obj) { return :tags, obj['tags'] },
'disabled' => ->(obj) { return :disabled, obj['disabled'] },
'createTime' => ->(obj) { return :create_time, parse_time_string(obj['createTime']) },
'substitutions' => ->(obj) { return :substitutions, obj['substitutions'] },
Expand Down

0 comments on commit 660eaf7

Please sign in to comment.