source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/vpc.rb | Ruby | mit | 220 | main | 599 | class Ufo::Cfn::Stack
class Vpc < Ufo::Cfn::Base
extend Memoist
include Ufo::TaskDefinition::Helpers
def id
vpc.id ? vpc.id : default_vpc
end
alias_method :vpc_id, :id
def vpc
Ufo.config.vpc
end
def elb_subnets
subnets(vpc.subnets.elb)
end
def ecs_subnets
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder.rb | Ruby | mit | 220 | main | 1,148 | class Ufo::Cfn::Stack
class Builder < Ufo::Cfn::Base
include Ufo::Utils::Logging
def initialize(options={})
super
@vars = options[:vars]
@template = {Description: "UFO ECS stack #{@vars[:stack_name]}"}
end
def build
logger.info "Building template"
@template[:Parameters]... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/vars.rb | Ruby | mit | 220 | main | 3,901 | class Ufo::Cfn::Stack
class Vars < Ufo::Cfn::Base
attr_reader :stack_name
def values
# Not passing stack down to vars beause its easier to debug. Will require another lookup by thats ok
{
cluster: @cluster,
container: container,
create_elb: create_elb?, # helps set Ecs Dep... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/custom_properties.rb | Ruby | mit | 220 | main | 2,416 | class Ufo::Cfn::Stack
class CustomProperties
def initialize(template, stack_name)
@template, @stack_name = template, stack_name
end
def apply
customizations = camelize(cfn)
@template["Resources"].each do |logical_id, attrs|
custom_props = customizations[logical_id]
next ... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/status.rb | Ruby | mit | 220 | main | 5,905 | require 'time'
# CloudFormation status codes, full list:
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html
#
# CREATE_COMPLETE
# ROLLBACK_COMPLETE
# DELETE_COMPLETE
# UPDATE_COMPLETE
# UPDATE_ROLLBACK_COMPLETE
#
# CREATE_FAILED
# DELETE_FAILED
# ROLLBAC... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/base.rb | Ruby | mit | 220 | main | 1,523 | class Ufo::Cfn::Stack::Builder
class Base < Ufo::Cfn::Base
attr_reader :vars
def initialize(options={})
super
@vars = options[:vars]
end
# type: elb or ecs
# NOTE: Application ELBs always seem to need a security group even though the docs say its not required
# However, there's a ... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/conditions.rb | Ruby | mit | 220 | main | 574 | class Ufo::Cfn::Stack::Builder
class Conditions < Base
def build
text =<<~EOL
CreateElbIsTrue:
Fn::Equals:
- Ref: CreateElb
- true
ElbTargetGroupIsBlank:
Fn::Equals:
- Ref: ElbTargetGroup
- ''
CreateTargetGroupIsTrue:
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/parameters.rb | Ruby | mit | 220 | main | 950 | class Ufo::Cfn::Stack::Builder
class Parameters < Base
def build
yaml =<<~EOL
Vpc:
Description: Existing vpc id
Type: AWS::EC2::VPC::Id
ElbSubnets:
Description: Existing subnet ids for ELB
Type: List<AWS::EC2::Subnet::Id>
EcsSubnets:
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources.rb | Ruby | mit | 220 | main | 1,077 | class Ufo::Cfn::Stack::Builder
class Resources < Base
def build
{
Dns: Dns.build(@options),
EcsService: EcsService.build(@options),
EcsSecurityGroup: SecurityGroup::Ecs.build(@options),
EcsSecurityGroupRule: SecurityGroup::EcsRule.build(@options),
Elb: Elb.build(@opti... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/outputs.rb | Ruby | mit | 220 | main | 454 | class Ufo::Cfn::Stack::Builder
class Outputs < Base
def build
outputs = {
ElbDns: {
Description: "Elb Dns",
Condition: "CreateElbIsTrue",
Value: {
"Fn::GetAtt": "Elb.DNSName"
}
}
}
if vars[:create_route53]
outputs[:Rout... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/listener.rb | Ruby | mit | 220 | main | 1,522 | class Ufo::Cfn::Stack::Builder::Resources
class Listener < Base
def build
return unless vars[:create_listener]
{
Type: "AWS::ElasticLoadBalancingV2::Listener",
Condition: "CreateElbIsTrue",
Properties: properties,
}
end
def properties
{
DefaultActio... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/target_group.rb | Ruby | mit | 220 | main | 1,592 | class Ufo::Cfn::Stack::Builder::Resources
class TargetGroup < Base
def build
{
Type: "AWS::ElasticLoadBalancingV2::TargetGroup",
Condition: "CreateTargetGroupIsTrue",
Properties: properties,
}
end
def properties
props = {
VpcId: {Ref: "Vpc"},
Tags... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/elb.rb | Ruby | mit | 220 | main | 793 | class Ufo::Cfn::Stack::Builder::Resources
class Elb < Base
def build
{
Type: "AWS::ElasticLoadBalancingV2::LoadBalancer",
Condition: "CreateElbIsTrue",
Properties: properties,
}
end
def properties
props = {
Type: vars[:elb_type],
Tags: [
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/listener_ssl.rb | Ruby | mit | 220 | main | 1,286 | class Ufo::Cfn::Stack::Builder::Resources
class ListenerSsl < Listener
def build
return unless vars[:create_listener_ssl]
{
Type: "AWS::ElasticLoadBalancingV2::Listener",
Condition: "CreateElbIsTrue",
Properties: properties,
}
end
def properties
props = sup... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/waf_association.rb | Ruby | mit | 220 | main | 484 | # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafv2-webaclassociation.html
class Ufo::Cfn::Stack::Builder::Resources
class WafAssociation < Base
def build
web_acl_arn = Ufo.config.waf.web_acl_arn
return if web_acl_arn.blank?
{
Type: "AWS::WAFv2::WebACLAss... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/task_definition.rb | Ruby | mit | 220 | main | 653 | class Ufo::Cfn::Stack::Builder::Resources
class TaskDefinition < Base
def build
return if vars[:rollback_task_definition]
{
Type: "AWS::ECS::TaskDefinition",
Properties: properties,
DeletionPolicy: "Retain",
UpdateReplacePolicy: "Retain",
}
end
def prope... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/dns.rb | Ruby | mit | 220 | main | 2,474 | class Ufo::Cfn::Stack::Builder::Resources
class Dns < Base
def build
return unless vars[:create_route53]
props = {
Name: dns_name, # {stack_name}.yourdomain. dont forget the trailing period
Comment: dns.comment,
Type: dns.type, # CNAME
TTL: dns.ttl, # 60 ttl has specia... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/ecs_service.rb | Ruby | mit | 220 | main | 2,453 | class Ufo::Cfn::Stack::Builder::Resources
class EcsService < Base
def build
attrs = {
Type: "AWS::ECS::Service",
Properties: properties
}
attrs[:DependsOn] = depends_on
attrs
end
def depends_on
return unless vars[:create_elb]
vars[:create_listener] ? ... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/listener_certificate.rb | Ruby | mit | 220 | main | 1,047 | class Ufo::Cfn::Stack::Builder::Resources
class ListenerCertificate < ListenerSsl
def build
return unless certificates && certificates.size >= 1 # already removed firt cert
{
Type: "AWS::ElasticLoadBalancingV2::ListenerCertificate",
Condition: "CreateElbIsTrue",
Properties: pro... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/scaling/role.rb | Ruby | mit | 220 | main | 1,038 | module Ufo::Cfn::Stack::Builder::Resources::Scaling
class Role < Base
def build
return unless autoscaling_enabled?
text =<<~EOL
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/scaling/policy.rb | Ruby | mit | 220 | main | 988 | module Ufo::Cfn::Stack::Builder::Resources::Scaling
class Policy < Base
def build
return unless autoscaling_enabled?
text =<<~EOL
Type: AWS::ApplicationAutoScaling::ScalingPolicy
Properties:
PolicyName: !Sub "${AWS::StackName}-auto-scaling-policy"
PolicyType: Targe... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/scaling/target.rb | Ruby | mit | 220 | main | 1,650 | module Ufo::Cfn::Stack::Builder::Resources::Scaling
class Target < Base
def build
return unless autoscaling_enabled?
text =<<~EOL
Type: AWS::ApplicationAutoScaling::ScalableTarget
DependsOn: EcsService
Properties:
RoleARN: !GetAtt ScalingRole.Arn
ResourceId... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/security_group/ecs_rule.rb | Ruby | mit | 220 | main | 619 | module Ufo::Cfn::Stack::Builder::Resources::SecurityGroup
class EcsRule < Base
def build
return unless manage_ecs_security_group?
{
Type: "AWS::EC2::SecurityGroupIngress",
Condition: "CreateElbIsTrue",
Properties: {
IpProtocol: "tcp",
FromPort: "0",
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/security_group/elb.rb | Ruby | mit | 220 | main | 1,287 | module Ufo::Cfn::Stack::Builder::Resources::SecurityGroup
class Elb < Base
def build
# Always create elb security group it seems like its required
return unless vars[:elb_type] == "application"
{
Type: "AWS::EC2::SecurityGroup",
Condition: "CreateElbIsTrue",
Properties: ... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/security_group/ecs.rb | Ruby | mit | 220 | main | 1,061 | module Ufo::Cfn::Stack::Builder::Resources::SecurityGroup
class Ecs < Base
def build
return unless manage_ecs_security_group?
return unless vars[:container][:network_mode].to_s == 'awsvpc'
{
Type: "AWS::EC2::SecurityGroup",
Properties: properties
}
end
def propert... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/task_definition/reconstructor.rb | Ruby | mit | 220 | main | 1,201 | class Ufo::Cfn::Stack::Builder::Resources::TaskDefinition
class Reconstructor
include Ufo::AwsServices
def initialize(task_definition, rollback=false)
@task_definition, @rollback = task_definition, rollback
end
def reconstruct
camelize(data)
end
def data
if @rollback
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cfn/stack/builder/resources/iam_roles/base.rb | Ruby | mit | 220 | main | 920 | module Ufo::Cfn::Stack::Builder::Resources::IamRoles
class Base < Ufo::Cfn::Stack::Builder::Base
def build
return unless self.class.build? # important because it runs Dsl#evaluate
Ufo::IamRole::Builder.new(self.class.role_type).build
end
class << self
def role_type
self.name.to_... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/logger/formatter.rb | Ruby | mit | 220 | main | 384 | class Ufo::Logger
class Formatter < ::Logger::Formatter
def call(severity, time, progname, msg)
# careful changing the format. All::Summary uses a regexp on this format to remove the timestamp
"[#{format_datetime(time)} ##{Process.pid} #{progname}]: #{msg}"
end
private
def format_datetime(t... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/aws_services/concerns.rb | Ruby | mit | 220 | main | 1,499 | require "cfn_status"
module Ufo::AwsServices
module Concerns
extend Memoist
def find_stack(stack_name)
resp = cfn.describe_stacks(stack_name: stack_name)
resp.stacks.first
rescue Aws::CloudFormation::Errors::ValidationError => e
# example: Stack with id demo-web does not exist
if... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/ecs/service.rb | Ruby | mit | 220 | main | 603 | # Creating this class pass so we can have a reference to their properties in
# memory: cluster_name and service_name.
# This helps us avoid making additional API calls to describe and lookup the information.
#
# Also this class allows us to pass one object around instead of both
# cluster_name and service_name.
#
# Thi... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/config/callable_option.rb | Ruby | mit | 220 | main | 2,198 | # Class represents a config option that is possibly callable. Examples:
#
# config.names.stack
# config.names.task_definition
#
# Abstraction is definitely obtuse. Using it to get rid of duplication.
#
class Ufo::Config
class CallableOption
include Ufo::Utils::Logging
def initialize(options={})
@... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/config/inits.rb | Ruby | mit | 220 | main | 236 | class Ufo::Config
class Inits
class << self
include DslEvaluator
def run_all
Dir.glob("#{Ufo.root}/.ufo/config/inits/*.rb").each do |path|
evaluate_file(path)
end
end
end
end
end |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/config/parse.rb | Ruby | mit | 220 | main | 1,277 | # Some limitations:
#
# * Only parsing one file: .ufo/config.rb
# * If user is using Ruby code that cannot be parse will fallback to default
#
# Think it's worth it so user only has to configure
#
# config.layering.show = true
#
class Ufo::Config
class Parse
def for(config, type: :boolean)
lines = IO.re... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/config/callable_option/concern.rb | Ruby | mit | 220 | main | 287 | class Ufo::Config::CallableOption
module Concern
def callable_option(options={})
callable_option = Ufo::Config::CallableOption.new(
config_name: options[:config_name],
passed_args: options[:passed_args],
)
callable_option.object
end
end
end |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/utils/execute.rb | Ruby | mit | 220 | main | 734 | module Ufo::Utils
module Execute
def execute(command, options={})
log = options[:log]
if log
command += " >> #{log}"
logger.info "=> #{command}"
FileUtils.mkdir_p(File.dirname(log))
File.open(log, 'a') { |f| f.puts "=> #{command}" }
out = `#{command}`
su... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/utils/pretty.rb | Ruby | mit | 220 | main | 620 | module Ufo::Utils
module Pretty
def pretty_path(path)
path.sub("#{Ufo.root}/",'').sub(/^\.\//,'')
end
# Replace HOME with ~ - different from the main pretty_path
def pretty_home(path)
path.sub(ENV['HOME'], '~')
end
# http://stackoverflow.com/questions/4175733/convert-duration-to-... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/utils/squeezer.rb | Ruby | mit | 220 | main | 716 | module Ufo::Utils
class Squeezer
def initialize(data)
@data = data
end
def squeeze(new_data=nil)
data = new_data.nil? ? @data : new_data
case data
when Array
# .compact prevents infinite loop when data = [nil] on accident
# IE: config.elb.ssl.certificates = acm_ce... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/utils/sure.rb | Ruby | mit | 220 | main | 443 | module Ufo::Utils
module Sure
def sure?(message=nil)
confirm = 'Are you sure?'
if @options[:yes]
yes = 'y'
else
out = if message
"#{message}\n#{confirm} (y/N) "
else
"#{confirm} (y/N) "
end
print out
yes ... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/yaml/loader.rb | Ruby | mit | 220 | main | 759 | require "yaml"
class Ufo::Yaml
class Loader
def initialize(text)
@text = text
end
def load
add_domain_types!
YAML.load(@text)
end
private
def add_domain_types!
intrinsic_functions.each do |name|
YAML.add_domain_type('', name) do |type,val|
key = type.... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/yaml/validator.rb | Ruby | mit | 220 | main | 844 | class Ufo::Yaml
class Validator
include Ufo::Utils::Logging
def initialize(path)
@path = path
end
def validate!
validate_yaml(@path)
end
def validate_yaml(path)
text = IO.read(path)
begin
YAML.load(text)
rescue Psych::SyntaxError => e
handle_yam... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/ext/core/module.rb | Ruby | mit | 220 | main | 1,484 | class Module
# Include all modules within the relative folder. IE: for dsl/syntax/mod/*
#
# include Common
# include Provider
# # etc
#
# Caller lines are different for OSes:
#
# windows: "C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/lono-1.1.1/lib/lono/builder.rb:34:in `build'"
# linux: "/ho... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/concerns/autoscaling.rb | Ruby | mit | 220 | main | 229 | module Ufo::Concerns
module Autoscaling
def autoscaling_enabled?
autoscaling.enabled && autoscaling.min_capacity && autoscaling.max_capacity
end
def autoscaling
Ufo.config.autoscaling
end
end
end |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/docker/builder.rb | Ruby | mit | 220 | main | 5,532 | module Ufo::Docker
class Builder
extend Memoist
include Concerns
include Ufo::Hooks::Concern
delegate :push, to: :pusher
def self.build(options={})
builder = Builder.new(options) # outside if because it need builder.docker_image
builder.build
pusher = Pusher.new(nil, options)
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/docker/compiler.rb | Ruby | mit | 220 | main | 850 | module Ufo::Docker
class Compiler
def initialize(dockerfile)
@dockerfile = dockerfile
@erb_file = "#{dockerfile}.erb"
end
def compile
return unless File.exist?(@erb_file)
puts "Compiled #{File.basename(@erb_file).color(:green)} to #{File.basename(@dockerfile).color(:green)}"
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/docker/cleaner.rb | Ruby | mit | 220 | main | 1,631 | module Ufo::Docker
class Cleaner
include Ufo::Utils::Execute
include Ufo::Utils::Logging
def initialize(docker_image_name, options)
# docker_image_name does not containg the tag
# Example: 123456789.dkr.ecr.us-east-1.amazonaws.com/image
@docker_image_name = docker_image_name
@opti... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/docker/state.rb | Ruby | mit | 220 | main | 532 | module Ufo::Docker
class State
extend Memoist
def initialize(options={})
@options = options
end
def update
storage.update
end
def read
storage.read
end
private
# Examples:
# File.new(@docker_image, @options)
# S3.new(@docker_image, @options)
def ... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/docker/dockerfile.rb | Ruby | mit | 220 | main | 989 | module Ufo::Docker
class Dockerfile
include Ufo::Utils::Logging
def initialize(docker_image, options={})
@docker_image, @options = docker_image, options
end
def update
write_new_dockerfile
end
def current_dockerfile
@current_dockerfile ||= IO.read(dockerfile_path)
end
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/docker/pusher.rb | Ruby | mit | 220 | main | 1,245 | module Ufo::Docker
class Pusher
include Concerns
include Ufo::Hooks::Concern
delegate :docker_image, to: :builder
attr_reader :last_image_name
def initialize(image, options)
@options = options
# docker_image ultimately uses @options, so @last_image_name assignment
# line must be... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/docker/state/s3.rb | Ruby | mit | 220 | main | 1,941 | class Ufo::Docker::State
class S3 < Base
extend Memoist
include Ufo::AwsServices
def read
current_data
end
def update
data = current_data
data["base_image"] = @base_image
# write data to s3
body = YAML.dump(data)
s3.put_object(
body: body,
buc... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/docker/state/base.rb | Ruby | mit | 220 | main | 375 | class Ufo::Docker::State
class Base
include Ufo::Utils::Logging
include Ufo::Utils::Pretty
def initialize(options={})
@options = options
# base_image only passed in with: ufo docker base
# State#update uses it.
# State#read wont have access to it and gets it from stored state
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/docker/state/file.rb | Ruby | mit | 220 | main | 1,315 | class Ufo::Docker::State
class File < Base
def read
current_data
end
def update
data = current_data
data["base_image"] = @base_image
pretty_path = state_path.sub("#{Ufo.root}/", "")
FileUtils.mkdir_p(::File.dirname(state_path))
IO.write(state_path, YAML.dump(data))
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/layering/layer.rb | Ruby | mit | 220 | main | 2,122 | require "aws_data"
# Layers example
#
# .ufo/vars.rb
# .ufo/vars/base.rb
# .ufo/vars/dev.rb
# .ufo/vars/prod.rb
# .ufo/vars/app1.rb
# .ufo/vars/app1/base.rb
# .ufo/vars/app1/dev.rb
# .ufo/vars/app1/prod.rb
#
module Ufo::Layering
class Layer
extend Memoist
include Ufo::Layering... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/releases.rb | Ruby | mit | 220 | main | 365 | require 'text-table'
class Ufo::CLI
class Releases < Base
def list
logger.info "Latest task definitions for stack: #{@stack_name}"
arns = task_definition_arns(@task_definition.name)
task_definitions = arns.map { |arn| arn.split('/').last }
task_definitions.each do |name|
logger.in... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/stop.rb | Ruby | mit | 220 | main | 1,457 | class Ufo::CLI
class Stop < Base
def run
service = info.service
return unless service # brand new deploy
@deployments = service.deployments
if @deployments.size >= 1
stop(service.service_name)
end
end
def stop(service_name)
tasks = service_tasks(service_name)
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/destroy.rb | Ruby | mit | 220 | main | 1,040 | class Ufo::CLI
class Destroy < Base
include Ufo::Hooks::Concern
def run
are_you_sure?
stack = find_stack(@stack_name)
unless stack
logger.info "Stack #{@stack_name.color(:green)} does not exist."
exit 1
end
if stack.stack_status =~ /_IN_PROGRESS$/
logge... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/ship.rb | Ruby | mit | 220 | main | 494 | class Ufo::CLI
class Ship < Base
include Ufo::Concerns
def run
are_you_sure?
build_task_definition
deploy.run
ps.run
end
def build_task_definition
return if @options[:rollback]
build.docker
build.task_definition
end
private
def are_you_sure?
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/build.rb | Ruby | mit | 220 | main | 622 | class Ufo::CLI
class Build < Base
def build
docker
task_definition
Ufo::Cfn::Stack.new(@options).build
end
alias_method :all, :build
def task_definition
Ufo::TaskDefinition::Builder.new(@options).build
end
def docker
return if @options[:docker] == false
# ... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/scale.rb | Ruby | mit | 220 | main | 2,746 | class Ufo::CLI
class Scale < Base
delegate :service, :service?, :stack_resources, to: :info
def initialize(options={})
super
@desired = options[:desired]
@min = options[:min]
@max = options[:max]
end
def update
unless service?
logger.error "ERROR: Unable to find... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/logs.rb | Ruby | mit | 220 | main | 2,741 | require "aws-logs"
class Ufo::CLI
class Logs < Base
delegate :service, to: :info
def run
log = find_log_group_name
logger.info "Showing logs for stack: #{@stack_name} log group: #{log["awslogs-group"]} and stream prefix: #{log["awslogs-stream-prefix"]}"
if log
cloudwatch_tail(log)
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/tasks.rb | Ruby | mit | 220 | main | 484 | class Ufo::CLI
class Tasks < Ufo::Command
desc "build", "Build task definitions."
long_desc Help.text("tasks:build")
option :image_override, desc: "Override image in task definition for quick testing"
def build
Tasks::Builder.new(options).build
end
desc "register", "Register all built t... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/docker.rb | Ruby | mit | 220 | main | 2,082 | class Ufo::CLI
class Docker < Ufo::Command
desc "build", "Build docker image."
long_desc Help.text("docker/build")
option :push, type: :boolean, default: false
def build
builder = Ufo::Docker::Builder.new(options)
builder.build
push if options[:push]
end
desc "compile", "Com... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/opts.rb | Ruby | mit | 220 | main | 935 | class Ufo::CLI
class Opts
def initialize(cli)
@cli = cli
end
def yes
with_cli_scope do
option :yes, aliases: :y, type: :boolean, desc: "Bypass are you sure prompt"
end
end
def docker
with_cli_scope do
option :docker, type: :boolean, default: true, desc: "S... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/new.rb | Ruby | mit | 220 | main | 879 | class Ufo::CLI
class New < Ufo::Command
desc "boot_hook", "Generate boot_hook"
long_desc Help.text("new/boot_hook")
BootHook.cli_options.each do |args|
option(*args)
end
register(BootHook, "boot_hook", "boot_hook", "Generate boot_hook")
desc "env_file", "Generate env_file"
long_desc... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/central.rb | Ruby | mit | 220 | main | 390 | class Ufo::CLI
class Central < Ufo::Command
opts = Opts.new(self)
desc "update", "update .ufo from central repo"
long_desc Help.text("central/update")
opts.yes
def update
Update.new(options).run
end
desc "clean", "remove ~/.ufo/central"
long_desc Help.text("central/clean")
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/base.rb | Ruby | mit | 220 | main | 423 | class Ufo::CLI
class Base
extend Memoist
include Ufo::AwsServices
include Ufo::Concerns
include Ufo::Utils::Logging
include Ufo::Utils::Pretty
include Ufo::Utils::Sure
attr_reader :task_definition
def initialize(options={})
@options = options
@task_definition = Ufo::TaskDe... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/help.rb | Ruby | mit | 220 | main | 1,592 | class Ufo::CLI
module Help
extend ActiveSupport::Concern
class_methods do
def main_commands
%w[
destroy
exec
logs
ps
ship
]
end
def help(shell, subcommand)
list = printable_commands(true, subcommand)
list.sor... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/upgrade.rb | Ruby | mit | 220 | main | 915 | class Ufo::CLI
class Upgrade < Ufo::Command
desc "v2to3", "Upgrade from version 2 to 3."
def v2to3
Upgrade3.new(options).run
end
desc "v33to34", "Upgrade from version 3.3 to 3.4"
def v33to34
Upgrade33to34.new(options).run
end
def self.options
[
[:force, type: :b... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/cancel.rb | Ruby | mit | 220 | main | 401 | class Ufo::CLI
class Cancel < Base
def run
are_you_sure?
stack = Ufo::Cfn::Stack.new(@options)
stack.cancel
stack.status.wait
end
def are_you_sure?
if @options[:yes]
logger.info "Canceling the #{@stack_name.color(:green)} stack"
else
sure?("You are abou... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/ps.rb | Ruby | mit | 220 | main | 5,175 | require 'text-table'
require 'tty-screen'
class Ufo::CLI
class Ps < Base
include Ufo::AwsServices
include Ufo::Concerns::Autoscaling
delegate :service, to: :info
def run
unless service
stack = find_stack(@stack_name)
if stack && stack.stack_status == "CREATE_IN_PROGRESS"
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/clean.rb | Ruby | mit | 220 | main | 381 | class Ufo::CLI
class Clean < Base
def run
folders = %w[log output tmp]
folders = folders.map do |folder|
".ufo/#{folder}"
end
sure?("Will remove folders: #{folders.join(' ')}")
folders.each do |folder|
FileUtils.rm_rf("#{Ufo.root}/#{folder}")
end
logger.in... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/rollback.rb | Ruby | mit | 220 | main | 1,990 | class Ufo::CLI
class Rollback < Base
include Ufo::Concerns
def deploy
are_you_sure?
rollback_task_definition = normalize_version(@options[:version])
logger.info "Rolling back ECS Service to task definition: #{rollback_task_definition}"
ship = Ship.new(@options.merge(rollback_task_defi... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/exec.rb | Ruby | mit | 220 | main | 2,527 | class Ufo::CLI
class Exec < Base
def run
check_install!
stack = info.stack
unless stack
logger.error "Stack not found: #{@stack_name}".color(:red)
exit 1
end
service = info.service
unless service # brand new deploy
logger.error "ECS Service not yet avai... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/central/base.rb | Ruby | mit | 220 | main | 651 | class Ufo::CLI::Central
class Base
include Ufo::Utils::Logging
include Ufo::Utils::Pretty
include Ufo::Utils::Sure
def initialize(options={})
@options = options
end
# Do not use logger.info for ufo central commands as .ufo may not be yet setup
# We do not want any config calls to t... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/central/update.rb | Ruby | mit | 220 | main | 3,073 | class Ufo::CLI::Central
class Update < Base
def run
validate!
action = File.exist?(".ufo") ? "update" : "create"
sure?("Will #{action} the .ufo symlink") # IE: Will create the .ufo symlink
log "Updating .ufo with #{central_repo}"
FileUtils.mkdir_p(tmp_area)
pull
symlink
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/central/clean.rb | Ruby | mit | 220 | main | 261 | class Ufo::CLI::Central
class Clean < Base
def run
path = "#{ENV['HOME']}/.ufo/central"
sure?("Will remove folder with repo caches: #{pretty_home(path)}")
FileUtils.rm_rf(path)
log "Removed: #{pretty_home(path)}"
end
end
end |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/ps/task.rb | Ruby | mit | 220 | main | 3,814 | class Ufo::CLI::Ps
class Task < Ufo::CLI::Base
def initialize(options={})
super
@task = options[:task] # task response from ecs.list_tasks
end
def to_a
row = [id, name, release, started, status, notes]
row
end
def id
@task['task_arn'].split('/').last.split('-').firs... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/ps/errors.rb | Ruby | mit | 220 | main | 6,215 | class Ufo::CLI::Ps
class Errors < Ufo::CLI::Ps
extend Memoist
def initialize(options={})
super
@tasks = options[:tasks]
end
def show
message = recent_message
return unless message
return if message =~ /has reached a steady state/
scale
target_group
de... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/new/env_file.rb | Ruby | mit | 220 | main | 523 | class Ufo::CLI::New
class EnvFile < Sequence
argument :type, default: "env", description: "IE: env or secrets" # description doesnt really show up
def self.cli_options
[
[:force, aliases: ["y"], type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
]
end
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/new/sequence.rb | Ruby | mit | 220 | main | 2,468 | require 'fileutils'
require 'thor'
class Ufo::CLI::New
class Sequence < Thor::Group
include Concerns
include Thor::Actions
include Ufo::Utils::Logging
add_runtime_options! # force, pretend, quiet, skip options
# https://github.com/erikhuda/thor/blob/master/lib/thor/actions.rb#L49
private
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/new/boot_hook.rb | Ruby | mit | 220 | main | 435 | class Ufo::CLI::New
class BootHook < Sequence
def self.cli_options
[
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
]
end
cli_options.each do |args|
class_option(*args)
end
def set_source
set_template_source "boot_hook"
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/new/hook.rb | Ruby | mit | 220 | main | 506 | class Ufo::CLI::New
class Hook < Sequence
argument :type, default: "ufo", description: "IE: docker, ufo" # description doesnt really show up
def self.cli_options
[
[:force, aliases: ["y"], type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
]
end
cli_... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/new/helper.rb | Ruby | mit | 220 | main | 578 | class Ufo::CLI::New
class Helper < Sequence
# required for name => underscore_name => .ufo/helpers/%underscore_name%_helper.rb.tt
argument :name, default: "custom"
def self.cli_options
[
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
]
e... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/new/init.rb | Ruby | mit | 220 | main | 1,409 | class Ufo::CLI::New
class Init < Sequence
def self.options
[
[:app, aliases: :a, desc: "App name. If not specified, it's inferred from the folder name"],
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
# note: aliases: :r messes up Usage he... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/cli/new/concerns.rb | Ruby | mit | 220 | main | 394 | class Ufo::CLI::New
module Concerns
extend ActiveSupport::Concern
private
def class_name
name.underscore.camelize
end
# Files should be named with underscores instead of dashes even though project name can contain a dash.
# This is because autoloading works with underscores in the filena... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/ecr/cleaner.rb | Ruby | mit | 220 | main | 1,825 | require "json"
module Ufo
class Ecr::Cleaner
include Ufo::AwsServices
include Ufo::Utils::Execute
include Ufo::Utils::Logging
def initialize(docker_image_name, options={})
# docker_image_name does not containg the tag
# Example: 123456789.dkr.ecr.us-east-1.amazonaws.com/image
@dock... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/ecr/auth.rb | Ruby | mit | 220 | main | 1,626 | require 'open3'
=begin
Normally, you must authorized to AWS ECR to push to their registry with:
eval $(aws ecr get-login --no-include-email)
If you haven't ever ran the ecr get-login command before then you'll get this error:
no basic auth credentials
If you have ran it before but the auto token has expired yo... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/s3/aws_setup.rb | Ruby | mit | 220 | main | 479 | module Ufo::S3
class AwsSetup
include Ufo::AwsServices
include Ufo::Utils::Logging
def check!
s3.config.region
rescue Aws::Errors::MissingRegionError => e
logger.info "ERROR: #{e.class}: #{e.message}".color(:red)
logger.info <<~EOL
Unable to detect the AWS_REGION to make AWS... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/s3/bucket.rb | Ruby | mit | 220 | main | 4,386 | module Ufo::S3
class Bucket
extend Memoist
extend Ufo::AwsServices
include Ufo::AwsServices
include Ufo::Utils::Logging
STACK_NAME = ENV['UFO_STACK_NAME'] || "ufo"
def initialize(options={})
@options = options
end
def deploy
stack = find_stack
if rollback.complete?
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/s3/rollback.rb | Ruby | mit | 220 | main | 1,257 | module Ufo::S3
class Rollback
extend Memoist
include Ufo::AwsServices
include Ufo::Utils::Logging
def initialize(stack)
@stack = stack
end
def delete_stack
return unless complete?
logger.info "Existing stack in ROLLBACK_COMPLETE state. Deleting stack before continuing."
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/upgrade/upgrade43to45.rb | Ruby | mit | 220 | main | 671 | require 'fileutils'
require 'yaml'
class Ufo::Upgrade
class Upgrade43to45
def initialize(options)
@options = options
end
def run
settings_path = ".ufo/settings.yml"
settings = YAML.load_file(settings_path)
if settings.dig("base", "stack_naming") == "append_ufo_env"
puts "... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/upgrade/upgrade3.rb | Ruby | mit | 220 | main | 3,471 | require 'fileutils'
require 'yaml'
class Ufo::Upgrade
class Upgrade3
def initialize(options)
@options = options
end
def run
if File.exist?("#{Ufo.root}/.ufo")
puts "It looks like you already have a .ufo folder in your project. This is the new project structure so exiting without upda... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/upgrade/upgrade33to34.rb | Ruby | mit | 220 | main | 993 | require 'fileutils'
require 'yaml'
class Ufo::Upgrade
class Upgrade33to34
def initialize(options)
@options = options
end
def run
if File.exist?("#{Ufo.root}/.ufo/params.yml")
puts "It looks like you already have a .ufo/params.yml project. This is the new project structure so exiting ... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/upgrade/upgrade4.rb | Ruby | mit | 220 | main | 4,259 | require 'fileutils'
require 'yaml'
class Ufo::Upgrade
class Upgrade4 < Ufo::Sequence
include Ufo::Network::Helper
Ufo::Upgrade.options.each { |o| class_option(*o) }
def already_ufo4_check
if File.exist?("#{Ufo.root}/.ufo/settings/network/default.yml")
puts "It looks like you already have ... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/task_definition/context.rb | Ruby | mit | 220 | main | 1,237 | class Ufo::TaskDefinition
module Context
include DslEvaluator
include Helpers
def load_context
load_variables
load_custom_helpers
end
def load_variables
layers = Ufo::Layering::Layer.new(@task_definition).paths
layers.each do |layer|
evaluate_file(layer)
end... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/task_definition/erb.rb | Ruby | mit | 220 | main | 2,189 | require 'ostruct'
class Ufo::TaskDefinition
class Erb < Ufo::CLI::Base
extend Memoist
include Context
delegate :name, :role, to: :task_definition
alias_method :task_definition_name, :name
alias_method :family, :name
def run
logger.info "Building Task Definition"
clean
load... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/task_definition/erb/json.rb | Ruby | mit | 220 | main | 698 | class Ufo::TaskDefinition::Erb
class Json < Base
def data
text = IO.read(@path)
JSON.load(text)
rescue JSON::ParserError => e
# NOTE: JSON::ParserError e.message is not very useful
logger.error "ERROR: #{e.class}".color(:red)
logger.error <<~EOL
Rendered file contains inv... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/task_definition/erb/base.rb | Ruby | mit | 220 | main | 405 | class Ufo::TaskDefinition::Erb
class Base < Ufo::CLI::Base
def initialize(options={})
super
@path = options[:path]
@task_definition = options[:task_definition]
end
def print_code(text)
lines = text.split("\n")
lpad = lines.size.to_s.size
lines.each_with_index do |line,... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/task_definition/erb/yaml.rb | Ruby | mit | 220 | main | 677 | class Ufo::TaskDefinition::Erb
class Yaml < Base
def data
text = IO.read(@path)
YAML.load(text)
rescue Psych::SyntaxError => e
logger.error "ERROR: #{e.class}: #{e.message}".color(:red)
logger.error <<~EOL
Rendered file contains invalid YAML. For debugging, files available at:
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/task_definition/helpers/vars.rb | Ruby | mit | 220 | main | 406 | module Ufo::TaskDefinition::Helpers
module Vars
def env(text)
Builder.new(text: text).env
end
alias_method :env_vars, :env
alias_method :environment, :env
def env_file(path=nil)
Builder.new(file: path).env
end
def secrets(text)
Builder.new(text: text).secrets
end
... |
github | boltops-tools/ufo | https://github.com/boltops-tools/ufo | lib/ufo/task_definition/helpers/aws_helper.rb | Ruby | mit | 220 | main | 420 | module Ufo::TaskDefinition::Helpers
# Named AwsHelper to avoid possible conflict with Aws elsewhere
module AwsHelper
extend Memoist
extend ActiveSupport::Concern
included do
delegate :account, :region, to: :aws
alias_method :aws_region, :region
alias_method :current_region, :region
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.