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

Commit

Permalink
More Cloudbuild Trigger Step support (#223)
Browse files Browse the repository at this point in the history
<!-- This change is generated by MagicModules. -->
/cc @chrisst
  • Loading branch information
modular-magician authored and chrisst committed Apr 2, 2019
1 parent d16dd13 commit e7b1ec4
Show file tree
Hide file tree
Showing 2 changed files with 321 additions and 3 deletions.
237 changes: 234 additions & 3 deletions lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,82 @@
define an entrypoint, the first element in args is used as the entrypoint,
and the remainder will be used as arguments.
required: false
env:
description:
- A list of environment variable definitions to be used when running a
step.
- The elements are of the form "KEY=VALUE" for the environment variable
"KEY" being given the value "VALUE".
required: false
id:
description:
- Unique identifier for this build step, used in `wait_for` to reference
this build step as a dependency.
required: false
entrypoint:
description:
- Entrypoint to be used instead of the build step image's default entrypoint.
- If unset, the image's default entrypoint is used .
required: false
dir:
description:
- Working directory to use when running this step's container.
- If this value is a relative path, it is relative to the build's working
directory. If this value is absolute, it may be outside the build's
working directory, in which case the contents of the path may not be
persisted across build step executions, unless a `volume` for that path
is specified.
- If the build specifies a `RepoSource` with `dir` and a step with a `dir`,
which specifies an absolute path, the `RepoSource` `dir` is ignored
for the step's execution.
required: false
secret_env:
description:
- A list of environment variables which are encrypted using a Cloud Key
Management Service crypto key. These values must be specified in the
build's `Secret`.
required: false
timeout:
description:
- Time limit for executing this build step. If not defined, the step has
no time limit and will be allowed to continue to run until either it
completes or the build itself times out.
required: false
timing:
description:
- Output only. Stores timing information for executing this build step.
required: false
volumes:
description:
- List of volumes to mount into the build step.
- Each volume is created as an empty volume prior to execution of the
build step. Upon completion of the build, volumes and their contents
are discarded.
- Using a named volume in only one step is not valid as it is indicative
of a build request with an incorrect configuration.
required: false
suboptions:
name:
description:
- Name of the volume to mount.
- Volume names must be unique per build step and must be valid names
for Docker volumes. Each named volume must be used by at least two
build steps.
required: false
path:
description:
- Path at which to mount the volume.
- Paths must be absolute and cannot conflict with other volume paths
on the same build step or with certain reserved volume paths.
required: false
wait_for:
description:
- The ID(s) of the step(s) that this build step depends on.
- This build step will not start until all the build steps in `wait_for`
have completed successfully. If `wait_for` is empty, this build step
will start when all previous build steps in the `Build.Steps` list have
completed successfully.
required: false
extends_documentation_fragment: gcp
notes:
- 'API Reference: U(https://cloud.google.com/cloud-build/docs/api/reference/rest/)'
Expand Down Expand Up @@ -359,6 +435,90 @@
the remainder will be used as arguments.
returned: success
type: list
env:
description:
- A list of environment variable definitions to be used when running a step.
- The elements are of the form "KEY=VALUE" for the environment variable
"KEY" being given the value "VALUE".
returned: success
type: list
id:
description:
- Unique identifier for this build step, used in `wait_for` to reference
this build step as a dependency.
returned: success
type: str
entrypoint:
description:
- Entrypoint to be used instead of the build step image's default entrypoint.
- If unset, the image's default entrypoint is used .
returned: success
type: str
dir:
description:
- Working directory to use when running this step's container.
- If this value is a relative path, it is relative to the build's working
directory. If this value is absolute, it may be outside the build's working
directory, in which case the contents of the path may not be persisted
across build step executions, unless a `volume` for that path is specified.
- If the build specifies a `RepoSource` with `dir` and a step with a `dir`,
which specifies an absolute path, the `RepoSource` `dir` is ignored for
the step's execution.
returned: success
type: str
secretEnv:
description:
- A list of environment variables which are encrypted using a Cloud Key
Management Service crypto key. These values must be specified in the build's
`Secret`.
returned: success
type: list
timeout:
description:
- Time limit for executing this build step. If not defined, the step has
no time limit and will be allowed to continue to run until either it completes
or the build itself times out.
returned: success
type: str
timing:
description:
- Output only. Stores timing information for executing this build step.
returned: success
type: str
volumes:
description:
- List of volumes to mount into the build step.
- Each volume is created as an empty volume prior to execution of the build
step. Upon completion of the build, volumes and their contents are discarded.
- Using a named volume in only one step is not valid as it is indicative
of a build request with an incorrect configuration.
returned: success
type: complex
contains:
name:
description:
- Name of the volume to mount.
- Volume names must be unique per build step and must be valid names
for Docker volumes. Each named volume must be used by at least two
build steps.
returned: success
type: str
path:
description:
- Path at which to mount the volume.
- Paths must be absolute and cannot conflict with other volume paths
on the same build step or with certain reserved volume paths.
returned: success
type: str
waitFor:
description:
- The ID(s) of the step(s) that this build step depends on.
- This build step will not start until all the build steps in `wait_for`
have completed successfully. If `wait_for` is empty, this build step will
start when all previous build steps in the `Build.Steps` list have completed
successfully.
returned: success
type: list
'''

################################################################################
Expand Down Expand Up @@ -402,7 +562,23 @@ def main():
options=dict(
tags=dict(type='list', elements='str'),
images=dict(type='list', elements='str'),
steps=dict(type='list', elements='dict', options=dict(name=dict(type='str'), args=dict(type='list', elements='str'))),
steps=dict(
type='list',
elements='dict',
options=dict(
name=dict(type='str'),
args=dict(type='list', elements='str'),
env=dict(type='list', elements='str'),
id=dict(type='str'),
entrypoint=dict(type='str'),
dir=dict(type='str'),
secret_env=dict(type='list', elements='str'),
timeout=dict(type='str'),
timing=dict(type='str'),
volumes=dict(type='list', elements='dict', options=dict(name=dict(type='str'), path=dict(type='str'))),
wait_for=dict(type='list', elements='str'),
),
),
),
),
),
Expand Down Expand Up @@ -627,10 +803,65 @@ def from_response(self):
return items

def _request_for_item(self, item):
return remove_nones_from_dict({u'name': item.get('name'), u'args': item.get('args')})
return remove_nones_from_dict(
{
u'name': item.get('name'),
u'args': item.get('args'),
u'env': item.get('env'),
u'id': item.get('id'),
u'entrypoint': item.get('entrypoint'),
u'dir': item.get('dir'),
u'secretEnv': item.get('secret_env'),
u'timeout': item.get('timeout'),
u'timing': item.get('timing'),
u'volumes': TriggerVolumesArray(item.get('volumes', []), self.module).to_request(),
u'waitFor': item.get('wait_for'),
}
)

def _response_from_item(self, item):
return remove_nones_from_dict(
{
u'name': item.get(u'name'),
u'args': item.get(u'args'),
u'env': item.get(u'env'),
u'id': item.get(u'id'),
u'entrypoint': item.get(u'entrypoint'),
u'dir': item.get(u'dir'),
u'secretEnv': item.get(u'secretEnv'),
u'timeout': item.get(u'timeout'),
u'timing': item.get(u'timing'),
u'volumes': TriggerVolumesArray(item.get(u'volumes', []), self.module).from_response(),
u'waitFor': item.get(u'waitFor'),
}
)


class TriggerVolumesArray(object):
def __init__(self, request, module):
self.module = module
if request:
self.request = request
else:
self.request = []

def to_request(self):
items = []
for item in self.request:
items.append(self._request_for_item(item))
return items

def from_response(self):
items = []
for item in self.request:
items.append(self._response_from_item(item))
return items

def _request_for_item(self, item):
return remove_nones_from_dict({u'name': item.get('name'), u'path': item.get('path')})

def _response_from_item(self, item):
return remove_nones_from_dict({u'name': item.get(u'name'), u'args': item.get(u'args')})
return remove_nones_from_dict({u'name': item.get(u'name'), u'path': item.get(u'path')})


if __name__ == '__main__':
Expand Down
87 changes: 87 additions & 0 deletions lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,93 @@
and the remainder will be used as arguments.
returned: success
type: list
env:
description:
- A list of environment variable definitions to be used when running
a step.
- The elements are of the form "KEY=VALUE" for the environment variable
"KEY" being given the value "VALUE".
returned: success
type: list
id:
description:
- Unique identifier for this build step, used in `wait_for` to reference
this build step as a dependency.
returned: success
type: str
entrypoint:
description:
- Entrypoint to be used instead of the build step image's default entrypoint.
- If unset, the image's default entrypoint is used .
returned: success
type: str
dir:
description:
- Working directory to use when running this step's container.
- If this value is a relative path, it is relative to the build's working
directory. If this value is absolute, it may be outside the build's
working directory, in which case the contents of the path may not
be persisted across build step executions, unless a `volume` for that
path is specified.
- If the build specifies a `RepoSource` with `dir` and a step with a
`dir`, which specifies an absolute path, the `RepoSource` `dir` is
ignored for the step's execution.
returned: success
type: str
secretEnv:
description:
- A list of environment variables which are encrypted using a Cloud
Key Management Service crypto key. These values must be specified
in the build's `Secret`.
returned: success
type: list
timeout:
description:
- Time limit for executing this build step. If not defined, the step
has no time limit and will be allowed to continue to run until either
it completes or the build itself times out.
returned: success
type: str
timing:
description:
- Output only. Stores timing information for executing this build step.
returned: success
type: str
volumes:
description:
- List of volumes to mount into the build step.
- Each volume is created as an empty volume prior to execution of the
build step. Upon completion of the build, volumes and their contents
are discarded.
- Using a named volume in only one step is not valid as it is indicative
of a build request with an incorrect configuration.
returned: success
type: complex
contains:
name:
description:
- Name of the volume to mount.
- Volume names must be unique per build step and must be valid names
for Docker volumes. Each named volume must be used by at least
two build steps.
returned: success
type: str
path:
description:
- Path at which to mount the volume.
- Paths must be absolute and cannot conflict with other volume paths
on the same build step or with certain reserved volume paths.
returned: success
type: str
waitFor:
description:
- The ID(s) of the step(s) that this build step depends on.
- This build step will not start until all the build steps in `wait_for`
have completed successfully. If `wait_for` is empty, this build step
will start when all previous build steps in the `Build.Steps` list
have completed successfully.
returned: success
type: list
'''

################################################################################
Expand Down

0 comments on commit e7b1ec4

Please sign in to comment.