From e7da7e9fbda47f942eadd3f488e4682dc41f5a2c Mon Sep 17 00:00:00 2001 From: fogfish Date: Mon, 11 Nov 2024 06:49:41 +0200 Subject: [PATCH] patch extensions with latest gurl (#68) --- x/awsapi/awsapi.go | 30 ++++++++++++++++-------------- x/awsapi/go.mod | 7 +++++-- x/awsapi/go.sum | 14 ++++++++++---- x/awsapi/version.go | 2 +- x/xhtml/go.mod | 9 ++++++--- x/xhtml/go.sum | 14 ++++++++++---- x/xhtml/version.go | 2 +- x/xhtml/xhtml.go | 2 +- 8 files changed, 50 insertions(+), 30 deletions(-) diff --git a/x/awsapi/awsapi.go b/x/awsapi/awsapi.go index 287a476..966f81b 100644 --- a/x/awsapi/awsapi.go +++ b/x/awsapi/awsapi.go @@ -23,26 +23,19 @@ import ( "github.com/aws/aws-sdk-go-v2/credentials/stscreds" "github.com/aws/aws-sdk-go-v2/service/sts" "github.com/fogfish/gurl/v2/http" + "github.com/fogfish/opts" ) // Configure HTTP Stack to use AWS Sign V4 -func WithSignatureV4(conf aws.Config) http.Config { - return func(p *http.Protocol) { - p.Socket = &signer{ - config: conf, - signer: v4.NewSigner(), - socket: p.Socket, - } - } -} +var WithSignatureV4 = opts.FMap(optsSigner) // Configure HTTP Stack to use AWS Sign V4 using assumed role -func WithAssumedRole(conf aws.Config, role, externalID string) http.Config { +func WithAssumedRole(conf aws.Config, role, externalID string) http.Option { if role == "" && externalID == "" { return WithSignatureV4(conf) } - return func(p *http.Protocol) { + return opts.From(func(p *http.Protocol) error { assumed, err := config.LoadDefaultConfig(context.Background(), config.WithCredentialsProvider( aws.NewCredentialsCache( @@ -57,11 +50,11 @@ func WithAssumedRole(conf aws.Config, role, externalID string) http.Config { ), ) if err != nil { - panic(err) + return err } - WithSignatureV4(assumed)(p) - } + return optsSigner(p, assumed) + })() } type signer struct { @@ -70,6 +63,15 @@ type signer struct { socket http.Socket } +func optsSigner(p *http.Protocol, conf aws.Config) error { + p.Socket = &signer{ + config: conf, + signer: v4.NewSigner(), + socket: p.Socket, + } + return nil +} + func (s *signer) Do(req *net.Request) (*net.Response, error) { credential, err := s.config.Credentials.Retrieve(req.Context()) if err != nil { diff --git a/x/awsapi/go.mod b/x/awsapi/go.mod index 1c24833..58aacae 100644 --- a/x/awsapi/go.mod +++ b/x/awsapi/go.mod @@ -1,13 +1,14 @@ module github.com/fogfish/gurl/x/awsapi -go 1.21.0 +go 1.23 require ( github.com/aws/aws-sdk-go-v2 v1.30.5 github.com/aws/aws-sdk-go-v2/config v1.27.33 github.com/aws/aws-sdk-go-v2/credentials v1.17.32 github.com/aws/aws-sdk-go-v2/service/sts v1.30.7 - github.com/fogfish/gurl/v2 v2.8.3 + github.com/fogfish/gurl/v2 v2.10.0 + github.com/fogfish/opts v0.0.2 ) require ( @@ -21,5 +22,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sso v1.22.7 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.7 // indirect github.com/aws/smithy-go v1.20.4 // indirect + github.com/fogfish/golem/hseq v1.2.0 // indirect + github.com/fogfish/golem/optics v0.13.1 // indirect golang.org/x/net v0.17.0 // indirect ) diff --git a/x/awsapi/go.sum b/x/awsapi/go.sum index 8fa9273..4702542 100644 --- a/x/awsapi/go.sum +++ b/x/awsapi/go.sum @@ -26,10 +26,16 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.30.7 h1:NKTa1eqZYw8tiHSRGpP0VtTdub/8 github.com/aws/aws-sdk-go-v2/service/sts v1.30.7/go.mod h1:NXi1dIAGteSaRLqYgarlhP/Ij0cFT+qmCwiJqWh/U5o= github.com/aws/smithy-go v1.20.4 h1:2HK1zBdPgRbjFOHlfeQZfpC4r72MOb9bZkiFwggKO+4= github.com/aws/smithy-go v1.20.4/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= -github.com/fogfish/gurl/v2 v2.8.3 h1:CH8dOHz+lMPg3M0/S5bWk5z3RD9FG4L8+uQMEv36ibU= -github.com/fogfish/gurl/v2 v2.8.3/go.mod h1:VDPaGeyMSZsbFByZXwKZuwKgOC1mOQNlOYhM4RgOVWQ= -github.com/fogfish/it/v2 v2.0.1 h1:vu3kV2xzYDPHoMHMABxXeu5CoMcTfRc4gkWkzOUkRJY= -github.com/fogfish/it/v2 v2.0.1/go.mod h1:h5FdKaEQT4sUEykiVkB8VV4jX27XabFVeWhoDZaRZtE= +github.com/fogfish/golem/hseq v1.2.0 h1:B6yrzOHQNoTqSlhLb+AvK7dhEAELjHThrCQTF/uqwbM= +github.com/fogfish/golem/hseq v1.2.0/go.mod h1:17XORt8nNKl6KOhF43MHSmjK8NksbkBsohAoJGiinUs= +github.com/fogfish/golem/optics v0.13.1 h1:gkvJ5f7/AXaL8EuHLu5dgE/BwUSg/WX50D7b8f4G+6s= +github.com/fogfish/golem/optics v0.13.1/go.mod h1:U1y90OVcXF/A61dIP3abQ0x2GweTmzVHPC15pv0pcM0= +github.com/fogfish/gurl/v2 v2.10.0 h1:91qNyuYG6H+qHEqrPIogct1e8WUeH/QUFWrBG7+u5i8= +github.com/fogfish/gurl/v2 v2.10.0/go.mod h1:7T4FFZiWmEXVYnTgSdqEbAM/bwPfWSkEYgaVAsVSIso= +github.com/fogfish/it/v2 v2.0.2 h1:UR6yVemf8zD3WVs6Bq0zE6LJwapZ8urv9zvU5VB5E6o= +github.com/fogfish/it/v2 v2.0.2/go.mod h1:HHwufnTaZTvlRVnSesPl49HzzlMrQtweKbf+8Co/ll4= +github.com/fogfish/opts v0.0.2 h1:Iro+QQHR/l6G5afX6N5TtqZtV+iVeUxJUOpW63gqhwk= +github.com/fogfish/opts v0.0.2/go.mod h1:fAM7yksrn+u5opbyAh2HiObd5Zx54WnSMGZIU21AGFw= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= diff --git a/x/awsapi/version.go b/x/awsapi/version.go index 5b021d8..d89a33a 100644 --- a/x/awsapi/version.go +++ b/x/awsapi/version.go @@ -8,4 +8,4 @@ package awsapi -const Version = "x/awsapi/v0.0.4" +const Version = "x/awsapi/v0.0.5" diff --git a/x/xhtml/go.mod b/x/xhtml/go.mod index f680855..a8dee85 100644 --- a/x/xhtml/go.mod +++ b/x/xhtml/go.mod @@ -1,16 +1,19 @@ module github.com/fogfish/gurl/x/xhtml -go 1.21.0 +go 1.23 require ( github.com/PuerkitoBio/goquery v1.9.1 - github.com/fogfish/gurl/v2 v2.9.0 - github.com/fogfish/it/v2 v2.0.1 + github.com/fogfish/gurl/v2 v2.10.0 + github.com/fogfish/it/v2 v2.0.2 ) require ( github.com/ajg/form v1.5.2-0.20200323032839-9aeb3cf462e1 // indirect github.com/andybalholm/cascadia v1.3.2 // indirect + github.com/fogfish/golem/hseq v1.2.0 // indirect + github.com/fogfish/golem/optics v0.13.1 // indirect + github.com/fogfish/opts v0.0.2 // indirect github.com/google/go-cmp v0.6.0 // indirect golang.org/x/net v0.21.0 // indirect ) diff --git a/x/xhtml/go.sum b/x/xhtml/go.sum index 0bfa4d1..7fb692c 100644 --- a/x/xhtml/go.sum +++ b/x/xhtml/go.sum @@ -4,10 +4,16 @@ github.com/ajg/form v1.5.2-0.20200323032839-9aeb3cf462e1 h1:8Qzi+0Uch1VJvdrOhJ8U github.com/ajg/form v1.5.2-0.20200323032839-9aeb3cf462e1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= -github.com/fogfish/gurl/v2 v2.9.0 h1:IZlOxZte9y+NFgKHkPYw5jS0VCNG9avu2Ywrm2c3S6k= -github.com/fogfish/gurl/v2 v2.9.0/go.mod h1:vBqw+SCrfOPNllWDCwPnuotrNeuuyTsYZ28iP13qF3Y= -github.com/fogfish/it/v2 v2.0.1 h1:vu3kV2xzYDPHoMHMABxXeu5CoMcTfRc4gkWkzOUkRJY= -github.com/fogfish/it/v2 v2.0.1/go.mod h1:h5FdKaEQT4sUEykiVkB8VV4jX27XabFVeWhoDZaRZtE= +github.com/fogfish/golem/hseq v1.2.0 h1:B6yrzOHQNoTqSlhLb+AvK7dhEAELjHThrCQTF/uqwbM= +github.com/fogfish/golem/hseq v1.2.0/go.mod h1:17XORt8nNKl6KOhF43MHSmjK8NksbkBsohAoJGiinUs= +github.com/fogfish/golem/optics v0.13.1 h1:gkvJ5f7/AXaL8EuHLu5dgE/BwUSg/WX50D7b8f4G+6s= +github.com/fogfish/golem/optics v0.13.1/go.mod h1:U1y90OVcXF/A61dIP3abQ0x2GweTmzVHPC15pv0pcM0= +github.com/fogfish/gurl/v2 v2.10.0 h1:91qNyuYG6H+qHEqrPIogct1e8WUeH/QUFWrBG7+u5i8= +github.com/fogfish/gurl/v2 v2.10.0/go.mod h1:7T4FFZiWmEXVYnTgSdqEbAM/bwPfWSkEYgaVAsVSIso= +github.com/fogfish/it/v2 v2.0.2 h1:UR6yVemf8zD3WVs6Bq0zE6LJwapZ8urv9zvU5VB5E6o= +github.com/fogfish/it/v2 v2.0.2/go.mod h1:HHwufnTaZTvlRVnSesPl49HzzlMrQtweKbf+8Co/ll4= +github.com/fogfish/opts v0.0.2 h1:Iro+QQHR/l6G5afX6N5TtqZtV+iVeUxJUOpW63gqhwk= +github.com/fogfish/opts v0.0.2/go.mod h1:fAM7yksrn+u5opbyAh2HiObd5Zx54WnSMGZIU21AGFw= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= diff --git a/x/xhtml/version.go b/x/xhtml/version.go index 404b03f..8205883 100644 --- a/x/xhtml/version.go +++ b/x/xhtml/version.go @@ -8,4 +8,4 @@ package xhtml -const Version = "x/xhtml/v0.0.2" +const Version = "x/xhtml/v0.0.3" diff --git a/x/xhtml/xhtml.go b/x/xhtml/xhtml.go index 365a7d3..617fcb5 100644 --- a/x/xhtml/xhtml.go +++ b/x/xhtml/xhtml.go @@ -47,7 +47,7 @@ type Client struct { // Create new instance of HTTP Client tailored for fetching HTML content // from public resources. -func New(opts ...http.Config) Client { +func New(opts ...http.Option) Client { return Client{Stack: http.New(opts...)} }