Created
October 7, 2019 19:00
-
-
Save coryodaniel/2ea7bcc75b5d3d605fd8898d3fc353a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
creationTimestamp: null | |
labels: | |
app: my-deployment | |
name: my-deployment | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: my-deployment | |
strategy: {} | |
template: | |
metadata: | |
creationTimestamp: null | |
labels: | |
app: my-deployment | |
spec: | |
containers: | |
- image: me/my-deployment:v1 | |
name: my-deployment | |
env: | |
- name: MIX_ENV | |
value: $(MIX_ENV) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namePrefix: var- | |
resources: | |
- deployment.yaml | |
configMapGenerator: | |
- name: my-config | |
literals: | |
- MIX_ENV=dev | |
vars: | |
- name: MIX_ENV | |
objref: | |
kind: ConfigMap | |
name: my-config | |
apiVersion: v1 | |
fieldref: | |
fieldpath: data.MIX_ENV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'optparse' | |
require 'json' | |
require "base64" | |
require 'fileutils' | |
$out = "/tmp/lol" | |
options = {} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: pasta.rb [options]" | |
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v| | |
options[:verbose] = v | |
end | |
opts.on("-pSTR", "--paste=STR", "String to paste") do |p| | |
options[:paste] = p | |
end | |
opts.on("-cPATH", "--copy=PATH", "Path to copy") do |c| | |
options[:copy] = c | |
end | |
end.parse! | |
if options[:copy] | |
wildcard_path = File.join(options[:copy], "**", "*") | |
files = Dir[wildcard_path].reject {|fn| File.directory?(fn) } | |
manifest = files.reduce({}) do |agg, filename| | |
agg[filename] = File.read(filename) | |
agg | |
end | |
json = JSON.generate(manifest) | |
output = Base64.strict_encode64(json) | |
puts output | |
elsif options[:paste] | |
json = Base64.decode64(options[:paste]) | |
manifest = JSON.parse(json) | |
manifest.each do |name, data| | |
filepath = File.expand_path(File.join($out, name)) | |
directory = File.dirname(filepath) | |
FileUtils.mkdir_p(directory) | |
File.open(filepath, "w+") do |f| | |
if options[:verbose] | |
puts "Creating: #{filepath}" | |
end | |
f.puts data | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment