Module: Cody::Dsl::Project
Defined Under Namespace
Modules: Ssm
Constant Summary collapse
- PROPERTIES =
%w[ Artifacts BadgeEnabled Cache Description EncryptionKey Environment LogsConfig Name QueuedTimeoutInMinutes SecondaryArtifacts SecondarySources ServiceRole Source Tags TimeoutInMinutes Triggers VpcConfig ]
Instance Method Summary collapse
- #buildspec(file = ".cody/buildspec.yaml") ⇒ Object (also: #build_spec)
- #environment_variables(vars) ⇒ Object
- #github_source(options = {}) ⇒ Object
-
#github_token(token) ⇒ Object
So it looks like the auth resource property doesnt really get used.
-
#github_url(url) ⇒ Object
Convenience wrapper methods.
- #linux_environment(options = {}) ⇒ Object
- #linux_image(name) ⇒ Object
- #local_cache(enable = true) ⇒ Object
- #type ⇒ Object
Methods included from Ssm
Instance Method Details
#buildspec(file = ".cody/buildspec.yaml") ⇒ Object Also known as: build_spec
35 36 37 |
# File 'lib/cody/dsl/project.rb', line 35 def buildspec(file=".cody/buildspec.yaml") @properties[:Source][:BuildSpec] = file end |
#environment_variables(vars) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/cody/dsl/project.rb', line 90 def environment_variables(vars) # Storing @mapped_env_vars as instance variable for later usage in linux_environment @mapped_env_vars = vars.map { |k,v| k, v = k.to_s, v.to_s if v =~ /^ssm:/ { Type: "PARAMETER_STORE", Name: k, Value: v.sub('ssm:','') } else { Type: "PLAINTEXT", Name: k, Value: v } end } @properties[:Environment] ||= {} @properties[:Environment][:EnvironmentVariables] = @mapped_env_vars end |
#github_source(options = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/cody/dsl/project.rb', line 50 def github_source(={}) source = { Type: "GITHUB", Location: [:Location], GitCloneDepth: 1, GitSubmodulesConfig: { fetch_submodules: true }, BuildSpec: [:BuildSpec] || ".cody/buildspec.yml", # options[:Buildspec] accounts for type already ReportBuildStatus: true, } if [:OauthToken] source[:Auth] = { Type: "OAUTH", Resource: [:OauthToken], } end @properties[:Source] = source end |
#github_token(token) ⇒ Object
So it looks like the auth resource property doesnt really get used. Instead an account level credential is worked. Refer to: github.com/tongueroo/cody/blob/master/readme/github_oauth.md
Keeping this method around in case the CloudFormation method works one day, or end up figuring out to use it properly.
46 47 48 |
# File 'lib/cody/dsl/project.rb', line 46 def github_token(token) @properties[:Source][:Auth][:Resource] = token end |
#github_url(url) ⇒ Object
Convenience wrapper methods
31 32 33 |
# File 'lib/cody/dsl/project.rb', line 31 def github_url(url) @properties[:Source][:Location] = url end |
#linux_environment(options = {}) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/cody/dsl/project.rb', line 74 def linux_environment(={}) image = [:Image] || "aws/codebuild/amazonlinux2-x86_64-standard:2.0" env = { ComputeType: [:ComputeType] || "BUILD_GENERAL1_SMALL", ImagePullCredentialsType: "CODEBUILD", # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-environment.html#cfn-codebuild-project-environment-imagepullcredentialstype PrivilegedMode: true, Image: image, Type: "LINUX_CONTAINER" } # @mapped_env_vars is in memory env[:EnvironmentVariables] = @mapped_env_vars if @mapped_env_vars # options has highest precedence env[:EnvironmentVariables] = [:EnvironmentVariables] if [:EnvironmentVariables] @properties[:Environment] = env end |
#linux_image(name) ⇒ Object
70 71 72 |
# File 'lib/cody/dsl/project.rb', line 70 def linux_image(name) linux_environment(Image: name) end |
#local_cache(enable = true) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/cody/dsl/project.rb', line 104 def local_cache(enable=true) cache = if enable { Type: "LOCAL", Modes: [ "LOCAL_DOCKER_LAYER_CACHE", "LOCAL_SOURCE_CACHE", "LOCAL_CUSTOM_CACHE" ] } else {type: "NO_CACHE"} end @properties[:Cache] = cache end |
#type ⇒ Object
120 121 122 |
# File 'lib/cody/dsl/project.rb', line 120 def type @options[:type] # should be lowercase end |