Externalise config
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
*.swp
|
||||
config/pipeline.yml
|
||||
.DS_Store
|
||||
tmp/*
|
||||
opt/
|
||||
|
||||
@@ -3,5 +3,5 @@ require "bundler/setup"
|
||||
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
||||
|
||||
require "pipeline"
|
||||
|
||||
Pipeline.spike
|
||||
Pipeline.load_config(File.expand_path('../../config/pipeline.yml', __FILE__))
|
||||
Pipeline.build_analyzer(ARGV[0])
|
||||
5
config/pipeline.yml.sample
Normal file
5
config/pipeline.yml.sample
Normal file
@@ -0,0 +1,5 @@
|
||||
aws_access_key_id: AKIA...
|
||||
aws_secret_access_key:
|
||||
aws_region: eu-west-1
|
||||
registry_endpoint:
|
||||
analyzer_suffix: -dev
|
||||
@@ -4,18 +4,24 @@ require "active_support"
|
||||
require 'securerandom'
|
||||
require 'rugged'
|
||||
require 'aws-sdk-ecr'
|
||||
|
||||
Aws.config.update({
|
||||
credentials: Aws::Credentials.new('AKIAZ5OU5BBSQDMMFQ7J', '+Q2fMSju+dJljn6G2XFZOt6vUHgSF56P736yPQhj')
|
||||
})
|
||||
require 'yaml'
|
||||
|
||||
module Pipeline
|
||||
def self.spike
|
||||
puts "OK"
|
||||
AnalyzerBuild.("ruby")
|
||||
# repo = Pipeline::AnalyzerRepo.new("/home/ccare/code/exercism/sample-analyzer")
|
||||
# repo.fetch!
|
||||
puts "DONE"
|
||||
|
||||
def self.load_config(config_path)
|
||||
config = YAML.load(File.read(config_path))
|
||||
Aws.config.update({
|
||||
credentials: Aws::Credentials.new(config["aws_access_key_id"], config["aws_secret_access_key"])
|
||||
})
|
||||
@config = config
|
||||
end
|
||||
|
||||
def self.config
|
||||
@config
|
||||
end
|
||||
|
||||
def self.build_analyzer(track_slug)
|
||||
AnalyzerBuild.(track_slug)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -24,10 +24,6 @@ class Pipeline::PublishImage
|
||||
img.logout(registry_endpoint)
|
||||
end
|
||||
|
||||
def registry_endpoint
|
||||
"681735686245.dkr.ecr.eu-west-1.amazonaws.com"
|
||||
end
|
||||
|
||||
def tag_build
|
||||
img.tag(image_tag, remote_tag)
|
||||
img.tag(image_tag, remote_human_tag) unless build_tag.nil?
|
||||
@@ -53,12 +49,7 @@ class Pipeline::PublishImage
|
||||
end
|
||||
|
||||
def registry_endpoint
|
||||
"681735686245.dkr.ecr.eu-west-1.amazonaws.com"
|
||||
Pipeline.config["registry_endpoint"]
|
||||
end
|
||||
|
||||
def slug
|
||||
image_tag
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ module Pipeline
|
||||
class BuildAndValidateTest < Minitest::Test
|
||||
|
||||
def test_build_and_validate_realish_image
|
||||
demo_analyzer_repo = "/home/ccare/code/exercism/sample-analyzer"
|
||||
demo_analyzer_repo = "https://github.com/exercism/stub-analyzer.git"
|
||||
repo = Pipeline::AnalyzerRepo.new(demo_analyzer_repo)
|
||||
img = Pipeline::Util::ImgWrapper.new
|
||||
image_tag = Pipeline::BuildImage.("master", "demo", repo, img)
|
||||
@@ -8,7 +8,7 @@ module Pipeline::Validation
|
||||
|
||||
def setup
|
||||
track_slug = "demo"
|
||||
demo_analyzer_repo = "/home/ccare/code/exercism/sample-analyzer"
|
||||
demo_analyzer_repo = "https://github.com/exercism/stub-analyzer.git"
|
||||
repo = Pipeline::AnalyzerRepo.new(demo_analyzer_repo)
|
||||
workdir = "/tmp/analyzer-scratch/#{SecureRandom.uuid}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user