Sha256: cecc25f08f701ed0f790cdadcec1ddbb2fb250df6b11a0c1bb021c0fd8d28283
Contents?: true
Size: 1.78 KB
Versions: 3
Compression:
Stored size: 1.78 KB
Contents
#!/bin/env ruby ## # fastly_upload_vcl - upload raw VCL files to Fastly # # Author:: Fastly Inc <support@fastly.com> # Copyright:: Copyright (c) 2011 Fastly Inc # License:: Distributes under the same terms as Ruby # # = USAGE # # fastly_upload_vcl <options> <service id or name> <path to vcl file> # # = CONFIGURATION # # You can either have a config file in either ~/.fastly or /etc/fastly with # # api_key = <key> # # or a config file with # # user = <login> # password = <password> # # Alternatively you can pass in any of those options on the command line # # fastly_upload_vcl --api_key <key> <service id or name> <path to vcl file> # fastly_upload_vcl --user <login> --password <password> <service id or name> <path to vcl file> # require 'rubygems' require 'fastly' # :nodoc: def die(message) warn message exit -1 end params = Fastly.get_options("#{ENV['HOME']}/.fastly", "/etc/fastly") service_id = ARGV.shift || die("You must pass in a service id") vcl_file = ARGV.shift || die("You must pass in a vcl file") die("Couldn't find any of the config files - #{configs.join(',')}") unless params.keys.size>0 die("Couldn't find vcl file #{vcl_file}") unless File.file?(vcl_file) fastly = Fastly.new(params) service = fastly.get_service(service_id) || die("Couldn't find service #{service_id}") old = service.version updated = old.clone puts "Uploading #{vcl_file} and bumping version from #{old.number} to #{updated.number}" begin name = File.basename(vcl_file, ".vcl") content = File.new(vcl_file, "r").read vcl = updated.vcl(name) if vcl vcl.content = content vcl.save! else updated.upload_vcl(name, content) end updated.activate! rescue => e die("Couldn't upload and activate vcl: #{e}") end puts "Done!"
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fastly-0.95 | bin/fastly_upload_vcl |
fastly-0.9 | bin/fastly_upload_vcl |
fastly-0.5 | bin/fastly_upload_vcl |