From 1cd247905c6616a3f870554aeaca4de8fe97a56a Mon Sep 17 00:00:00 2001 From: Andrew Lytvynov Date: Wed, 8 Apr 2020 10:30:12 -0700 Subject: [PATCH 1/2] Fix broken build in example Go client code The API of auth package changed in an incompatible way. Fix the usage. --- examples/go-client/main.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/go-client/main.go b/examples/go-client/main.go index 54c8cc5c46d..1329913a48d 100644 --- a/examples/go-client/main.go +++ b/examples/go-client/main.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "context" "crypto/tls" "log" "path/filepath" @@ -33,13 +34,14 @@ func main() { // Teleport HTTPS client uses TLS client authentication // so we have to set up certificates there - tlsConfig, err := setupClientTLS() + tlsConfig, err := setupClientTLS(context.Background()) if err != nil { log.Fatalf("Failed to parse TLS config: %v", err) } - authServerAddr := []utils.NetAddr{*utils.MustParseAddr("127.0.0.1:3025")} - client, err := auth.NewTLSClient(authServerAddr, tlsConfig) + clientConfig := auth.ClientConfig{Addrs: authServerAddr, TLS: tlsConfig} + + client, err := auth.NewTLSClient(clientConfig) if err != nil { log.Fatalf("Failed to create client: %v", err) } @@ -61,8 +63,8 @@ func main() { // and Teleport Auth server. This function uses hardcoded certificate paths, // assuming program runs alongside auth server, but it can be ran // on a remote location, assuming client has all the client certificates. -func setupClientTLS() (*tls.Config, error) { - storage, err := auth.NewProcessStorage(filepath.Join("/var/lib/teleport", teleport.ComponentProcess)) +func setupClientTLS(ctx context.Context) (*tls.Config, error) { + storage, err := auth.NewProcessStorage(ctx, filepath.Join("/var/lib/teleport", teleport.ComponentProcess)) if err != nil { return nil, trace.Wrap(err) } From afe814e72482b22808b2b5d4ad0cf06ea02600a4 Mon Sep 17 00:00:00 2001 From: Andrew Lytvynov Date: Wed, 8 Apr 2020 10:31:02 -0700 Subject: [PATCH 2/2] Ensure `make test` covers all packages Selectively listing package paths is error-prone. Use `go list` to get the complete list instead. Filter out integration tests since they are slower. Also, enable the race detector by default. Local `make test` runs should not skip it. --- Makefile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index ed0499d704a..f924836c5a4 100644 --- a/Makefile +++ b/Makefile @@ -193,12 +193,10 @@ run-docs: # tests everything: called by Jenkins # .PHONY: test -test: FLAGS ?= +test: FLAGS ?= '-race' +test: PACKAGES := $(shell go list ./... | grep -v integration) test: $(VERSRC) - go test -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" ./tool/tsh/... \ - ./lib/... \ - ./tool/teleport... $(FLAGS) $(ADDFLAGS) - go vet ./tool/... ./lib/... + go test -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" $(PACKAGES) $(FLAGS) $(ADDFLAGS) # # integration tests. need a TTY to work and not compatible with a race detector