Skip to content

Commit

Permalink
Merge pull request #33 from linode/allow-arbitrary-root-cas
Browse files Browse the repository at this point in the history
Support arbitrary root CAs
  • Loading branch information
asauber authored Jun 27, 2019
2 parents 992122b + 2201e84 commit eabc5d6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
27 changes: 23 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,43 @@ REV=$(shell git describe --long --tags --dirty)

export GO111MODULE=on

.PHONY: all linode clean linode-container

.PHONY: all
all: linode

.PHONY: vendor
vendor:
go mod vendor
test:
go test -v ./... -cover

.PHONY: fmt
fmt:
go fmt ./...

.PHONY: vet
vet: fmt
go vet ./...

.PHONY: test
test: vet
go test -v ./... -cover

.PHONY: linode
linode: vendor test
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-X main.vendorVersion=$(REV) -extldflags "-static"' -o _output/linode ./app/linode

.PHONY: linode-container
linode-container: linode
docker build -t $(IMAGE_TAG) -f ./app/linode/Dockerfile .

.PHONY: push
push: linode-container
#@echo "$$DOCKER_PASSWORD" | docker login -u "$$DOCKER_USERNAME" --password-stdin
docker push $(IMAGE_TAG)

.PHONY: verify
verify:
go mod verify

.PHONY: clean
clean:
@GOOS=linux go clean -i -r -x ./...
-rm -rf _output
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/hashicorp/golang-lru v0.5.0 // indirect
github.com/json-iterator/go v1.1.5 // indirect
github.com/kubernetes-csi/csi-test v1.1.0
github.com/linode/linodego v0.9.0
github.com/linode/linodego v0.10.0
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
Expand All @@ -36,7 +36,7 @@ require (
github.com/stretchr/testify v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 // indirect
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a
golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba
golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba // indirect
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c // indirect
google.golang.org/grpc v1.16.0
gopkg.in/inf.v0 v0.9.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kubernetes-csi/csi-test v1.1.0 h1:a7CfGqhGDs0h7AZt1f6LTIUzBazcRf6eBdTUBXB4xE4=
github.com/kubernetes-csi/csi-test v1.1.0/go.mod h1:YxJ4UiuPWIhMBkxUKY5c267DyA0uDZ/MtAimhx/2TA0=
github.com/linode/linodego v0.9.0 h1:FnWYh6myo4yuiRmui0rpU0TsCVwLbgX1L7/ibmFYenE=
github.com/linode/linodego v0.9.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8LANE4eXA=
github.com/linode/linodego v0.10.0 h1:AMdb82HVgY8o3mjBXJcUv9B+fnJjfDMn2rNRGbX+jvM=
github.com/linode/linodego v0.10.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8LANE4eXA=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
Expand Down
16 changes: 3 additions & 13 deletions pkg/linode-client/linode-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package linodeclient
import (
"context"
"fmt"
"net/http"

"github.com/linode/linodego"
"golang.org/x/oauth2"
)

type LinodeClient interface {
Expand All @@ -27,19 +25,11 @@ type LinodeClient interface {
}

func NewLinodeClient(token, uaPrefix string, url string) *linodego.Client {
tokenSource := oauth2.StaticTokenSource(&oauth2.Token{
AccessToken: token,
})

oauth2Client := &http.Client{
Transport: &oauth2.Transport{
Source: tokenSource,
},
}

ua := fmt.Sprintf("%s linodego/%s", uaPrefix, linodego.Version)
linodeClient := linodego.NewClient(oauth2Client)
// Use linodego built-in http client which supports setting root CA cert
linodeClient := linodego.NewClient(nil)
linodeClient.SetUserAgent(ua)
linodeClient.SetToken(token)
linodeClient.SetDebug(true)

if url != "" {
Expand Down

0 comments on commit eabc5d6

Please sign in to comment.