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
-
#git_branch(branch_or_tag) ⇒ Object
Convenience wrapper methods.
-
#git_provider(type = "GITHUB") ⇒ Object
Convenience wrapper methods.
- #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
45 46 47 |
# File 'lib/cody/dsl/project.rb', line 45 def buildspec(file=".cody/buildspec.yaml") @properties[:Source][:BuildSpec] = file end |
#environment_variables(vars) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/cody/dsl/project.rb', line 103 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 |
#git_branch(branch_or_tag) ⇒ Object
Convenience wrapper methods
41 42 43 |
# File 'lib/cody/dsl/project.rb', line 41 def git_branch(branch_or_tag) @properties[:SourceVersion] = branch_or_tag end |
#git_provider(type = "GITHUB") ⇒ Object
Convenience wrapper methods
36 37 38 |
# File 'lib/cody/dsl/project.rb', line 36 def git_provider(type="GITHUB") @properties[:Source][:Type] = type end |
#github_source(options = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/cody/dsl/project.rb', line 60 def github_source(={}) source = { Type: [:Type] || "GITHUB", Location: [:Location], GitCloneDepth: 1, GitSubmodulesConfig: { fetch_submodules: true }, BuildSpec: [:BuildSpec] || ".cody/buildspec.yml", # options[:Buildspec] accounts for type already } if source[:Type] =~ /GITHUB/ source[:ReportBuildStatus] = true end 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.
56 57 58 |
# File 'lib/cody/dsl/project.rb', line 56 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
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/cody/dsl/project.rb', line 87 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
83 84 85 |
# File 'lib/cody/dsl/project.rb', line 83 def linux_image(name) linux_environment(Image: name) end |
#local_cache(enable = true) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/cody/dsl/project.rb', line 117 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
133 134 135 |
# File 'lib/cody/dsl/project.rb', line 133 def type @options[:type] # should be lowercase end |