Class: Cody::Project

Inherits:
Dsl::Base show all
Includes:
Dsl::Project, Evaluate, Variables
Defined in:
lib/cody/project.rb

Constant Summary

Constants included from Dsl::Project

Dsl::Project::PROPERTIES

Instance Attribute Summary collapse

Attributes inherited from Dsl::Base

#full_project_name, #options, #project_name, #type

Instance Method Summary collapse

Methods included from Variables

#load_variables, #load_variables_file

Methods included from Evaluate

#lookup_cody_file

Methods included from Evaluate::Interface

#full_project_name, #project_name

Methods included from Dsl::Project

#buildspec, #environment_variables, #git_branch, #git_provider, #github_source, #github_token, #github_url, #linux_environment, #linux_image, #local_cache, #type

Methods included from Dsl::Project::Ssm

#ssm, #ssm_client

Methods inherited from Dsl::Base

#auto_camelize

Constructor Details

#initialize(options = {}) ⇒ Project

Returns a new instance of Project.



10
11
12
13
# File 'lib/cody/project.rb', line 10

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

Instance Attribute Details

#project_pathObject (readonly)

Returns the value of attribute project_path.



9
10
11
# File 'lib/cody/project.rb', line 9

def project_path
  @project_path
end

Instance Method Details

#build_specObject



64
65
66
# File 'lib/cody/project.rb', line 64

def build_spec
  lookup_cody_file("buildspec.yml")
end

#default_propertiesObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/cody/project.rb', line 31

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

#exist?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/cody/project.rb', line 15

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

#get_project_pathObject



60
61
62
# File 'lib/cody/project.rb', line 60

def get_project_path
  lookup_cody_file("project.rb")
end

#runObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cody/project.rb', line 19

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