Skip to content

Commit 17f3ee6

Browse files
committed
Merge remote-tracking branch 'origin' into kube-secrets
2 parents fb486eb + 632aa95 commit 17f3ee6

3 files changed

Lines changed: 82 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Prepare release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
create_release:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: actions/create-release@v1
13+
id: create_release
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
with:
17+
tag_name: ${{ github.ref }}
18+
release_name: "checkenv ${{ github.ref_name }}"
19+
body: |
20+
Version ${{ github.ref_name }} of checkenv
21+
draft: true
22+
prerelease: false
23+
outputs:
24+
upload_url: ${{ steps.create_release.outputs.upload_url }}
25+
upload_assets:
26+
runs-on: ubuntu-20.04
27+
needs: create_release
28+
strategy:
29+
fail-fast: true
30+
matrix:
31+
os: ["linux", "darwin", "windows"]
32+
arch: ["386", "amd64", "arm64"]
33+
exclude:
34+
- os: "darwin"
35+
arch: "arm"
36+
- os: "darwin"
37+
arch: "386"
38+
- os: "windows"
39+
arch: "arm"
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: actions/setup-go@v2
43+
with:
44+
go-version: ^1.16.0
45+
- name: Build binary for each valid (GOOS, GOARCH) pair
46+
env:
47+
GOOS: ${{ matrix.os }}
48+
GOARCH: ${{ matrix.arch }}
49+
run: |
50+
BUILD_DIR="checkenv-${{ github.ref_name }}-${GOOS}-${GOARCH}"
51+
EXTENSION=""
52+
if [ "$GOOS" = "windows" ]; then
53+
EXTENSION=".exe"
54+
fi
55+
mkdir "$BUILD_DIR"
56+
cp README.md "$BUILD_DIR/README.md"
57+
go build -o "$BUILD_DIR/checkenv${EXTENSION}" .
58+
zip -r "$BUILD_DIR.zip" "$BUILD_DIR"
59+
- name: Upload release asset for each valid (GOOS, GOARH) pair
60+
uses: actions/upload-release-asset@v1
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
with:
64+
upload_url: ${{ needs.create_release.outputs.upload_url }}
65+
asset_path: ./checkenv-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }}.zip
66+
asset_name: checkenv-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }}.zip
67+
asset_content_type: application/zip

checkenv.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99
)
1010

11-
const CHECKENV_VERSION = "v0.0.3"
11+
const CHECKENV_VERSION = "v0.0.4"
1212

1313
type showSpec struct {
1414
loadFrom map[string]interface{}
@@ -56,6 +56,15 @@ func VariablesFromProviderSpec(providerSpec string) (map[string]string, error) {
5656
return plugin.Provider(providerArgs)
5757
}
5858

59+
// Append quotes to value if needed
60+
func AddValueQuotes(val string, showQuotes bool) string {
61+
if showQuotes {
62+
return fmt.Sprintf("\"%s\"", val)
63+
}
64+
65+
return val
66+
}
67+
5968
func main() {
6069
pluginsCommand := "plugins"
6170
pluginsFlags := flag.NewFlagSet("plugins", flag.ExitOnError)
@@ -67,6 +76,7 @@ func main() {
6776
showHelp := showFlags.Bool("h", false, "Use this flag if you want help with this command")
6877
showFlags.BoolVar(showHelp, "help", false, "Use this flag if you want help with this command")
6978
showExport := showFlags.Bool("export", false, "Use this flag to prepend and \"export \" before every environment variable definition")
79+
showQuotes := showFlags.Bool("quotes", false, "Use this flag to put value in quotes")
7080
showRaw := showFlags.Bool("raw", false, "Use this flag to prevent comments output")
7181
showValue := showFlags.Bool("value", false, "Print value only")
7282
showName := showFlags.Bool("name", false, "Print name only")
@@ -126,9 +136,9 @@ func main() {
126136
}
127137
for k, v := range providedVars[providerSpec] {
128138
if !*showValue && !*showName {
129-
fmt.Printf("%s%s=%s\n", exportPrefix, k, v)
139+
fmt.Printf("%s%s=%s\n", exportPrefix, k, AddValueQuotes(v, *showQuotes))
130140
} else if *showValue {
131-
fmt.Printf("%s\n", v)
141+
fmt.Printf("%s\n", AddValueQuotes(v, *showQuotes))
132142
} else if *showName {
133143
fmt.Printf("%s\n", k)
134144
}
@@ -145,9 +155,9 @@ func main() {
145155
fmt.Printf("# UNDEFINED: %s\n", k)
146156
} else {
147157
if !*showValue {
148-
fmt.Printf("%s%s=%s\n", exportPrefix, k, v)
158+
fmt.Printf("%s%s=%s\n", exportPrefix, k, AddValueQuotes(v, *showQuotes))
149159
} else {
150-
fmt.Printf("%s\n", v)
160+
fmt.Printf("%s\n", AddValueQuotes(v, *showQuotes))
151161
}
152162
}
153163
}

dev.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ PROGRAM_NAME="checkenv_dev"
88
go build -o "$PROGRAM_NAME" .
99

1010
./"$PROGRAM_NAME" "$@"
11-

0 commit comments

Comments
 (0)