Sha256: 45ca26d0dadd6d2599dc2780f4855c1807af567cb6462d306ce891f7d6d50eea

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

require "yaml"

module Cody
  class Project < Dsl::Base
    include Dsl::Project
    include Evaluate
    include Variables

    attr_reader :project_path
    def initialize(options={})
      super
      @project_path = options[:project_path] || get_project_path
    end

    def exist?
      File.exist?(@project_path)
    end

    def run
      load_variables
      evaluate(@project_path)
      resource = {
        CodeBuild: {
          Type: "AWS::CodeBuild::Project",
          Properties: @properties
        }
      }
      auto_camelize(resource)
    end

    def default_properties
      {
        Name: @full_project_name,
        Description: @full_project_name,
        Artifacts: { Type: "NO_ARTIFACTS" },
        ServiceRole: { Ref: "IamRole" },
        BadgeEnabled: true,
        TimeoutInMinutes: 20,
        LogsConfig: {
          CloudWatchLogs: {
            Status: "ENABLED",
            # the default log group name is thankfully the project name
          }
        },
        Source: {
          Type: "GITHUB",
          # location: "", # required
          # GitCloneDepth: 1,
          GitSubmodulesConfig: { FetchSubmodules: true },
          BuildSpec: build_spec,
          # auth doesnt seem to work, refer to https://github.com/tongueroo/cody/blob/master/readme/GithubOauth.md
          # Auth: {
          #   Type: "OAUTH",
          #   # Resource: "", # required
          # },
        }
      }
    end

    def get_project_path
      lookup_cody_file("project.rb")
    end

    def build_spec
      lookup_cody_file("buildspec.yml")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cody-1.0.6 lib/cody/project.rb
cody-1.0.5 lib/cody/project.rb
cody-1.0.4 lib/cody/project.rb
cody-1.0.3 lib/cody/project.rb
cody-1.0.2 lib/cody/project.rb