Skip to content

Commit

Permalink
allow empty paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jwaldrip committed Jan 10, 2020
1 parent f953dcd commit 241fcb5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion shard.yml
@@ -1,5 +1,5 @@
name: psykube
version: 2.22.2
version: 2.23.0
crystal: 0.30.0

authors:
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/apply.cr
Expand Up @@ -44,7 +44,7 @@ class Psykube::CLI::Commands::Apply < Admiral::Command
if actor.manifest.type == "Deployment" && flags.wait
kubectl_run("rollout", ["status", "#{actor.manifest.type}/#{actor.manifest.name}".downcase])
end
kubectl_run("annotate", ["namespace", namespace, "psykube.io/last-modified=#{Time.now.to_json}"], flags: {"--overwrite" => "true"})
kubectl_run("annotate", ["namespace", namespace, "psykube.io/last-modified=#{Time.utc.to_json}"], flags: {"--overwrite" => "true"})
elsif flags.skip_if_no_cluster
@error_io.puts "cluster not defined: `#{actor.cluster_name}`, skipping...".colorize(:yellow)
else
Expand Down
12 changes: 8 additions & 4 deletions src/cli/commands/edit_secret.cr
Expand Up @@ -7,9 +7,13 @@ class Psykube::CLI::Commands::EditSecret < Admiral::Command
define_help description: "Edit a secrets plain text values"

define_argument name, description: "The name of the secret."
define_flag dry_run : Bool, description: "Display the change without writing it to the cluster."

def run
secret = Pyrite::Api::Core::V1::Secret.from_json(kubectl_json(resource: "secret", name: arguments.name || actor.name))
json = kubectl_json(resource: "secret", name: arguments.name || actor.name)
puts json
return;
secret = Pyrite::Api::Core::V1::Secret.from_json(json)
data = decode(secret.data || {} of String => String)
tempfile =
{% if compare_versions(Crystal::VERSION, "0.27.0") < 0 %}
Expand All @@ -23,9 +27,9 @@ class Psykube::CLI::Commands::EditSecret < Admiral::Command
{% end %}
Process.run(command: ENV["EDITOR"] || "vim", args: [tempfile.path], input: STDIN, output: STDOUT, error: STDERR)
secret.data = encode(Hash(String, String).from_yaml(File.read(tempfile.path)))
kubectl_run("apply", manifest: secret)
flags.dry_run ? puts(secret.to_yaml) : kubectl_run("apply", manifest: secret)
ensure
tempfile.delete if tempfile
# tempfile.delete if tempfile
end

private def decode(data : Hash(String, String))
Expand All @@ -36,7 +40,7 @@ class Psykube::CLI::Commands::EditSecret < Admiral::Command

private def encode(data : Hash(String, String))
data.each_with_object({} of String => String) do |(k, v), o|
o[k] = Base64.encode(v)
o[k] = Base64.strict_encode(v).strip
end
end
end
2 changes: 1 addition & 1 deletion src/cli/commands/status.cr
Expand Up @@ -11,7 +11,7 @@ class Psykube::CLI::Commands::Status < Admiral::Command
case pod
when Pyrite::Api::Core::V1::Pod
if (status = pod.status)
age_span = (Time.now - (status.start_time || Time.now))
age_span = (Time.utc - (status.start_time || Time.utc))
age_string = ""
age_string += "#{age_span.total_days.to_i}d" if age_span.total_days.to_i > 0
age_string += "#{age_span.hours.to_i}h" if age_span.hours.to_i > 0
Expand Down
7 changes: 3 additions & 4 deletions src/psykube/v1/manifest/ingress/host.cr
Expand Up @@ -2,17 +2,16 @@ require "./tls"

class Psykube::V1::Manifest::Ingress::Host
alias PathList = Array(String)
alias PathMap = Hash(String, Path)
alias PathMap = Hash(String?, Path)

Macros.mapping({
tls: {type: Tls | Bool, optional: true},
port: {type: Int32 | String, default: "default"},
path: {type: String, default: "/"},
path: {type: String, optional: true},
paths: {type: PathList | PathMap, optional: true},
})

def initialize
@path = "/"
@port = "default"
end

Expand All @@ -28,7 +27,7 @@ class Psykube::V1::Manifest::Ingress::Host
else
PathMap.new
end
path_map[path] = Path.new(port) if path
path_map[path] = Path.new(port)
path_map
end
end
Expand Down

0 comments on commit 241fcb5

Please sign in to comment.