Skip to content

Commit

Permalink
Update version of go-tsuruclient
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Apr 3, 2024
1 parent 1d3d2b1 commit b978225
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0
github.com/stretchr/testify v1.8.4
github.com/tsuru/go-tsuruclient v0.0.0-20230810191332-d7797f6ca207
github.com/tsuru/go-tsuruclient v0.0.0-20240403182619-fe8da980483b
github.com/tsuru/rpaas-operator v0.37.1-0.20230811141023-a01d7e5bde12
k8s.io/apimachinery v0.26.2
)
Expand All @@ -31,7 +31,7 @@ require (
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/docker v20.10.24+incompatible // indirect
github.com/docker/docker v23.0.0-rc.1+incompatible // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
Expand Down Expand Up @@ -134,7 +134,7 @@ require (
github.com/tsuru/gnuflag v0.0.0-20151217162021-86b8c1b864aa // indirect
github.com/tsuru/nginx-operator v0.13.2 // indirect
github.com/tsuru/tablecli v0.0.0-20190131152944-7ded8a3383c6 // indirect
github.com/tsuru/tsuru v0.0.0-20230721211340-f41fb455f8c3 // indirect
github.com/tsuru/tsuru v0.0.0-20240325190920-410c71393b77 // indirect
github.com/uber/jaeger-client-go v2.25.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.0+incompatible // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
Expand Down Expand Up @@ -174,7 +174,7 @@ require (
k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d // indirect
k8s.io/kubectl v0.26.2 // indirect
k8s.io/metrics v0.26.2 // indirect
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
knative.dev/pkg v0.0.0-20230306194819-b77a78c6c0ad // indirect
sigs.k8s.io/controller-runtime v0.14.5 // indirect
sigs.k8s.io/gateway-api v0.4.3 // indirect
Expand Down
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8
github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE=
github.com/docker/docker v20.10.24+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v23.0.0-rc.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
Expand Down Expand Up @@ -754,6 +755,8 @@ github.com/tsuru/gnuflag v0.0.0-20151217162021-86b8c1b864aa h1:JlLQP1xa13a994p/A
github.com/tsuru/gnuflag v0.0.0-20151217162021-86b8c1b864aa/go.mod h1:UibOSvkMFKRe/eiwktAPAvQG8L+p8nYsECJvu3Dgw7I=
github.com/tsuru/go-tsuruclient v0.0.0-20230810191332-d7797f6ca207 h1:w+lEWe6tu1mAKi3fpvVrus95QcM1VyFiYm2yw5pguYE=
github.com/tsuru/go-tsuruclient v0.0.0-20230810191332-d7797f6ca207/go.mod h1:BmePxHey9hxrxk0kzTMHFFr7aJWXSxtlrUx6FIeV0Ic=
github.com/tsuru/go-tsuruclient v0.0.0-20240403182619-fe8da980483b h1:CWioMVdmtkdipWKCWVnuT+6ZqzVzB/R6hdX0SW4KJOI=
github.com/tsuru/go-tsuruclient v0.0.0-20240403182619-fe8da980483b/go.mod h1:qwh/KJ6ypa2GISRI79XFOHhnSjGOe1cZVPHF3nfrf18=
github.com/tsuru/nginx-operator v0.13.2 h1:b6D+FnoVgt51/3JYUFTDYcQJwPufy+KjOUtgx6WDL9E=
github.com/tsuru/nginx-operator v0.13.2/go.mod h1:CPfOU74PhA3kpR/hNkTswfTNYCsXK8L7ZCx25IYtlM0=
github.com/tsuru/rpaas-operator v0.37.1-0.20230811141023-a01d7e5bde12 h1:1savFWcYIGRISsjX+Hh9k5NHKf2NrnwnrW702NzyL+c=
Expand All @@ -764,6 +767,8 @@ github.com/tsuru/tablecli v0.0.0-20190131152944-7ded8a3383c6 h1:1XDdWFAjIbCSG1Oj
github.com/tsuru/tablecli v0.0.0-20190131152944-7ded8a3383c6/go.mod h1:ztYpOhW+u1k21FEqp7nZNgpWbr0dUKok5lgGCZi+1AQ=
github.com/tsuru/tsuru v0.0.0-20230721211340-f41fb455f8c3 h1:Fi5mEiJiHlTCaSYpfP19kbiOzJD26yqwVojUKdLsVHA=
github.com/tsuru/tsuru v0.0.0-20230721211340-f41fb455f8c3/go.mod h1:wk2+TMnFgB/2EPCRPPONfCipUbl6pF1U4ncfWygtKR0=
github.com/tsuru/tsuru v0.0.0-20240325190920-410c71393b77 h1:cuWFjNLaemdQZhojqJbb/rOXO97tlcPeLAHg/x+EQGk=
github.com/tsuru/tsuru v0.0.0-20240325190920-410c71393b77/go.mod h1:QxMVXEjpb6mPnlaLMQdxJ3XCg+vOa4/MwZWLk3/naec=
github.com/uber/jaeger-client-go v2.25.0+incompatible h1:IxcNZ7WRY1Y3G4poYlx24szfsn/3LvK9QHCq9oQw8+U=
github.com/uber/jaeger-client-go v2.25.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
github.com/uber/jaeger-lib v2.4.0+incompatible h1:fY7QsGQWiCt8pajv4r7JEvmATdCVaWxXbjwyYwsNaLQ=
Expand Down Expand Up @@ -1400,6 +1405,8 @@ k8s.io/utils v0.0.0-20210820185131-d34e5cb4466e/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 h1:kmDqav+P+/5e1i9tFfHq1qcF3sOrDp+YEkVDAHu7Jwk=
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
knative.dev/pkg v0.0.0-20230306194819-b77a78c6c0ad h1:cYCDdgSMOKiCGm6v1vvR2v4l/naGorbwoJKE/e39BJI=
knative.dev/pkg v0.0.0-20230306194819-b77a78c6c0ad/go.mod h1:S+KfTInuwEkZSTwvWqrWZV/TEw6ps51GUGaSC1Fnbe0=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
16 changes: 12 additions & 4 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
tsuruclient "github.com/tsuru/go-tsuruclient/pkg/client"
"github.com/tsuru/go-tsuruclient/pkg/config"
rpaasclient "github.com/tsuru/rpaas-operator/pkg/rpaas/client"
"github.com/tsuru/rpaas-operator/pkg/rpaas/client/autogenerated"
"github.com/tsuru/tsuru/cmd"
)

var Version string = "undefined"
Expand Down Expand Up @@ -159,7 +159,7 @@ func getProviderConfigOpts(d *schema.ResourceData) (*ProviderConfigOptions, erro
}

if opts.TsuruTarget != "" {
target, err := cmd.ReadTarget()
target, err := config.ReadTarget()
if err != nil {
return nil, err
}
Expand All @@ -168,7 +168,7 @@ func getProviderConfigOpts(d *schema.ResourceData) (*ProviderConfigOptions, erro
}

if opts.TsuruTarget != "" && opts.TsuruToken == "" {
token, err := cmd.ReadToken()
token, err := readToken()
if err != nil {
return nil, err
}
Expand All @@ -195,7 +195,7 @@ func getLegacyClient(opts *ProviderConfigOptions) (rpaasclient.Client, error) {
}

if opts.TsuruToken == "" {
token, err := cmd.ReadToken()
token, err := readToken()
if err != nil {
return nil, err
}
Expand All @@ -206,6 +206,14 @@ func getLegacyClient(opts *ProviderConfigOptions) (rpaasclient.Client, error) {
return rpaasclient.NewClientThroughTsuruWithOptions(opts.TsuruTarget, opts.TsuruToken, service, legacyClientOpts)
}

func readToken() (string, error) {
_, tokenProvider, err := tsuruclient.RoundTripperAndTokenProvider()
if err != nil {
return "", err
}
return tokenProvider.Token()
}

func getAutogeneratedClient(opts *ProviderConfigOptions) *autogenerated.APIClient {
serverURL := opts.URL
if serverURL == "" {
Expand Down

0 comments on commit b978225

Please sign in to comment.