Skip to content

Commit

Permalink
update vendor deps; add optional -timeout flag to runtimevar tool
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaronland committed Jun 14, 2023
1 parent 0c406b9 commit cfa2f00
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 11 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
GOMOD=vendor

cli:
go build -mod vendor -ldflags="-s -w" -o bin/runtimevar cmd/runtimevar/main.go
go build -mod $(GOMOD) -ldflags="-s -w" -o bin/runtimevar cmd/runtimevar/main.go
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"context"
"flag"
"fmt"
"github.com/sfomuseum/runtimevar"
_ "gocloud.dev/runtimevar/awsparamstore"
_ "gocloud.dev/runtimevar/constantvar"
Expand All @@ -36,8 +37,20 @@ func main() {

## Tools

```
$> make cli
go build -mod vendor -ldflags="-s -w" -o bin/runtimevar cmd/runtimevar/main.go
```

### runtimevar

```
$> ./bin/runtimevar -h
Usage of ./bin/runtimevar:
-timeout int
The maximum number of second in which a variable can be resolved. If 0 no timeout is applied.
```

```
$> go run cmd/runtimevar/main.go 'constant://?val=hello+world'
hello world
Expand Down
14 changes: 13 additions & 1 deletion cmd/runtimevar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@ import (
"context"
"flag"
"fmt"
"log"
"time"

"github.com/sfomuseum/runtimevar"
_ "gocloud.dev/runtimevar/awsparamstore"
_ "gocloud.dev/runtimevar/constantvar"
_ "gocloud.dev/runtimevar/filevar"
"log"
)

func main() {

timeout := flag.Int("timeout", 0, "The maximum number of second in which a variable can be resolved. If 0 no timeout is applied.")

flag.Parse()

ctx := context.Background()

if *timeout > 0 {

c, cancel := context.WithTimeout(ctx, time.Duration(*timeout)*time.Second)
defer cancel()

ctx = c
}

for _, uri := range flag.Args() {

str_var, err := runtimevar.StringVar(ctx, uri)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/sfomuseum/runtimevar
go 1.18

require (
github.com/aaronland/go-aws-session v0.1.0
github.com/aaronland/go-aws-session v0.2.1
gocloud.dev v0.29.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:H
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/aaronland/go-aws-session v0.1.0 h1:1dj3oQhw8Jtecz8jeT5AAzTul0KbLZ8YhmZbql79SyQ=
github.com/aaronland/go-aws-session v0.1.0/go.mod h1:M5imkutLPvwnI1Bb38minI3TCy1eSvwP6odMtCmBzqk=
github.com/aaronland/go-aws-session v0.2.1 h1:sNCuxR1w2ng8fxHsl08AFcAWvZqmN4hmnBbBRNRORd0=
github.com/aaronland/go-aws-session v0.2.1/go.mod h1:M5imkutLPvwnI1Bb38minI3TCy1eSvwP6odMtCmBzqk=
github.com/aaronland/go-string v1.0.0 h1:fPHmC1i9JhGzgi4qdCSXKc4xTCaLLe0uvlJMu9dHhco=
github.com/aaronland/go-string v1.0.0/go.mod h1:URh3Au/fNbM0++WjBseurE3QTp875wiJ9ImrecD+7tI=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
Expand Down
4 changes: 2 additions & 2 deletions string.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/aaronland/go-aws-session"
gc "gocloud.dev/runtimevar"
"gocloud.dev/runtimevar/awsparamstore"
_ "gocloud.dev/runtimevar/constantvar"
_ "gocloud.dev/runtimevar/filevar"
_ "gocloud.dev/runtimevar/constantvar"
_ "gocloud.dev/runtimevar/filevar"
_ "log"
"net/url"
)
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/aaronland/go-aws-session/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 28 additions & 3 deletions vendor/github.com/aaronland/go-aws-session/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/aaronland/go-aws-session/credentials.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# github.com/aaronland/go-aws-session v0.1.0
# github.com/aaronland/go-aws-session v0.2.1
## explicit; go 1.18
github.com/aaronland/go-aws-session
# github.com/aaronland/go-string v1.0.0
Expand Down

0 comments on commit cfa2f00

Please sign in to comment.