Skip to content

Commit

Permalink
chore: parse "boolean" variables
Browse files Browse the repository at this point in the history
Makes make WITH_DEBUG=1 work.

Closes siderolabs/talos#3534.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
  • Loading branch information
AlekSi authored and talos-bot committed May 13, 2021
1 parent 148e228 commit 3a6c5b9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ SFYRA_CLUSTERCTL_CONFIG ?= $(HOME)/.cluster-api/clusterctl.sfyra.yaml

GO_BUILDFLAGS ?=

WITH_DEBUG ?=
WITH_DEBUG ?= false

ifeq ($(WITH_DEBUG), true)
ifeq ($(shell hack/parsebool.sh $(WITH_DEBUG); echo $$?), 1)
GO_BUILDFLAGS += -tags sidero.debug
endif

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/talos-systems/cluster-api-bootstrap-provider-talos v0.2.0-alpha.11
github.com/talos-systems/cluster-api-control-plane-provider-talos v0.1.0-alpha.11
github.com/talos-systems/go-blockdevice v0.1.1-0.20201218174450-f2728a581972
github.com/talos-systems/go-debug v0.1.0
github.com/talos-systems/go-debug v0.2.0
github.com/talos-systems/go-kmsg v0.1.0
github.com/talos-systems/go-procfs v0.0.0-20210108152626-8cbc42d3dc24
github.com/talos-systems/go-retry v0.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ github.com/talos-systems/crypto v0.2.1-0.20210202170911-39584f1b6e54 h1:2IGs3f0q
github.com/talos-systems/crypto v0.2.1-0.20210202170911-39584f1b6e54/go.mod h1:OXCK52Q0dzm88YRG4VdTBdidkPUtqrCxCyW7bUs4DAw=
github.com/talos-systems/go-blockdevice v0.1.1-0.20201218174450-f2728a581972 h1:/yEPl6h6+pK9XIfQEiZ989GDuw6dCUBeinzUcCu6dyY=
github.com/talos-systems/go-blockdevice v0.1.1-0.20201218174450-f2728a581972/go.mod h1:efEE9wjtgxiovqsZAV39xlOd/AOI/0sLuZqb5jEgeqo=
github.com/talos-systems/go-debug v0.1.0 h1:lURdF1U2UwB0by/CiunePULUHBR5BXdsG8I4Mjv+uUw=
github.com/talos-systems/go-debug v0.1.0/go.mod h1:pR4NjsZQNFqGx3n4qkD4MIj1F2CxyIF8DCiO1+05JO0=
github.com/talos-systems/go-debug v0.2.0 h1:IbBfDSJE7tUaSXKuytOksHFI/wAbU2/1/szGvnKpgqc=
github.com/talos-systems/go-debug v0.2.0/go.mod h1:pR4NjsZQNFqGx3n4qkD4MIj1F2CxyIF8DCiO1+05JO0=
github.com/talos-systems/go-kmsg v0.1.0 h1:juoZn+XioduYvtie6nqi/miKGJPLYSBNXRv5jRe6+lE=
github.com/talos-systems/go-kmsg v0.1.0/go.mod h1:dppwQn+/mrdvsziGMbXjzfc4E+75oZhr39UIP6LgL0w=
github.com/talos-systems/go-procfs v0.0.0-20210108152626-8cbc42d3dc24 h1:fN8vYvlB9XBQ5aImb1vLgR0ZaDwvfZfBMptqkpi3aEg=
Expand Down
16 changes: 16 additions & 0 deletions hack/parsebool.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# parsebool.sh exits with code:
# 0 if passed argument is false, FALSE, f, 0, etc
# 1 if passed argument is true, TRUE, t, 1, etc
# 2 if passed argument is absent, an empty string or something else

set -e

arg=$(echo $* | tr '[:upper:]' '[:lower:]')

case $arg in
false|f|0) exit 0 ;;
true|t|1) exit 1 ;;
*) exit 2 ;;
esac
2 changes: 1 addition & 1 deletion sfyra/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/stretchr/testify v1.7.0
github.com/talos-systems/cluster-api-bootstrap-provider-talos v0.2.0-alpha.11
github.com/talos-systems/cluster-api-control-plane-provider-talos v0.1.0-alpha.11
github.com/talos-systems/go-debug v0.1.0
github.com/talos-systems/go-debug v0.2.0
github.com/talos-systems/go-loadbalancer v0.1.1
github.com/talos-systems/go-procfs v0.0.0-20210108152626-8cbc42d3dc24
github.com/talos-systems/go-retry v0.2.1-0.20210119124456-b9dc1a990133
Expand Down
4 changes: 2 additions & 2 deletions sfyra/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -959,8 +959,8 @@ github.com/talos-systems/go-blockdevice v0.2.1-0.20210305142622-bb3ad73f6983 h1:
github.com/talos-systems/go-blockdevice v0.2.1-0.20210305142622-bb3ad73f6983/go.mod h1:Wt0/JMsa+WysYRDlNo6fu9rdn/re73uRnktFWyVUqjs=
github.com/talos-systems/go-cmd v0.0.0-20210216164758-68eb0067e0f0 h1:DI+BjK+fcrLBc70Fi50dZocQcaHosqsuWHrGHKp2NzE=
github.com/talos-systems/go-cmd v0.0.0-20210216164758-68eb0067e0f0/go.mod h1:kf+rZzTEmlDiYQ6ulslvRONnKLQH8x83TowltGMhO+k=
github.com/talos-systems/go-debug v0.1.0 h1:lURdF1U2UwB0by/CiunePULUHBR5BXdsG8I4Mjv+uUw=
github.com/talos-systems/go-debug v0.1.0/go.mod h1:pR4NjsZQNFqGx3n4qkD4MIj1F2CxyIF8DCiO1+05JO0=
github.com/talos-systems/go-debug v0.2.0 h1:IbBfDSJE7tUaSXKuytOksHFI/wAbU2/1/szGvnKpgqc=
github.com/talos-systems/go-debug v0.2.0/go.mod h1:pR4NjsZQNFqGx3n4qkD4MIj1F2CxyIF8DCiO1+05JO0=
github.com/talos-systems/go-kmsg v0.1.0/go.mod h1:dppwQn+/mrdvsziGMbXjzfc4E+75oZhr39UIP6LgL0w=
github.com/talos-systems/go-loadbalancer v0.1.0/go.mod h1:D5Qjfz+29WVjONWECZvOkmaLsBb3f5YeWME0u/5HmIc=
github.com/talos-systems/go-loadbalancer v0.1.1 h1:qjC0uWHu6O7VXG9EN4ovVPg79sRbypXTrJZJskdaa2k=
Expand Down

0 comments on commit 3a6c5b9

Please sign in to comment.