Module: Cody::Dsl::Project
Defined Under Namespace
Modules: Ssm
Constant Summary collapse
- PROPERTIES =
%w[ artifacts badge_enabled cache description encryption_key environment logs_config name queued_timeout_in_minutes secondary_artifacts secondary_sources service_role source tags timeout_in_minutes triggers vpc_config ]
Instance Method Summary collapse
- #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
#environment_variables(vars) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/cody/dsl/project.rb', line 85 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][:environment_variables] = @mapped_env_vars end |
#github_source(options = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cody/dsl/project.rb', line 45 def github_source(={}) source = { type: "GITHUB", location: [:location], git_clone_depth: 1, git_submodules_config: { fetch_submodules: true }, build_spec: [:buildspec] || ".cody/buildspec.yml", # options[:buildspec] accounts for type already report_build_status: true, } if [:oauth_token] source[:auth] = { type: "OAUTH", resource: [:oauth_token], } 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.
41 42 43 |
# File 'lib/cody/dsl/project.rb', line 41 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
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/cody/dsl/project.rb', line 69 def linux_environment(={}) image = [:image] || "aws/codebuild/ruby:2.5.3-1.7.0" env = { compute_type: [:compute_type] || "BUILD_GENERAL1_SMALL", image_pull_credentials_type: "CODEBUILD", # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-environment.html#cfn-codebuild-project-environment-imagepullcredentialstype privileged_mode: true, image: image, type: "LINUX_CONTAINER" } # @mapped_env_vars is in memory env[:environment_variables] = @mapped_env_vars if @mapped_env_vars # options has highest precedence env[:environment_variables] = [:environment_variables] if [:environment_variables] @properties[:environment] = env end |
#linux_image(name) ⇒ Object
65 66 67 |
# File 'lib/cody/dsl/project.rb', line 65 def linux_image(name) linux_environment(image: name) end |
#local_cache(enable = true) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/cody/dsl/project.rb', line 99 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
115 116 117 |
# File 'lib/cody/dsl/project.rb', line 115 def type @options[:type] end |