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

Added pubsubConfig and webhookConfig support to the cloud build resource. #533

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added pubsubConfig and webhookConfig support to the cloud build resou…
…rce. (#4931)

Co-authored-by: Sumit Madan <sumit.madan@pantheon.io>
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician and iamsumit committed Jul 9, 2021
commit 6baf6449e6639710d90fa5159e4bb08a7fa5dd4d
16 changes: 16 additions & 0 deletions docs/resources/google_cloudbuild_trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ Properties that can be accessed from the `google_cloudbuild_trigger` resource:

* `tag`: Regex of tags to match. Specify only one of branch or tag.

* `pubsub_config`: PubsubConfig describes the configuration of a trigger that creates a build whenever a Pub/Sub message is published.

* `subscription`: Output only. Name of the subscription.

* `topic`: The name of the topic from which this subscription is receiving messages.

* `service_account_email`: Service account that will make the push request.

* `state`: Potential issues with the underlying Pub/Sub subscription configuration. Only populated on get requests.

* `webhook_config`: WebhookConfig describes the configuration of a trigger that creates a build whenever a webhook is sent to a trigger's webhook URL.

* `secret`: Resource name for the secret required as a URL parameter.

* `state`: Potential issues with the underlying Pub/Sub subscription configuration. Only populated on get requests.

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

* `source`: The location of the source files to build.
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/google_cloudbuild_triggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ See [google_cloudbuild_trigger.md](google_cloudbuild_trigger.md) for more detail
* `included_files`: an array of `google_cloudbuild_trigger` included_files
* `trigger_templates`: an array of `google_cloudbuild_trigger` trigger_template
* `githubs`: an array of `google_cloudbuild_trigger` github
* `pubsub_configs`: an array of `google_cloudbuild_trigger` pubsub_config
* `webhook_configs`: an array of `google_cloudbuild_trigger` webhook_config
* `builds`: an array of `google_cloudbuild_trigger` build

## Filter Criteria
Expand Down
43 changes: 43 additions & 0 deletions libraries/google/cloudbuild/property/trigger_pubsub_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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 TriggerPubsubConfig
attr_reader :subscription

attr_reader :topic

attr_reader :service_account_email

attr_reader :state

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@subscription = args['subscription']
@topic = args['topic']
@service_account_email = args['service_account_email']
@state = args['state']
end

def to_s
"#{@parent_identifier} TriggerPubsubConfig"
end
end
end
end
end
37 changes: 37 additions & 0 deletions libraries/google/cloudbuild/property/trigger_webhook_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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 TriggerWebhookConfig
attr_reader :secret

attr_reader :state

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@secret = args['secret']
@state = args['state']
end

def to_s
"#{@parent_identifier} TriggerWebhookConfig"
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 @@ -28,7 +28,9 @@
require 'google/cloudbuild/property/trigger_github'
require 'google/cloudbuild/property/trigger_github_pull_request'
require 'google/cloudbuild/property/trigger_github_push'
require 'google/cloudbuild/property/trigger_pubsub_config'
require 'google/cloudbuild/property/trigger_trigger_template'
require 'google/cloudbuild/property/trigger_webhook_config'

# A provider to manage Cloud Build resources.
class CloudBuildTrigger < GcpResourceBase
Expand All @@ -49,6 +51,8 @@ class CloudBuildTrigger < GcpResourceBase
attr_reader :included_files
attr_reader :trigger_template
attr_reader :github
attr_reader :pubsub_config
attr_reader :webhook_config
attr_reader :build

def initialize(params)
Expand All @@ -71,6 +75,8 @@ def parse
@included_files = @fetched['includedFiles']
@trigger_template = GoogleInSpec::CloudBuild::Property::TriggerTriggerTemplate.new(@fetched['triggerTemplate'], to_s)
@github = GoogleInSpec::CloudBuild::Property::TriggerGithub.new(@fetched['github'], to_s)
@pubsub_config = GoogleInSpec::CloudBuild::Property::TriggerPubsubConfig.new(@fetched['pubsubConfig'], to_s)
@webhook_config = GoogleInSpec::CloudBuild::Property::TriggerWebhookConfig.new(@fetched['webhookConfig'], to_s)
@build = GoogleInSpec::CloudBuild::Property::TriggerBuild.new(@fetched['build'], to_s)
end

Expand Down
4 changes: 4 additions & 0 deletions libraries/google_cloudbuild_triggers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class CloudBuildTriggers < GcpResourceBase
filter_table_config.add(:included_files, field: :included_files)
filter_table_config.add(:trigger_templates, field: :trigger_template)
filter_table_config.add(:githubs, field: :github)
filter_table_config.add(:pubsub_configs, field: :pubsub_config)
filter_table_config.add(:webhook_configs, field: :webhook_config)
filter_table_config.add(:builds, field: :build)

filter_table_config.connect(self, :table)
Expand Down Expand Up @@ -87,6 +89,8 @@ def transformers
'includedFiles' => ->(obj) { return :included_files, obj['includedFiles'] },
'triggerTemplate' => ->(obj) { return :trigger_template, GoogleInSpec::CloudBuild::Property::TriggerTriggerTemplate.new(obj['triggerTemplate'], to_s) },
'github' => ->(obj) { return :github, GoogleInSpec::CloudBuild::Property::TriggerGithub.new(obj['github'], to_s) },
'pubsubConfig' => ->(obj) { return :pubsub_config, GoogleInSpec::CloudBuild::Property::TriggerPubsubConfig.new(obj['pubsubConfig'], to_s) },
'webhookConfig' => ->(obj) { return :webhook_config, GoogleInSpec::CloudBuild::Property::TriggerWebhookConfig.new(obj['webhookConfig'], to_s) },
'build' => ->(obj) { return :build, GoogleInSpec::CloudBuild::Property::TriggerBuild.new(obj['build'], to_s) },
}
end
Expand Down