kran 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79c4036c8b185127e7157d85eff69305ef0d9bc124e4fbfc9f1ff336fdaae6fe
4
- data.tar.gz: 1950703c5f3f10e734a39277ec2ede994fa6703ff2c16c3b5f174f03dc9aafab
3
+ metadata.gz: cadcace7c5bf8d83aa3ab9007caba40361fef547a91a7d9016a4707c92daa813
4
+ data.tar.gz: f9b29ad876cbe00d2e4b47fb8143ac399243de3207c28f4e3c5c766747cb7bd1
5
5
  SHA512:
6
- metadata.gz: 93fc5a593bb95f3b212d5657d446b08d264de9e186302732320671f94eef43713cd6b84a59b690c800950c4b45d0b74501aa9557146077251d856557821fa0a4
7
- data.tar.gz: e058664d0ede94f9fa65d6d8e59f18e9b55836b176f612cf387e597c8d030e392cc50df4118cabbe3105223c6a90fc969524cb02eff709252129db934b963f99
6
+ metadata.gz: 385f44dd50a3464299967fe2b85018a40d791a44c9272a7acb687e7a58be39324f03c4ad684097b0cc6259224746df737320f7b6a37ac7472362ac8e6ef6b3b2
7
+ data.tar.gz: eeb759046f23efeb8baa880e02aea5fb9bcca32e9542d243bf81b864f0ca37c76a0313ea74c6599033460642c0cfaa2547f2a179ca132b6fe774a0fdff509d2f
data/README.md CHANGED
@@ -1,11 +1,14 @@
1
1
  # kran
2
2
 
3
+ [![Gem Version](https://img.shields.io/gem/v/kran)](https://rubygems.org/gems/kran)
4
+ [![CI](https://github.com/yfxie/kran/actions/workflows/ci.yml/badge.svg)](https://github.com/yfxie/kran/actions/workflows/ci.yml)
5
+ [![Coverage Status](https://coveralls.io/repos/github/yfxie/kran/badge.svg?branch=main)](https://coveralls.io/github/yfxie/kran?branch=main)
6
+ [![License](https://img.shields.io/github/license/yfxie/kran)](LICENSE)
7
+
3
8
  Deploy to Kubernetes with [krane](https://github.com/Shopify/krane), the simple way.
4
9
  One command builds the image, pushes it, renders the krane templates and deploys them. A few more
5
10
  commands cover the daily work: logs, exec, details, audit.
6
11
 
7
- Kran is the German word for crane.
8
-
9
12
  ## Install
10
13
 
11
14
  ```sh
@@ -34,7 +37,6 @@ If you have used [kamal](https://kamal-deploy.org), this will feel just as simpl
34
37
  one config file, one command to deploy.
35
38
 
36
39
  Documentation: https://kran.bincode.tw
37
- Source: https://github.com/yfxie/kran
38
40
 
39
41
  ## Develop
40
42
 
@@ -28,9 +28,8 @@ module Kran
28
28
  private
29
29
 
30
30
  def docker(*args)
31
- command = Shell.join(["docker", *args.compact])
32
- remote = @config.builder.remote
33
- remote ? "DOCKER_HOST=#{Shell.escape(remote)} #{command}" : command
31
+ env = @config.env.merge({ "DOCKER_HOST" => @config.builder.remote }.compact)
32
+ Shell.with_env(env, Shell.join(["docker", *args.compact]))
34
33
  end
35
34
 
36
35
  def platform(archs)
@@ -18,8 +18,7 @@ module Kran
18
18
  # krane parses options with Thor, where a repeated -f replaces the earlier one
19
19
  # instead of appending to it, so every file has to follow a single -f.
20
20
  files = [@config.krane.secrets, "-"].compact
21
- command = krane("deploy", kubernetes.namespace, kubernetes.context, "-f", *files)
22
- kubernetes.kubeconfig ? "KUBECONFIG=#{Shell.escape(kubernetes.kubeconfig)} #{command}" : command
21
+ krane("deploy", kubernetes.namespace, kubernetes.context, "-f", *files, kubeconfig: kubernetes.kubeconfig)
23
22
  end
24
23
 
25
24
  def pipeline(tag)
@@ -36,8 +35,9 @@ module Kran
36
35
 
37
36
  private
38
37
 
39
- def krane(*args)
40
- "#{@config.krane.command} #{Shell.join(args)}"
38
+ def krane(*args, kubeconfig: nil)
39
+ env = @config.env.merge({ "KUBECONFIG" => kubeconfig }.compact)
40
+ Shell.with_env(env, "#{@config.krane.command} #{Shell.join(args)}")
41
41
  end
42
42
  end
43
43
  end
@@ -46,8 +46,8 @@ module Kran
46
46
 
47
47
  def kubectl(*args)
48
48
  kubernetes = @config.kubernetes
49
- command = Shell.join(["kubectl", "--context", kubernetes.context, "--namespace", kubernetes.namespace, *args.compact])
50
- kubernetes.kubeconfig ? "KUBECONFIG=#{Shell.escape(kubernetes.kubeconfig)} #{command}" : command
49
+ env = @config.env.merge({ "KUBECONFIG" => kubernetes.kubeconfig }.compact)
50
+ Shell.with_env(env, Shell.join(["kubectl", "--context", kubernetes.context, "--namespace", kubernetes.namespace, *args.compact]))
51
51
  end
52
52
  end
53
53
  end
@@ -71,5 +71,9 @@ module Kran
71
71
  def aliases
72
72
  @raw.fetch("aliases", {})
73
73
  end
74
+
75
+ def env
76
+ @raw.fetch("env", {}).transform_values(&:to_s)
77
+ end
74
78
  end
75
79
  end
data/lib/kran/shell.rb CHANGED
@@ -15,5 +15,10 @@ module Kran
15
15
  def join(words)
16
16
  words.map { |word| escape(word) }.join(" ")
17
17
  end
18
+
19
+ def with_env(env, command)
20
+ assignments = env.map { |name, value| "#{name}=#{escape(value)}" }
21
+ [*assignments, command].join(" ")
22
+ end
18
23
  end
19
24
  end
@@ -46,6 +46,12 @@ app:
46
46
  # Container inside the pod (kubectl -c). Defaults to the pod's default container.
47
47
  # container: web
48
48
 
49
+ # Environment variables put in front of every docker, krane and kubectl command, for settings those
50
+ # tools read from the environment: which cloud account docker's credential helper and kubectl's
51
+ # auth plugin sign in with, for example.
52
+ # env:
53
+ # CLOUDSDK_ACTIVE_CONFIG_NAME: acme
54
+
49
55
  # Shortcuts run with `kran <alias>`. Extra arguments are appended to the command.
50
56
  aliases:
51
57
  shell: exec --interactive bash
data/lib/kran/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kran
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kran
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yi Feng Xie