diff --git a/cmd/kola/options.go b/cmd/kola/options.go index ee949be35..e46be3e54 100644 --- a/cmd/kola/options.go +++ b/cmd/kola/options.go @@ -40,7 +40,7 @@ var ( kolaOffering string defaultTargetBoard = sdk.DefaultBoard() kolaArchitectures = []string{"amd64"} - kolaPlatforms = []string{"aws", "azure", "do", "esx", "external", "gce", "openstack", "equinixmetal", "qemu", "qemu-unpriv"} + kolaPlatforms = []string{"aws", "azure", "brightbox", "do", "esx", "external", "gce", "openstack", "equinixmetal", "qemu", "qemu-unpriv"} kolaDistros = []string{"cl", "fcos", "rhcos"} kolaChannels = []string{"alpha", "beta", "stable", "edge", "lts"} kolaOfferings = []string{"basic", "pro"} @@ -227,6 +227,12 @@ func init() { sv(&kola.QEMUOptions.BIOSImage, "qemu-bios", "", "BIOS to use for QEMU vm") bv(&kola.QEMUOptions.UseVanillaImage, "qemu-skip-mangle", false, "don't modify CL disk image to capture console log") sv(&kola.QEMUOptions.ExtraBaseDiskSize, "qemu-grow-base-disk-by", "", "grow base disk by the given size in bytes, following optional 1024-based suffixes are allowed: b (ignored), k, K, M, G, T") + + // BrightBox specific options + sv(&kola.BrightboxOptions.ClientID, "brightbox-client-id", "", "Brightbox client ID") + sv(&kola.BrightboxOptions.ClientSecret, "brightbox-client-secret", "", "Brightbox client secret") + sv(&kola.BrightboxOptions.Image, "brightbox-image", "", "Brightbox image ref") + sv(&kola.BrightboxOptions.ServerType, "brightbox-server-type", "2gb.ssd", "Brightbox server type") } // Sync up the command line options if there is dependency @@ -245,6 +251,7 @@ func syncOptions() error { kola.AWSOptions.Board = board kola.EquinixMetalOptions.Board = board kola.EquinixMetalOptions.GSOptions = &kola.GCEOptions + kola.BrightboxOptions.Board = board validateOption := func(name, item string, valid []string) error { for _, v := range valid { diff --git a/cmd/ore/brightbox.go b/cmd/ore/brightbox.go new file mode 100644 index 000000000..9ba56a90c --- /dev/null +++ b/cmd/ore/brightbox.go @@ -0,0 +1,11 @@ +// Copyright The Mantle Authors. +// SPDX-License-Identifier: Apache-2.0 +package main + +import ( + "github.com/flatcar/mantle/cmd/ore/brightbox" +) + +func init() { + root.AddCommand(brightbox.Brightbox) +} diff --git a/cmd/ore/brightbox/brightbox.go b/cmd/ore/brightbox/brightbox.go new file mode 100644 index 000000000..349033a5d --- /dev/null +++ b/cmd/ore/brightbox/brightbox.go @@ -0,0 +1,41 @@ +// Copyright The Mantle Authors. +// SPDX-License-Identifier: Apache-2.0 +package brightbox + +import ( + "fmt" + + "github.com/coreos/pkg/capnslog" + "github.com/spf13/cobra" + + "github.com/flatcar/mantle/cli" + "github.com/flatcar/mantle/platform/api/brightbox" +) + +var ( + plog = capnslog.NewPackageLogger("github.com/flatcar/mantle", "ore/brightbox") + + Brightbox = &cobra.Command{ + Use: "brightbox [command]", + Short: "Brightbox machine utilities", + } + + API *brightbox.API + options brightbox.Options +) + +func init() { + Brightbox.PersistentFlags().StringVar(&options.ClientID, "brightbox-client-id", "", "Brightbox client ID") + Brightbox.PersistentFlags().StringVar(&options.ClientSecret, "brightbox-client-secret", "", "Brightbox client secret") + cli.WrapPreRun(Brightbox, preflightCheck) +} + +func preflightCheck(cmd *cobra.Command, args []string) error { + api, err := brightbox.New(&options) + if err != nil { + return fmt.Errorf("creating Brightbox client: %w", err) + } + + API = api + return nil +} diff --git a/cmd/ore/brightbox/create.go b/cmd/ore/brightbox/create.go new file mode 100644 index 000000000..21aec9b01 --- /dev/null +++ b/cmd/ore/brightbox/create.go @@ -0,0 +1,42 @@ +// Copyright The Mantle Authors. +// SPDX-License-Identifier: Apache-2.0 +package brightbox + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" +) + +var ( + cmdCreate = &cobra.Command{ + Use: "create-image", + Short: "Create image on Brightbox", + Long: `Upload an image to Brigthbox. + +After a successful run, the final line of output will be the ID of the image. +`, + RunE: runCreate, + } + + url, name string +) + +func init() { + Brightbox.AddCommand(cmdCreate) + cmdCreate.Flags().StringVar(&url, "url", + "https://stable.release.flatcar-linux.net/amd64-usr/current/flatcar_production_openstack_image.img", + "Flatcar image URL") + cmdCreate.Flags().StringVar(&name, "name", "", "image name") +} + +func runCreate(cmd *cobra.Command, args []string) error { + id, err := API.UploadImage(context.Background(), name, url) + if err != nil { + return fmt.Errorf("creating an image: %w", err) + } + + fmt.Println(id) + return nil +} diff --git a/cmd/ore/brightbox/delete.go b/cmd/ore/brightbox/delete.go new file mode 100644 index 000000000..a0835cddf --- /dev/null +++ b/cmd/ore/brightbox/delete.go @@ -0,0 +1,34 @@ +// Copyright The Mantle Authors. +// SPDX-License-Identifier: Apache-2.0 +package brightbox + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" +) + +var ( + cmdDelete = &cobra.Command{ + Use: "delete-image", + Short: "Delete image on Brightbox", + Long: `Delete an image from Brightbox.`, + RunE: runDelete, + } + + id string +) + +func init() { + Brightbox.AddCommand(cmdDelete) + cmdDelete.Flags().StringVar(&id, "id", "", "image ID") +} + +func runDelete(cmd *cobra.Command, args []string) error { + if err := API.DeleteImage(context.Background(), id); err != nil { + return fmt.Errorf("deleting image: %w", err) + } + + return nil +} diff --git a/cmd/ore/brightbox/gc.go b/cmd/ore/brightbox/gc.go new file mode 100644 index 000000000..3b5329505 --- /dev/null +++ b/cmd/ore/brightbox/gc.go @@ -0,0 +1,35 @@ +// Copyright The Mantle Authors. +// SPDX-License-Identifier: Apache-2.0 +package brightbox + +import ( + "context" + "fmt" + "time" + + "github.com/spf13/cobra" +) + +var ( + cmdGC = &cobra.Command{ + Use: "gc", + Short: "GC resources in Brightbox", + Long: `Delete instances and images created over the given duration ago`, + RunE: runGC, + } + + gcDuration time.Duration +) + +func init() { + Brightbox.AddCommand(cmdGC) + cmdGC.Flags().DurationVar(&gcDuration, "duration", 5*time.Hour, "how old resources must be before they're considered garbage") +} + +func runGC(cmd *cobra.Command, args []string) error { + if err := API.GC(context.Background(), gcDuration); err != nil { + return fmt.Errorf("running garbage collection: %w", err) + } + + return nil +} diff --git a/cmd/ore/brightbox/remove-cloudips.go b/cmd/ore/brightbox/remove-cloudips.go new file mode 100644 index 000000000..db145221d --- /dev/null +++ b/cmd/ore/brightbox/remove-cloudips.go @@ -0,0 +1,31 @@ +// Copyright The Mantle Authors. +// SPDX-License-Identifier: Apache-2.0 +package brightbox + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" +) + +var ( + cmdRemoveCloudIPs = &cobra.Command{ + Use: "remove-ips", + Short: "Remove any remaining cloud IPs", + Long: `Remove left overs IP from previous garbage collection`, + RunE: removeCloudIPs, + } +) + +func init() { + Brightbox.AddCommand(cmdRemoveCloudIPs) +} + +func removeCloudIPs(cmd *cobra.Command, args []string) error { + if err := API.RemoveCloudIPs(context.Background()); err != nil { + return fmt.Errorf("removing cloud IPs: %w", err) + } + + return nil +} diff --git a/cmd/ore/brightbox/remove-servers.go b/cmd/ore/brightbox/remove-servers.go new file mode 100644 index 000000000..88ec22e51 --- /dev/null +++ b/cmd/ore/brightbox/remove-servers.go @@ -0,0 +1,31 @@ +// Copyright The Mantle Authors. +// SPDX-License-Identifier: Apache-2.0 +package brightbox + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" +) + +var ( + cmdRemoveServers = &cobra.Command{ + Use: "remove-servers", + Short: "Remove any remaining servers", + Long: `Remove left overs server from previous garbage collection`, + RunE: removeServers, + } +) + +func init() { + Brightbox.AddCommand(cmdRemoveServers) +} + +func removeServers(cmd *cobra.Command, args []string) error { + if err := API.RemoveServers(context.Background()); err != nil { + return fmt.Errorf("removing servers: %w", err) + } + + return nil +} diff --git a/go.mod b/go.mod index 5c5c3c759..77e5a77cb 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/Azure/go-autorest/autorest/azure/auth v0.5.8 github.com/Microsoft/azure-vhd-utils v0.0.0-20210818134022-97083698b75f github.com/aws/aws-sdk-go v1.44.46 + github.com/brightbox/gobrightbox/v2 v2.2.0 github.com/coreos/butane v0.14.1-0.20220401164106-6b5239299226 github.com/coreos/coreos-cloudinit v1.11.0 github.com/coreos/go-iptables v0.5.0 @@ -40,11 +41,11 @@ require ( go.etcd.io/etcd/client/pkg/v3 v3.5.2 go.etcd.io/etcd/server/v3 v3.5.2 go.uber.org/zap v1.17.0 - golang.org/x/crypto v0.14.0 - golang.org/x/net v0.17.0 - golang.org/x/oauth2 v0.11.0 - golang.org/x/sys v0.13.0 - golang.org/x/text v0.13.0 + golang.org/x/crypto v0.15.0 + golang.org/x/net v0.18.0 + golang.org/x/oauth2 v0.14.0 + golang.org/x/sys v0.14.0 + golang.org/x/text v0.14.0 google.golang.org/api v0.126.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -115,10 +116,10 @@ require ( go.uber.org/multierr v1.6.0 // indirect go4.org v0.0.0-20201209231011-d4a079459e60 // indirect golang.org/x/sync v0.3.0 // indirect - golang.org/x/term v0.13.0 // indirect + golang.org/x/term v0.14.0 // indirect golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/appengine v1.6.7 // indirect + google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect diff --git a/go.sum b/go.sum index 5b14123bc..96f40760d 100644 --- a/go.sum +++ b/go.sum @@ -99,6 +99,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/brightbox/gobrightbox/v2 v2.2.0 h1:JCPuAaBSvHI6FoUqbm99ccrMAZ/nJVxFj9jjghBC7Ww= +github.com/brightbox/gobrightbox/v2 v2.2.0/go.mod h1:rsW/MRrDarDbSyID2p6VUeuJZ4GI6S+ezcW46fbFmUM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054 h1:uH66TXeswKn5PW5zdZ39xEwfS9an067BirqA+P4QaLI= @@ -586,8 +588,8 @@ golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211202192323-5770296d904e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= +golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -660,15 +662,15 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= +golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU= -golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk= +golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0= +golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -732,13 +734,13 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8= +golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -748,8 +750,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -831,8 +833,8 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -926,6 +928,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/kola/harness.go b/kola/harness.go index 349bb74d9..09025c9b8 100644 --- a/kola/harness.go +++ b/kola/harness.go @@ -40,6 +40,7 @@ import ( "github.com/flatcar/mantle/platform" awsapi "github.com/flatcar/mantle/platform/api/aws" azureapi "github.com/flatcar/mantle/platform/api/azure" + brightboxapi "github.com/flatcar/mantle/platform/api/brightbox" doapi "github.com/flatcar/mantle/platform/api/do" equinixmetalapi "github.com/flatcar/mantle/platform/api/equinixmetal" esxapi "github.com/flatcar/mantle/platform/api/esx" @@ -48,6 +49,7 @@ import ( "github.com/flatcar/mantle/platform/conf" "github.com/flatcar/mantle/platform/machine/aws" "github.com/flatcar/mantle/platform/machine/azure" + "github.com/flatcar/mantle/platform/machine/brightbox" "github.com/flatcar/mantle/platform/machine/do" "github.com/flatcar/mantle/platform/machine/equinixmetal" "github.com/flatcar/mantle/platform/machine/esx" @@ -65,6 +67,7 @@ var ( Options = platform.Options{} AWSOptions = awsapi.Options{Options: &Options} // glue to set platform options from main AzureOptions = azureapi.Options{Options: &Options} // glue to set platform options from main + BrightboxOptions = brightboxapi.Options{Options: &Options} // glue to set platform options from main DOOptions = doapi.Options{Options: &Options} // glue to set platform options from main ESXOptions = esxapi.Options{Options: &Options} // glue to set platform options from main ExternalOptions = external.Options{Options: &Options} // glue to set platform options from main @@ -225,6 +228,8 @@ func NewFlight(pltfrm string) (flight platform.Flight, err error) { flight, err = aws.NewFlight(&AWSOptions) case "azure": flight, err = azure.NewFlight(&AzureOptions) + case "brightbox": + flight, err = brightbox.NewFlight(&BrightboxOptions) case "do": flight, err = do.NewFlight(&DOOptions) case "esx": diff --git a/kola/tests/ignition/empty.go b/kola/tests/ignition/empty.go index 1a024e665..f22e91d36 100644 --- a/kola/tests/ignition/empty.go +++ b/kola/tests/ignition/empty.go @@ -27,10 +27,11 @@ import ( func init() { // Tests for https://github.com/coreos/bugs/issues/1184 register.Register(®ister.Test{ - Name: "cl.ignition.misc.empty", - Run: empty, - ClusterSize: 1, - ExcludePlatforms: []string{"qemu", "esx"}, + Name: "cl.ignition.misc.empty", + Run: empty, + ClusterSize: 1, + // brightbox does not support yet adding SSH keys to the metadata service. + ExcludePlatforms: []string{"qemu", "esx", "brightbox"}, Distros: []string{"cl"}, // The userdata injection of disabling the update server won't work // for an empty config, we still take care of doing later it via SSH @@ -43,7 +44,7 @@ func init() { Name: "cl.ignition.v1.noop", Run: empty, ClusterSize: 1, - ExcludePlatforms: []string{"qemu", "esx", "openstack"}, + ExcludePlatforms: []string{"qemu", "esx", "openstack", "brightbox"}, Distros: []string{"cl"}, Flags: []register.Flag{register.NoSSHKeyInUserData}, UserData: conf.Ignition(`{"ignitionVersion": 1}`), @@ -53,7 +54,7 @@ func init() { Name: "cl.ignition.v2.noop", Run: empty, ClusterSize: 1, - ExcludePlatforms: []string{"qemu", "esx"}, + ExcludePlatforms: []string{"qemu", "esx", "brightbox"}, Distros: []string{"cl"}, Flags: []register.Flag{register.NoSSHKeyInUserData}, UserData: conf.Ignition(`{"ignition":{"version":"2.0.0"}}`), diff --git a/kola/tests/kubeadm/kubeadm.go b/kola/tests/kubeadm/kubeadm.go index a91275dcc..0198d15c1 100644 --- a/kola/tests/kubeadm/kubeadm.go +++ b/kola/tests/kubeadm/kubeadm.go @@ -224,6 +224,8 @@ func init() { } } + cni := CNI + register.Register(®ister.Test{ Name: fmt.Sprintf("kubeadm.%s.%s%s.base", version, CNI, cgroupSuffix), Distros: []string{"cl"}, @@ -236,10 +238,14 @@ func init() { MinVersion: semver.Version{Major: major}, Flags: flags, SkipFunc: func(version semver.Version, channel, arch, platform string) bool { - // LTS (3033) does not have the network-kargs service pulled in: + // * LTS (3033) does not have the network-kargs service pulled in: // https://github.com/flatcar/coreos-overlay/pull/1848/commits/9e04bc12c3c7eb38da05173dc0ff7beaefa13446 - // Let's skip this test for < 3034 on ESX. - return version.LessThan(semver.Version{Major: 3034}) && platform == "esx" + // Let's skip this test for < 3034 on ESX + // * For Cilium Calico/CNI on Brightbox: + // unprocessable_entity: User data is too long (maximum is 16384 characters) + // Should be reenabled once we switch to Butane provisioning because of internal compression. + return (version.LessThan(semver.Version{Major: 3034}) && platform == "esx") || + (platform == "brightbox" && (cni == "cilium" || cni == "calico")) }, }) } diff --git a/platform/api/brightbox/api.go b/platform/api/brightbox/api.go new file mode 100644 index 000000000..018135de7 --- /dev/null +++ b/platform/api/brightbox/api.go @@ -0,0 +1,272 @@ +// Copyright The Mantle Authors. +// SPDX-License-Identifier: Apache-2.0 +package brightbox + +import ( + "context" + "encoding/base64" + "fmt" + "time" + + brightbox "github.com/brightbox/gobrightbox/v2" + "github.com/brightbox/gobrightbox/v2/clientcredentials" + "github.com/brightbox/gobrightbox/v2/enums/arch" + "github.com/brightbox/gobrightbox/v2/enums/imagestatus" + "github.com/brightbox/gobrightbox/v2/enums/serverstatus" + + "github.com/coreos/pkg/capnslog" + "github.com/flatcar/mantle/platform" + "github.com/flatcar/mantle/util" +) + +var ( + plog = capnslog.NewPackageLogger("github.com/flatcar/mantle", "platform/api/brightbox") +) + +type Options struct { + *platform.Options + + // ClientID is the ID of the API client. + ClientID string + // ClientSecret is the secret of the API client. + ClientSecret string + // Image is the image to deploy. + Image string + // ServerType is the amount of memory and type of server (e.g 2gb.ssd). + ServerType string +} + +type API struct { + client *brightbox.Client + opts *Options +} + +type Server struct{ *brightbox.Server } + +func New(opts *Options) (*API, error) { + // Setup OAuth2 authentication + conf := &clientcredentials.Config{ + ID: opts.ClientID, + Secret: opts.ClientSecret, + } + + ctx := context.Background() + + client, err := brightbox.Connect(ctx, conf) + if err != nil { + return nil, fmt.Errorf("connecting to Brightbox: %w", err) + } + + return &API{ + client: client, + opts: opts, + }, nil +} + +func (a *API) AddKey(name, key string) error { + return nil +} + +// CreateServer using the Brightbox API. +func (a *API) CreateServer(ctx context.Context, name, userdata, cloudIP string) (*Server, error) { + // Not in the spec, but userdata needs to be base64 encoded. + userdata = base64.StdEncoding.EncodeToString([]byte(userdata)) + + s, err := a.client.CreateServer(ctx, brightbox.ServerOptions{ + Image: &a.opts.Image, + Name: &name, + UserData: &userdata, + ServerType: &a.opts.ServerType, + }) + if err != nil { + return nil, fmt.Errorf("creating server from API: %w", err) + } + + // If the cloud IP already exists, we reuse it - otherwise we create a new one. + if cloudIP == "" { + plog.Info("No cloud IP already available: creating a new one.") + cip, err := a.client.CreateCloudIP(ctx, brightbox.CloudIPOptions{}) + if err != nil { + return nil, fmt.Errorf("creating a cloud IP from API: %w", err) + } + + cloudIP = cip.ID + } + + // Let's assign this IP to this new server. + if _, err := a.client.MapCloudIP(ctx, cloudIP, brightbox.CloudIPAttachment{Destination: s.ID}); err != nil { + _ = a.DeleteServer(ctx, s.ID) + return nil, fmt.Errorf("mapping cloud IP to server: %w", err) + } + + // Refetch the server to get the new information regarding the freshly assigned cloud IP. + s, err = a.client.Server(ctx, s.ID) + if err != nil { + _ = a.DeleteServer(ctx, s.ID) + return nil, fmt.Errorf("getting server from API: %w", err) + } + + return &Server{s}, nil +} + +func (a *API) DeleteKey(name string) error { + return nil +} + +// DeleteImage will remove the image from Brightbox. +func (a *API) DeleteImage(ctx context.Context, id string) error { + if _, err := a.client.DestroyImage(ctx, id); err != nil { + return fmt.Errorf("destroying image from API: %w", err) + } + + return nil +} + +// DeleteCloudIP will remove a cloud IP from Brightbox. +func (a *API) DeleteCloudIP(ctx context.Context, id string) error { + if _, err := a.client.DestroyCloudIP(ctx, id); err != nil { + return fmt.Errorf("destroying cloud IP from API: %w", err) + } + + return nil +} + +func (a *API) DeleteServer(ctx context.Context, id string) error { + // Let's first unassign the cloud IP. + s, err := a.client.Server(ctx, id) + if err != nil { + return fmt.Errorf("getting server from API: %w", err) + } + + var cloudIP string + if s != nil && len(s.CloudIPs) >= 1 { + cloudIP = s.CloudIPs[0].ID + } + + if cloudIP != "" { + if _, err := a.client.UnMapCloudIP(ctx, cloudIP); err != nil { + return fmt.Errorf("unmaping cloud IP from API: %w", err) + } + plog.Info("Cloud IP released.") + } + + if _, err := a.client.DestroyServer(ctx, id); err != nil { + return fmt.Errorf("destroying server from API: %w", err) + } + + return nil +} + +func (a *API) GC(ctx context.Context, gracePeriod time.Duration) error { + threshold := time.Now().Add(-gracePeriod) + // TODO: CloudIP has no creation date for now. + // We can't safely delete "old" cloud IPs. + // NOTE: Currently, cloud IPs removal is implemented as an independant + // 'ore' subcommand. + + servers, err := a.client.Servers(ctx) + if err != nil { + return fmt.Errorf("listing servers from API: %w", err) + } + + for _, server := range servers { + if server.Status == serverstatus.Deleted || server.CreatedAt.After(threshold) { + continue + } + + if err := a.DeleteServer(ctx, server.ID); err != nil { + return fmt.Errorf("deleting server: %w", err) + } + } + + images, err := a.client.Images(ctx) + if err != nil { + return fmt.Errorf("listing servers from API: %w", err) + } + + for _, image := range images { + if image.Public || image.Status == imagestatus.Deleted || image.CreatedAt.After(threshold) { + continue + } + + if err := a.DeleteImage(ctx, image.ID); err != nil { + return fmt.Errorf("deleting image: %w", err) + } + } + + return nil +} + +func (a *API) GetConsoleOutput(id string) (string, error) { + // NOTE: There is no way to get console output from the API. + // A workaround would be the fetch the console_url + console_token to read from this + // endpoint. + return "", nil +} + +// UploadImage will upload an image from the URL on Brightbox and wait for it to become +// available. +func (a *API) UploadImage(ctx context.Context, name, URL string) (string, error) { + defaultUsername := "core" + + img, err := a.client.CreateImage(ctx, brightbox.ImageOptions{ + Name: &name, + URL: URL, + Username: &defaultUsername, + Arch: arch.X86_64, + }) + if err != nil { + return "", fmt.Errorf("creating image from API: %w", err) + } + + // It usually takes around 20 seconds to extract the image. + if err := util.WaitUntilReady(2*time.Minute, 5*time.Second, func() (bool, error) { + image, err := a.client.Image(ctx, img.ID) + if err != nil { + return false, fmt.Errorf("getting image status: %w", err) + } + + return image.Status == imagestatus.Available, nil + }); err != nil { + a.DeleteImage(ctx, img.ID) + return "", fmt.Errorf("getting image active: %w", err) + } + + return img.ID, nil +} + +// RemoveCloudIPs remove any left overs IPs. +func (a *API) RemoveCloudIPs(ctx context.Context) error { + cloudIPs, err := a.client.CloudIPs(ctx) + if err != nil { + return fmt.Errorf("getting cloud IPs: %w", err) + } + + for _, cloudIP := range cloudIPs { + if err := a.DeleteCloudIP(ctx, cloudIP.ID); err != nil { + return fmt.Errorf("deleting cloud IP: %w", err) + } + } + + return nil +} + +// RemoveServers remove any left overs servers before running a test. +func (a *API) RemoveServers(ctx context.Context) error { + servers, err := a.client.Servers(ctx) + if err != nil { + return fmt.Errorf("getting servers: %w", err) + } + + for _, server := range servers { + if server.Status == serverstatus.Deleted { + continue + } + + if err := a.DeleteServer(ctx, server.ID); err != nil { + return fmt.Errorf("deleting server: %w", err) + } + } + + return nil +} diff --git a/platform/machine/brightbox/cluster.go b/platform/machine/brightbox/cluster.go new file mode 100644 index 000000000..082a5293b --- /dev/null +++ b/platform/machine/brightbox/cluster.go @@ -0,0 +1,86 @@ +// Copyright The Mantle Authors. +// SPDX-License-Identifier: Apache-2.0 + +package brightbox + +import ( + "context" + "crypto/rand" + "fmt" + "os" + "path/filepath" + + "github.com/flatcar/mantle/platform" + "github.com/flatcar/mantle/platform/conf" +) + +type cluster struct { + *platform.BaseCluster + flight *flight +} + +func (bc *cluster) NewMachine(userdata *conf.UserData) (platform.Machine, error) { + conf, err := bc.RenderUserData(userdata, map[string]string{ + "$public_ipv4": "${COREOS_OPENSTACK_IPV4_PUBLIC}", + "$private_ipv4": "${COREOS_OPENSTACK_IPV4_LOCAL}", + }) + if err != nil { + return nil, err + } + + // Allocate a free cloudIP, this only works for low enough --parallel= values because "select default" does not block + var cloudIP string + select { + case i := <-bc.flight.cloudIPs: + cloudIP = i + default: + cloudIP = "" + } + + instance, err := bc.flight.api.CreateServer(context.TODO(), bc.vmname(), conf.String(), cloudIP) + if err != nil { + return nil, err + } + + mach := &machine{ + cluster: bc, + mach: instance, + } + + mach.dir = filepath.Join(bc.RuntimeConf().OutputDir, mach.ID()) + if err := os.Mkdir(mach.dir, 0777); err != nil { + mach.Destroy() + return nil, err + } + + confPath := filepath.Join(mach.dir, "user-data") + if err := conf.WriteFile(confPath); err != nil { + mach.Destroy() + return nil, err + } + + if mach.journal, err = platform.NewJournal(mach.dir); err != nil { + mach.Destroy() + return nil, err + } + + if err := platform.StartMachine(mach, mach.journal); err != nil { + mach.Destroy() + return nil, err + } + + bc.AddMach(mach) + + return mach, nil +} + +func (bc *cluster) vmname() string { + b := make([]byte, 5) + rand.Read(b) + return fmt.Sprintf("%s-%x", bc.Name()[0:13], b) +} + +func (bc *cluster) Destroy() { + bc.BaseCluster.Destroy() + bc.flight.DelCluster(bc) +} diff --git a/platform/machine/brightbox/flight.go b/platform/machine/brightbox/flight.go new file mode 100644 index 000000000..57abbd4ea --- /dev/null +++ b/platform/machine/brightbox/flight.go @@ -0,0 +1,80 @@ +// Copyright The Mantle Authors. +// SPDX-License-Identifier: Apache-2.0 + +package brightbox + +import ( + "context" + "fmt" + + "github.com/coreos/pkg/capnslog" + ctplatform "github.com/flatcar/container-linux-config-transpiler/config/platform" + + "github.com/flatcar/mantle/platform" + "github.com/flatcar/mantle/platform/api/brightbox" +) + +const ( + Platform platform.Name = "brightbox" +) + +var ( + plog = capnslog.NewPackageLogger("github.com/flatcar/mantle", "platform/machine/brightbox") +) + +type flight struct { + *platform.BaseFlight + api *brightbox.API + cloudIPs chan string +} + +func NewFlight(opts *brightbox.Options) (platform.Flight, error) { + api, err := brightbox.New(opts) + if err != nil { + return nil, fmt.Errorf("creating brightbox API client: %w", err) + } + + base, err := platform.NewBaseFlight(opts.Options, Platform, ctplatform.OpenStackMetadata) + if err != nil { + return nil, fmt.Errorf("creating base flight: %w", err) + } + + bf := &flight{ + BaseFlight: base, + api: api, + // Current CloudIPs limit is 5. + cloudIPs: make(chan string, 999), + } + + return bf, nil +} + +// NewCluster creates an instance of a Cluster suitable for spawning +// instances on the OpenStack platform. +func (bf *flight) NewCluster(rconf *platform.RuntimeConfig) (platform.Cluster, error) { + bc, err := platform.NewBaseCluster(bf.BaseFlight, rconf) + if err != nil { + return nil, fmt.Errorf("creating brightbox base cluster: %w", err) + } + + c := &cluster{ + BaseCluster: bc, + flight: bf, + } + + bf.AddCluster(c) + + return c, nil +} + +func (bf *flight) Destroy() { + // Clean the provisioned cloud IPs. + close(bf.cloudIPs) + for id := range bf.cloudIPs { + if err := bf.api.DeleteCloudIP(context.TODO(), id); err != nil { + plog.Errorf("deleting cloud IP %s: %v", id, err) + } + } + + bf.BaseFlight.Destroy() +} diff --git a/platform/machine/brightbox/machine.go b/platform/machine/brightbox/machine.go new file mode 100644 index 000000000..034e8ce4f --- /dev/null +++ b/platform/machine/brightbox/machine.go @@ -0,0 +1,134 @@ +// Copyright The Mantle Authors. +// SPDX-License-Identifier: Apache-2.0 +package brightbox + +import ( + "context" + "fmt" + "os" + "path/filepath" + + "golang.org/x/crypto/ssh" + + "github.com/flatcar/mantle/platform" + "github.com/flatcar/mantle/platform/api/brightbox" +) + +type machine struct { + cluster *cluster + mach *brightbox.Server + dir string + journal *platform.Journal + console string +} + +// ID returns the ID of the machine. +func (bm *machine) ID() string { + return bm.mach.Server.ID +} + +// IP returns the IP of the machine. +// The machine should only get one "cloud" IP. +func (bm *machine) IP() string { + if bm.mach.Server != nil && len(bm.mach.Server.CloudIPs) >= 1 { + return bm.mach.Server.CloudIPs[0].PublicIPv4 + } + + return "" +} + +func (bm *machine) PrivateIP() string { + // Return the first IPv4 address, assuming it's the private one. + for _, iface := range bm.mach.Server.Interfaces { + return iface.IPv4Address + } + + // Otherwise returns the public one in last resort. + return bm.IP() +} + +func (bm *machine) RuntimeConf() *platform.RuntimeConfig { + return bm.cluster.RuntimeConf() +} + +func (bm *machine) SSHClient() (*ssh.Client, error) { + return bm.cluster.SSHClient(bm.IP()) +} + +func (bm *machine) PasswordSSHClient(user string, password string) (*ssh.Client, error) { + return bm.cluster.PasswordSSHClient(bm.IP(), user, password) +} + +func (bm *machine) SSH(cmd string) ([]byte, []byte, error) { + return bm.cluster.SSH(bm, cmd) +} + +func (bm *machine) Reboot() error { + return platform.RebootMachine(bm, bm.journal) +} + +func (bm *machine) Destroy() { + // Keep the cloud IP ID to add it to the available pool after + // machine deletion. + var cloudIP string + if bm.mach.Server != nil && len(bm.mach.Server.CloudIPs) >= 1 { + cloudIP = bm.mach.Server.CloudIPs[0].ID + } + + if err := bm.saveConsole(); err != nil { + plog.Errorf("Error saving console for instance %v: %v", bm.ID(), err) + } + + if err := bm.cluster.flight.api.DeleteServer(context.TODO(), bm.ID()); err != nil { + plog.Errorf("deleting server %v: %v", bm.ID(), err) + } + + if bm.journal != nil { + bm.journal.Destroy() + } + + bm.cluster.DelMach(bm) + + if cloudIP != "" { + plog.Infof("Adding Cloud IP to the pool: %s", cloudIP) + bm.cluster.flight.cloudIPs <- cloudIP + } +} + +func (bm *machine) ConsoleOutput() string { + return bm.console +} + +func (bm *machine) saveConsole() error { + var err error + bm.console, err = bm.cluster.flight.api.GetConsoleOutput(bm.ID()) + if err != nil { + return fmt.Errorf("Error retrieving console log for %v: %v", bm.ID(), err) + } + + path := filepath.Join(bm.dir, "console.txt") + f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0644) + if err != nil { + return err + } + defer f.Close() + f.WriteString(bm.console) + + return nil +} + +func (bm *machine) JournalOutput() string { + if bm.journal == nil { + return "" + } + + data, err := bm.journal.Read() + if err != nil { + plog.Errorf("Reading journal for instance %v: %v", bm.ID(), err) + } + return string(data) +} + +func (bm *machine) Board() string { + return bm.cluster.flight.Options().Board +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/LICENSE.txt b/vendor/github.com/brightbox/gobrightbox/v2/LICENSE.txt new file mode 100644 index 000000000..28af8a9df --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2015 Brightbox Systems Ltd. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/brightbox/gobrightbox/v2/accounts.go b/vendor/github.com/brightbox/gobrightbox/v2/accounts.go new file mode 100644 index 000000000..c69415d4c --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/accounts.go @@ -0,0 +1,75 @@ +package brightbox + +import ( + "time" + + "github.com/brightbox/gobrightbox/v2/enums/accountstatus" +) + +//go:generate ./generate_enum accountstatus pending active overdue warning suspended terminated closed deleted + +// Account represents a Brightbox Cloud Account +// https://api.gb1.brightbox.com/1.0/#account +type Account struct { + ResourceRef + ID string + Name string + Status accountstatus.Enum `json:"status"` + Address1 string `json:"address_1"` + Address2 string `json:"address_2"` + City string + County string + Postcode string + CountryCode string `json:"country_code"` + CountryName string `json:"country_name"` + VatRegistrationNumber string `json:"vat_registration_number"` + TelephoneNumber string `json:"telephone_number"` + TelephoneVerified bool `json:"telephone_verified"` + VerifiedTelephone string `json:"verified_telephone"` + VerifiedIP string `json:"verified_ip"` + ValidCreditCard bool `json:"valid_credit_card"` + ServersUsed uint `json:"servers_used"` + RAMLimit uint `json:"ram_limit"` + RAMUsed uint `json:"ram_used"` + DbsInstancesUsed uint `json:"dbs_instances_used"` + DbsRAMLimit uint `json:"dbs_ram_limit"` + DbsRAMUsed uint `json:"dbs_ram_used"` + BlockStorageLimit uint `json:"block_storage_limit"` + BlockStorageUsed uint `json:"block_storage_used"` + CloudIPsLimit uint `json:"cloud_ips_limit"` + CloudIPsUsed uint `json:"cloud_ips_used"` + LoadBalancersLimit uint `json:"load_balancers_limit"` + LoadBalancersUsed uint `json:"load_balancers_used"` + LibraryFtpHost string `json:"library_ftp_host"` + LibraryFtpUser string `json:"library_ftp_user"` + LibraryFtpPassword string `json:"library_ftp_password"` + CreatedAt *time.Time `json:"created_at"` + VerifiedAt *time.Time `json:"verified_at"` + Owner *User + Clients []APIClient + Images []Image + Servers []Server + LoadBalancers []LoadBalancer `json:"load_balancers"` + DatabaseServers []DatabaseServer `json:"database_servers"` + DatabaseSnapshots []DatabaseSnapshot `json:"database_snapshots"` + CloudIPs []CloudIP `json:"cloud_ips"` + ServerGroups []ServerGroup `json:"server_groups"` + FirewallPolicies []FirewallPolicy `json:"firewall_policies"` + Users []User + Volumes []Volume + Zones []Zone +} + +// AccountOptions is used to update objects +type AccountOptions struct { + ID string `json:"-"` + Name *string `json:"name,omitempty"` + Address1 *string `json:"address_1,omitempty"` + Address2 *string `json:"address_2,omitempty"` + City *string `json:"city,omitempty"` + County *string `json:"county,omitempty"` + Postcode *string `json:"postcode,omitempty"` + CountryCode *string `json:"country_code,omitempty"` + VatRegistrationNumber *string `json:"vat_registration_number,omitempty"` + TelephoneNumber *string `json:"telephone_number,omitempty"` +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/accounts_default.go b/vendor/github.com/brightbox/gobrightbox/v2/accounts_default.go new file mode 100644 index 000000000..2c0f666fc --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/accounts_default.go @@ -0,0 +1,42 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // accountAPIPath returns the relative URL path to the Account endpoint + accountAPIPath = "accounts" +) + +// Accounts returns the collection view for Account +func (c *Client) Accounts(ctx context.Context) ([]Account, error) { + return apiGetCollection[[]Account](ctx, c, accountAPIPath) +} + +// Account retrieves a detailed view of one resource +func (c *Client) Account(ctx context.Context, identifier string) (*Account, error) { + return apiGet[Account](ctx, c, path.Join(accountAPIPath, identifier)) +} + +// UpdateAccount updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of AccountOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateAccount(ctx context.Context, updateAccount AccountOptions) (*Account, error) { + return apiPut[Account](ctx, c, path.Join(accountAPIPath, updateAccount.ID), updateAccount) +} + +// CreatedAt implements the CreateDated interface for Account +func (s Account) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() +} + +// ResetAccountPassword resets the password in Account, returning it +// in the returned resource. This is the only time the new password is +// available in plaintext. +func (c *Client) ResetAccountPassword(ctx context.Context, identifier string) (*Account, error) { + return apiPost[Account](ctx, c, path.Join(accountAPIPath, identifier, "reset_ftp_password"), nil) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/api_clients.go b/vendor/github.com/brightbox/gobrightbox/v2/api_clients.go new file mode 100644 index 000000000..8c5a10cfe --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/api_clients.go @@ -0,0 +1,30 @@ +package brightbox + +import ( + "time" + + "github.com/brightbox/gobrightbox/v2/enums/permissionsgroup" +) + +//go:generate ./generate_enum permissionsgroup full storage + +// APIClient represents an API client. +// https://api.gb1.brightbox.com/1.0/#api_client +type APIClient struct { + ResourceRef + ID string + Name string + Description string + Secret string + PermissionsGroup permissionsgroup.Enum `json:"permissions_group"` + RevokedAt *time.Time `json:"revoked_at"` + Account *Account +} + +// APIClientOptions is used to create and update api clients +type APIClientOptions struct { + ID string `json:"-"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + PermissionsGroup permissionsgroup.Enum `json:"permissions_group,omitempty"` +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/api_clients_default.go b/vendor/github.com/brightbox/gobrightbox/v2/api_clients_default.go new file mode 100644 index 000000000..00a09ee93 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/api_clients_default.go @@ -0,0 +1,50 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // apiclientAPIPath returns the relative URL path to the APIClient endpoint + apiclientAPIPath = "api_clients" +) + +// APIClients returns the collection view for APIClient +func (c *Client) APIClients(ctx context.Context) ([]APIClient, error) { + return apiGetCollection[[]APIClient](ctx, c, apiclientAPIPath) +} + +// APIClient retrieves a detailed view of one resource +func (c *Client) APIClient(ctx context.Context, identifier string) (*APIClient, error) { + return apiGet[APIClient](ctx, c, path.Join(apiclientAPIPath, identifier)) +} + +// CreateAPIClient creates a new resource from the supplied option map. +// +// It takes an instance of APIClientOptions. Not all attributes can be +// specified at create time (such as ID, which is allocated for you). +func (c *Client) CreateAPIClient(ctx context.Context, newAPIClient APIClientOptions) (*APIClient, error) { + return apiPost[APIClient](ctx, c, apiclientAPIPath, newAPIClient) +} + +// UpdateAPIClient updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of APIClientOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateAPIClient(ctx context.Context, updateAPIClient APIClientOptions) (*APIClient, error) { + return apiPut[APIClient](ctx, c, path.Join(apiclientAPIPath, updateAPIClient.ID), updateAPIClient) +} + +// DestroyAPIClient destroys an existing resource. +func (c *Client) DestroyAPIClient(ctx context.Context, identifier string) (*APIClient, error) { + return apiDelete[APIClient](ctx, c, path.Join(apiclientAPIPath, identifier)) +} + +// ResetAPIClientPassword resets the password in APIClient, returning it +// in the returned resource. This is the only time the new password is +// available in plaintext. +func (c *Client) ResetAPIClientPassword(ctx context.Context, identifier string) (*APIClient, error) { + return apiPost[APIClient](ctx, c, path.Join(apiclientAPIPath, identifier, "reset_secret"), nil) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/api_error.go b/vendor/github.com/brightbox/gobrightbox/v2/api_error.go new file mode 100644 index 000000000..0fde181db --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/api_error.go @@ -0,0 +1,60 @@ +package brightbox + +import ( + "fmt" + "net/url" + "strings" +) + +// APIError can be returned when an API request fails. It provides any error +// messages provided by the API, along with other details about the response. +type APIError struct { + // StatusCode will hold the HTTP status code from the request that errored + StatusCode int + // Status will hold the HTTP status line from the request that errored + Status string + // AuthError will hold any available OAuth "error" field contents. See + // https://api.gb1.brightbox.com/1.0/#errors + AuthError string `json:"error"` + // AuthErrorDescription will hold any available OAuth "error_description" + // field contents. See https://api.gb1.brightbox.com/1.0/#errors + AuthErrorDescription string `json:"error_description"` + // ErrorName will hold any available Brightbox API "error_name" field + // contents. See https://api.gb1.brightbox.com/1.0/#request_errors + ErrorName string `json:"error_name"` + // Errors will hold any available Brightbox API "errors" field contents. See + // https://api.gb1.brightbox.com/1.0/#request_errors + Errors []string `json:"errors"` + // ParseError will hold any errors from the JSON parser whilst parsing an + // API response + ParseError error + // RequestURL will hold the full URL used to make the request that errored, + // if available + RequestURL *url.URL + // ResponseBody will hold the raw respose body of the request that errored, + // if available + ResponseBody []byte +} + +// Error implements the error interface +func (e *APIError) Error() string { + if e.AuthError != "" { + return fmt.Sprintf("%s, %s", e.AuthError, e.AuthErrorDescription) + } + if e.ErrorName != "" { + if len(e.Errors) == 0 { + return e.ErrorName + } + return fmt.Sprintf("%s: %s", e.ErrorName, strings.Join(e.Errors, ": ")) + } + if e.ParseError != nil { + return fmt.Sprintf("ParseError at %s: %s", e.RequestURL, e.ParseError.Error()) + } + return fmt.Sprintf("HttpError at %s: %s", e.RequestURL, e.Status) +} + +// Unwrap implements the error wrapping interface +// Returns the parse errors from the JSON parser and Unmarshal interface +func (e *APIError) Unwrap() error { + return e.ParseError +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/brightbox.go b/vendor/github.com/brightbox/gobrightbox/v2/brightbox.go new file mode 100644 index 000000000..64bac5802 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/brightbox.go @@ -0,0 +1,32 @@ +package brightbox + +import ( + "context" + "net/http" + "net/url" + + "golang.org/x/oauth2" +) + +// Oauth2 is the abstract interface for any Brightbox oauth2 client generator +type Oauth2 interface { + Client(ctx context.Context) (*http.Client, oauth2.TokenSource, error) + APIURL() (*url.URL, error) +} + +// Connect allocates and configures a Client for interacting with the API. +func Connect(ctx context.Context, config Oauth2) (*Client, error) { + baseURL, err := config.APIURL() + if err != nil { + return nil, err + } + httpClient, tokenSource, err := config.Client(ctx) + if err != nil { + return nil, err + } + return &Client{ + baseURL: baseURL, + client: httpClient, + tokensource: tokenSource, + }, nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/client.go b/vendor/github.com/brightbox/gobrightbox/v2/client.go new file mode 100644 index 000000000..9d11597ac --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/client.go @@ -0,0 +1,245 @@ +package brightbox + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/url" + + "golang.org/x/oauth2" +) + +//go:generate ./generate_default_functions paths.yaml + +// Client represents a connection to the Brightbox API. You should use NewConnect +// to allocate and configure Clients, and pass in either a +// clientcredentials or password configuration. +type Client struct { + UserAgent string + baseURL *url.URL + client *http.Client + tokensource oauth2.TokenSource + hardcoreDecode bool +} + +// ResourceBaseURL returns the base URL within the client +func (q *Client) ResourceBaseURL() *url.URL { + return q.baseURL +} + +// HTTPClient returns the current HTTP structure within the client +func (q *Client) HTTPClient() *http.Client { + return q.client +} + +// ExtractTokenID implements the AuthResult interface for gophercloud clients +func (q *Client) ExtractTokenID() (string, error) { + token, err := q.tokensource.Token() + if err != nil { + return "", err + } + return token.AccessToken, nil +} + +// AllowUnknownFields stops the Client generating an error is an unsupported field is +// returned by the API. +func (q *Client) AllowUnknownFields() { + q.hardcoreDecode = false +} + +// DisallowUnknownFields causes the Client to generate an error if an unsupported field is +// returned by the API. +func (q *Client) DisallowUnknownFields() { + q.hardcoreDecode = true +} + +// apiGet makes a GET request to the API +// and decoding any JSON response. +// +// relURL is the relative path of the endpoint to the base URL, e.g. "servers". +func apiGet[O any]( + ctx context.Context, + q *Client, + relURL string, +) (*O, error) { + return apiCommand[O](ctx, q, "GET", relURL) +} + +// apiGetCollection makes a GET request to the API +// and decoding any JSON response into an appropriate slice +// +// relURL is the relative path of the endpoint to the base URL, e.g. "servers". +func apiGetCollection[S ~[]O, O any]( + ctx context.Context, + q *Client, + relURL string, +) (S, error) { + collection, err := apiGet[S](ctx, q, relURL) + if collection == nil { + return nil, err + } + return *collection, err +} + +// apiPost makes a POST request to the API, JSON encoding any given data +// and decoding any JSON response. +// +// relURL is the relative path of the endpoint to the base URL, e.g. "servers". +// +// if reqBody is non-nil, it will be Marshaled to JSON and set as the request +// body. +func apiPost[O any]( + ctx context.Context, + q *Client, + relURL string, + reqBody interface{}, +) (*O, error) { + return apiObject[O](ctx, q, "POST", relURL, reqBody) +} + +// apiPut makes a PUT request to the API, JSON encoding any given data +// and decoding any JSON response. +// +// relURL is the relative path of the endpoint to the base URL, e.g. "servers". +// +// if reqBody is non-nil, it will be Marshaled to JSON and set as the request +// body. +func apiPut[O any]( + ctx context.Context, + q *Client, + relURL string, + reqBody interface{}, +) (*O, error) { + return apiObject[O](ctx, q, "PUT", relURL, reqBody) +} + +// apiDelete makes a DELETE request to the API +// +// relURL is the relative path of the endpoint to the base URL, e.g. "servers". +func apiDelete[O any]( + ctx context.Context, + q *Client, + relURL string, +) (*O, error) { + return apiCommand[O](ctx, q, "DELETE", relURL) +} + +func apiObject[O any]( + ctx context.Context, + q *Client, + method string, + relURL string, + reqBody interface{}, +) (*O, error) { + req, err := jsonRequest(ctx, q, method, relURL, reqBody) + if err != nil { + return nil, err + } + res, err := q.client.Do(req) + if err != nil { + return nil, err + } + defer res.Body.Close() + return jsonResponse[O](res, q.hardcoreDecode) +} + +func apiCommand[O any]( + ctx context.Context, + q *Client, + method string, + relURL string, +) (*O, error) { + return apiObject[O](ctx, q, method, relURL, nil) +} + +func jsonResponse[O any](res *http.Response, hardcoreDecode bool) (*O, error) { + if res.StatusCode >= 200 && res.StatusCode <= 299 { + decode := json.NewDecoder(res.Body) + if hardcoreDecode { + decode.DisallowUnknownFields() + } + result := new(O) + err := decode.Decode(result) + if err != nil { + var unmarshalError *json.UnmarshalTypeError + if errors.As(err, &unmarshalError) { + unmarshalError.Offset = decode.InputOffset() + } + return nil, &APIError{ + RequestURL: res.Request.URL, + StatusCode: res.StatusCode, + Status: res.Status, + ParseError: err, + } + } + if decode.More() { + return nil, &APIError{ + RequestURL: res.Request.URL, + StatusCode: res.StatusCode, + Status: res.Status, + ParseError: fmt.Errorf("Response body has additional unparsed data at position %d", decode.InputOffset()+1), + } + } + return result, err + } + return nil, newAPIError(res) +} + +func newAPIError(res *http.Response) *APIError { + if res.StatusCode >= 200 && res.StatusCode <= 299 { + return nil + } + apierr := APIError{ + RequestURL: res.Request.URL, + StatusCode: res.StatusCode, + Status: res.Status, + } + var body []byte + body, apierr.ParseError = io.ReadAll(res.Body) + + if len(body) > 0 { + err := json.Unmarshal(body, &apierr) + apierr.ParseError = err + } + apierr.ResponseBody = body + return &apierr +} + +func jsonRequest(ctx context.Context, q *Client, method string, relURL string, body interface{}) (*http.Request, error) { + absUrl, err := q.baseURL.Parse(relURL) + if err != nil { + return nil, err + } + absUrl.RawQuery = q.baseURL.RawQuery + buf, err := jsonReader(body) + if err != nil { + return nil, err + } + req, err := http.NewRequestWithContext(ctx, method, absUrl.String(), buf) + if err != nil { + return nil, err + } + req.Header.Add("Accept", "application/json") + req.Header.Add("Content-Type", "application/json") + + if q.UserAgent != "" { + req.Header.Add("User-Agent", q.UserAgent) + } + return req, nil +} + +func jsonReader(from interface{}) (io.Reader, error) { + var buf bytes.Buffer + if from == nil { + return &buf, nil + } + err := json.NewEncoder(&buf).Encode(from) + if err != nil { + return nil, err + } + return &buf, nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/clientcredentials/clientcredentials.go b/vendor/github.com/brightbox/gobrightbox/v2/clientcredentials/clientcredentials.go new file mode 100644 index 000000000..f972ac391 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/clientcredentials/clientcredentials.go @@ -0,0 +1,41 @@ +// Package clientcredentials implements the API client credentials +// access method. +// +// API client credentials are an identifier and secret issued to a +// single account to access the API, commonly used for authenticating +// automated systems. +package clientcredentials + +import ( + "context" + "net/http" + + "github.com/brightbox/gobrightbox/v2/endpoint" + "golang.org/x/oauth2" + oauth2cc "golang.org/x/oauth2/clientcredentials" +) + +// Config includes the items necessary to authenticate using client +// credentials. +type Config struct { + ID string // Client identifier in the form cli-xxxxx. + Secret string // Randomly generated secret associate with the client ID. + endpoint.Config +} + +// Client implements the [brightbox.Oauth2] access interface. +func (c *Config) Client(ctx context.Context) (*http.Client, oauth2.TokenSource, error) { + tokenURL, err := c.TokenURL() + if err != nil { + return nil, nil, err + } + + conf := oauth2cc.Config{ + ClientID: c.ID, + ClientSecret: c.Secret, + Scopes: c.Scopes, + TokenURL: tokenURL, + } + ts := conf.TokenSource(ctx) + return oauth2.NewClient(ctx, ts), ts, nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/cloud_ips.go b/vendor/github.com/brightbox/gobrightbox/v2/cloud_ips.go new file mode 100644 index 000000000..717c33a70 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/cloud_ips.go @@ -0,0 +1,81 @@ +package brightbox + +import ( + "context" + "path" + + "github.com/brightbox/gobrightbox/v2/enums/cloudipstatus" + "github.com/brightbox/gobrightbox/v2/enums/mode" + "github.com/brightbox/gobrightbox/v2/enums/transportprotocol" +) + +//go:generate ./generate_enum cloudipstatus mapped unmapped +//go:generate ./generate_enum mode nat route +//go:generate ./generate_enum transportprotocol tcp udp + +// CloudIP represents a Cloud IP +// https://api.gb1.brightbox.com/1.0/#cloud_ip +type CloudIP struct { + ResourceRef + ID string + Name string + PublicIP string `json:"public_ip"` + PublicIPv4 string `json:"public_ipv4"` + PublicIPv6 string `json:"public_ipv6"` + Status cloudipstatus.Enum `json:"status"` + ReverseDNS string `json:"reverse_dns"` + Fqdn string + Mode mode.Enum + Account *Account + Interface *Interface + Server *Server + ServerGroup *ServerGroup `json:"server_group"` + PortTranslators []PortTranslator `json:"port_translators"` + LoadBalancer *LoadBalancer `json:"load_balancer"` + DatabaseServer *DatabaseServer `json:"database_server"` +} + +// PortTranslator represents a port translator on a Cloud IP +type PortTranslator struct { + Incoming uint16 `json:"incoming"` + Outgoing uint16 `json:"outgoing"` + Protocol transportprotocol.Enum `json:"protocol,omitempty"` +} + +// CloudIPOptions is used in conjunction with CreateCloudIP and UpdateCloudIP to +// create and update cloud IPs. +type CloudIPOptions struct { + ID string `json:"-"` + ReverseDNS *string `json:"reverse_dns,omitempty"` + Mode mode.Enum `json:"mode,omitempty"` + Name *string `json:"name,omitempty"` + PortTranslators []PortTranslator `json:"port_translators,omitempty"` +} + +// CloudIPAttachment is used in conjunction with MapCloudIP to specify +// the destination the CloudIP should be mapped to +type CloudIPAttachment struct { + Destination string `json:"destination"` +} + +// MapCloudIP issues a request to map the cloud ip to the destination. The +// destination can be an identifier of any resource capable of receiving a Cloud +// IP, such as a server interface, a load balancer, or a cloud sql instace. +func (c *Client) MapCloudIP(ctx context.Context, identifier string, attachment CloudIPAttachment) (*CloudIP, error) { + return apiPost[CloudIP]( + ctx, + c, + path.Join(cloudipAPIPath, identifier, "map"), + attachment, + ) +} + +// UnMapCloudIP issues a request to unmap the cloud ip. +func (c *Client) UnMapCloudIP(ctx context.Context, identifier string) (*CloudIP, error) { + return apiPost[CloudIP]( + ctx, + c, + path.Join(cloudipAPIPath, identifier, "unmap"), + nil, + ) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/cloud_ips_default.go b/vendor/github.com/brightbox/gobrightbox/v2/cloud_ips_default.go new file mode 100644 index 000000000..7581f17d2 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/cloud_ips_default.go @@ -0,0 +1,43 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // cloudipAPIPath returns the relative URL path to the CloudIP endpoint + cloudipAPIPath = "cloud_ips" +) + +// CloudIPs returns the collection view for CloudIP +func (c *Client) CloudIPs(ctx context.Context) ([]CloudIP, error) { + return apiGetCollection[[]CloudIP](ctx, c, cloudipAPIPath) +} + +// CloudIP retrieves a detailed view of one resource +func (c *Client) CloudIP(ctx context.Context, identifier string) (*CloudIP, error) { + return apiGet[CloudIP](ctx, c, path.Join(cloudipAPIPath, identifier)) +} + +// CreateCloudIP creates a new resource from the supplied option map. +// +// It takes an instance of CloudIPOptions. Not all attributes can be +// specified at create time (such as ID, which is allocated for you). +func (c *Client) CreateCloudIP(ctx context.Context, newCloudIP CloudIPOptions) (*CloudIP, error) { + return apiPost[CloudIP](ctx, c, cloudipAPIPath, newCloudIP) +} + +// UpdateCloudIP updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of CloudIPOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateCloudIP(ctx context.Context, updateCloudIP CloudIPOptions) (*CloudIP, error) { + return apiPut[CloudIP](ctx, c, path.Join(cloudipAPIPath, updateCloudIP.ID), updateCloudIP) +} + +// DestroyCloudIP destroys an existing resource. +func (c *Client) DestroyCloudIP(ctx context.Context, identifier string) (*CloudIP, error) { + return apiDelete[CloudIP](ctx, c, path.Join(cloudipAPIPath, identifier)) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/collaborations.go b/vendor/github.com/brightbox/gobrightbox/v2/collaborations.go new file mode 100644 index 000000000..7255d6416 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/collaborations.go @@ -0,0 +1,40 @@ +package brightbox + +import ( + "context" + "path" + "time" + + "github.com/brightbox/gobrightbox/v2/enums/collaborationstatus" +) + +//go:generate ./generate_enum collaborationstatus pending accepted rejected cancelled ended + +// Collaboration represents an API client. +// https://api.gb1.brightbox.com/1.0/#api_client +type Collaboration struct { + ResourceRef + ID string + Email string + Role string + RoleLabel string `json:"role_label"` + Status collaborationstatus.Enum + CreatedAt *time.Time `json:"created_at"` + StartedAt *time.Time `json:"started_at"` + FinishedAt *time.Time `json:"finished_at"` + Account *Account + User *User + Inviter *User +} + +// CollaborationOptions is used to create and update api clients +type CollaborationOptions struct { + ID string `json:"-"` + Email *string `json:"email,omitempty"` + Role *string `json:"role,omitempty"` +} + +// ResendCollaboration resends the invitation email to the collaborator. +func (c *Client) ResendCollaboration(ctx context.Context, identifier string) (*Collaboration, error) { + return apiPost[Collaboration](ctx, c, path.Join(collaborationAPIPath, identifier, "resend"), nil) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/collaborations_default.go b/vendor/github.com/brightbox/gobrightbox/v2/collaborations_default.go new file mode 100644 index 000000000..fd4391a20 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/collaborations_default.go @@ -0,0 +1,39 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // collaborationAPIPath returns the relative URL path to the Collaboration endpoint + collaborationAPIPath = "collaborations" +) + +// Collaborations returns the collection view for Collaboration +func (c *Client) Collaborations(ctx context.Context) ([]Collaboration, error) { + return apiGetCollection[[]Collaboration](ctx, c, collaborationAPIPath) +} + +// Collaboration retrieves a detailed view of one resource +func (c *Client) Collaboration(ctx context.Context, identifier string) (*Collaboration, error) { + return apiGet[Collaboration](ctx, c, path.Join(collaborationAPIPath, identifier)) +} + +// CreateCollaboration creates a new resource from the supplied option map. +// +// It takes an instance of CollaborationOptions. Not all attributes can be +// specified at create time (such as ID, which is allocated for you). +func (c *Client) CreateCollaboration(ctx context.Context, newCollaboration CollaborationOptions) (*Collaboration, error) { + return apiPost[Collaboration](ctx, c, collaborationAPIPath, newCollaboration) +} + +// DestroyCollaboration destroys an existing resource. +func (c *Client) DestroyCollaboration(ctx context.Context, identifier string) (*Collaboration, error) { + return apiDelete[Collaboration](ctx, c, path.Join(collaborationAPIPath, identifier)) +} + +// CreatedAt implements the CreateDated interface for Collaboration +func (s Collaboration) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/config_maps.go b/vendor/github.com/brightbox/gobrightbox/v2/config_maps.go new file mode 100644 index 000000000..57da401f9 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/config_maps.go @@ -0,0 +1,17 @@ +package brightbox + +// ConfigMap represents a config map +// https://api.gb1.brightbox.com/1.0/#config_maps +type ConfigMap struct { + ResourceRef + ID string `json:"id"` + Name string `json:"name"` + Data map[string]interface{} `json:"data"` +} + +// ConfigMapOptions is used to create and update config maps +type ConfigMapOptions struct { + ID string `json:"-"` + Name *string `json:"name,omitempty"` + Data *map[string]interface{} `json:"data,omitempty"` +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/config_maps_default.go b/vendor/github.com/brightbox/gobrightbox/v2/config_maps_default.go new file mode 100644 index 000000000..36f6f6f92 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/config_maps_default.go @@ -0,0 +1,43 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // configmapAPIPath returns the relative URL path to the ConfigMap endpoint + configmapAPIPath = "config_maps" +) + +// ConfigMaps returns the collection view for ConfigMap +func (c *Client) ConfigMaps(ctx context.Context) ([]ConfigMap, error) { + return apiGetCollection[[]ConfigMap](ctx, c, configmapAPIPath) +} + +// ConfigMap retrieves a detailed view of one resource +func (c *Client) ConfigMap(ctx context.Context, identifier string) (*ConfigMap, error) { + return apiGet[ConfigMap](ctx, c, path.Join(configmapAPIPath, identifier)) +} + +// CreateConfigMap creates a new resource from the supplied option map. +// +// It takes an instance of ConfigMapOptions. Not all attributes can be +// specified at create time (such as ID, which is allocated for you). +func (c *Client) CreateConfigMap(ctx context.Context, newConfigMap ConfigMapOptions) (*ConfigMap, error) { + return apiPost[ConfigMap](ctx, c, configmapAPIPath, newConfigMap) +} + +// UpdateConfigMap updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of ConfigMapOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateConfigMap(ctx context.Context, updateConfigMap ConfigMapOptions) (*ConfigMap, error) { + return apiPut[ConfigMap](ctx, c, path.Join(configmapAPIPath, updateConfigMap.ID), updateConfigMap) +} + +// DestroyConfigMap destroys an existing resource. +func (c *Client) DestroyConfigMap(ctx context.Context, identifier string) (*ConfigMap, error) { + return apiDelete[ConfigMap](ctx, c, path.Join(configmapAPIPath, identifier)) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/constraints.go b/vendor/github.com/brightbox/gobrightbox/v2/constraints.go new file mode 100644 index 000000000..46f27694d --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/constraints.go @@ -0,0 +1,8 @@ +package brightbox + +// CreateDated is a constraint type that selects all Brightbox objects +// with a creation date +type CreateDated interface { + // The Unix time in seconds the API object was created + CreatedAtUnix() int64 +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/database_servers.go b/vendor/github.com/brightbox/gobrightbox/v2/database_servers.go new file mode 100644 index 000000000..e2a2c16f7 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/database_servers.go @@ -0,0 +1,59 @@ +package brightbox + +import ( + "time" + + "github.com/brightbox/gobrightbox/v2/enums/databaseserverstatus" +) + +//go:generate ./generate_enum databaseserverstatus creating active deleting deleted failing failed + +// DatabaseServer represents a database server. +// https://api.gb1.brightbox.com/1.0/#database_server +type DatabaseServer struct { + ResourceRef + ID string + Name string + Description string + Status databaseserverstatus.Enum + DatabaseEngine string `json:"database_engine"` + DatabaseVersion string `json:"database_version"` + AdminUsername string `json:"admin_username"` + AdminPassword string `json:"admin_password"` + SnapshotsRetention string `json:"snapshots_retention"` + SnapshotsSchedule string `json:"snapshots_schedule"` + AllowAccess []string `json:"allow_access"` + MaintenanceWeekday uint8 `json:"maintenance_weekday"` + MaintenanceHour uint8 `json:"maintenance_hour"` + Locked bool + CreatedAt *time.Time `json:"created_at"` + DeletedAt *time.Time `json:"deleted_at"` + UpdatedAt *time.Time `json:"updated_at"` + SnapshotsScheduleNextAt *time.Time `json:"snapshots_schedule_next_at"` + Account *Account + Zone *Zone + DatabaseServerType *DatabaseServerType `json:"database_server_type"` + CloudIPs []CloudIP `json:"cloud_ips"` +} + +// DatabaseServerOptions is used in conjunction with CreateDatabaseServer and +// UpdateDatabaseServer to create and update database servers. +type DatabaseServerOptions struct { + ID string `json:"-"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + Engine string `json:"engine,omitempty"` + Version string `json:"version,omitempty"` + AllowAccess []string `json:"allow_access,omitempty"` + Snapshot string `json:"snapshot,omitempty"` + Zone string `json:"zone,omitempty"` + DatabaseType string `json:"database_type,omitempty"` + MaintenanceWeekday *uint8 `json:"maintenance_weekday,omitempty"` + MaintenanceHour *uint8 `json:"maintenance_hour,omitempty"` + SnapshotsRetention *string `json:"snapshots_retention,omitempty"` + SnapshotsSchedule *string `json:"snapshots_schedule,omitempty"` +} + +// DatabaseServerNewSize is used in conjunction with ResizeDatabaseServer +// to specify the new DatabaseServerType for the Database Server +type DatabaseServerNewSize = ServerNewSize diff --git a/vendor/github.com/brightbox/gobrightbox/v2/database_servers_default.go b/vendor/github.com/brightbox/gobrightbox/v2/database_servers_default.go new file mode 100644 index 000000000..81854daf7 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/database_servers_default.go @@ -0,0 +1,76 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // databaseserverAPIPath returns the relative URL path to the DatabaseServer endpoint + databaseserverAPIPath = "database_servers" +) + +// DatabaseServers returns the collection view for DatabaseServer +func (c *Client) DatabaseServers(ctx context.Context) ([]DatabaseServer, error) { + return apiGetCollection[[]DatabaseServer](ctx, c, databaseserverAPIPath) +} + +// DatabaseServer retrieves a detailed view of one resource +func (c *Client) DatabaseServer(ctx context.Context, identifier string) (*DatabaseServer, error) { + return apiGet[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier)) +} + +// CreateDatabaseServer creates a new resource from the supplied option map. +// +// It takes an instance of DatabaseServerOptions. Not all attributes can be +// specified at create time (such as ID, which is allocated for you). +func (c *Client) CreateDatabaseServer(ctx context.Context, newDatabaseServer DatabaseServerOptions) (*DatabaseServer, error) { + return apiPost[DatabaseServer](ctx, c, databaseserverAPIPath, newDatabaseServer) +} + +// UpdateDatabaseServer updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of DatabaseServerOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateDatabaseServer(ctx context.Context, updateDatabaseServer DatabaseServerOptions) (*DatabaseServer, error) { + return apiPut[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, updateDatabaseServer.ID), updateDatabaseServer) +} + +// DestroyDatabaseServer destroys an existing resource. +func (c *Client) DestroyDatabaseServer(ctx context.Context, identifier string) (*DatabaseServer, error) { + return apiDelete[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier)) +} + +// LockDatabaseServer locks a resource against destroy requests +func (c *Client) LockDatabaseServer(ctx context.Context, identifier string) (*DatabaseServer, error) { + return apiPut[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier, "lock_resource"), nil) +} + +// UnlockDatabaseServer unlocks a resource, re-enabling destroy requests +func (c *Client) UnlockDatabaseServer(ctx context.Context, identifier string) (*DatabaseServer, error) { + return apiPut[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier, "unlock_resource"), nil) +} + +// CreatedAt implements the CreateDated interface for DatabaseServer +func (s DatabaseServer) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() +} + +// ResetDatabaseServerPassword resets the password in DatabaseServer, returning it +// in the returned resource. This is the only time the new password is +// available in plaintext. +func (c *Client) ResetDatabaseServerPassword(ctx context.Context, identifier string) (*DatabaseServer, error) { + return apiPost[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier, "reset_password"), nil) +} + +// ResizeDatabaseServer issues a request to change the server type of a server +// changing the amount of cpu and ram it has. +func (c *Client) ResizeDatabaseServer(ctx context.Context, identifier string, newSize DatabaseServerNewSize) (*DatabaseServer, error) { + return apiPost[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier, "resize"), newSize) +} + +// ResetDatabaseServer issues a "reset" instruction to a DatabaseServer +func (c *Client) ResetDatabaseServer(ctx context.Context, identifier string) (*DatabaseServer, error) { + return apiPost[DatabaseServer](ctx, c, path.Join(databaseserverAPIPath, identifier, "reset"), nil) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/database_snapshots.go b/vendor/github.com/brightbox/gobrightbox/v2/database_snapshots.go new file mode 100644 index 000000000..c08550459 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/database_snapshots.go @@ -0,0 +1,36 @@ +package brightbox + +import ( + "time" + + "github.com/brightbox/gobrightbox/v2/enums/databasesnapshotstatus" +) + +//go:generate ./generate_enum databasesnapshotstatus creating available deleting deleted failed + +// DatabaseSnapshot represents a snapshot of a database server. +// https://api.gb1.brightbox.com/1.0/#databaseSnapshot +type DatabaseSnapshot struct { + ResourceRef + ID string + Name string + Description string + Status databasesnapshotstatus.Enum + DatabaseEngine string `json:"database_engine"` + DatabaseVersion string `json:"database_version"` + Source string + SourceTrigger string `json:"source_trigger"` + Size uint + CreatedAt *time.Time `json:"created_at"` + UpdatedAt *time.Time `json:"updated_at"` + DeletedAt *time.Time `json:"deleted_at"` + Locked bool + Account Account +} + +// DatabaseSnapshotOptions is used to update snapshots +type DatabaseSnapshotOptions struct { + ID string `json:"-"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/database_snapshots_default.go b/vendor/github.com/brightbox/gobrightbox/v2/database_snapshots_default.go new file mode 100644 index 000000000..039ac5861 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/database_snapshots_default.go @@ -0,0 +1,50 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // databasesnapshotAPIPath returns the relative URL path to the DatabaseSnapshot endpoint + databasesnapshotAPIPath = "database_snapshots" +) + +// DatabaseSnapshots returns the collection view for DatabaseSnapshot +func (c *Client) DatabaseSnapshots(ctx context.Context) ([]DatabaseSnapshot, error) { + return apiGetCollection[[]DatabaseSnapshot](ctx, c, databasesnapshotAPIPath) +} + +// DatabaseSnapshot retrieves a detailed view of one resource +func (c *Client) DatabaseSnapshot(ctx context.Context, identifier string) (*DatabaseSnapshot, error) { + return apiGet[DatabaseSnapshot](ctx, c, path.Join(databasesnapshotAPIPath, identifier)) +} + +// UpdateDatabaseSnapshot updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of DatabaseSnapshotOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateDatabaseSnapshot(ctx context.Context, updateDatabaseSnapshot DatabaseSnapshotOptions) (*DatabaseSnapshot, error) { + return apiPut[DatabaseSnapshot](ctx, c, path.Join(databasesnapshotAPIPath, updateDatabaseSnapshot.ID), updateDatabaseSnapshot) +} + +// DestroyDatabaseSnapshot destroys an existing resource. +func (c *Client) DestroyDatabaseSnapshot(ctx context.Context, identifier string) (*DatabaseSnapshot, error) { + return apiDelete[DatabaseSnapshot](ctx, c, path.Join(databasesnapshotAPIPath, identifier)) +} + +// LockDatabaseSnapshot locks a resource against destroy requests +func (c *Client) LockDatabaseSnapshot(ctx context.Context, identifier string) (*DatabaseSnapshot, error) { + return apiPut[DatabaseSnapshot](ctx, c, path.Join(databasesnapshotAPIPath, identifier, "lock_resource"), nil) +} + +// UnlockDatabaseSnapshot unlocks a resource, re-enabling destroy requests +func (c *Client) UnlockDatabaseSnapshot(ctx context.Context, identifier string) (*DatabaseSnapshot, error) { + return apiPut[DatabaseSnapshot](ctx, c, path.Join(databasesnapshotAPIPath, identifier, "unlock_resource"), nil) +} + +// CreatedAt implements the CreateDated interface for DatabaseSnapshot +func (s DatabaseSnapshot) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/database_types.go b/vendor/github.com/brightbox/gobrightbox/v2/database_types.go new file mode 100644 index 000000000..6b53ab3be --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/database_types.go @@ -0,0 +1,13 @@ +package brightbox + +// DatabaseServerType represents a database server type +// https://api.gb1.brightbox.com/1.0/#database_type +type DatabaseServerType struct { + ResourceRef + ID string + Name string + Description string + RAM uint + DiskSize uint `json:"disk_size"` + Default bool +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/database_types_default.go b/vendor/github.com/brightbox/gobrightbox/v2/database_types_default.go new file mode 100644 index 000000000..b112ce815 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/database_types_default.go @@ -0,0 +1,21 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // databaseservertypeAPIPath returns the relative URL path to the DatabaseServerType endpoint + databaseservertypeAPIPath = "database_types" +) + +// DatabaseServerTypes returns the collection view for DatabaseServerType +func (c *Client) DatabaseServerTypes(ctx context.Context) ([]DatabaseServerType, error) { + return apiGetCollection[[]DatabaseServerType](ctx, c, databaseservertypeAPIPath) +} + +// DatabaseServerType retrieves a detailed view of one resource +func (c *Client) DatabaseServerType(ctx context.Context, identifier string) (*DatabaseServerType, error) { + return apiGet[DatabaseServerType](ctx, c, path.Join(databaseservertypeAPIPath, identifier)) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/doc.go b/vendor/github.com/brightbox/gobrightbox/v2/doc.go new file mode 100644 index 000000000..7b9024250 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/doc.go @@ -0,0 +1,17 @@ +/* +Package brightbox provides a client to access the Brightbox API + +A [Client] is created by passing a context and a config to the [Connect] function + + // Setup connection to API + client, err := brightbox.Connect(ctx, conf) + +There are two types of Config available. +A [clientcredentials.Config] authenticates using an [API Client] and is specific to a particular Brightbox account. +A [passwordcredentials.Config] authenticates using a [Username] and can be used with any authorised Brightbox account. + +[API Client]: https://www.brightbox.com/docs/reference/authentication/#api-client-authentication +[Username]: https://www.brightbox.com/docs/reference/authentication/#user-authentication + +*/ +package brightbox diff --git a/vendor/github.com/brightbox/gobrightbox/v2/endpoint/constants.go b/vendor/github.com/brightbox/gobrightbox/v2/endpoint/constants.go new file mode 100644 index 000000000..4b08ce668 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/endpoint/constants.go @@ -0,0 +1,30 @@ +package endpoint + +import ( + "golang.org/x/oauth2" +) + +// API constants. +const ( + DefaultBaseURL = "https://api.gb1.brightbox.com/" + DefaultVersion = "1.0" + DefaultOrbitBaseURL = "https://orbit.brightbox.com/" + DefaultOrbitVersion = "v1" +) + +// InfrastructureScope tokens are used to access the Brightbox API +var InfrastructureScope = []string{"infrastructure"} + +// OrbitScope tokens restrict access to Orbit files only +var OrbitScope = []string{"orbit"} + +// FullScope tokens allow access to both the API and Orbit +var FullScope = append(InfrastructureScope, OrbitScope...) + +// Brightbox is the default oauth2 endpoint +// As Brightbox is a direct access API using oauth2 mechanisms there is +// no AuthURL. Everything is driven via the TokenURL. +var Brightbox = oauth2.Endpoint{ + TokenURL: DefaultBaseURL + "token/", + AuthStyle: oauth2.AuthStyleInHeader, +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/endpoint/endpoint.go b/vendor/github.com/brightbox/gobrightbox/v2/endpoint/endpoint.go new file mode 100644 index 000000000..342c93a4b --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/endpoint/endpoint.go @@ -0,0 +1,131 @@ +// Package endpoint manages the API endpoint details +// +// The API uses an endpoint URL and a semantic version number. This +// structure manages variations on the defaults and provides a function +// to access the correct URL +package endpoint + +import ( + "net/url" + + "golang.org/x/oauth2" +) + +// Config contains the endpoint,version and account of the Brightbox API +// +// BaseURL should be an url of the form https://api.region.brightbox.com, +// e.g: https://api.gb1.brightbox.com. Leave empty to use the default. +// +// Account should be the identifier of the default account to be used with +// the API. Clients authenticated with Brightbox APIClient credentials are +// only ever associated with one single Account, so you can leave this empty for +// those. Client's authenticated with Brightbox User credentials can have access +// to multiple accounts, so this parameter should be provided. +// +// Version is the major and minor numbers of the version of the Brightbox API you +// wish to access. Leave blank to use the default "1.0" +// +// Scopes specify optional requested permissions. Leave blank to +// request a token that can be used for all Brightbox API operations. Use +// [InfrastructureScope] or [OrbitScope] to restrict the token to those areas. +type Config struct { + BaseURL string + Version string + Account string + Scopes []string +} + +// APIURL provides the base URL for accessing the API using the Config +// entries. Where entries are missing, library defaults will be used. +// +// If Account is set, then a query parameter will be added to the URL to +// reference that account. +// +// APIURL is part of the [brightbox.Oauth2] access interface. +func (c *Config) APIURL() (*url.URL, error) { + var rawURL string + var rawVersion string + if c.BaseURL == "" { + rawURL = DefaultBaseURL + } else { + rawURL = c.BaseURL + } + u, err := url.Parse(rawURL) + if err != nil { + return nil, err + } + if c.Version == "" { + rawVersion = DefaultVersion + } else { + rawVersion = c.Version + } + u, err = u.Parse(rawVersion + "/") + if err != nil { + return nil, err + } + if c.Account != "" { + v := url.Values{} + v.Set("account_id", c.Account) + u.RawQuery = v.Encode() + } + return u, nil +} + +// StorageURL provides the base URL for accessing Orbit using the Config +// entries. Where entries are missing, library defaults will be used. +// +// If Account is set, then a query parameter will be added to the URL to +// reference that account. +func (c *Config) StorageURL() (string, error) { + var rawURL string + var path string + if c.BaseURL == "" { + rawURL = DefaultOrbitBaseURL + } else { + rawURL = c.BaseURL + } + u, err := url.Parse(rawURL) + if err != nil { + return "", err + } + if c.Version == "" { + path = DefaultOrbitVersion + } else { + path = c.Version + } + if c.Account != "" { + path = path + "/" + c.Account + } + newURL, err := u.Parse(path + "/") + if err != nil { + return "", err + } + return newURL.String(), nil +} + +// TokenURL provides the OAuth2 URL from the Config BaseURL entries. Where +// entries are missing, library defaults will be used. +func (c *Config) TokenURL() (string, error) { + tokenConfig := &Config{ + BaseURL: c.BaseURL, + Version: "token", + } + u, err := tokenConfig.APIURL() + if err != nil { + return "", err + } + return u.String(), nil +} + +// Endpoint provides an oauth2 Endpoint from the Brightbox endpoint +// entries. Where entries are missing, library defaults will be used. +func (c *Config) Endpoint() (*oauth2.Endpoint, error) { + tokenurl, err := c.TokenURL() + if err != nil { + return nil, err + } + return &oauth2.Endpoint{ + TokenURL: tokenurl, + AuthStyle: oauth2.AuthStyleInHeader, + }, nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/accountstatus/accountstatus.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/accountstatus/accountstatus.go new file mode 100644 index 000000000..a7694beaa --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/accountstatus/accountstatus.go @@ -0,0 +1,114 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package accountstatus is an enumeration of the states Pending, Active, Overdue, Warning, Suspended, Terminated, Closed, Deleted +package accountstatus + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Pending is an enumeration for accountstatus.Enum + Pending Enum = iota + 1 + // Active is an enumeration for accountstatus.Enum + Active + // Overdue is an enumeration for accountstatus.Enum + Overdue + // Warning is an enumeration for accountstatus.Enum + Warning + // Suspended is an enumeration for accountstatus.Enum + Suspended + // Terminated is an enumeration for accountstatus.Enum + Terminated + // Closed is an enumeration for accountstatus.Enum + Closed + // Deleted is an enumeration for accountstatus.Enum + Deleted +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Pending.String(), + Active.String(), + Overdue.String(), + Warning.String(), + Suspended.String(), + Terminated.String(), + Closed.String(), + Deleted.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "pending": + return Pending, nil + case "active": + return Active, nil + case "overdue": + return Overdue, nil + case "warning": + return Warning, nil + case "suspended": + return Suspended, nil + case "terminated": + return Terminated, nil + case "closed": + return Closed, nil + case "deleted": + return Deleted, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid accountstatus.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Pending: + return []byte("pending"), nil + case Active: + return []byte("active"), nil + case Overdue: + return []byte("overdue"), nil + case Warning: + return []byte("warning"), nil + case Suspended: + return []byte("suspended"), nil + case Terminated: + return []byte("terminated"), nil + case Closed: + return []byte("closed"), nil + case Deleted: + return []byte("deleted"), nil + } + return nil, fmt.Errorf("%d is not a valid accountstatus.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/arch/arch.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/arch/arch.go new file mode 100644 index 000000000..a27b3cc69 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/arch/arch.go @@ -0,0 +1,72 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package arch is an enumeration of the states X86_64, I686 +package arch + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // X86_64 is an enumeration for arch.Enum + X86_64 Enum = iota + 1 + // I686 is an enumeration for arch.Enum + I686 +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + X86_64.String(), + I686.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "x86_64": + return X86_64, nil + case "i686": + return I686, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid arch.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case X86_64: + return []byte("x86_64"), nil + case I686: + return []byte("i686"), nil + } + return nil, fmt.Errorf("%d is not a valid arch.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/balancingpolicy/balancingpolicy.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/balancingpolicy/balancingpolicy.go new file mode 100644 index 000000000..ac5843024 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/balancingpolicy/balancingpolicy.go @@ -0,0 +1,79 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package balancingpolicy is an enumeration of the states LeastConnections, RoundRobin, SourceAddress +package balancingpolicy + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // LeastConnections is an enumeration for balancingpolicy.Enum + LeastConnections Enum = iota + 1 + // RoundRobin is an enumeration for balancingpolicy.Enum + RoundRobin + // SourceAddress is an enumeration for balancingpolicy.Enum + SourceAddress +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + LeastConnections.String(), + RoundRobin.String(), + SourceAddress.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "least-connections": + return LeastConnections, nil + case "round-robin": + return RoundRobin, nil + case "source-address": + return SourceAddress, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid balancingpolicy.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case LeastConnections: + return []byte("least-connections"), nil + case RoundRobin: + return []byte("round-robin"), nil + case SourceAddress: + return []byte("source-address"), nil + } + return nil, fmt.Errorf("%d is not a valid balancingpolicy.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/cloudipstatus/cloudipstatus.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/cloudipstatus/cloudipstatus.go new file mode 100644 index 000000000..4906a587e --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/cloudipstatus/cloudipstatus.go @@ -0,0 +1,72 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package cloudipstatus is an enumeration of the states Mapped, Unmapped +package cloudipstatus + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Mapped is an enumeration for cloudipstatus.Enum + Mapped Enum = iota + 1 + // Unmapped is an enumeration for cloudipstatus.Enum + Unmapped +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Mapped.String(), + Unmapped.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "mapped": + return Mapped, nil + case "unmapped": + return Unmapped, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid cloudipstatus.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Mapped: + return []byte("mapped"), nil + case Unmapped: + return []byte("unmapped"), nil + } + return nil, fmt.Errorf("%d is not a valid cloudipstatus.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/collaborationstatus/collaborationstatus.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/collaborationstatus/collaborationstatus.go new file mode 100644 index 000000000..85b642d3e --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/collaborationstatus/collaborationstatus.go @@ -0,0 +1,93 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package collaborationstatus is an enumeration of the states Pending, Accepted, Rejected, Cancelled, Ended +package collaborationstatus + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Pending is an enumeration for collaborationstatus.Enum + Pending Enum = iota + 1 + // Accepted is an enumeration for collaborationstatus.Enum + Accepted + // Rejected is an enumeration for collaborationstatus.Enum + Rejected + // Cancelled is an enumeration for collaborationstatus.Enum + Cancelled + // Ended is an enumeration for collaborationstatus.Enum + Ended +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Pending.String(), + Accepted.String(), + Rejected.String(), + Cancelled.String(), + Ended.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "pending": + return Pending, nil + case "accepted": + return Accepted, nil + case "rejected": + return Rejected, nil + case "cancelled": + return Cancelled, nil + case "ended": + return Ended, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid collaborationstatus.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Pending: + return []byte("pending"), nil + case Accepted: + return []byte("accepted"), nil + case Rejected: + return []byte("rejected"), nil + case Cancelled: + return []byte("cancelled"), nil + case Ended: + return []byte("ended"), nil + } + return nil, fmt.Errorf("%d is not a valid collaborationstatus.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/databaseserverstatus/databaseserverstatus.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/databaseserverstatus/databaseserverstatus.go new file mode 100644 index 000000000..86d936ab9 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/databaseserverstatus/databaseserverstatus.go @@ -0,0 +1,100 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package databaseserverstatus is an enumeration of the states Creating, Active, Deleting, Deleted, Failing, Failed +package databaseserverstatus + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Creating is an enumeration for databaseserverstatus.Enum + Creating Enum = iota + 1 + // Active is an enumeration for databaseserverstatus.Enum + Active + // Deleting is an enumeration for databaseserverstatus.Enum + Deleting + // Deleted is an enumeration for databaseserverstatus.Enum + Deleted + // Failing is an enumeration for databaseserverstatus.Enum + Failing + // Failed is an enumeration for databaseserverstatus.Enum + Failed +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Creating.String(), + Active.String(), + Deleting.String(), + Deleted.String(), + Failing.String(), + Failed.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "creating": + return Creating, nil + case "active": + return Active, nil + case "deleting": + return Deleting, nil + case "deleted": + return Deleted, nil + case "failing": + return Failing, nil + case "failed": + return Failed, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid databaseserverstatus.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Creating: + return []byte("creating"), nil + case Active: + return []byte("active"), nil + case Deleting: + return []byte("deleting"), nil + case Deleted: + return []byte("deleted"), nil + case Failing: + return []byte("failing"), nil + case Failed: + return []byte("failed"), nil + } + return nil, fmt.Errorf("%d is not a valid databaseserverstatus.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/databasesnapshotstatus/databasesnapshotstatus.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/databasesnapshotstatus/databasesnapshotstatus.go new file mode 100644 index 000000000..8d373661a --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/databasesnapshotstatus/databasesnapshotstatus.go @@ -0,0 +1,93 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package databasesnapshotstatus is an enumeration of the states Creating, Available, Deleting, Deleted, Failed +package databasesnapshotstatus + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Creating is an enumeration for databasesnapshotstatus.Enum + Creating Enum = iota + 1 + // Available is an enumeration for databasesnapshotstatus.Enum + Available + // Deleting is an enumeration for databasesnapshotstatus.Enum + Deleting + // Deleted is an enumeration for databasesnapshotstatus.Enum + Deleted + // Failed is an enumeration for databasesnapshotstatus.Enum + Failed +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Creating.String(), + Available.String(), + Deleting.String(), + Deleted.String(), + Failed.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "creating": + return Creating, nil + case "available": + return Available, nil + case "deleting": + return Deleting, nil + case "deleted": + return Deleted, nil + case "failed": + return Failed, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid databasesnapshotstatus.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Creating: + return []byte("creating"), nil + case Available: + return []byte("available"), nil + case Deleting: + return []byte("deleting"), nil + case Deleted: + return []byte("deleted"), nil + case Failed: + return []byte("failed"), nil + } + return nil, fmt.Errorf("%d is not a valid databasesnapshotstatus.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/filesystemtype/filesystemtype.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/filesystemtype/filesystemtype.go new file mode 100644 index 000000000..5935ba3a8 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/filesystemtype/filesystemtype.go @@ -0,0 +1,72 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package filesystemtype is an enumeration of the states Xfs, Ext4 +package filesystemtype + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Xfs is an enumeration for filesystemtype.Enum + Xfs Enum = iota + 1 + // Ext4 is an enumeration for filesystemtype.Enum + Ext4 +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Xfs.String(), + Ext4.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "xfs": + return Xfs, nil + case "ext4": + return Ext4, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid filesystemtype.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Xfs: + return []byte("xfs"), nil + case Ext4: + return []byte("ext4"), nil + } + return nil, fmt.Errorf("%d is not a valid filesystemtype.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/healthchecktype/healthchecktype.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/healthchecktype/healthchecktype.go new file mode 100644 index 000000000..cd2c6148e --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/healthchecktype/healthchecktype.go @@ -0,0 +1,72 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package healthchecktype is an enumeration of the states Tcp, Http +package healthchecktype + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Tcp is an enumeration for healthchecktype.Enum + Tcp Enum = iota + 1 + // Http is an enumeration for healthchecktype.Enum + Http +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Tcp.String(), + Http.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "tcp": + return Tcp, nil + case "http": + return Http, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid healthchecktype.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Tcp: + return []byte("tcp"), nil + case Http: + return []byte("http"), nil + } + return nil, fmt.Errorf("%d is not a valid healthchecktype.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/imagestatus/imagestatus.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/imagestatus/imagestatus.go new file mode 100644 index 000000000..b9b86141d --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/imagestatus/imagestatus.go @@ -0,0 +1,107 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package imagestatus is an enumeration of the states Creating, Available, Deprecated, Unavailable, Deleting, Deleted, Failed +package imagestatus + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Creating is an enumeration for imagestatus.Enum + Creating Enum = iota + 1 + // Available is an enumeration for imagestatus.Enum + Available + // Deprecated is an enumeration for imagestatus.Enum + Deprecated + // Unavailable is an enumeration for imagestatus.Enum + Unavailable + // Deleting is an enumeration for imagestatus.Enum + Deleting + // Deleted is an enumeration for imagestatus.Enum + Deleted + // Failed is an enumeration for imagestatus.Enum + Failed +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Creating.String(), + Available.String(), + Deprecated.String(), + Unavailable.String(), + Deleting.String(), + Deleted.String(), + Failed.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "creating": + return Creating, nil + case "available": + return Available, nil + case "deprecated": + return Deprecated, nil + case "unavailable": + return Unavailable, nil + case "deleting": + return Deleting, nil + case "deleted": + return Deleted, nil + case "failed": + return Failed, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid imagestatus.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Creating: + return []byte("creating"), nil + case Available: + return []byte("available"), nil + case Deprecated: + return []byte("deprecated"), nil + case Unavailable: + return []byte("unavailable"), nil + case Deleting: + return []byte("deleting"), nil + case Deleted: + return []byte("deleted"), nil + case Failed: + return []byte("failed"), nil + } + return nil, fmt.Errorf("%d is not a valid imagestatus.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/listenerprotocol/listenerprotocol.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/listenerprotocol/listenerprotocol.go new file mode 100644 index 000000000..b520167df --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/listenerprotocol/listenerprotocol.go @@ -0,0 +1,79 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package listenerprotocol is an enumeration of the states Tcp, Http, Https +package listenerprotocol + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Tcp is an enumeration for listenerprotocol.Enum + Tcp Enum = iota + 1 + // Http is an enumeration for listenerprotocol.Enum + Http + // Https is an enumeration for listenerprotocol.Enum + Https +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Tcp.String(), + Http.String(), + Https.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "tcp": + return Tcp, nil + case "http": + return Http, nil + case "https": + return Https, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid listenerprotocol.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Tcp: + return []byte("tcp"), nil + case Http: + return []byte("http"), nil + case Https: + return []byte("https"), nil + } + return nil, fmt.Errorf("%d is not a valid listenerprotocol.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/loadbalancerstatus/loadbalancerstatus.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/loadbalancerstatus/loadbalancerstatus.go new file mode 100644 index 000000000..a73be241c --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/loadbalancerstatus/loadbalancerstatus.go @@ -0,0 +1,100 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package loadbalancerstatus is an enumeration of the states Creating, Active, Deleting, Deleted, Failing, Failed +package loadbalancerstatus + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Creating is an enumeration for loadbalancerstatus.Enum + Creating Enum = iota + 1 + // Active is an enumeration for loadbalancerstatus.Enum + Active + // Deleting is an enumeration for loadbalancerstatus.Enum + Deleting + // Deleted is an enumeration for loadbalancerstatus.Enum + Deleted + // Failing is an enumeration for loadbalancerstatus.Enum + Failing + // Failed is an enumeration for loadbalancerstatus.Enum + Failed +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Creating.String(), + Active.String(), + Deleting.String(), + Deleted.String(), + Failing.String(), + Failed.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "creating": + return Creating, nil + case "active": + return Active, nil + case "deleting": + return Deleting, nil + case "deleted": + return Deleted, nil + case "failing": + return Failing, nil + case "failed": + return Failed, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid loadbalancerstatus.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Creating: + return []byte("creating"), nil + case Active: + return []byte("active"), nil + case Deleting: + return []byte("deleting"), nil + case Deleted: + return []byte("deleted"), nil + case Failing: + return []byte("failing"), nil + case Failed: + return []byte("failed"), nil + } + return nil, fmt.Errorf("%d is not a valid loadbalancerstatus.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/mode/mode.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/mode/mode.go new file mode 100644 index 000000000..a015a2e9e --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/mode/mode.go @@ -0,0 +1,72 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package mode is an enumeration of the states Nat, Route +package mode + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Nat is an enumeration for mode.Enum + Nat Enum = iota + 1 + // Route is an enumeration for mode.Enum + Route +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Nat.String(), + Route.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "nat": + return Nat, nil + case "route": + return Route, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid mode.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Nat: + return []byte("nat"), nil + case Route: + return []byte("route"), nil + } + return nil, fmt.Errorf("%d is not a valid mode.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/permissionsgroup/permissionsgroup.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/permissionsgroup/permissionsgroup.go new file mode 100644 index 000000000..786d23766 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/permissionsgroup/permissionsgroup.go @@ -0,0 +1,72 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package permissionsgroup is an enumeration of the states Full, Storage +package permissionsgroup + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Full is an enumeration for permissionsgroup.Enum + Full Enum = iota + 1 + // Storage is an enumeration for permissionsgroup.Enum + Storage +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Full.String(), + Storage.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "full": + return Full, nil + case "storage": + return Storage, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid permissionsgroup.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Full: + return []byte("full"), nil + case Storage: + return []byte("storage"), nil + } + return nil, fmt.Errorf("%d is not a valid permissionsgroup.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/proxyprotocol/proxyprotocol.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/proxyprotocol/proxyprotocol.go new file mode 100644 index 000000000..bd0177366 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/proxyprotocol/proxyprotocol.go @@ -0,0 +1,86 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package proxyprotocol is an enumeration of the states V1, V2, V2Ssl, V2SslCn +package proxyprotocol + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // V1 is an enumeration for proxyprotocol.Enum + V1 Enum = iota + 1 + // V2 is an enumeration for proxyprotocol.Enum + V2 + // V2Ssl is an enumeration for proxyprotocol.Enum + V2Ssl + // V2SslCn is an enumeration for proxyprotocol.Enum + V2SslCn +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + V1.String(), + V2.String(), + V2Ssl.String(), + V2SslCn.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "v1": + return V1, nil + case "v2": + return V2, nil + case "v2-ssl": + return V2Ssl, nil + case "v2-ssl-cn": + return V2SslCn, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid proxyprotocol.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case V1: + return []byte("v1"), nil + case V2: + return []byte("v2"), nil + case V2Ssl: + return []byte("v2-ssl"), nil + case V2SslCn: + return []byte("v2-ssl-cn"), nil + } + return nil, fmt.Errorf("%d is not a valid proxyprotocol.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/serverstatus/serverstatus.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/serverstatus/serverstatus.go new file mode 100644 index 000000000..75c82db43 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/serverstatus/serverstatus.go @@ -0,0 +1,107 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package serverstatus is an enumeration of the states Creating, Active, Inactive, Deleting, Deleted, Failed, Unavailable +package serverstatus + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Creating is an enumeration for serverstatus.Enum + Creating Enum = iota + 1 + // Active is an enumeration for serverstatus.Enum + Active + // Inactive is an enumeration for serverstatus.Enum + Inactive + // Deleting is an enumeration for serverstatus.Enum + Deleting + // Deleted is an enumeration for serverstatus.Enum + Deleted + // Failed is an enumeration for serverstatus.Enum + Failed + // Unavailable is an enumeration for serverstatus.Enum + Unavailable +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Creating.String(), + Active.String(), + Inactive.String(), + Deleting.String(), + Deleted.String(), + Failed.String(), + Unavailable.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "creating": + return Creating, nil + case "active": + return Active, nil + case "inactive": + return Inactive, nil + case "deleting": + return Deleting, nil + case "deleted": + return Deleted, nil + case "failed": + return Failed, nil + case "unavailable": + return Unavailable, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid serverstatus.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Creating: + return []byte("creating"), nil + case Active: + return []byte("active"), nil + case Inactive: + return []byte("inactive"), nil + case Deleting: + return []byte("deleting"), nil + case Deleted: + return []byte("deleted"), nil + case Failed: + return []byte("failed"), nil + case Unavailable: + return []byte("unavailable"), nil + } + return nil, fmt.Errorf("%d is not a valid serverstatus.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/servertypestatus/servertypestatus.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/servertypestatus/servertypestatus.go new file mode 100644 index 000000000..19df289ac --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/servertypestatus/servertypestatus.go @@ -0,0 +1,79 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package servertypestatus is an enumeration of the states Experimental, Available, Deprecated +package servertypestatus + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Experimental is an enumeration for servertypestatus.Enum + Experimental Enum = iota + 1 + // Available is an enumeration for servertypestatus.Enum + Available + // Deprecated is an enumeration for servertypestatus.Enum + Deprecated +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Experimental.String(), + Available.String(), + Deprecated.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "experimental": + return Experimental, nil + case "available": + return Available, nil + case "deprecated": + return Deprecated, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid servertypestatus.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Experimental: + return []byte("experimental"), nil + case Available: + return []byte("available"), nil + case Deprecated: + return []byte("deprecated"), nil + } + return nil, fmt.Errorf("%d is not a valid servertypestatus.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/sourcetrigger/sourcetrigger.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/sourcetrigger/sourcetrigger.go new file mode 100644 index 000000000..d1671bca5 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/sourcetrigger/sourcetrigger.go @@ -0,0 +1,72 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package sourcetrigger is an enumeration of the states Manual, Schedule +package sourcetrigger + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Manual is an enumeration for sourcetrigger.Enum + Manual Enum = iota + 1 + // Schedule is an enumeration for sourcetrigger.Enum + Schedule +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Manual.String(), + Schedule.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "manual": + return Manual, nil + case "schedule": + return Schedule, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid sourcetrigger.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Manual: + return []byte("manual"), nil + case Schedule: + return []byte("schedule"), nil + } + return nil, fmt.Errorf("%d is not a valid sourcetrigger.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/sourcetype/sourcetype.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/sourcetype/sourcetype.go new file mode 100644 index 000000000..7acb56960 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/sourcetype/sourcetype.go @@ -0,0 +1,72 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package sourcetype is an enumeration of the states Upload, Snapshot +package sourcetype + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Upload is an enumeration for sourcetype.Enum + Upload Enum = iota + 1 + // Snapshot is an enumeration for sourcetype.Enum + Snapshot +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Upload.String(), + Snapshot.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "upload": + return Upload, nil + case "snapshot": + return Snapshot, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid sourcetype.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Upload: + return []byte("upload"), nil + case Snapshot: + return []byte("snapshot"), nil + } + return nil, fmt.Errorf("%d is not a valid sourcetype.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/storagetype/storagetype.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/storagetype/storagetype.go new file mode 100644 index 000000000..5cd725942 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/storagetype/storagetype.go @@ -0,0 +1,72 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package storagetype is an enumeration of the states Local, Network +package storagetype + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Local is an enumeration for storagetype.Enum + Local Enum = iota + 1 + // Network is an enumeration for storagetype.Enum + Network +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Local.String(), + Network.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "local": + return Local, nil + case "network": + return Network, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid storagetype.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Local: + return []byte("local"), nil + case Network: + return []byte("network"), nil + } + return nil, fmt.Errorf("%d is not a valid storagetype.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/transportprotocol/transportprotocol.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/transportprotocol/transportprotocol.go new file mode 100644 index 000000000..a0a3835d2 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/transportprotocol/transportprotocol.go @@ -0,0 +1,72 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package transportprotocol is an enumeration of the states Tcp, Udp +package transportprotocol + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Tcp is an enumeration for transportprotocol.Enum + Tcp Enum = iota + 1 + // Udp is an enumeration for transportprotocol.Enum + Udp +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Tcp.String(), + Udp.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "tcp": + return Tcp, nil + case "udp": + return Udp, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid transportprotocol.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Tcp: + return []byte("tcp"), nil + case Udp: + return []byte("udp"), nil + } + return nil, fmt.Errorf("%d is not a valid transportprotocol.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/volumestatus/volumestatus.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/volumestatus/volumestatus.go new file mode 100644 index 000000000..cdfa6a0c1 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/volumestatus/volumestatus.go @@ -0,0 +1,100 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package volumestatus is an enumeration of the states Creating, Attached, Detached, Deleting, Deleted, Failed +package volumestatus + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Creating is an enumeration for volumestatus.Enum + Creating Enum = iota + 1 + // Attached is an enumeration for volumestatus.Enum + Attached + // Detached is an enumeration for volumestatus.Enum + Detached + // Deleting is an enumeration for volumestatus.Enum + Deleting + // Deleted is an enumeration for volumestatus.Enum + Deleted + // Failed is an enumeration for volumestatus.Enum + Failed +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Creating.String(), + Attached.String(), + Detached.String(), + Deleting.String(), + Deleted.String(), + Failed.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "creating": + return Creating, nil + case "attached": + return Attached, nil + case "detached": + return Detached, nil + case "deleting": + return Deleting, nil + case "deleted": + return Deleted, nil + case "failed": + return Failed, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid volumestatus.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Creating: + return []byte("creating"), nil + case Attached: + return []byte("attached"), nil + case Detached: + return []byte("detached"), nil + case Deleting: + return []byte("deleting"), nil + case Deleted: + return []byte("deleted"), nil + case Failed: + return []byte("failed"), nil + } + return nil, fmt.Errorf("%d is not a valid volumestatus.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/enums/volumetype/volumetype.go b/vendor/github.com/brightbox/gobrightbox/v2/enums/volumetype/volumetype.go new file mode 100644 index 000000000..2c5d10233 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/enums/volumetype/volumetype.go @@ -0,0 +1,79 @@ +// Code generated by generate_enum; DO NOT EDIT. + +// Package volumetype is an enumeration of the states Image, Volume, Raw +package volumetype + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// Enum is an enumerated type +type Enum uint8 + +const ( + // Image is an enumeration for volumetype.Enum + Image Enum = iota + 1 + // Volume is an enumeration for volumetype.Enum + Volume + // Raw is an enumeration for volumetype.Enum + Raw +) + +// ValidStrings is the set of strings that are valid inputs to ParseEnum +var ValidStrings = []string{ + Image.String(), + Volume.String(), + Raw.String(), +} + +// String makes Enum satisfy the Stringer interface +func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" +} + +// ParseEnum attempts to convert a string into a Enum +func ParseEnum(name string) (Enum, error) { + switch name { + case "image": + return Image, nil + case "volume": + return Volume, nil + case "raw": + return Raw, nil + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid volumetype.Enum", name) +} + +// MarshalText implements the text marshaller method +func (i Enum) MarshalText() ([]byte, error) { + switch i { + case Image: + return []byte("image"), nil + case Volume: + return []byte("volume"), nil + case Raw: + return []byte("raw"), nil + } + return nil, fmt.Errorf("%d is not a valid volumetype.Enum", i) +} + +// UnmarshalText implements the text unmarshaller method +func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/firewall_policies.go b/vendor/github.com/brightbox/gobrightbox/v2/firewall_policies.go new file mode 100644 index 000000000..d209a7e0d --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/firewall_policies.go @@ -0,0 +1,61 @@ +package brightbox + +import ( + "context" + "path" + "time" +) + +// FirewallPolicy represents a firewall policy. +// https://api.gb1.brightbox.com/1.0/#firewall_policy +type FirewallPolicy struct { + ResourceRef + ID string + Name string + Default bool + Description string + CreatedAt *time.Time `json:"created_at"` + Account *Account + ServerGroup *ServerGroup `json:"server_group"` + Rules []FirewallRule `json:"rules"` +} + +// FirewallPolicyOptions is used in conjunction with CreateFirewallPolicy and +// UpdateFirewallPolicy to create and update firewall policies. +type FirewallPolicyOptions struct { + ID string `json:"-"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + *FirewallPolicyAttachment +} + +// FirewallPolicyAttachment is used in conjunction with FirewallPolicyOptions, +// ApplyFirewallPolicy and RemoveFirewallPolicy to specify the group that +// the firewall policy should apply to. The ServerGroup parameter should +// be a server group identifier. +type FirewallPolicyAttachment struct { + ServerGroup string `json:"server_group"` +} + +// ApplyFirewallPolicy issues a request to apply the given firewall policy to +// the given server group. +func (c *Client) ApplyFirewallPolicy(ctx context.Context, identifier string, attachment FirewallPolicyAttachment) (*FirewallPolicy, error) { + return apiPost[FirewallPolicy]( + ctx, + c, + path.Join(firewallpolicyAPIPath, identifier, "apply_to"), + attachment, + ) + +} + +// RemoveFirewallPolicy issues a request to remove the given firewall policy from +// the given server group. +func (c *Client) RemoveFirewallPolicy(ctx context.Context, identifier string, serverGroup FirewallPolicyAttachment) (*FirewallPolicy, error) { + return apiPost[FirewallPolicy]( + ctx, + c, + path.Join(firewallpolicyAPIPath, identifier, "remove"), + serverGroup, + ) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/firewall_policies_default.go b/vendor/github.com/brightbox/gobrightbox/v2/firewall_policies_default.go new file mode 100644 index 000000000..0071380e8 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/firewall_policies_default.go @@ -0,0 +1,48 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // firewallpolicyAPIPath returns the relative URL path to the FirewallPolicy endpoint + firewallpolicyAPIPath = "firewall_policies" +) + +// FirewallPolicies returns the collection view for FirewallPolicy +func (c *Client) FirewallPolicies(ctx context.Context) ([]FirewallPolicy, error) { + return apiGetCollection[[]FirewallPolicy](ctx, c, firewallpolicyAPIPath) +} + +// FirewallPolicy retrieves a detailed view of one resource +func (c *Client) FirewallPolicy(ctx context.Context, identifier string) (*FirewallPolicy, error) { + return apiGet[FirewallPolicy](ctx, c, path.Join(firewallpolicyAPIPath, identifier)) +} + +// CreateFirewallPolicy creates a new resource from the supplied option map. +// +// It takes an instance of FirewallPolicyOptions. Not all attributes can be +// specified at create time (such as ID, which is allocated for you). +func (c *Client) CreateFirewallPolicy(ctx context.Context, newFirewallPolicy FirewallPolicyOptions) (*FirewallPolicy, error) { + return apiPost[FirewallPolicy](ctx, c, firewallpolicyAPIPath, newFirewallPolicy) +} + +// UpdateFirewallPolicy updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of FirewallPolicyOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateFirewallPolicy(ctx context.Context, updateFirewallPolicy FirewallPolicyOptions) (*FirewallPolicy, error) { + return apiPut[FirewallPolicy](ctx, c, path.Join(firewallpolicyAPIPath, updateFirewallPolicy.ID), updateFirewallPolicy) +} + +// DestroyFirewallPolicy destroys an existing resource. +func (c *Client) DestroyFirewallPolicy(ctx context.Context, identifier string) (*FirewallPolicy, error) { + return apiDelete[FirewallPolicy](ctx, c, path.Join(firewallpolicyAPIPath, identifier)) +} + +// CreatedAt implements the CreateDated interface for FirewallPolicy +func (s FirewallPolicy) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/firewall_rules.go b/vendor/github.com/brightbox/gobrightbox/v2/firewall_rules.go new file mode 100644 index 000000000..2cc286c9f --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/firewall_rules.go @@ -0,0 +1,35 @@ +package brightbox + +import ( + "time" +) + +// FirewallRule represents a firewall rule. +// https://api.gb1.brightbox.com/1.0/#firewall_rule +type FirewallRule struct { + ResourceRef + ID string + Source string `json:"source"` + SourcePort string `json:"source_port"` + Destination string `json:"destination"` + DestinationPort string `json:"destination_port"` + Protocol string `json:"protocol"` + IcmpTypeName string `json:"icmp_type_name"` + Description string `json:"description"` + CreatedAt *time.Time `json:"created_at"` + FirewallPolicy *FirewallPolicy `json:"firewall_policy"` +} + +// FirewallRuleOptions is used in conjunction with CreateFirewallRule and +// UpdateFirewallRule to create and update firewall rules. +type FirewallRuleOptions struct { + ID string `json:"-"` + FirewallPolicy string `json:"firewall_policy,omitempty"` + Protocol *string `json:"protocol,omitempty"` + Source *string `json:"source,omitempty"` + SourcePort *string `json:"source_port,omitempty"` + Destination *string `json:"destination,omitempty"` + DestinationPort *string `json:"destination_port,omitempty"` + IcmpTypeName *string `json:"icmp_type_name,omitempty"` + Description *string `json:"description,omitempty"` +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/firewall_rules_default.go b/vendor/github.com/brightbox/gobrightbox/v2/firewall_rules_default.go new file mode 100644 index 000000000..7341d08a2 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/firewall_rules_default.go @@ -0,0 +1,48 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // firewallruleAPIPath returns the relative URL path to the FirewallRule endpoint + firewallruleAPIPath = "firewall_rules" +) + +// FirewallRules returns the collection view for FirewallRule +func (c *Client) FirewallRules(ctx context.Context) ([]FirewallRule, error) { + return apiGetCollection[[]FirewallRule](ctx, c, firewallruleAPIPath) +} + +// FirewallRule retrieves a detailed view of one resource +func (c *Client) FirewallRule(ctx context.Context, identifier string) (*FirewallRule, error) { + return apiGet[FirewallRule](ctx, c, path.Join(firewallruleAPIPath, identifier)) +} + +// CreateFirewallRule creates a new resource from the supplied option map. +// +// It takes an instance of FirewallRuleOptions. Not all attributes can be +// specified at create time (such as ID, which is allocated for you). +func (c *Client) CreateFirewallRule(ctx context.Context, newFirewallRule FirewallRuleOptions) (*FirewallRule, error) { + return apiPost[FirewallRule](ctx, c, firewallruleAPIPath, newFirewallRule) +} + +// UpdateFirewallRule updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of FirewallRuleOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateFirewallRule(ctx context.Context, updateFirewallRule FirewallRuleOptions) (*FirewallRule, error) { + return apiPut[FirewallRule](ctx, c, path.Join(firewallruleAPIPath, updateFirewallRule.ID), updateFirewallRule) +} + +// DestroyFirewallRule destroys an existing resource. +func (c *Client) DestroyFirewallRule(ctx context.Context, identifier string) (*FirewallRule, error) { + return apiDelete[FirewallRule](ctx, c, path.Join(firewallruleAPIPath, identifier)) +} + +// CreatedAt implements the CreateDated interface for FirewallRule +func (s FirewallRule) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/generate_default_functions b/vendor/github.com/brightbox/gobrightbox/v2/generate_default_functions new file mode 100644 index 000000000..3d618ceca --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/generate_default_functions @@ -0,0 +1,446 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# Generate Default Command and Tests from supplied yaml file + +require 'yaml' + +def generate_default_tested_api_commands(struct, options) + file_prefix = options['path'].downcase + generate_default_api_commands(struct, options, "#{file_prefix}_default.go") + generate_default_test_commands(struct, options, "#{file_prefix}_default_test.go") + %W[#{file_prefix}_default.go #{file_prefix}_default_test.go] +end + +def generate_default_api_commands(struct, options, output_filename) + plural = options['plural'] || "#{struct}s" + File.open(output_filename, 'w') do |f| + f << file_header + f << "import \"fmt\"\n\n" if options['crud'].include?('handle') + f << path_constant(struct, options['path']) + f << collection_function(struct, plural) + f << instance_function(struct) + f << instance_by_handle_function(struct, plural) if options['crud'].include?('handle') + f << create_function(struct) if options['crud'].include?('create') + f << update_function(struct) if options['crud'].include?('update') + f << destroy_function(struct) if options['crud'].include?('delete') + f << lock_functions(struct) if options['crud'].include?('lock') + f << created_at_function(struct) if options['crud'].include?('createdate') + f << reset_password_function(struct, options['password']) if options['password'] + f << resize_function(struct) if options['crud'].include?('resize') + f << simple_function(struct, 'reset') if options['crud'].include?('reset') + end +end + +def generate_default_test_commands(struct, options, output_filename) + plural = options['plural'] || "#{struct}s" + File.open(output_filename, 'w') do |f| + f << test_file_header(options) + f << test_collection_function(struct, plural, options) + f << test_instance_function(struct, options) + f << test_instance_by_handle_function(struct, options) if options['crud'].include?('handle') + f << test_create_function(struct, options) if options['crud'].include?('create') + f << test_update_function(struct, options) if options['crud'].include?('update') + f << test_destroy_function(struct, options) if options['crud'].include?('delete') + f << test_lock_functions(struct, options) if options['crud'].include?('lock') + f << test_created_at_function(struct) if options['crud'].include?('createdate') + f << test_reset_password_function(struct, options) if options['password'] + f << test_resize_function(struct, options) if options['crud'].include?('resize') + f << test_simple_function(struct, options, 'reset') if options['crud'].include?('reset') + end +end + +def test_file_header(options) + <<~ENDFUNC + // Code generated by go generate; DO NOT EDIT. + + package brightbox + + import ( + "path" + "testing" + #{options['crud'].include?('createdate') ? '"time"' : ''} + + "gotest.tools/v3/assert" + ) + + ENDFUNC +end + +def test_collection_function(struct, plural, options) + <<~ENDFUNC + func Test#{plural}(t *testing.T) { + instance := testAll( + t, + (*Client).#{plural}, + "#{struct}", + "#{options['path']}", + "#{plural}", + ) + assert.Equal(t, instance.ID, "#{options['testid']}") + } + + ENDFUNC +end + +def test_instance_function(struct, options) + <<~ENDFUNC + func Test#{struct}(t *testing.T) { + instance := testInstance( + t, + (*Client).#{struct}, + "#{struct}", + path.Join("#{options['path']}", "#{options['testid']}"), + "#{options['jsonpath']}", + "#{options['testid']}", + ) + assert.Equal(t, instance.ID, "#{options['testid']}") + } + + ENDFUNC +end + +def test_instance_by_handle_function(struct, options) + <<~ENDFUNC + func Test#{struct}ByHandle(t *testing.T) { + instance := testInstance( + t, + (*Client).#{struct}, + "#{struct}", + path.Join("#{options['path']}", "#{options['testid']}"), + "#{options['jsonpath']}", + "#{options['testid']}", + ) + assert.Equal(t, instance.ID, "#{options['testid']}") + handleInstance := testInstance[#{struct}]( + t, + (*Client).#{struct}ByHandle, + "#{struct}", + path.Join("#{options['path']}"), + "#{options['path']}", + instance.Handle, + ) + assert.Equal(t, instance.ID, handleInstance.ID) + } + + ENDFUNC +end + +def test_resize_function(struct, options) + <<~GO + func TestResize#{struct}(t *testing.T) { + instance := testLink( + t, + (*Client).Resize#{struct}, + "#{options['testid']}", + #{struct}NewSize{#{options['resize_request']}}, + "#{options['jsonpath']}", + "POST", + path.Join("#{options['path']}", "#{options['testid']}", "resize"), + `#{options['resize_response']}`, + ) + assert.Equal(t, instance.ID, "#{options['testid']}") + } + + GO +end + +def test_create_function(struct, options) + <<~ENDFUNC + func TestCreate#{struct}(t *testing.T) { + newResource := #{struct}Options{} + instance := testModify( + t, + (*Client).Create#{struct}, + newResource, + "#{options['jsonpath']}", + "POST", + path.Join("#{options['path']}"), + "{}", + ) + assert.Equal(t, instance.ID, "#{options['testid']}") + } + + ENDFUNC +end + +def test_update_function(struct, options) + <<~ENDFUNC + func TestUpdate#{struct}(t *testing.T) { + updatedResource := #{struct}Options{ID: "#{options['testid']}"} + instance := testModify( + t, + (*Client).Update#{struct}, + updatedResource, + "#{options['jsonpath']}", + "PUT", + path.Join("#{options['path']}", updatedResource.ID), + "{}", + ) + assert.Equal(t, instance.ID, updatedResource.ID) + } + + ENDFUNC +end + +def test_destroy_function(struct, options) + <<~ENDFUNC + func TestDestroy#{struct}(t *testing.T) { + deletedResource := testModify( + t, + (*Client).Destroy#{struct}, + "#{options['testid']}", + "#{options['jsonpath']}", + "DELETE", + path.Join("#{options['path']}", "#{options['testid']}"), + "", + ) + assert.Equal(t, deletedResource.ID, "#{options['testid']}") + } + + ENDFUNC +end + +def test_lock_functions(struct, options) + <<~ENDFUNC + func TestLock#{struct}(t *testing.T) { + lockedResource := testModify( + t, + (*Client).Lock#{struct}, + "#{options['testid']}", + "#{options['jsonpath']}", + "PUT", + path.Join("#{options['path']}", "#{options['testid']}", "lock_resource"), + "", + ) + assert.Equal(t, lockedResource.ID, "#{options['testid']}") + } + + func TestUnlock#{struct}(t *testing.T) { + unlockedResource := testModify( + t, + (*Client).Unlock#{struct}, + "#{options['testid']}", + "#{options['jsonpath']}", + "PUT", + path.Join("#{options['path']}", "#{options['testid']}", "unlock_resource"), + "", + ) + assert.Equal(t, unlockedResource.ID, "#{options['testid']}") + } + + ENDFUNC +end + +def test_created_at_function(struct) + <<~ENDFUNC + + func Test#{struct}CreatedAtUnix(t *testing.T) { + tm := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC) + target := #{struct}{CreatedAt: &tm} + assert.Equal(t, target.CreatedAtUnix(), tm.Unix()) + } + + ENDFUNC +end + +def test_reset_password_function(struct, options) + <<~ENDFUNC + func TestReset#{struct}Password(t *testing.T) { + instance := testModify( + t, + (*Client).Reset#{struct}Password, + "#{options['testid']}", + "#{options['jsonpath']}", + "POST", + path.Join("#{options['path']}", "#{options['testid']}", "#{options['password']}"), + "", + ) + assert.Equal(t, instance.ID, "#{options['testid']}") + } + + ENDFUNC +end + +def test_simple_function(struct, options, function) + function_name = "#{function.capitalize}#{struct}" + + <<~ENDFUNC + func Test#{function_name}(t *testing.T) { + instance := testModify( + t, + (*Client).#{function_name}, + "#{options['testid']}", + "#{options['jsonpath']}", + "POST", + path.Join("#{options['path']}", "#{options['testid']}", "#{function}"), + "", + ) + assert.Equal(t, instance.ID, "#{options['testid']}") + } + + ENDFUNC +end + +def file_header + <<~ENDFUNC + // Code generated by go generate; DO NOT EDIT. + + package brightbox + + import "context" + import "path" + + ENDFUNC +end + +def path_constant(struct, pathname) + <<~ENDFUNC + const ( + // #{struct.downcase}APIPath returns the relative URL path to the #{struct} endpoint + #{struct.downcase}APIPath = "#{pathname}" + ) + + ENDFUNC +end + +def collection_function(struct, plural) + <<~ENDFUNC + // #{plural} returns the collection view for #{struct} + func (c *Client) #{plural}(ctx context.Context) ([]#{struct}, error) { + return apiGetCollection[[]#{struct}](ctx, c, #{struct.downcase}APIPath) + } + + ENDFUNC +end + +def instance_function(struct) + <<~ENDFUNC + // #{struct} retrieves a detailed view of one resource + func (c *Client) #{struct}(ctx context.Context, identifier string) (*#{struct}, error) { + return apiGet[#{struct}](ctx, c, path.Join(#{struct.downcase}APIPath, identifier)) + } + + ENDFUNC +end + +def instance_by_handle_function(struct, plural) + <<~ENDFUNC + + // #{struct} retrieves a detailed view of one resource using a handle + func (c *Client) #{struct}ByHandle(ctx context.Context, handle string) (*#{struct}, error) { + collection, err := c.#{plural}(ctx) + if err != nil { + return nil, err + } + for _, instance := range collection { + if instance.Handle == handle { + return &instance, nil + } + } + return nil, fmt.Errorf("Resource with handle '%s' doesn't exist", handle) + } + + ENDFUNC +end + +def create_function(struct) + <<~ENDFUNC + // Create#{struct} creates a new resource from the supplied option map. + // + // It takes an instance of #{struct}Options. Not all attributes can be + // specified at create time (such as ID, which is allocated for you). + func (c *Client) Create#{struct}(ctx context.Context, new#{struct} #{struct}Options) (*#{struct}, error) { + return apiPost[#{struct}](ctx, c, #{struct.downcase}APIPath, new#{struct}) + } + + ENDFUNC +end + +def update_function(struct) + <<~ENDFUNC + // Update#{struct} updates an existing resources's attributes. Not all + // attributes can be changed (such as ID). + // + // It takes an instance of #{struct}Options. Specify the resource you + // want to update using the ID field. + func (c *Client) Update#{struct}(ctx context.Context, update#{struct} #{struct}Options) (*#{struct}, error) { + return apiPut[#{struct}](ctx, c, path.Join(#{struct.downcase}APIPath, update#{struct}.ID), update#{struct}) + } + + ENDFUNC +end + +def resize_function(struct) + function_name = "Resize#{struct}" + size_type = "#{struct}NewSize" + <<~GO + // #{function_name} issues a request to change the server type of a server + // changing the amount of cpu and ram it has. + func (c *Client) #{function_name}(ctx context.Context, identifier string, newSize #{size_type}) (*#{struct}, error) { + return apiPost[#{struct}](ctx, c, path.Join(#{struct.downcase}APIPath, identifier, "resize"), newSize) + } + + GO +end + +def destroy_function(struct) + <<~ENDFUNC + // Destroy#{struct} destroys an existing resource. + func (c *Client) Destroy#{struct}(ctx context.Context, identifier string) (*#{struct}, error) { + return apiDelete[#{struct}](ctx, c, path.Join(#{struct.downcase}APIPath, identifier)) + } + + ENDFUNC +end + +def lock_functions(struct) + <<~ENDFUNC + // Lock#{struct} locks a resource against destroy requests + func (c *Client) Lock#{struct}(ctx context.Context, identifier string) (*#{struct}, error) { + return apiPut[#{struct}](ctx, c, path.Join(#{struct.downcase}APIPath, identifier, "lock_resource"), nil) + } + + // Unlock#{struct} unlocks a resource, re-enabling destroy requests + func (c *Client) Unlock#{struct}(ctx context.Context, identifier string) (*#{struct}, error) { + return apiPut[#{struct}](ctx, c, path.Join(#{struct.downcase}APIPath, identifier, "unlock_resource"), nil) + } + ENDFUNC +end + +def created_at_function(struct) + <<~ENDFUNC + // CreatedAt implements the CreateDated interface for #{struct} + func (s #{struct}) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() + } + + ENDFUNC +end + +def reset_password_function(struct, endpoint) + <<~ENDFUNC + // Reset#{struct}Password resets the password in #{struct}, returning it + // in the returned resource. This is the only time the new password is + // available in plaintext. + func (c *Client) Reset#{struct}Password(ctx context.Context, identifier string) (*#{struct}, error) { + return apiPost[#{struct}](ctx, c, path.Join(#{struct.downcase}APIPath, identifier, "#{endpoint}"), nil) + } + + ENDFUNC +end + +def simple_function(struct, endpoint) + function_name = "#{endpoint.capitalize}#{struct}" + <<~GO + // #{function_name} issues a "#{endpoint}" instruction to a #{struct} + func (c *Client) #{function_name}(ctx context.Context, identifier string) (*#{struct}, error) { + return apiPost[#{struct}](ctx, c, path.Join(#{struct.downcase}APIPath, identifier, "#{endpoint}"), nil) + } + GO +end + +object_hash = YAML.safe_load(ARGF.read) +files = %w[gofmt -w] +object_hash.each { |k, v| files << generate_default_tested_api_commands(k, v) } +exec(*files.flatten) diff --git a/vendor/github.com/brightbox/gobrightbox/v2/generate_enum b/vendor/github.com/brightbox/gobrightbox/v2/generate_enum new file mode 100644 index 000000000..cf7b36b70 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/generate_enum @@ -0,0 +1,176 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'fileutils' +require 'optparse' + +def snake_case(str) + return str.downcase if str =~ /\A[A-Z]+\z/ + + str.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') + .gsub(/([a-z])([A-Z])/, '\1_\2') + .downcase +end + +def make_identifier(str) + str.split(/[_-](?!\d)/).collect(&:capitalize).join +end + +def generate_enumeration(file_name, package_name, states, iota_offset) + File.open(file_name, 'w') do |f| + f << file_header(package_name, states) + f << generate_states(package_name, states, iota_offset) + f << generate_valid_strings(states) + f << stringer + f << generate_parser(package_name, states) + f << generate_marshal(package_name, states) + f << unmarshal_text + end +end + +def file_header(package_name, states) + <<~ENDFUNC + // Code generated by generate_enum; DO NOT EDIT. + + // Package #{package_name} is an enumeration of the states #{states.map { |x| make_identifier(x) }.join(', ')} + package #{package_name} + + import ( + "fmt" + "encoding/json" + "reflect" + ) + + ENDFUNC +end + +def generate_states(package_name, states, iota_offset) + first = make_identifier(states[0]) + result = <<~FIRST + // Enum is an enumerated type + type Enum uint8 + + const ( + // #{first} is an enumeration for #{package_name}.Enum + #{first} Enum = iota + #{iota_offset} + FIRST + states[1..-1].reduce(result.dup) do |memo, state| + identifier = make_identifier(state) + memo << <<-NEXT + // #{identifier} is an enumeration for #{package_name}.Enum + #{identifier} + NEXT + end << <<~FINAL + ) + + FINAL +end + +def generate_valid_strings(states) + result = <<~FIRST + // ValidStrings is the set of strings that are valid inputs to ParseEnum + var ValidStrings = []string{ + FIRST + states.reduce(result.dup) do |memo, state| + memo << <<-NEXT + #{make_identifier(state)}.String(), + NEXT + end << <<-FINAL + } + + FINAL +end + +def stringer + <<~ENDFUNC + // String makes Enum satisfy the Stringer interface + func (i Enum) String() string { + tmp, err := i.MarshalText() + if err == nil { + return string(tmp) + } + return "" + } + + ENDFUNC +end + +def generate_parser(package_name, states) + result = <<~FIRST + // ParseEnum attempts to convert a string into a Enum + func ParseEnum(name string) (Enum, error) { + switch name { + FIRST + states.reduce(result.dup) do |memo, state| + memo << <<-NEXT + case "#{state.downcase}": + return #{make_identifier(state)}, nil + NEXT + end << <<~FINAL + } + var zero Enum + return zero, fmt.Errorf("%s is not a valid #{package_name}.Enum", name) + } + + FINAL +end + +def generate_marshal(package_name, states) + result = <<~FIRST + // MarshalText implements the text marshaller method + func (i Enum) MarshalText() ([]byte, error) { + switch i { + FIRST + states.reduce(result.dup) do |memo, state| + memo << <<-NEXT + case #{make_identifier(state)}: + return []byte("#{state.downcase}"), nil + NEXT + end << <<~FINAL + } + return nil, fmt.Errorf("%d is not a valid #{package_name}.Enum", i) + } + + FINAL +end + +def unmarshal_text + <<~ENDFUNC + // UnmarshalText implements the text unmarshaller method + func (i *Enum) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseEnum(name) + if err != nil { + return &json.UnmarshalTypeError{ + Value: name, + Type: reflect.TypeOf(*i), + } + } + *i = tmp + return nil + } + + ENDFUNC +end + +# Check if the zero value is to be used in this enumeration +iota = 1 +OptionParser.new do |opts| + opts.on('-z', 'Make first enumeration the default') do |default| + iota = default ? 0 : 1 + end +end.parse! + +# First argument is the package name +package_name = ARGV.shift +if package_name.to_s.empty? || ARGV.empty? + warn('Need a package name and at least one enumeration') + exit 1 +end +enum_dir = File.join('enums', package_name) +file_name = File.join(enum_dir, "#{package_name}.go") +FileUtils.mkdir_p(enum_dir) + +# Generate the enumeration from the rest of the arguments +generate_enumeration(file_name, package_name, ARGV, iota) +exec('gofmt', '-w', file_name) diff --git a/vendor/github.com/brightbox/gobrightbox/v2/generate_server_commands b/vendor/github.com/brightbox/gobrightbox/v2/generate_server_commands new file mode 100644 index 000000000..948b5c79d --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/generate_server_commands @@ -0,0 +1,106 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'fileutils' + +def snake_case(str) + return str.downcase if str =~ /\A[A-Z]+\z/ + + str.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') + .gsub(/([a-z])([A-Z])/, '\1_\2') + .downcase +end + +def make_identifier(str) + str.split(/[_-]/).collect(&:capitalize).join +end + +def file_header(package_name) + <<~ENDFUNC + // Code generated by generate_server_commands; DO NOT EDIT. + + package #{package_name} + + import "context" + import "path" + + ENDFUNC +end + +def test_header(package_name) + <<~ENDFUNC + // Code generated by generate_server_commands; DO NOT EDIT. + + package #{package_name} + + import ( + "path" + "testing" + + "gotest.tools/v3/assert" + ) + + ENDFUNC +end + +def make_server_identifier(command) + # FIXME: This is hacky. Sorry. + return make_identifier("#{command}_for_server") if command.include?('console') + + make_identifier("#{command}_server") +end + +def generate_server_command(command, text) + identifier = make_server_identifier(command) + <<~ENDFUNC + // #{identifier} #{text} + func (c *Client) #{identifier}(ctx context.Context, identifier string) (*Server, error) { + return apiPost[Server](ctx, c, path.Join(serverAPIPath, identifier, "#{command}"), nil) + } + + ENDFUNC +end + +def generate_server_command_test(command) + identifier = make_server_identifier(command) + <<~ENDFUNC + func Test#{identifier}(t *testing.T) { + instance := testModify[Server, string]( + t, + (*Client).#{identifier}, + "srv-lv426", + "server", + "POST", + path.Join("servers", "srv-lv426", "#{command}"), + "", + ) + assert.Equal(t, instance.ID, "srv-lv426") + } + + ENDFUNC +end + +commands = { + 'start' => 'will issue a start request for the server to become active.', + 'stop' => 'will issue a stop request for the server to become inactve.', + 'reboot' => 'issues a "soft" reboot to the server, however the OS make ignore it. The console remains connected.', + 'reset' => 'issues a "hard" reboot to the server which cannot be ignored by the OS. The console remains connected.', + 'shutdown' => 'will issue a safe shutdown request to the server.', + 'activate_console' => 'will issue a request to enable the graphical console for an existing server.' +} + +File.open('server_commands.go', 'w') do |f| + f << file_header('brightbox') + commands.each do |k, v| + f << generate_server_command(k, v) + end +end + +File.open('server_commands_test.go', 'w') do |f| + f << test_header('brightbox') + commands.each_key do |k| + f << generate_server_command_test(k) + end +end + +exec('gofmt', '-w', 'server_commands.go', 'server_commands_test.go') diff --git a/vendor/github.com/brightbox/gobrightbox/v2/images.go b/vendor/github.com/brightbox/gobrightbox/v2/images.go new file mode 100644 index 000000000..f54046ce9 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/images.go @@ -0,0 +1,57 @@ +package brightbox + +import ( + "time" + + "github.com/brightbox/gobrightbox/v2/enums/arch" + "github.com/brightbox/gobrightbox/v2/enums/imagestatus" + "github.com/brightbox/gobrightbox/v2/enums/sourcetrigger" + "github.com/brightbox/gobrightbox/v2/enums/sourcetype" +) + +//go:generate ./generate_enum imagestatus creating available deprecated unavailable deleting deleted failed +//go:generate ./generate_enum arch x86_64 i686 +//go:generate ./generate_enum sourcetrigger manual schedule +//go:generate ./generate_enum sourcetype upload snapshot + +// Image represents a Machine Image +// https://api.gb1.brightbox.com/1.0/#image +type Image struct { + ResourceRef + ID string + Name string + Username string + Status imagestatus.Enum + Locked bool + Description string + Source string + Arch arch.Enum + Official bool + Public bool + Owner string + SourceTrigger sourcetrigger.Enum `json:"source_trigger"` + SourceType sourcetype.Enum `json:"source_type"` + VirtualSize uint `json:"virtual_size"` + DiskSize uint `json:"disk_size"` + MinRAM *uint `json:"min_ram"` + CompatibilityMode bool `json:"compatibility_mode"` + LicenceName string `json:"licence_name"` + CreatedAt *time.Time `json:"created_at"` + Ancestor *Image +} + +// ImageOptions is used to create and update machine images +type ImageOptions struct { + ID string `json:"-"` + Name *string `json:"name,omitempty"` + Username *string `json:"username,omitempty"` + Description *string `json:"description,omitempty"` + MinRAM *uint `json:"min_ram,omitempty"` + Server string `json:"server,omitempty"` + Volume string `json:"volume,omitempty"` + Arch arch.Enum `json:"arch,omitempty"` + Status imagestatus.Enum `json:"status,omitempty"` + Public *bool `json:"public,omitempty"` + CompatibilityMode *bool `json:"compatibility_mode,omitempty"` + URL string `json:"http_url,omitempty"` +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/images_default.go b/vendor/github.com/brightbox/gobrightbox/v2/images_default.go new file mode 100644 index 000000000..af0e437d4 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/images_default.go @@ -0,0 +1,58 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // imageAPIPath returns the relative URL path to the Image endpoint + imageAPIPath = "images" +) + +// Images returns the collection view for Image +func (c *Client) Images(ctx context.Context) ([]Image, error) { + return apiGetCollection[[]Image](ctx, c, imageAPIPath) +} + +// Image retrieves a detailed view of one resource +func (c *Client) Image(ctx context.Context, identifier string) (*Image, error) { + return apiGet[Image](ctx, c, path.Join(imageAPIPath, identifier)) +} + +// CreateImage creates a new resource from the supplied option map. +// +// It takes an instance of ImageOptions. Not all attributes can be +// specified at create time (such as ID, which is allocated for you). +func (c *Client) CreateImage(ctx context.Context, newImage ImageOptions) (*Image, error) { + return apiPost[Image](ctx, c, imageAPIPath, newImage) +} + +// UpdateImage updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of ImageOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateImage(ctx context.Context, updateImage ImageOptions) (*Image, error) { + return apiPut[Image](ctx, c, path.Join(imageAPIPath, updateImage.ID), updateImage) +} + +// DestroyImage destroys an existing resource. +func (c *Client) DestroyImage(ctx context.Context, identifier string) (*Image, error) { + return apiDelete[Image](ctx, c, path.Join(imageAPIPath, identifier)) +} + +// LockImage locks a resource against destroy requests +func (c *Client) LockImage(ctx context.Context, identifier string) (*Image, error) { + return apiPut[Image](ctx, c, path.Join(imageAPIPath, identifier, "lock_resource"), nil) +} + +// UnlockImage unlocks a resource, re-enabling destroy requests +func (c *Client) UnlockImage(ctx context.Context, identifier string) (*Image, error) { + return apiPut[Image](ctx, c, path.Join(imageAPIPath, identifier, "unlock_resource"), nil) +} + +// CreatedAt implements the CreateDated interface for Image +func (s Image) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/interfaces.go b/vendor/github.com/brightbox/gobrightbox/v2/interfaces.go new file mode 100644 index 000000000..a12a0003d --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/interfaces.go @@ -0,0 +1,12 @@ +package brightbox + +// Interface represent a server's network interface(s) +// https://api.gb1.brightbox.com/1.0/#interface +type Interface struct { + ResourceRef + ID string + MacAddress string `json:"mac_address"` + IPv4Address string `json:"ipv4_address"` + IPv6Address string `json:"ipv6_address"` + Server *Server +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/interfaces_default.go b/vendor/github.com/brightbox/gobrightbox/v2/interfaces_default.go new file mode 100644 index 000000000..edff1ef9b --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/interfaces_default.go @@ -0,0 +1,21 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // interfaceAPIPath returns the relative URL path to the Interface endpoint + interfaceAPIPath = "interfaces" +) + +// Interfaces returns the collection view for Interface +func (c *Client) Interfaces(ctx context.Context) ([]Interface, error) { + return apiGetCollection[[]Interface](ctx, c, interfaceAPIPath) +} + +// Interface retrieves a detailed view of one resource +func (c *Client) Interface(ctx context.Context, identifier string) (*Interface, error) { + return apiGet[Interface](ctx, c, path.Join(interfaceAPIPath, identifier)) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/load_balancers.go b/vendor/github.com/brightbox/gobrightbox/v2/load_balancers.go new file mode 100644 index 000000000..d5f01dc0d --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/load_balancers.go @@ -0,0 +1,150 @@ +package brightbox + +import ( + "context" + "path" + "time" + + "github.com/brightbox/gobrightbox/v2/enums/balancingpolicy" + "github.com/brightbox/gobrightbox/v2/enums/healthchecktype" + "github.com/brightbox/gobrightbox/v2/enums/listenerprotocol" + "github.com/brightbox/gobrightbox/v2/enums/loadbalancerstatus" + "github.com/brightbox/gobrightbox/v2/enums/proxyprotocol" +) + +//go:generate ./generate_enum loadbalancerstatus creating active deleting deleted failing failed +//go:generate ./generate_enum proxyprotocol v1 v2 v2-ssl v2-ssl-cn +//go:generate ./generate_enum balancingpolicy least-connections round-robin source-address +//go:generate ./generate_enum healthchecktype tcp http +//go:generate ./generate_enum listenerprotocol tcp http https + +// LoadBalancer represents a Load Balancer +// https://api.gb1.brightbox.com/1.0/#load_balancer +type LoadBalancer struct { + ResourceRef + ID string + Name string + Status loadbalancerstatus.Enum + Locked bool + HTTPSRedirect bool `json:"https_redirect"` + SslMinimumVersion string `json:"ssl_minimum_version"` + BufferSize uint `json:"buffer_size"` + Policy balancingpolicy.Enum + Listeners []LoadBalancerListener + Healthcheck LoadBalancerHealthcheck + Certificate *LoadBalancerAcmeCertificate + Acme *LoadBalancerAcme + CreatedAt *time.Time `json:"created_at"` + DeletedAt *time.Time `json:"deleted_at"` + Account *Account + Nodes []Server + CloudIPs []CloudIP `json:"cloud_ips"` +} + +// LoadBalancerAcme represents an ACME object on a LoadBalancer +type LoadBalancerAcme struct { + Certificate *LoadBalancerAcmeCertificate `json:"certificate"` + Domains []LoadBalancerAcmeDomain `json:"domains"` +} + +// LoadBalancerAcmeCertificate represents an ACME issued certificate on +// a LoadBalancer +type LoadBalancerAcmeCertificate struct { + Fingerprint string `json:"fingerprint"` + ExpiresAt time.Time `json:"expires_at"` + IssuedAt time.Time `json:"issued_at"` +} + +// LoadBalancerAcmeDomain represents a domain for which ACME support +// has been requested +type LoadBalancerAcmeDomain struct { + Identifier string `json:"identifier"` + Status string `json:"status"` + LastMessage string `json:"last_message"` +} + +// LoadBalancerHealthcheck represents a health check on a LoadBalancer +type LoadBalancerHealthcheck struct { + Type healthchecktype.Enum `json:"type"` + Port uint16 `json:"port"` + Request string `json:"request,omitempty"` + Interval uint `json:"interval,omitempty"` + Timeout uint `json:"timeout,omitempty"` + ThresholdUp uint `json:"threshold_up,omitempty"` + ThresholdDown uint `json:"threshold_down,omitempty"` +} + +// LoadBalancerListener represents a listener on a LoadBalancer +type LoadBalancerListener struct { + Protocol listenerprotocol.Enum `json:"protocol,omitempty"` + In uint16 `json:"in,omitempty"` + Out uint16 `json:"out,omitempty"` + Timeout uint `json:"timeout,omitempty"` + ProxyProtocol proxyprotocol.Enum `json:"proxy_protocol,omitempty"` +} + +// LoadBalancerOptions is used in conjunction with CreateLoadBalancer and +// UpdateLoadBalancer to create and update load balancers +type LoadBalancerOptions struct { + ID string `json:"-"` + Name *string `json:"name,omitempty"` + Nodes []LoadBalancerNode `json:"nodes,omitempty"` + Policy balancingpolicy.Enum `json:"policy,omitempty"` + Listeners []LoadBalancerListener `json:"listeners,omitempty"` + Healthcheck *LoadBalancerHealthcheck `json:"healthcheck,omitempty"` + Domains *[]string `json:"domains,omitempty"` + CertificatePem *string `json:"certificate_pem,omitempty"` + CertificatePrivateKey *string `json:"certificate_private_key,omitempty"` + SslMinimumVersion *string `json:"ssl_minimum_version,omitempty"` + HTTPSRedirect *bool `json:"https_redirect,omitempty"` +} + +// LoadBalancerNode is used in conjunction with LoadBalancerOptions, +// AddNodesToLoadBalancer, RemoveNodesFromLoadBalancer to specify a list of +// servers to use as load balancer nodes. The Node parameter should be a server +// identifier. +type LoadBalancerNode struct { + Node string `json:"node,omitempty"` +} + +// AddNodesToLoadBalancer adds nodes to an existing load balancer. +func (c *Client) AddNodesToLoadBalancer(ctx context.Context, identifier string, nodes []LoadBalancerNode) (*LoadBalancer, error) { + return apiPost[LoadBalancer]( + ctx, + c, + path.Join(loadbalancerAPIPath, identifier, "add_nodes"), + nodes, + ) + +} + +// RemoveNodesFromLoadBalancer removes nodes from an existing load balancer. +func (c *Client) RemoveNodesFromLoadBalancer(ctx context.Context, identifier string, nodes []LoadBalancerNode) (*LoadBalancer, error) { + return apiPost[LoadBalancer]( + ctx, + c, + path.Join(loadbalancerAPIPath, identifier, "remove_nodes"), + nodes, + ) +} + +// AddListenersToLoadBalancer adds listeners to an existing load balancer. +func (c *Client) AddListenersToLoadBalancer(ctx context.Context, identifier string, listeners []LoadBalancerListener) (*LoadBalancer, error) { + return apiPost[LoadBalancer]( + ctx, + c, + path.Join(loadbalancerAPIPath, identifier, "add_listeners"), + listeners, + ) + +} + +// RemoveListenersFromLoadBalancer removes listeners from an existing load balancer. +func (c *Client) RemoveListenersFromLoadBalancer(ctx context.Context, identifier string, listeners []LoadBalancerListener) (*LoadBalancer, error) { + return apiPost[LoadBalancer]( + ctx, + c, + path.Join(loadbalancerAPIPath, identifier, "remove_listeners"), + listeners, + ) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/load_balancers_default.go b/vendor/github.com/brightbox/gobrightbox/v2/load_balancers_default.go new file mode 100644 index 000000000..9f6437d83 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/load_balancers_default.go @@ -0,0 +1,58 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // loadbalancerAPIPath returns the relative URL path to the LoadBalancer endpoint + loadbalancerAPIPath = "load_balancers" +) + +// LoadBalancers returns the collection view for LoadBalancer +func (c *Client) LoadBalancers(ctx context.Context) ([]LoadBalancer, error) { + return apiGetCollection[[]LoadBalancer](ctx, c, loadbalancerAPIPath) +} + +// LoadBalancer retrieves a detailed view of one resource +func (c *Client) LoadBalancer(ctx context.Context, identifier string) (*LoadBalancer, error) { + return apiGet[LoadBalancer](ctx, c, path.Join(loadbalancerAPIPath, identifier)) +} + +// CreateLoadBalancer creates a new resource from the supplied option map. +// +// It takes an instance of LoadBalancerOptions. Not all attributes can be +// specified at create time (such as ID, which is allocated for you). +func (c *Client) CreateLoadBalancer(ctx context.Context, newLoadBalancer LoadBalancerOptions) (*LoadBalancer, error) { + return apiPost[LoadBalancer](ctx, c, loadbalancerAPIPath, newLoadBalancer) +} + +// UpdateLoadBalancer updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of LoadBalancerOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateLoadBalancer(ctx context.Context, updateLoadBalancer LoadBalancerOptions) (*LoadBalancer, error) { + return apiPut[LoadBalancer](ctx, c, path.Join(loadbalancerAPIPath, updateLoadBalancer.ID), updateLoadBalancer) +} + +// DestroyLoadBalancer destroys an existing resource. +func (c *Client) DestroyLoadBalancer(ctx context.Context, identifier string) (*LoadBalancer, error) { + return apiDelete[LoadBalancer](ctx, c, path.Join(loadbalancerAPIPath, identifier)) +} + +// LockLoadBalancer locks a resource against destroy requests +func (c *Client) LockLoadBalancer(ctx context.Context, identifier string) (*LoadBalancer, error) { + return apiPut[LoadBalancer](ctx, c, path.Join(loadbalancerAPIPath, identifier, "lock_resource"), nil) +} + +// UnlockLoadBalancer unlocks a resource, re-enabling destroy requests +func (c *Client) UnlockLoadBalancer(ctx context.Context, identifier string) (*LoadBalancer, error) { + return apiPut[LoadBalancer](ctx, c, path.Join(loadbalancerAPIPath, identifier, "unlock_resource"), nil) +} + +// CreatedAt implements the CreateDated interface for LoadBalancer +func (s LoadBalancer) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/paths.yaml b/vendor/github.com/brightbox/gobrightbox/v2/paths.yaml new file mode 100644 index 000000000..e4a37ab87 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/paths.yaml @@ -0,0 +1,105 @@ +Account: + path: accounts + crud: [update, createdate] + testid: acc-43ks4 + jsonpath: account + password: reset_ftp_password +APIClient: + path: api_clients + crud: [create, update, delete] + testid: cli-dsse2 + jsonpath: api_client + password: reset_secret +CloudIP: + path: cloud_ips + crud: [create, update, delete] + testid: cip-k4a25 + jsonpath: cloud_ip +Collaboration: + path: collaborations + crud: [create, delete, createdate] + testid: col-klek3 + jsonpath: collaboration +ConfigMap: + path: config_maps + crud: [create, update, delete] + testid: cfg-dsse2 + jsonpath: config_map +DatabaseServer: + path: database_servers + crud: [create, update, delete, lock, createdate, resize, reset] + testid: dbs-123ab + jsonpath: database_server + password: reset_password + resize_request: '"dbt-12345"' + resize_response: '{"new_type":"dbt-12345"}' +DatabaseSnapshot: + path: database_snapshots + crud: [update, delete, lock, createdate] + testid: dbi-12345 + jsonpath: database_snapshot +DatabaseServerType: + path: database_types + crud: [] + testid: dbt-12345 + jsonpath: database_type +FirewallPolicy: + path: firewall_policies + crud: [create, update, delete, createdate] + plural: FirewallPolicies + testid: fwp-j3654 + jsonpath: firewall_policy +FirewallRule: + path: firewall_rules + crud: [create, update, delete, createdate] + testid: fwr-k32ls + jsonpath: firewall_rule +Image: + path: images + crud: [create, update, delete, lock, createdate] + testid: img-3ikco + jsonpath: image +Interface: + path: interfaces + crud: [] + testid: int-ds42k + jsonpath: interface +LoadBalancer: + path: load_balancers + crud: [create, update, delete, lock, createdate] + testid: lba-1235f + jsonpath: load_balancer +Server: + path: servers + crud: [create, update, delete, lock, createdate, resize] + testid: srv-lv426 + jsonpath: server + resize_request: '"typ-12345"' + resize_response: '{"new_type":"typ-12345"}' +ServerGroup: + path: server_groups + crud: [create, update, delete, createdate] + testid: grp-sda44 + jsonpath: server_group +ServerType: + path: server_types + crud: [handle] + testid: typ-zx45f + jsonpath: server_type +User: + path: users + crud: [update, createdate] + testid: usr-kl435 + jsonpath: user +Volume: + path: volumes + crud: [create, update, delete, lock, createdate, resize] + testid: vol-po5we + jsonpath: volume + resize_request: '40960, 61440' + resize_response: '{"from":40960,"to":61440}' +Zone: + path: zones + crud: [handle] + testid: zon-328ds + jsonpath: zone diff --git a/vendor/github.com/brightbox/gobrightbox/v2/resource_ref.go b/vendor/github.com/brightbox/gobrightbox/v2/resource_ref.go new file mode 100644 index 000000000..772a97e40 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/resource_ref.go @@ -0,0 +1,7 @@ +package brightbox + +// ResourceRef contains the header fields in every API object +type ResourceRef struct { + URL string `json:"url"` + ResourceType string `json:"resource_type"` +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/server_commands.go b/vendor/github.com/brightbox/gobrightbox/v2/server_commands.go new file mode 100644 index 000000000..fffaecb3b --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/server_commands.go @@ -0,0 +1,36 @@ +// Code generated by generate_server_commands; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +// StartServer will issue a start request for the server to become active. +func (c *Client) StartServer(ctx context.Context, identifier string) (*Server, error) { + return apiPost[Server](ctx, c, path.Join(serverAPIPath, identifier, "start"), nil) +} + +// StopServer will issue a stop request for the server to become inactve. +func (c *Client) StopServer(ctx context.Context, identifier string) (*Server, error) { + return apiPost[Server](ctx, c, path.Join(serverAPIPath, identifier, "stop"), nil) +} + +// RebootServer issues a "soft" reboot to the server, however the OS make ignore it. The console remains connected. +func (c *Client) RebootServer(ctx context.Context, identifier string) (*Server, error) { + return apiPost[Server](ctx, c, path.Join(serverAPIPath, identifier, "reboot"), nil) +} + +// ResetServer issues a "hard" reboot to the server which cannot be ignored by the OS. The console remains connected. +func (c *Client) ResetServer(ctx context.Context, identifier string) (*Server, error) { + return apiPost[Server](ctx, c, path.Join(serverAPIPath, identifier, "reset"), nil) +} + +// ShutdownServer will issue a safe shutdown request to the server. +func (c *Client) ShutdownServer(ctx context.Context, identifier string) (*Server, error) { + return apiPost[Server](ctx, c, path.Join(serverAPIPath, identifier, "shutdown"), nil) +} + +// ActivateConsoleForServer will issue a request to enable the graphical console for an existing server. +func (c *Client) ActivateConsoleForServer(ctx context.Context, identifier string) (*Server, error) { + return apiPost[Server](ctx, c, path.Join(serverAPIPath, identifier, "activate_console"), nil) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/server_groups.go b/vendor/github.com/brightbox/gobrightbox/v2/server_groups.go new file mode 100644 index 000000000..233328e14 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/server_groups.go @@ -0,0 +1,74 @@ +package brightbox + +import ( + "context" + "path" + "time" +) + +// ServerGroup represents a server group +// https://api.gb1.brightbox.com/1.0/#server_group +type ServerGroup struct { + ResourceRef + ID string + Name string + Description string + Default bool + Fqdn string + CreatedAt *time.Time `json:"created_at"` + Account *Account + FirewallPolicy *FirewallPolicy `json:"firewall_policy"` + Servers []Server +} + +// ServerGroupOptions is used in combination with CreateServerGroup and +// UpdateServerGroup to create and update server groups +type ServerGroupOptions struct { + ID string `json:"-"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` +} + +// ServerGroupMember is used to add, remove and move a server between server groups +type ServerGroupMember struct { + Server string `json:"server"` +} + +// ServerGroupMemberList is used to add, remove and move servers between server groups +type ServerGroupMemberList struct { + Servers []ServerGroupMember `json:"servers"` +} + +// AddServersToServerGroup adds servers to an existing server group +func (c *Client) AddServersToServerGroup(ctx context.Context, identifier string, attachment ServerGroupMemberList) (*ServerGroup, error) { + return apiPost[ServerGroup]( + ctx, + c, + path.Join(servergroupAPIPath, identifier, "add_servers"), + attachment, + ) +} + +// RemoveServersFromServerGroup remove servers from an existing server group +func (c *Client) RemoveServersFromServerGroup(ctx context.Context, identifier string, attachment ServerGroupMemberList) (*ServerGroup, error) { + return apiPost[ServerGroup]( + ctx, + c, + path.Join(servergroupAPIPath, identifier, "remove_servers"), + attachment, + ) +} + +// MoveServersToServerGroup moves servers between two existing server groups +func (c *Client) MoveServersToServerGroup(ctx context.Context, from string, to string, servers ServerGroupMemberList) (*ServerGroup, error) { + opts := struct { + ServerGroupMemberList + Destination string `json:"destination"` + }{servers, to} + return apiPost[ServerGroup]( + ctx, + c, + path.Join(servergroupAPIPath, from, "move_servers"), + opts, + ) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/server_groups_default.go b/vendor/github.com/brightbox/gobrightbox/v2/server_groups_default.go new file mode 100644 index 000000000..1df7db837 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/server_groups_default.go @@ -0,0 +1,48 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // servergroupAPIPath returns the relative URL path to the ServerGroup endpoint + servergroupAPIPath = "server_groups" +) + +// ServerGroups returns the collection view for ServerGroup +func (c *Client) ServerGroups(ctx context.Context) ([]ServerGroup, error) { + return apiGetCollection[[]ServerGroup](ctx, c, servergroupAPIPath) +} + +// ServerGroup retrieves a detailed view of one resource +func (c *Client) ServerGroup(ctx context.Context, identifier string) (*ServerGroup, error) { + return apiGet[ServerGroup](ctx, c, path.Join(servergroupAPIPath, identifier)) +} + +// CreateServerGroup creates a new resource from the supplied option map. +// +// It takes an instance of ServerGroupOptions. Not all attributes can be +// specified at create time (such as ID, which is allocated for you). +func (c *Client) CreateServerGroup(ctx context.Context, newServerGroup ServerGroupOptions) (*ServerGroup, error) { + return apiPost[ServerGroup](ctx, c, servergroupAPIPath, newServerGroup) +} + +// UpdateServerGroup updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of ServerGroupOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateServerGroup(ctx context.Context, updateServerGroup ServerGroupOptions) (*ServerGroup, error) { + return apiPut[ServerGroup](ctx, c, path.Join(servergroupAPIPath, updateServerGroup.ID), updateServerGroup) +} + +// DestroyServerGroup destroys an existing resource. +func (c *Client) DestroyServerGroup(ctx context.Context, identifier string) (*ServerGroup, error) { + return apiDelete[ServerGroup](ctx, c, path.Join(servergroupAPIPath, identifier)) +} + +// CreatedAt implements the CreateDated interface for ServerGroup +func (s ServerGroup) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/server_types.go b/vendor/github.com/brightbox/gobrightbox/v2/server_types.go new file mode 100644 index 000000000..baf797531 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/server_types.go @@ -0,0 +1,23 @@ +package brightbox + +import ( + "github.com/brightbox/gobrightbox/v2/enums/servertypestatus" + "github.com/brightbox/gobrightbox/v2/enums/storagetype" +) + +//go:generate ./generate_enum servertypestatus experimental available deprecated +//go:generate ./generate_enum storagetype local network + +// ServerType represents a Server Type +// https://api.gb1.brightbox.com/1.0/#server_type +type ServerType struct { + ResourceRef + ID string + Name string + Status servertypestatus.Enum + Cores uint + RAM uint + Handle string + DiskSize uint `json:"disk_size"` + StorageType storagetype.Enum `json:"storage_type"` +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/server_types_default.go b/vendor/github.com/brightbox/gobrightbox/v2/server_types_default.go new file mode 100644 index 000000000..4373d7675 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/server_types_default.go @@ -0,0 +1,37 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +import "fmt" + +const ( + // servertypeAPIPath returns the relative URL path to the ServerType endpoint + servertypeAPIPath = "server_types" +) + +// ServerTypes returns the collection view for ServerType +func (c *Client) ServerTypes(ctx context.Context) ([]ServerType, error) { + return apiGetCollection[[]ServerType](ctx, c, servertypeAPIPath) +} + +// ServerType retrieves a detailed view of one resource +func (c *Client) ServerType(ctx context.Context, identifier string) (*ServerType, error) { + return apiGet[ServerType](ctx, c, path.Join(servertypeAPIPath, identifier)) +} + +// ServerType retrieves a detailed view of one resource using a handle +func (c *Client) ServerTypeByHandle(ctx context.Context, handle string) (*ServerType, error) { + collection, err := c.ServerTypes(ctx) + if err != nil { + return nil, err + } + for _, instance := range collection { + if instance.Handle == handle { + return &instance, nil + } + } + return nil, fmt.Errorf("Resource with handle '%s' doesn't exist", handle) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/servers.go b/vendor/github.com/brightbox/gobrightbox/v2/servers.go new file mode 100644 index 000000000..5ce06921b --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/servers.go @@ -0,0 +1,83 @@ +package brightbox + +import ( + "time" + + "github.com/brightbox/gobrightbox/v2/enums/serverstatus" +) + +//go:generate ./generate_enum serverstatus creating active inactive deleting deleted failed unavailable +//go:generate ./generate_server_commands + +// Server represents a Cloud Server +// https://api.gb1.brightbox.com/1.0/#server +// DeletedAt is nil if the server has not yet been deleted +type Server struct { + ResourceRef + ServerConsole + ID string + Name string + Status serverstatus.Enum `json:"status"` + Hostname string + Fqdn string + UserData string `json:"user_data"` + CreatedAt *time.Time `json:"created_at"` + DeletedAt *time.Time `json:"deleted_at"` + StartedAt *time.Time `json:"started_at"` + SnapshotsSchedule string `json:"snapshots_schedule"` + SnapshotsScheduleNextAt *time.Time `json:"snapshots_schedule_next_at"` + SnapshotsRetention string `json:"snapshots_retention"` + Locked bool `json:"locked"` + CompatibilityMode bool `json:"compatibility_mode"` + DiskEncrypted bool `json:"disk_encrypted"` + Account *Account + Image *Image + Zone *Zone + ServerType *ServerType `json:"server_type"` + CloudIPs []CloudIP `json:"cloud_ips"` + ServerGroups []ServerGroup `json:"server_groups"` + Snapshots []Image + Interfaces []Interface + Volumes []Volume +} + +// ServerConsole is embedded into Server and contains the fields used in response +// to an ActivateConsoleForServer request. +type ServerConsole struct { + ConsoleToken *string `json:"console_token"` + ConsoleURL *string `json:"console_url"` + ConsoleTokenExpires *time.Time `json:"console_token_expires"` +} + +// ServerOptions is used in conjunction with CreateServer and UpdateServer to +// create and update servers. +type ServerOptions struct { + ID string `json:"-"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + ServerType *string `json:"server_type,omitempty"` + Zone *string `json:"zone,omitempty"` + UserData *string `json:"user_data,omitempty"` + SnapshotsRetention *string `json:"snapshots_retention,omitempty"` + SnapshotsSchedule *string `json:"snapshots_schedule,omitempty"` + ServerGroups []string `json:"server_groups,omitempty"` + CompatibilityMode *bool `json:"compatibility_mode,omitempty"` + DiskEncrypted *bool `json:"disk_encrypted,omitempty"` + CloudIP *bool `json:"cloud_ip,omitempty"` + Volumes []VolumeEntry `json:"volumes,omitempty"` +} + +// ServerNewSize is used in conjunction with ResizeServer +// to specify the new Server type for the Server +type ServerNewSize struct { + NewType string `json:"new_type"` +} + +// VolumeEntry is used within ServerOptions to specify the boot +// volume for a server on creation. Either volume or image/disk size can +// be given +type VolumeEntry struct { + Volume string `json:"volume,omitempty"` + Size uint `json:"size,omitempty"` + Image string `json:"image,omitempty"` +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/servers_default.go b/vendor/github.com/brightbox/gobrightbox/v2/servers_default.go new file mode 100644 index 000000000..7d55c3723 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/servers_default.go @@ -0,0 +1,64 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // serverAPIPath returns the relative URL path to the Server endpoint + serverAPIPath = "servers" +) + +// Servers returns the collection view for Server +func (c *Client) Servers(ctx context.Context) ([]Server, error) { + return apiGetCollection[[]Server](ctx, c, serverAPIPath) +} + +// Server retrieves a detailed view of one resource +func (c *Client) Server(ctx context.Context, identifier string) (*Server, error) { + return apiGet[Server](ctx, c, path.Join(serverAPIPath, identifier)) +} + +// CreateServer creates a new resource from the supplied option map. +// +// It takes an instance of ServerOptions. Not all attributes can be +// specified at create time (such as ID, which is allocated for you). +func (c *Client) CreateServer(ctx context.Context, newServer ServerOptions) (*Server, error) { + return apiPost[Server](ctx, c, serverAPIPath, newServer) +} + +// UpdateServer updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of ServerOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateServer(ctx context.Context, updateServer ServerOptions) (*Server, error) { + return apiPut[Server](ctx, c, path.Join(serverAPIPath, updateServer.ID), updateServer) +} + +// DestroyServer destroys an existing resource. +func (c *Client) DestroyServer(ctx context.Context, identifier string) (*Server, error) { + return apiDelete[Server](ctx, c, path.Join(serverAPIPath, identifier)) +} + +// LockServer locks a resource against destroy requests +func (c *Client) LockServer(ctx context.Context, identifier string) (*Server, error) { + return apiPut[Server](ctx, c, path.Join(serverAPIPath, identifier, "lock_resource"), nil) +} + +// UnlockServer unlocks a resource, re-enabling destroy requests +func (c *Client) UnlockServer(ctx context.Context, identifier string) (*Server, error) { + return apiPut[Server](ctx, c, path.Join(serverAPIPath, identifier, "unlock_resource"), nil) +} + +// CreatedAt implements the CreateDated interface for Server +func (s Server) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() +} + +// ResizeServer issues a request to change the server type of a server +// changing the amount of cpu and ram it has. +func (c *Client) ResizeServer(ctx context.Context, identifier string, newSize ServerNewSize) (*Server, error) { + return apiPost[Server](ctx, c, path.Join(serverAPIPath, identifier, "resize"), newSize) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/users.go b/vendor/github.com/brightbox/gobrightbox/v2/users.go new file mode 100644 index 000000000..7649bfd25 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/users.go @@ -0,0 +1,34 @@ +package brightbox + +import "time" + +// User represents a Brightbox User +// https://api.gb1.brightbox.com/1.0/#user +type User struct { + ResourceRef + ID string + Name string + EmailAddress string `json:"email_address"` + EmailVerified bool `json:"email_verified"` + SSHKey string `json:"ssh_key"` + MessagingPref bool `json:"messaging_pref"` + CreatedAt *time.Time `json:"created_at"` + TwoFactorAuth TwoFactorAuthType `json:"2fa"` + DefaultAccount *Account `json:"default_account"` + Accounts []Account +} + +// TwoFactorAuthType is nested in User +type TwoFactorAuthType struct { + Enabled bool +} + +// UserOptions is used to update objects +type UserOptions struct { + ID string `json:"-"` + Name *string `json:"name,omitempty"` + EmailAddress *string `json:"email_address,omitempty"` + SSHKey *string `json:"ssh_key,omitempty"` + Password *string `json:"password,omitempty"` + PasswordConfirmation *string `json:"password_confirmation,omitempty"` +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/users_default.go b/vendor/github.com/brightbox/gobrightbox/v2/users_default.go new file mode 100644 index 000000000..2c463c44f --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/users_default.go @@ -0,0 +1,35 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // userAPIPath returns the relative URL path to the User endpoint + userAPIPath = "users" +) + +// Users returns the collection view for User +func (c *Client) Users(ctx context.Context) ([]User, error) { + return apiGetCollection[[]User](ctx, c, userAPIPath) +} + +// User retrieves a detailed view of one resource +func (c *Client) User(ctx context.Context, identifier string) (*User, error) { + return apiGet[User](ctx, c, path.Join(userAPIPath, identifier)) +} + +// UpdateUser updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of UserOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateUser(ctx context.Context, updateUser UserOptions) (*User, error) { + return apiPut[User](ctx, c, path.Join(userAPIPath, updateUser.ID), updateUser) +} + +// CreatedAt implements the CreateDated interface for User +func (s User) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/volumes.go b/vendor/github.com/brightbox/gobrightbox/v2/volumes.go new file mode 100644 index 000000000..61709982e --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/volumes.go @@ -0,0 +1,92 @@ +package brightbox + +import ( + "context" + "path" + "time" + + "github.com/brightbox/gobrightbox/v2/enums/filesystemtype" + "github.com/brightbox/gobrightbox/v2/enums/storagetype" + "github.com/brightbox/gobrightbox/v2/enums/volumestatus" + "github.com/brightbox/gobrightbox/v2/enums/volumetype" +) + +//go:generate ./generate_enum volumestatus creating attached detached deleting deleted failed +//go:generate ./generate_enum filesystemtype xfs ext4 +//go:generate ./generate_enum volumetype image volume raw + +// Volume represents a Brightbox Volume +// https://api.gb1.brightbox.com/1.0/#volume +type Volume struct { + ResourceRef + ID string + Name string + Status volumestatus.Enum + Description string + DeleteWithServer bool `json:"delete_with_server"` + Boot bool + Encrypted bool + FilesystemLabel string `json:"filesystem_label"` + FilesystemType filesystemtype.Enum `json:"filesystem_type"` + Locked bool + Serial string + Size uint + Source string + SourceType volumetype.Enum `json:"source_type"` + StorageType storagetype.Enum `json:"storage_type"` + CreatedAt *time.Time `json:"created_at"` + DeletedAt *time.Time `json:"deleted_at"` + UpdatedAt *time.Time `json:"updated_at"` + Server *Server + Account *Account + Image *Image +} + +// VolumeOptions is used to create and update volumes +// create and update servers. +type VolumeOptions struct { + ID string `json:"-"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + Serial *string `json:"serial,omitempty"` + DeleteWithServer *bool `json:"delete_with_server,omitempty"` + FilesystemLabel *string `json:"filesystem_label,omitempty"` + FilesystemType filesystemtype.Enum `json:"filesystem_type,omitempty"` + Size *uint `json:"size,omitempty"` + Image *string `json:"image,omitempty"` + Encrypted *bool `json:"encrypted,omitempty"` +} + +// VolumeAttachment is used in conjunction with AttachVolume and DetachVolume +type VolumeAttachment struct { + Server string `json:"server"` + Boot bool `json:"boot"` +} + +// VolumeNewSize is used in conjunction with ResizeVolume +// to specify the change in the disk size +type VolumeNewSize struct { + From uint `json:"from"` + To uint `json:"to"` +} + +// AttachVolume issues a request to attach the volume to a particular server and +// optionally mark it as the boot volume +func (c *Client) AttachVolume(ctx context.Context, identifier string, attachment VolumeAttachment) (*Volume, error) { + return apiPost[Volume]( + ctx, + c, + path.Join(volumeAPIPath, identifier, "attach"), + attachment, + ) +} + +// DetachVolume issues a request to disconnect a volume from a server +func (c *Client) DetachVolume(ctx context.Context, identifier string) (*Volume, error) { + return apiPost[Volume]( + ctx, + c, + path.Join(volumeAPIPath, identifier, "detach"), + nil, + ) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/volumes_default.go b/vendor/github.com/brightbox/gobrightbox/v2/volumes_default.go new file mode 100644 index 000000000..e86251b6a --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/volumes_default.go @@ -0,0 +1,64 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +const ( + // volumeAPIPath returns the relative URL path to the Volume endpoint + volumeAPIPath = "volumes" +) + +// Volumes returns the collection view for Volume +func (c *Client) Volumes(ctx context.Context) ([]Volume, error) { + return apiGetCollection[[]Volume](ctx, c, volumeAPIPath) +} + +// Volume retrieves a detailed view of one resource +func (c *Client) Volume(ctx context.Context, identifier string) (*Volume, error) { + return apiGet[Volume](ctx, c, path.Join(volumeAPIPath, identifier)) +} + +// CreateVolume creates a new resource from the supplied option map. +// +// It takes an instance of VolumeOptions. Not all attributes can be +// specified at create time (such as ID, which is allocated for you). +func (c *Client) CreateVolume(ctx context.Context, newVolume VolumeOptions) (*Volume, error) { + return apiPost[Volume](ctx, c, volumeAPIPath, newVolume) +} + +// UpdateVolume updates an existing resources's attributes. Not all +// attributes can be changed (such as ID). +// +// It takes an instance of VolumeOptions. Specify the resource you +// want to update using the ID field. +func (c *Client) UpdateVolume(ctx context.Context, updateVolume VolumeOptions) (*Volume, error) { + return apiPut[Volume](ctx, c, path.Join(volumeAPIPath, updateVolume.ID), updateVolume) +} + +// DestroyVolume destroys an existing resource. +func (c *Client) DestroyVolume(ctx context.Context, identifier string) (*Volume, error) { + return apiDelete[Volume](ctx, c, path.Join(volumeAPIPath, identifier)) +} + +// LockVolume locks a resource against destroy requests +func (c *Client) LockVolume(ctx context.Context, identifier string) (*Volume, error) { + return apiPut[Volume](ctx, c, path.Join(volumeAPIPath, identifier, "lock_resource"), nil) +} + +// UnlockVolume unlocks a resource, re-enabling destroy requests +func (c *Client) UnlockVolume(ctx context.Context, identifier string) (*Volume, error) { + return apiPut[Volume](ctx, c, path.Join(volumeAPIPath, identifier, "unlock_resource"), nil) +} + +// CreatedAt implements the CreateDated interface for Volume +func (s Volume) CreatedAtUnix() int64 { + return s.CreatedAt.Unix() +} + +// ResizeVolume issues a request to change the server type of a server +// changing the amount of cpu and ram it has. +func (c *Client) ResizeVolume(ctx context.Context, identifier string, newSize VolumeNewSize) (*Volume, error) { + return apiPost[Volume](ctx, c, path.Join(volumeAPIPath, identifier, "resize"), newSize) +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/zones.go b/vendor/github.com/brightbox/gobrightbox/v2/zones.go new file mode 100644 index 000000000..3b79772d3 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/zones.go @@ -0,0 +1,9 @@ +package brightbox + +// Zone represents a Zone +// https://api.gb1.brightbox.com/1.0/#zone +type Zone struct { + ResourceRef + ID string + Handle string +} diff --git a/vendor/github.com/brightbox/gobrightbox/v2/zones_default.go b/vendor/github.com/brightbox/gobrightbox/v2/zones_default.go new file mode 100644 index 000000000..60615fcd0 --- /dev/null +++ b/vendor/github.com/brightbox/gobrightbox/v2/zones_default.go @@ -0,0 +1,37 @@ +// Code generated by go generate; DO NOT EDIT. + +package brightbox + +import "context" +import "path" + +import "fmt" + +const ( + // zoneAPIPath returns the relative URL path to the Zone endpoint + zoneAPIPath = "zones" +) + +// Zones returns the collection view for Zone +func (c *Client) Zones(ctx context.Context) ([]Zone, error) { + return apiGetCollection[[]Zone](ctx, c, zoneAPIPath) +} + +// Zone retrieves a detailed view of one resource +func (c *Client) Zone(ctx context.Context, identifier string) (*Zone, error) { + return apiGet[Zone](ctx, c, path.Join(zoneAPIPath, identifier)) +} + +// Zone retrieves a detailed view of one resource using a handle +func (c *Client) ZoneByHandle(ctx context.Context, handle string) (*Zone, error) { + collection, err := c.Zones(ctx) + if err != nil { + return nil, err + } + for _, instance := range collection { + if instance.Handle == handle { + return &instance, nil + } + } + return nil, fmt.Errorf("Resource with handle '%s' doesn't exist", handle) +} diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_arm64.go b/vendor/golang.org/x/crypto/chacha20/chacha_arm64.go index 5dfacbb98..661ea132e 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_arm64.go +++ b/vendor/golang.org/x/crypto/chacha20/chacha_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc && !purego -// +build gc,!purego package chacha20 diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_arm64.s b/vendor/golang.org/x/crypto/chacha20/chacha_arm64.s index f1f66230d..7dd2638e8 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_arm64.s +++ b/vendor/golang.org/x/crypto/chacha20/chacha_arm64.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc && !purego -// +build gc,!purego #include "textflag.h" diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_noasm.go b/vendor/golang.org/x/crypto/chacha20/chacha_noasm.go index 02ff3d05e..db42e6676 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_noasm.go +++ b/vendor/golang.org/x/crypto/chacha20/chacha_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (!arm64 && !s390x && !ppc64le) || !gc || purego -// +build !arm64,!s390x,!ppc64le !gc purego package chacha20 diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go b/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go index da420b2e9..3a4287f99 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go +++ b/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc && !purego -// +build gc,!purego package chacha20 diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.s b/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.s index 5c0fed26f..66aebae25 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.s +++ b/vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.s @@ -20,7 +20,6 @@ // due to the calling conventions and initialization of constants. //go:build gc && !purego -// +build gc,!purego #include "textflag.h" diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_s390x.go b/vendor/golang.org/x/crypto/chacha20/chacha_s390x.go index 4652247b8..683ccfd1c 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_s390x.go +++ b/vendor/golang.org/x/crypto/chacha20/chacha_s390x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc && !purego -// +build gc,!purego package chacha20 diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_s390x.s b/vendor/golang.org/x/crypto/chacha20/chacha_s390x.s index f3ef5a019..1eda91a3d 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_s390x.s +++ b/vendor/golang.org/x/crypto/chacha20/chacha_s390x.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc && !purego -// +build gc,!purego #include "go_asm.h" #include "textflag.h" diff --git a/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.go b/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.go index 0c408c570..50695a14f 100644 --- a/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.go +++ b/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc && !purego -// +build gc,!purego package chacha20poly1305 diff --git a/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.s b/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.s index 867c181a1..731d2ac6d 100644 --- a/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.s +++ b/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.s @@ -5,7 +5,6 @@ // This file was originally from https://golang.org/cl/24717 by Vlad Krasnov of CloudFlare. //go:build gc && !purego -// +build gc,!purego #include "textflag.h" // General register allocation @@ -184,11 +183,31 @@ GLOBL ·andMask<>(SB), (NOPTR+RODATA), $240 #define shiftD1Right BYTE $0x66; BYTE $0x45; BYTE $0x0f; BYTE $0x3a; BYTE $0x0f; BYTE $0xd2; BYTE $0x04 // PALIGNR $4, X10, X10 #define shiftD2Right BYTE $0x66; BYTE $0x45; BYTE $0x0f; BYTE $0x3a; BYTE $0x0f; BYTE $0xdb; BYTE $0x04 // PALIGNR $4, X11, X11 #define shiftD3Right BYTE $0x66; BYTE $0x45; BYTE $0x0f; BYTE $0x3a; BYTE $0x0f; BYTE $0xff; BYTE $0x04 // PALIGNR $4, X15, X15 + // Some macros + +// ROL rotates the uint32s in register R left by N bits, using temporary T. +#define ROL(N, R, T) \ + MOVO R, T; PSLLL $(N), T; PSRLL $(32-(N)), R; PXOR T, R + +// ROL16 rotates the uint32s in register R left by 16, using temporary T if needed. +#ifdef GOAMD64_v2 +#define ROL16(R, T) PSHUFB ·rol16<>(SB), R +#else +#define ROL16(R, T) ROL(16, R, T) +#endif + +// ROL8 rotates the uint32s in register R left by 8, using temporary T if needed. +#ifdef GOAMD64_v2 +#define ROL8(R, T) PSHUFB ·rol8<>(SB), R +#else +#define ROL8(R, T) ROL(8, R, T) +#endif + #define chachaQR(A, B, C, D, T) \ - PADDD B, A; PXOR A, D; PSHUFB ·rol16<>(SB), D \ + PADDD B, A; PXOR A, D; ROL16(D, T) \ PADDD D, C; PXOR C, B; MOVO B, T; PSLLL $12, T; PSRLL $20, B; PXOR T, B \ - PADDD B, A; PXOR A, D; PSHUFB ·rol8<>(SB), D \ + PADDD B, A; PXOR A, D; ROL8(D, T) \ PADDD D, C; PXOR C, B; MOVO B, T; PSLLL $7, T; PSRLL $25, B; PXOR T, B #define chachaQR_AVX2(A, B, C, D, T) \ diff --git a/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_noasm.go b/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_noasm.go index f832b33d4..34e6ab1df 100644 --- a/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_noasm.go +++ b/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 || !gc || purego -// +build !amd64 !gc purego package chacha20poly1305 diff --git a/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.go b/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.go index edcf163c4..70c541692 100644 --- a/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.go +++ b/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.go @@ -1,7 +1,6 @@ // Code generated by command: go run fe_amd64_asm.go -out ../fe_amd64.s -stubs ../fe_amd64.go -pkg field. DO NOT EDIT. //go:build amd64 && gc && !purego -// +build amd64,gc,!purego package field diff --git a/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.s b/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.s index 293f013c9..60817acc4 100644 --- a/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.s +++ b/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.s @@ -1,7 +1,6 @@ // Code generated by command: go run fe_amd64_asm.go -out ../fe_amd64.s -stubs ../fe_amd64.go -pkg field. DO NOT EDIT. //go:build amd64 && gc && !purego -// +build amd64,gc,!purego #include "textflag.h" diff --git a/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64_noasm.go b/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64_noasm.go index ddb6c9b8f..9da280d1d 100644 --- a/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64_noasm.go +++ b/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !amd64 || !gc || purego -// +build !amd64 !gc purego package field diff --git a/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.go b/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.go index af459ef51..075fe9b92 100644 --- a/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.go +++ b/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 && gc && !purego -// +build arm64,gc,!purego package field diff --git a/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.s b/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.s index 5c91e4589..3126a4341 100644 --- a/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.s +++ b/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 && gc && !purego -// +build arm64,gc,!purego #include "textflag.h" diff --git a/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64_noasm.go b/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64_noasm.go index 234a5b2e5..fc029ac12 100644 --- a/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64_noasm.go +++ b/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !arm64 || !gc || purego -// +build !arm64 !gc purego package field diff --git a/vendor/golang.org/x/crypto/hkdf/hkdf.go b/vendor/golang.org/x/crypto/hkdf/hkdf.go index dda3f143b..f4ded5fee 100644 --- a/vendor/golang.org/x/crypto/hkdf/hkdf.go +++ b/vendor/golang.org/x/crypto/hkdf/hkdf.go @@ -56,7 +56,9 @@ func (f *hkdf) Read(p []byte) (int, error) { // Fill the rest of the buffer for len(p) > 0 { - f.expander.Reset() + if f.counter > 1 { + f.expander.Reset() + } f.expander.Write(f.prev) f.expander.Write(f.info) f.expander.Write([]byte{f.counter}) diff --git a/vendor/golang.org/x/crypto/internal/alias/alias.go b/vendor/golang.org/x/crypto/internal/alias/alias.go index 69c17f822..551ff0c35 100644 --- a/vendor/golang.org/x/crypto/internal/alias/alias.go +++ b/vendor/golang.org/x/crypto/internal/alias/alias.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !purego -// +build !purego // Package alias implements memory aliasing tests. package alias diff --git a/vendor/golang.org/x/crypto/internal/alias/alias_purego.go b/vendor/golang.org/x/crypto/internal/alias/alias_purego.go index 4775b0a43..6fe61b5c6 100644 --- a/vendor/golang.org/x/crypto/internal/alias/alias_purego.go +++ b/vendor/golang.org/x/crypto/internal/alias/alias_purego.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build purego -// +build purego // Package alias implements memory aliasing tests. package alias diff --git a/vendor/golang.org/x/crypto/internal/poly1305/bits_compat.go b/vendor/golang.org/x/crypto/internal/poly1305/bits_compat.go index 45b5c966b..d33c8890f 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/bits_compat.go +++ b/vendor/golang.org/x/crypto/internal/poly1305/bits_compat.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !go1.13 -// +build !go1.13 package poly1305 diff --git a/vendor/golang.org/x/crypto/internal/poly1305/bits_go1.13.go b/vendor/golang.org/x/crypto/internal/poly1305/bits_go1.13.go index ed52b3418..495c1fa69 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/bits_go1.13.go +++ b/vendor/golang.org/x/crypto/internal/poly1305/bits_go1.13.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build go1.13 -// +build go1.13 package poly1305 diff --git a/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go b/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go index f184b67d9..333da285b 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go +++ b/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (!amd64 && !ppc64le && !s390x) || !gc || purego -// +build !amd64,!ppc64le,!s390x !gc purego package poly1305 diff --git a/vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.go b/vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.go index 6d522333f..164cd47d3 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.go +++ b/vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc && !purego -// +build gc,!purego package poly1305 diff --git a/vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.s b/vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.s index 1d74f0f88..e0d3c6475 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.s +++ b/vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc && !purego -// +build gc,!purego #include "textflag.h" diff --git a/vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.go b/vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.go index 4a069941a..4aec4874b 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.go +++ b/vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc && !purego -// +build gc,!purego package poly1305 diff --git a/vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.s b/vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.s index 58422aad2..d2ca5deeb 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.s +++ b/vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc && !purego -// +build gc,!purego #include "textflag.h" diff --git a/vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.go b/vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.go index ec9596688..e1d033a49 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.go +++ b/vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc && !purego -// +build gc,!purego package poly1305 diff --git a/vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.s b/vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.s index aa9e0494c..0fe3a7c21 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.s +++ b/vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc && !purego -// +build gc,!purego #include "textflag.h" diff --git a/vendor/golang.org/x/crypto/ssh/agent/client.go b/vendor/golang.org/x/crypto/ssh/agent/client.go index 9f09aae7d..fecba8eb3 100644 --- a/vendor/golang.org/x/crypto/ssh/agent/client.go +++ b/vendor/golang.org/x/crypto/ssh/agent/client.go @@ -141,9 +141,14 @@ const ( agentAddSmartcardKeyConstrained = 26 // 3.7 Key constraint identifiers - agentConstrainLifetime = 1 - agentConstrainConfirm = 2 - agentConstrainExtension = 3 + agentConstrainLifetime = 1 + agentConstrainConfirm = 2 + // Constraint extension identifier up to version 2 of the protocol. A + // backward incompatible change will be required if we want to add support + // for SSH_AGENT_CONSTRAIN_MAXSIGN which uses the same ID. + agentConstrainExtensionV00 = 3 + // Constraint extension identifier in version 3 and later of the protocol. + agentConstrainExtension = 255 ) // maxAgentResponseBytes is the maximum agent reply size that is accepted. This @@ -205,7 +210,7 @@ type constrainLifetimeAgentMsg struct { } type constrainExtensionAgentMsg struct { - ExtensionName string `sshtype:"3"` + ExtensionName string `sshtype:"255|3"` ExtensionDetails []byte // Rest is a field used for parsing, not part of message diff --git a/vendor/golang.org/x/crypto/ssh/agent/server.go b/vendor/golang.org/x/crypto/ssh/agent/server.go index dd2e0a3e7..e35ca7ce3 100644 --- a/vendor/golang.org/x/crypto/ssh/agent/server.go +++ b/vendor/golang.org/x/crypto/ssh/agent/server.go @@ -208,7 +208,7 @@ func parseConstraints(constraints []byte) (lifetimeSecs uint32, confirmBeforeUse case agentConstrainConfirm: confirmBeforeUse = true constraints = constraints[1:] - case agentConstrainExtension: + case agentConstrainExtension, agentConstrainExtensionV00: var msg constrainExtensionAgentMsg if err = ssh.Unmarshal(constraints, &msg); err != nil { return 0, false, nil, err diff --git a/vendor/golang.org/x/crypto/ssh/common.go b/vendor/golang.org/x/crypto/ssh/common.go index b419c761e..dd2ab0d69 100644 --- a/vendor/golang.org/x/crypto/ssh/common.go +++ b/vendor/golang.org/x/crypto/ssh/common.go @@ -10,7 +10,6 @@ import ( "fmt" "io" "math" - "strings" "sync" _ "crypto/sha1" @@ -140,8 +139,6 @@ var supportedPubKeyAuthAlgos = []string{ KeyAlgoDSA, } -var supportedPubKeyAuthAlgosList = strings.Join(supportedPubKeyAuthAlgos, ",") - // unexpectedMessageError results when the SSH message that we received didn't // match what we wanted. func unexpectedMessageError(expected, got uint8) error { diff --git a/vendor/golang.org/x/crypto/ssh/handshake.go b/vendor/golang.org/x/crypto/ssh/handshake.go index 70a7369ff..49bbba769 100644 --- a/vendor/golang.org/x/crypto/ssh/handshake.go +++ b/vendor/golang.org/x/crypto/ssh/handshake.go @@ -11,6 +11,7 @@ import ( "io" "log" "net" + "strings" "sync" ) @@ -50,6 +51,10 @@ type handshakeTransport struct { // connection. hostKeys []Signer + // publicKeyAuthAlgorithms is non-empty if we are the server. In that case, + // it contains the supported client public key authentication algorithms. + publicKeyAuthAlgorithms []string + // hostKeyAlgorithms is non-empty if we are the client. In that case, // we accept these key types from the server as host key. hostKeyAlgorithms []string @@ -141,6 +146,7 @@ func newClientTransport(conn keyingTransport, clientVersion, serverVersion []byt func newServerTransport(conn keyingTransport, clientVersion, serverVersion []byte, config *ServerConfig) *handshakeTransport { t := newHandshakeTransport(conn, &config.Config, clientVersion, serverVersion) t.hostKeys = config.hostKeys + t.publicKeyAuthAlgorithms = config.PublicKeyAuthAlgorithms go t.readLoop() go t.kexLoop() return t @@ -649,6 +655,7 @@ func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error { // message with the server-sig-algs extension if the client supports it. See // RFC 8308, Sections 2.4 and 3.1, and [PROTOCOL], Section 1.9. if !isClient && firstKeyExchange && contains(clientInit.KexAlgos, "ext-info-c") { + supportedPubKeyAuthAlgosList := strings.Join(t.publicKeyAuthAlgorithms, ",") extInfo := &extInfoMsg{ NumExtensions: 2, Payload: make([]byte, 0, 4+15+4+len(supportedPubKeyAuthAlgosList)+4+16+4+1), diff --git a/vendor/golang.org/x/crypto/ssh/keys.go b/vendor/golang.org/x/crypto/ssh/keys.go index ef1bad731..df4ebdada 100644 --- a/vendor/golang.org/x/crypto/ssh/keys.go +++ b/vendor/golang.org/x/crypto/ssh/keys.go @@ -1232,16 +1232,27 @@ func ParseRawPrivateKeyWithPassphrase(pemBytes, passphrase []byte) (interface{}, return nil, fmt.Errorf("ssh: cannot decode encrypted private keys: %v", err) } + var result interface{} + switch block.Type { case "RSA PRIVATE KEY": - return x509.ParsePKCS1PrivateKey(buf) + result, err = x509.ParsePKCS1PrivateKey(buf) case "EC PRIVATE KEY": - return x509.ParseECPrivateKey(buf) + result, err = x509.ParseECPrivateKey(buf) case "DSA PRIVATE KEY": - return ParseDSAPrivateKey(buf) + result, err = ParseDSAPrivateKey(buf) default: - return nil, fmt.Errorf("ssh: unsupported key type %q", block.Type) + err = fmt.Errorf("ssh: unsupported key type %q", block.Type) } + // Because of deficiencies in the format, DecryptPEMBlock does not always + // detect an incorrect password. In these cases decrypted DER bytes is + // random noise. If the parsing of the key returns an asn1.StructuralError + // we return x509.IncorrectPasswordError. + if _, ok := err.(asn1.StructuralError); ok { + return nil, x509.IncorrectPasswordError + } + + return result, err } // ParseDSAPrivateKey returns a DSA private key from its ASN.1 DER encoding, as diff --git a/vendor/golang.org/x/crypto/ssh/server.go b/vendor/golang.org/x/crypto/ssh/server.go index 727c71b9c..8f1505af9 100644 --- a/vendor/golang.org/x/crypto/ssh/server.go +++ b/vendor/golang.org/x/crypto/ssh/server.go @@ -64,6 +64,13 @@ type ServerConfig struct { // Config contains configuration shared between client and server. Config + // PublicKeyAuthAlgorithms specifies the supported client public key + // authentication algorithms. Note that this should not include certificate + // types since those use the underlying algorithm. This list is sent to the + // client if it supports the server-sig-algs extension. Order is irrelevant. + // If unspecified then a default set of algorithms is used. + PublicKeyAuthAlgorithms []string + hostKeys []Signer // NoClientAuth is true if clients are allowed to connect without @@ -201,6 +208,15 @@ func NewServerConn(c net.Conn, config *ServerConfig) (*ServerConn, <-chan NewCha if fullConf.MaxAuthTries == 0 { fullConf.MaxAuthTries = 6 } + if len(fullConf.PublicKeyAuthAlgorithms) == 0 { + fullConf.PublicKeyAuthAlgorithms = supportedPubKeyAuthAlgos + } else { + for _, algo := range fullConf.PublicKeyAuthAlgorithms { + if !contains(supportedPubKeyAuthAlgos, algo) { + return nil, nil, nil, fmt.Errorf("ssh: unsupported public key authentication algorithm %s", algo) + } + } + } // Check if the config contains any unsupported key exchanges for _, kex := range fullConf.KeyExchanges { if _, ok := serverForbiddenKexAlgos[kex]; ok { @@ -524,7 +540,7 @@ userAuthLoop: return nil, parseError(msgUserAuthRequest) } algo := string(algoBytes) - if !contains(supportedPubKeyAuthAlgos, underlyingAlgo(algo)) { + if !contains(config.PublicKeyAuthAlgorithms, underlyingAlgo(algo)) { authErr = fmt.Errorf("ssh: algorithm %q not accepted", algo) break } @@ -591,7 +607,7 @@ userAuthLoop: // algorithm name that corresponds to algo with // sig.Format. This is usually the same, but // for certs, the names differ. - if !contains(supportedPubKeyAuthAlgos, sig.Format) { + if !contains(config.PublicKeyAuthAlgorithms, sig.Format) { authErr = fmt.Errorf("ssh: algorithm %q not accepted", sig.Format) break } diff --git a/vendor/golang.org/x/net/context/go17.go b/vendor/golang.org/x/net/context/go17.go index 2cb9c408f..0c1b86793 100644 --- a/vendor/golang.org/x/net/context/go17.go +++ b/vendor/golang.org/x/net/context/go17.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build go1.7 -// +build go1.7 package context diff --git a/vendor/golang.org/x/net/context/go19.go b/vendor/golang.org/x/net/context/go19.go index 64d31ecc3..e31e35a90 100644 --- a/vendor/golang.org/x/net/context/go19.go +++ b/vendor/golang.org/x/net/context/go19.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build go1.9 -// +build go1.9 package context diff --git a/vendor/golang.org/x/net/context/pre_go17.go b/vendor/golang.org/x/net/context/pre_go17.go index 7b6b68511..065ff3dfa 100644 --- a/vendor/golang.org/x/net/context/pre_go17.go +++ b/vendor/golang.org/x/net/context/pre_go17.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !go1.7 -// +build !go1.7 package context diff --git a/vendor/golang.org/x/net/context/pre_go19.go b/vendor/golang.org/x/net/context/pre_go19.go index 1f9715341..ec5a63803 100644 --- a/vendor/golang.org/x/net/context/pre_go19.go +++ b/vendor/golang.org/x/net/context/pre_go19.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !go1.9 -// +build !go1.9 package context diff --git a/vendor/golang.org/x/net/http2/databuffer.go b/vendor/golang.org/x/net/http2/databuffer.go index a3067f8de..e6f55cbd1 100644 --- a/vendor/golang.org/x/net/http2/databuffer.go +++ b/vendor/golang.org/x/net/http2/databuffer.go @@ -20,41 +20,44 @@ import ( // TODO: Benchmark to determine if the pools are necessary. The GC may have // improved enough that we can instead allocate chunks like this: // make([]byte, max(16<<10, expectedBytesRemaining)) -var ( - dataChunkSizeClasses = []int{ - 1 << 10, - 2 << 10, - 4 << 10, - 8 << 10, - 16 << 10, - } - dataChunkPools = [...]sync.Pool{ - {New: func() interface{} { return make([]byte, 1<<10) }}, - {New: func() interface{} { return make([]byte, 2<<10) }}, - {New: func() interface{} { return make([]byte, 4<<10) }}, - {New: func() interface{} { return make([]byte, 8<<10) }}, - {New: func() interface{} { return make([]byte, 16<<10) }}, - } -) +var dataChunkPools = [...]sync.Pool{ + {New: func() interface{} { return new([1 << 10]byte) }}, + {New: func() interface{} { return new([2 << 10]byte) }}, + {New: func() interface{} { return new([4 << 10]byte) }}, + {New: func() interface{} { return new([8 << 10]byte) }}, + {New: func() interface{} { return new([16 << 10]byte) }}, +} func getDataBufferChunk(size int64) []byte { - i := 0 - for ; i < len(dataChunkSizeClasses)-1; i++ { - if size <= int64(dataChunkSizeClasses[i]) { - break - } + switch { + case size <= 1<<10: + return dataChunkPools[0].Get().(*[1 << 10]byte)[:] + case size <= 2<<10: + return dataChunkPools[1].Get().(*[2 << 10]byte)[:] + case size <= 4<<10: + return dataChunkPools[2].Get().(*[4 << 10]byte)[:] + case size <= 8<<10: + return dataChunkPools[3].Get().(*[8 << 10]byte)[:] + default: + return dataChunkPools[4].Get().(*[16 << 10]byte)[:] } - return dataChunkPools[i].Get().([]byte) } func putDataBufferChunk(p []byte) { - for i, n := range dataChunkSizeClasses { - if len(p) == n { - dataChunkPools[i].Put(p) - return - } + switch len(p) { + case 1 << 10: + dataChunkPools[0].Put((*[1 << 10]byte)(p)) + case 2 << 10: + dataChunkPools[1].Put((*[2 << 10]byte)(p)) + case 4 << 10: + dataChunkPools[2].Put((*[4 << 10]byte)(p)) + case 8 << 10: + dataChunkPools[3].Put((*[8 << 10]byte)(p)) + case 16 << 10: + dataChunkPools[4].Put((*[16 << 10]byte)(p)) + default: + panic(fmt.Sprintf("unexpected buffer len=%v", len(p))) } - panic(fmt.Sprintf("unexpected buffer len=%v", len(p))) } // dataBuffer is an io.ReadWriter backed by a list of data chunks. diff --git a/vendor/golang.org/x/net/http2/go111.go b/vendor/golang.org/x/net/http2/go111.go deleted file mode 100644 index 5bf62b032..000000000 --- a/vendor/golang.org/x/net/http2/go111.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build go1.11 -// +build go1.11 - -package http2 - -import ( - "net/http/httptrace" - "net/textproto" -) - -func traceHasWroteHeaderField(trace *httptrace.ClientTrace) bool { - return trace != nil && trace.WroteHeaderField != nil -} - -func traceWroteHeaderField(trace *httptrace.ClientTrace, k, v string) { - if trace != nil && trace.WroteHeaderField != nil { - trace.WroteHeaderField(k, []string{v}) - } -} - -func traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.MIMEHeader) error { - if trace != nil { - return trace.Got1xxResponse - } - return nil -} diff --git a/vendor/golang.org/x/net/http2/go115.go b/vendor/golang.org/x/net/http2/go115.go deleted file mode 100644 index 908af1ab9..000000000 --- a/vendor/golang.org/x/net/http2/go115.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build go1.15 -// +build go1.15 - -package http2 - -import ( - "context" - "crypto/tls" -) - -// dialTLSWithContext uses tls.Dialer, added in Go 1.15, to open a TLS -// connection. -func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) { - dialer := &tls.Dialer{ - Config: cfg, - } - cn, err := dialer.DialContext(ctx, network, addr) - if err != nil { - return nil, err - } - tlsCn := cn.(*tls.Conn) // DialContext comment promises this will always succeed - return tlsCn, nil -} diff --git a/vendor/golang.org/x/net/http2/go118.go b/vendor/golang.org/x/net/http2/go118.go deleted file mode 100644 index aca4b2b31..000000000 --- a/vendor/golang.org/x/net/http2/go118.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build go1.18 -// +build go1.18 - -package http2 - -import ( - "crypto/tls" - "net" -) - -func tlsUnderlyingConn(tc *tls.Conn) net.Conn { - return tc.NetConn() -} diff --git a/vendor/golang.org/x/net/http2/not_go111.go b/vendor/golang.org/x/net/http2/not_go111.go deleted file mode 100644 index cc0baa819..000000000 --- a/vendor/golang.org/x/net/http2/not_go111.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !go1.11 -// +build !go1.11 - -package http2 - -import ( - "net/http/httptrace" - "net/textproto" -) - -func traceHasWroteHeaderField(trace *httptrace.ClientTrace) bool { return false } - -func traceWroteHeaderField(trace *httptrace.ClientTrace, k, v string) {} - -func traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.MIMEHeader) error { - return nil -} diff --git a/vendor/golang.org/x/net/http2/not_go115.go b/vendor/golang.org/x/net/http2/not_go115.go deleted file mode 100644 index e6c04cf7a..000000000 --- a/vendor/golang.org/x/net/http2/not_go115.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !go1.15 -// +build !go1.15 - -package http2 - -import ( - "context" - "crypto/tls" -) - -// dialTLSWithContext opens a TLS connection. -func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) { - cn, err := tls.Dial(network, addr, cfg) - if err != nil { - return nil, err - } - if err := cn.Handshake(); err != nil { - return nil, err - } - if cfg.InsecureSkipVerify { - return cn, nil - } - if err := cn.VerifyHostname(cfg.ServerName); err != nil { - return nil, err - } - return cn, nil -} diff --git a/vendor/golang.org/x/net/http2/not_go118.go b/vendor/golang.org/x/net/http2/not_go118.go deleted file mode 100644 index eab532c96..000000000 --- a/vendor/golang.org/x/net/http2/not_go118.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !go1.18 -// +build !go1.18 - -package http2 - -import ( - "crypto/tls" - "net" -) - -func tlsUnderlyingConn(tc *tls.Conn) net.Conn { - return nil -} diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go index 02c88b6b3..ae94c6408 100644 --- a/vendor/golang.org/x/net/http2/server.go +++ b/vendor/golang.org/x/net/http2/server.go @@ -2549,7 +2549,6 @@ type responseWriterState struct { wroteHeader bool // WriteHeader called (explicitly or implicitly). Not necessarily sent to user yet. sentHeader bool // have we sent the header frame? handlerDone bool // handler has finished - dirty bool // a Write failed; don't reuse this responseWriterState sentContentLen int64 // non-zero if handler set a Content-Length header wroteBytes int64 @@ -2669,7 +2668,6 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { date: date, }) if err != nil { - rws.dirty = true return 0, err } if endStream { @@ -2690,7 +2688,6 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { if len(p) > 0 || endStream { // only send a 0 byte DATA frame if we're ending the stream. if err := rws.conn.writeDataFromHandler(rws.stream, p, endStream); err != nil { - rws.dirty = true return 0, err } } @@ -2702,9 +2699,6 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { trailers: rws.trailers, endStream: true, }) - if err != nil { - rws.dirty = true - } return len(p), err } return len(p), nil @@ -2920,14 +2914,12 @@ func (rws *responseWriterState) writeHeader(code int) { h.Del("Transfer-Encoding") } - if rws.conn.writeHeaders(rws.stream, &writeResHeaders{ + rws.conn.writeHeaders(rws.stream, &writeResHeaders{ streamID: rws.stream.id, httpResCode: code, h: h, endStream: rws.handlerDone && !rws.hasTrailers(), - }) != nil { - rws.dirty = true - } + }) return } @@ -2992,19 +2984,10 @@ func (w *responseWriter) write(lenData int, dataB []byte, dataS string) (n int, func (w *responseWriter) handlerDone() { rws := w.rws - dirty := rws.dirty rws.handlerDone = true w.Flush() w.rws = nil - if !dirty { - // Only recycle the pool if all prior Write calls to - // the serverConn goroutine completed successfully. If - // they returned earlier due to resets from the peer - // there might still be write goroutines outstanding - // from the serverConn referencing the rws memory. See - // issue 20704. - responseWriterStatePool.Put(rws) - } + responseWriterStatePool.Put(rws) } // Push errors. @@ -3187,6 +3170,7 @@ func (sc *serverConn) startPush(msg *startPushRequest) { panic(fmt.Sprintf("newWriterAndRequestNoBody(%+v): %v", msg.url, err)) } + sc.curHandlers++ go sc.runHandler(rw, req, sc.handler.ServeHTTP) return promisedID, nil } diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index 4515b22c4..df578b86c 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -1018,7 +1018,7 @@ func (cc *ClientConn) forceCloseConn() { if !ok { return } - if nc := tlsUnderlyingConn(tc); nc != nil { + if nc := tc.NetConn(); nc != nil { nc.Close() } } @@ -3201,3 +3201,34 @@ func traceFirstResponseByte(trace *httptrace.ClientTrace) { trace.GotFirstResponseByte() } } + +func traceHasWroteHeaderField(trace *httptrace.ClientTrace) bool { + return trace != nil && trace.WroteHeaderField != nil +} + +func traceWroteHeaderField(trace *httptrace.ClientTrace, k, v string) { + if trace != nil && trace.WroteHeaderField != nil { + trace.WroteHeaderField(k, []string{v}) + } +} + +func traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.MIMEHeader) error { + if trace != nil { + return trace.Got1xxResponse + } + return nil +} + +// dialTLSWithContext uses tls.Dialer, added in Go 1.15, to open a TLS +// connection. +func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) { + dialer := &tls.Dialer{ + Config: cfg, + } + cn, err := dialer.DialContext(ctx, network, addr) + if err != nil { + return nil, err + } + tlsCn := cn.(*tls.Conn) // DialContext comment promises this will always succeed + return tlsCn, nil +} diff --git a/vendor/golang.org/x/net/idna/go118.go b/vendor/golang.org/x/net/idna/go118.go index c5c4338db..712f1ad83 100644 --- a/vendor/golang.org/x/net/idna/go118.go +++ b/vendor/golang.org/x/net/idna/go118.go @@ -5,7 +5,6 @@ // license that can be found in the LICENSE file. //go:build go1.18 -// +build go1.18 package idna diff --git a/vendor/golang.org/x/net/idna/idna10.0.0.go b/vendor/golang.org/x/net/idna/idna10.0.0.go index 64ccf85fe..7b3717884 100644 --- a/vendor/golang.org/x/net/idna/idna10.0.0.go +++ b/vendor/golang.org/x/net/idna/idna10.0.0.go @@ -5,7 +5,6 @@ // license that can be found in the LICENSE file. //go:build go1.10 -// +build go1.10 // Package idna implements IDNA2008 using the compatibility processing // defined by UTS (Unicode Technical Standard) #46, which defines a standard to diff --git a/vendor/golang.org/x/net/idna/idna9.0.0.go b/vendor/golang.org/x/net/idna/idna9.0.0.go index ee1698cef..cc6a892a4 100644 --- a/vendor/golang.org/x/net/idna/idna9.0.0.go +++ b/vendor/golang.org/x/net/idna/idna9.0.0.go @@ -5,7 +5,6 @@ // license that can be found in the LICENSE file. //go:build !go1.10 -// +build !go1.10 // Package idna implements IDNA2008 using the compatibility processing // defined by UTS (Unicode Technical Standard) #46, which defines a standard to diff --git a/vendor/golang.org/x/net/idna/pre_go118.go b/vendor/golang.org/x/net/idna/pre_go118.go index 3aaccab1c..40e74bb3d 100644 --- a/vendor/golang.org/x/net/idna/pre_go118.go +++ b/vendor/golang.org/x/net/idna/pre_go118.go @@ -5,7 +5,6 @@ // license that can be found in the LICENSE file. //go:build !go1.18 -// +build !go1.18 package idna diff --git a/vendor/golang.org/x/net/idna/tables10.0.0.go b/vendor/golang.org/x/net/idna/tables10.0.0.go index d1d62ef45..c6c2bf10a 100644 --- a/vendor/golang.org/x/net/idna/tables10.0.0.go +++ b/vendor/golang.org/x/net/idna/tables10.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.10 && !go1.13 -// +build go1.10,!go1.13 package idna diff --git a/vendor/golang.org/x/net/idna/tables11.0.0.go b/vendor/golang.org/x/net/idna/tables11.0.0.go index 167efba71..76789393c 100644 --- a/vendor/golang.org/x/net/idna/tables11.0.0.go +++ b/vendor/golang.org/x/net/idna/tables11.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.13 && !go1.14 -// +build go1.13,!go1.14 package idna diff --git a/vendor/golang.org/x/net/idna/tables12.0.0.go b/vendor/golang.org/x/net/idna/tables12.0.0.go index ab40f7bcc..0600cd2ae 100644 --- a/vendor/golang.org/x/net/idna/tables12.0.0.go +++ b/vendor/golang.org/x/net/idna/tables12.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.14 && !go1.16 -// +build go1.14,!go1.16 package idna diff --git a/vendor/golang.org/x/net/idna/tables13.0.0.go b/vendor/golang.org/x/net/idna/tables13.0.0.go index 66701eadf..2fb768ef6 100644 --- a/vendor/golang.org/x/net/idna/tables13.0.0.go +++ b/vendor/golang.org/x/net/idna/tables13.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.16 && !go1.21 -// +build go1.16,!go1.21 package idna diff --git a/vendor/golang.org/x/net/idna/tables15.0.0.go b/vendor/golang.org/x/net/idna/tables15.0.0.go index 40033778f..5ff05fe1a 100644 --- a/vendor/golang.org/x/net/idna/tables15.0.0.go +++ b/vendor/golang.org/x/net/idna/tables15.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.21 -// +build go1.21 package idna diff --git a/vendor/golang.org/x/net/idna/tables9.0.0.go b/vendor/golang.org/x/net/idna/tables9.0.0.go index 4074b5332..0f25e84ca 100644 --- a/vendor/golang.org/x/net/idna/tables9.0.0.go +++ b/vendor/golang.org/x/net/idna/tables9.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build !go1.10 -// +build !go1.10 package idna diff --git a/vendor/golang.org/x/net/idna/trie12.0.0.go b/vendor/golang.org/x/net/idna/trie12.0.0.go index bb63f904b..8a75b9667 100644 --- a/vendor/golang.org/x/net/idna/trie12.0.0.go +++ b/vendor/golang.org/x/net/idna/trie12.0.0.go @@ -5,7 +5,6 @@ // license that can be found in the LICENSE file. //go:build !go1.16 -// +build !go1.16 package idna diff --git a/vendor/golang.org/x/net/idna/trie13.0.0.go b/vendor/golang.org/x/net/idna/trie13.0.0.go index 7d68a8dc1..fa45bb907 100644 --- a/vendor/golang.org/x/net/idna/trie13.0.0.go +++ b/vendor/golang.org/x/net/idna/trie13.0.0.go @@ -5,7 +5,6 @@ // license that can be found in the LICENSE file. //go:build go1.16 -// +build go1.16 package idna diff --git a/vendor/golang.org/x/oauth2/clientcredentials/clientcredentials.go b/vendor/golang.org/x/oauth2/clientcredentials/clientcredentials.go new file mode 100644 index 000000000..2459d069f --- /dev/null +++ b/vendor/golang.org/x/oauth2/clientcredentials/clientcredentials.go @@ -0,0 +1,124 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package clientcredentials implements the OAuth2.0 "client credentials" token flow, +// also known as the "two-legged OAuth 2.0". +// +// This should be used when the client is acting on its own behalf or when the client +// is the resource owner. It may also be used when requesting access to protected +// resources based on an authorization previously arranged with the authorization +// server. +// +// See https://tools.ietf.org/html/rfc6749#section-4.4 +package clientcredentials // import "golang.org/x/oauth2/clientcredentials" + +import ( + "context" + "fmt" + "net/http" + "net/url" + "strings" + + "golang.org/x/oauth2" + "golang.org/x/oauth2/internal" +) + +// Config describes a 2-legged OAuth2 flow, with both the +// client application information and the server's endpoint URLs. +type Config struct { + // ClientID is the application's ID. + ClientID string + + // ClientSecret is the application's secret. + ClientSecret string + + // TokenURL is the resource server's token endpoint + // URL. This is a constant specific to each server. + TokenURL string + + // Scope specifies optional requested permissions. + Scopes []string + + // EndpointParams specifies additional parameters for requests to the token endpoint. + EndpointParams url.Values + + // AuthStyle optionally specifies how the endpoint wants the + // client ID & client secret sent. The zero value means to + // auto-detect. + AuthStyle oauth2.AuthStyle + + // authStyleCache caches which auth style to use when Endpoint.AuthStyle is + // the zero value (AuthStyleAutoDetect). + authStyleCache internal.LazyAuthStyleCache +} + +// Token uses client credentials to retrieve a token. +// +// The provided context optionally controls which HTTP client is used. See the oauth2.HTTPClient variable. +func (c *Config) Token(ctx context.Context) (*oauth2.Token, error) { + return c.TokenSource(ctx).Token() +} + +// Client returns an HTTP client using the provided token. +// The token will auto-refresh as necessary. +// +// The provided context optionally controls which HTTP client +// is returned. See the oauth2.HTTPClient variable. +// +// The returned Client and its Transport should not be modified. +func (c *Config) Client(ctx context.Context) *http.Client { + return oauth2.NewClient(ctx, c.TokenSource(ctx)) +} + +// TokenSource returns a TokenSource that returns t until t expires, +// automatically refreshing it as necessary using the provided context and the +// client ID and client secret. +// +// Most users will use Config.Client instead. +func (c *Config) TokenSource(ctx context.Context) oauth2.TokenSource { + source := &tokenSource{ + ctx: ctx, + conf: c, + } + return oauth2.ReuseTokenSource(nil, source) +} + +type tokenSource struct { + ctx context.Context + conf *Config +} + +// Token refreshes the token by using a new client credentials request. +// tokens received this way do not include a refresh token +func (c *tokenSource) Token() (*oauth2.Token, error) { + v := url.Values{ + "grant_type": {"client_credentials"}, + } + if len(c.conf.Scopes) > 0 { + v.Set("scope", strings.Join(c.conf.Scopes, " ")) + } + for k, p := range c.conf.EndpointParams { + // Allow grant_type to be overridden to allow interoperability with + // non-compliant implementations. + if _, ok := v[k]; ok && k != "grant_type" { + return nil, fmt.Errorf("oauth2: cannot overwrite parameter %q", k) + } + v[k] = p + } + + tk, err := internal.RetrieveToken(c.ctx, c.conf.ClientID, c.conf.ClientSecret, c.conf.TokenURL, v, internal.AuthStyle(c.conf.AuthStyle), c.conf.authStyleCache.Get()) + if err != nil { + if rErr, ok := err.(*internal.RetrieveError); ok { + return nil, (*oauth2.RetrieveError)(rErr) + } + return nil, err + } + t := &oauth2.Token{ + AccessToken: tk.AccessToken, + TokenType: tk.TokenType, + RefreshToken: tk.RefreshToken, + Expiry: tk.Expiry, + } + return t.WithExtra(tk.Raw), nil +} diff --git a/vendor/golang.org/x/oauth2/deviceauth.go b/vendor/golang.org/x/oauth2/deviceauth.go new file mode 100644 index 000000000..e99c92f39 --- /dev/null +++ b/vendor/golang.org/x/oauth2/deviceauth.go @@ -0,0 +1,198 @@ +package oauth2 + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "strings" + "time" + + "golang.org/x/oauth2/internal" +) + +// https://datatracker.ietf.org/doc/html/rfc8628#section-3.5 +const ( + errAuthorizationPending = "authorization_pending" + errSlowDown = "slow_down" + errAccessDenied = "access_denied" + errExpiredToken = "expired_token" +) + +// DeviceAuthResponse describes a successful RFC 8628 Device Authorization Response +// https://datatracker.ietf.org/doc/html/rfc8628#section-3.2 +type DeviceAuthResponse struct { + // DeviceCode + DeviceCode string `json:"device_code"` + // UserCode is the code the user should enter at the verification uri + UserCode string `json:"user_code"` + // VerificationURI is where user should enter the user code + VerificationURI string `json:"verification_uri"` + // VerificationURIComplete (if populated) includes the user code in the verification URI. This is typically shown to the user in non-textual form, such as a QR code. + VerificationURIComplete string `json:"verification_uri_complete,omitempty"` + // Expiry is when the device code and user code expire + Expiry time.Time `json:"expires_in,omitempty"` + // Interval is the duration in seconds that Poll should wait between requests + Interval int64 `json:"interval,omitempty"` +} + +func (d DeviceAuthResponse) MarshalJSON() ([]byte, error) { + type Alias DeviceAuthResponse + var expiresIn int64 + if !d.Expiry.IsZero() { + expiresIn = int64(time.Until(d.Expiry).Seconds()) + } + return json.Marshal(&struct { + ExpiresIn int64 `json:"expires_in,omitempty"` + *Alias + }{ + ExpiresIn: expiresIn, + Alias: (*Alias)(&d), + }) + +} + +func (c *DeviceAuthResponse) UnmarshalJSON(data []byte) error { + type Alias DeviceAuthResponse + aux := &struct { + ExpiresIn int64 `json:"expires_in"` + // workaround misspelling of verification_uri + VerificationURL string `json:"verification_url"` + *Alias + }{ + Alias: (*Alias)(c), + } + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + if aux.ExpiresIn != 0 { + c.Expiry = time.Now().UTC().Add(time.Second * time.Duration(aux.ExpiresIn)) + } + if c.VerificationURI == "" { + c.VerificationURI = aux.VerificationURL + } + return nil +} + +// DeviceAuth returns a device auth struct which contains a device code +// and authorization information provided for users to enter on another device. +func (c *Config) DeviceAuth(ctx context.Context, opts ...AuthCodeOption) (*DeviceAuthResponse, error) { + // https://datatracker.ietf.org/doc/html/rfc8628#section-3.1 + v := url.Values{ + "client_id": {c.ClientID}, + } + if len(c.Scopes) > 0 { + v.Set("scope", strings.Join(c.Scopes, " ")) + } + for _, opt := range opts { + opt.setValue(v) + } + return retrieveDeviceAuth(ctx, c, v) +} + +func retrieveDeviceAuth(ctx context.Context, c *Config, v url.Values) (*DeviceAuthResponse, error) { + if c.Endpoint.DeviceAuthURL == "" { + return nil, errors.New("endpoint missing DeviceAuthURL") + } + + req, err := http.NewRequest("POST", c.Endpoint.DeviceAuthURL, strings.NewReader(v.Encode())) + if err != nil { + return nil, err + } + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + req.Header.Set("Accept", "application/json") + + t := time.Now() + r, err := internal.ContextClient(ctx).Do(req) + if err != nil { + return nil, err + } + + body, err := io.ReadAll(io.LimitReader(r.Body, 1<<20)) + if err != nil { + return nil, fmt.Errorf("oauth2: cannot auth device: %v", err) + } + if code := r.StatusCode; code < 200 || code > 299 { + return nil, &RetrieveError{ + Response: r, + Body: body, + } + } + + da := &DeviceAuthResponse{} + err = json.Unmarshal(body, &da) + if err != nil { + return nil, fmt.Errorf("unmarshal %s", err) + } + + if !da.Expiry.IsZero() { + // Make a small adjustment to account for time taken by the request + da.Expiry = da.Expiry.Add(-time.Since(t)) + } + + return da, nil +} + +// DeviceAccessToken polls the server to exchange a device code for a token. +func (c *Config) DeviceAccessToken(ctx context.Context, da *DeviceAuthResponse, opts ...AuthCodeOption) (*Token, error) { + if !da.Expiry.IsZero() { + var cancel context.CancelFunc + ctx, cancel = context.WithDeadline(ctx, da.Expiry) + defer cancel() + } + + // https://datatracker.ietf.org/doc/html/rfc8628#section-3.4 + v := url.Values{ + "client_id": {c.ClientID}, + "grant_type": {"urn:ietf:params:oauth:grant-type:device_code"}, + "device_code": {da.DeviceCode}, + } + if len(c.Scopes) > 0 { + v.Set("scope", strings.Join(c.Scopes, " ")) + } + for _, opt := range opts { + opt.setValue(v) + } + + // "If no value is provided, clients MUST use 5 as the default." + // https://datatracker.ietf.org/doc/html/rfc8628#section-3.2 + interval := da.Interval + if interval == 0 { + interval = 5 + } + + ticker := time.NewTicker(time.Duration(interval) * time.Second) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return nil, ctx.Err() + case <-ticker.C: + tok, err := retrieveToken(ctx, c, v) + if err == nil { + return tok, nil + } + + e, ok := err.(*RetrieveError) + if !ok { + return nil, err + } + switch e.ErrorCode { + case errSlowDown: + // https://datatracker.ietf.org/doc/html/rfc8628#section-3.5 + // "the interval MUST be increased by 5 seconds for this and all subsequent requests" + interval += 5 + ticker.Reset(time.Duration(interval) * time.Second) + case errAuthorizationPending: + // Do nothing. + case errAccessDenied, errExpiredToken: + fallthrough + default: + return tok, err + } + } + } +} diff --git a/vendor/golang.org/x/oauth2/google/default.go b/vendor/golang.org/x/oauth2/google/default.go index 2cf71f0f9..12b12a30c 100644 --- a/vendor/golang.org/x/oauth2/google/default.go +++ b/vendor/golang.org/x/oauth2/google/default.go @@ -19,7 +19,10 @@ import ( "golang.org/x/oauth2/authhandler" ) -const adcSetupURL = "https://cloud.google.com/docs/authentication/external/set-up-adc" +const ( + adcSetupURL = "https://cloud.google.com/docs/authentication/external/set-up-adc" + universeDomainDefault = "googleapis.com" +) // Credentials holds Google credentials, including "Application Default Credentials". // For more details, see: @@ -37,6 +40,18 @@ type Credentials struct { // environment and not with a credentials file, e.g. when code is // running on Google Cloud Platform. JSON []byte + + // universeDomain is the default service domain for a given Cloud universe. + universeDomain string +} + +// UniverseDomain returns the default service domain for a given Cloud universe. +// The default value is "googleapis.com". +func (c *Credentials) UniverseDomain() string { + if c.universeDomain == "" { + return universeDomainDefault + } + return c.universeDomain } // DefaultCredentials is the old name of Credentials. @@ -200,15 +215,23 @@ func CredentialsFromJSONWithParams(ctx context.Context, jsonData []byte, params if err := json.Unmarshal(jsonData, &f); err != nil { return nil, err } + + universeDomain := f.UniverseDomain + // Authorized user credentials are only supported in the googleapis.com universe. + if f.Type == userCredentialsKey { + universeDomain = universeDomainDefault + } + ts, err := f.tokenSource(ctx, params) if err != nil { return nil, err } ts = newErrWrappingTokenSource(ts) return &Credentials{ - ProjectID: f.ProjectID, - TokenSource: ts, - JSON: jsonData, + ProjectID: f.ProjectID, + TokenSource: ts, + JSON: jsonData, + universeDomain: universeDomain, }, nil } diff --git a/vendor/golang.org/x/oauth2/google/doc.go b/vendor/golang.org/x/oauth2/google/doc.go index ca717634a..03c42c6f8 100644 --- a/vendor/golang.org/x/oauth2/google/doc.go +++ b/vendor/golang.org/x/oauth2/google/doc.go @@ -101,6 +101,8 @@ // executable-sourced credentials), please check out: // https://cloud.google.com/iam/docs/workforce-obtaining-short-lived-credentials#generate_a_configuration_file_for_non-interactive_sign-in // +// # Security considerations +// // Note that this library does not perform any validation on the token_url, token_info_url, // or service_account_impersonation_url fields of the credential configuration. // It is not recommended to use a credential configuration that you did not generate with diff --git a/vendor/golang.org/x/oauth2/google/google.go b/vendor/golang.org/x/oauth2/google/google.go index cc1223889..c66c53527 100644 --- a/vendor/golang.org/x/oauth2/google/google.go +++ b/vendor/golang.org/x/oauth2/google/google.go @@ -16,14 +16,16 @@ import ( "cloud.google.com/go/compute/metadata" "golang.org/x/oauth2" "golang.org/x/oauth2/google/internal/externalaccount" + "golang.org/x/oauth2/google/internal/externalaccountauthorizeduser" "golang.org/x/oauth2/jwt" ) // Endpoint is Google's OAuth 2.0 default endpoint. var Endpoint = oauth2.Endpoint{ - AuthURL: "https://accounts.google.com/o/oauth2/auth", - TokenURL: "https://oauth2.googleapis.com/token", - AuthStyle: oauth2.AuthStyleInParams, + AuthURL: "https://accounts.google.com/o/oauth2/auth", + TokenURL: "https://oauth2.googleapis.com/token", + DeviceAuthURL: "https://oauth2.googleapis.com/device/code", + AuthStyle: oauth2.AuthStyleInParams, } // MTLSTokenURL is Google's OAuth 2.0 default mTLS endpoint. @@ -95,10 +97,11 @@ func JWTConfigFromJSON(jsonKey []byte, scope ...string) (*jwt.Config, error) { // JSON key file types. const ( - serviceAccountKey = "service_account" - userCredentialsKey = "authorized_user" - externalAccountKey = "external_account" - impersonatedServiceAccount = "impersonated_service_account" + serviceAccountKey = "service_account" + userCredentialsKey = "authorized_user" + externalAccountKey = "external_account" + externalAccountAuthorizedUserKey = "external_account_authorized_user" + impersonatedServiceAccount = "impersonated_service_account" ) // credentialsFile is the unmarshalled representation of a credentials file. @@ -106,12 +109,13 @@ type credentialsFile struct { Type string `json:"type"` // Service Account fields - ClientEmail string `json:"client_email"` - PrivateKeyID string `json:"private_key_id"` - PrivateKey string `json:"private_key"` - AuthURL string `json:"auth_uri"` - TokenURL string `json:"token_uri"` - ProjectID string `json:"project_id"` + ClientEmail string `json:"client_email"` + PrivateKeyID string `json:"private_key_id"` + PrivateKey string `json:"private_key"` + AuthURL string `json:"auth_uri"` + TokenURL string `json:"token_uri"` + ProjectID string `json:"project_id"` + UniverseDomain string `json:"universe_domain"` // User Credential fields // (These typically come from gcloud auth.) @@ -131,6 +135,9 @@ type credentialsFile struct { QuotaProjectID string `json:"quota_project_id"` WorkforcePoolUserProject string `json:"workforce_pool_user_project"` + // External Account Authorized User fields + RevokeURL string `json:"revoke_url"` + // Service account impersonation SourceCredentials *credentialsFile `json:"source_credentials"` } @@ -199,6 +206,19 @@ func (f *credentialsFile) tokenSource(ctx context.Context, params CredentialsPar WorkforcePoolUserProject: f.WorkforcePoolUserProject, } return cfg.TokenSource(ctx) + case externalAccountAuthorizedUserKey: + cfg := &externalaccountauthorizeduser.Config{ + Audience: f.Audience, + RefreshToken: f.RefreshToken, + TokenURL: f.TokenURLExternal, + TokenInfoURL: f.TokenInfoURL, + ClientID: f.ClientID, + ClientSecret: f.ClientSecret, + RevokeURL: f.RevokeURL, + QuotaProjectID: f.QuotaProjectID, + Scopes: params.Scopes, + } + return cfg.TokenSource(ctx) case impersonatedServiceAccount: if f.ServiceAccountImpersonationURL == "" || f.SourceCredentials == nil { return nil, errors.New("missing 'source_credentials' field or 'service_account_impersonation_url' in credentials") diff --git a/vendor/golang.org/x/oauth2/google/internal/externalaccount/aws.go b/vendor/golang.org/x/oauth2/google/internal/externalaccount/aws.go index 2bf3202b2..bd4efd19b 100644 --- a/vendor/golang.org/x/oauth2/google/internal/externalaccount/aws.go +++ b/vendor/golang.org/x/oauth2/google/internal/externalaccount/aws.go @@ -274,49 +274,6 @@ type awsRequest struct { Headers []awsRequestHeader `json:"headers"` } -func (cs awsCredentialSource) validateMetadataServers() error { - if err := cs.validateMetadataServer(cs.RegionURL, "region_url"); err != nil { - return err - } - if err := cs.validateMetadataServer(cs.CredVerificationURL, "url"); err != nil { - return err - } - return cs.validateMetadataServer(cs.IMDSv2SessionTokenURL, "imdsv2_session_token_url") -} - -var validHostnames []string = []string{"169.254.169.254", "fd00:ec2::254"} - -func (cs awsCredentialSource) isValidMetadataServer(metadataUrl string) bool { - if metadataUrl == "" { - // Zero value means use default, which is valid. - return true - } - - u, err := url.Parse(metadataUrl) - if err != nil { - // Unparseable URL means invalid - return false - } - - for _, validHostname := range validHostnames { - if u.Hostname() == validHostname { - // If it's one of the valid hostnames, everything is good - return true - } - } - - // hostname not found in our allowlist, so not valid - return false -} - -func (cs awsCredentialSource) validateMetadataServer(metadataUrl, urlName string) error { - if !cs.isValidMetadataServer(metadataUrl) { - return fmt.Errorf("oauth2/google: invalid hostname %s for %s", metadataUrl, urlName) - } - - return nil -} - func (cs awsCredentialSource) doRequest(req *http.Request) (*http.Response, error) { if cs.client == nil { cs.client = oauth2.NewClient(cs.ctx, nil) @@ -339,6 +296,10 @@ func shouldUseMetadataServer() bool { return !canRetrieveRegionFromEnvironment() || !canRetrieveSecurityCredentialFromEnvironment() } +func (cs awsCredentialSource) credentialSourceType() string { + return "aws" +} + func (cs awsCredentialSource) subjectToken() (string, error) { if cs.requestSigner == nil { headers := make(map[string]string) diff --git a/vendor/golang.org/x/oauth2/google/internal/externalaccount/basecredentials.go b/vendor/golang.org/x/oauth2/google/internal/externalaccount/basecredentials.go index dcd252a61..33288d367 100644 --- a/vendor/golang.org/x/oauth2/google/internal/externalaccount/basecredentials.go +++ b/vendor/golang.org/x/oauth2/google/internal/externalaccount/basecredentials.go @@ -8,13 +8,12 @@ import ( "context" "fmt" "net/http" - "net/url" "regexp" "strconv" - "strings" "time" "golang.org/x/oauth2" + "golang.org/x/oauth2/google/internal/stsexchange" ) // now aliases time.Now for testing @@ -63,31 +62,10 @@ type Config struct { WorkforcePoolUserProject string } -// Each element consists of a list of patterns. validateURLs checks for matches -// that include all elements in a given list, in that order. - var ( validWorkforceAudiencePattern *regexp.Regexp = regexp.MustCompile(`//iam\.googleapis\.com/locations/[^/]+/workforcePools/`) ) -func validateURL(input string, patterns []*regexp.Regexp, scheme string) bool { - parsed, err := url.Parse(input) - if err != nil { - return false - } - if !strings.EqualFold(parsed.Scheme, scheme) { - return false - } - toTest := parsed.Host - - for _, pattern := range patterns { - if pattern.MatchString(toTest) { - return true - } - } - return false -} - func validateWorkforceAudience(input string) bool { return validWorkforceAudiencePattern.MatchString(input) } @@ -185,10 +163,6 @@ func (c *Config) parse(ctx context.Context) (baseCredentialSource, error) { awsCredSource.IMDSv2SessionTokenURL = c.CredentialSource.IMDSv2SessionTokenURL } - if err := awsCredSource.validateMetadataServers(); err != nil { - return nil, err - } - return awsCredSource, nil } } else if c.CredentialSource.File != "" { @@ -202,6 +176,7 @@ func (c *Config) parse(ctx context.Context) (baseCredentialSource, error) { } type baseCredentialSource interface { + credentialSourceType() string subjectToken() (string, error) } @@ -211,6 +186,15 @@ type tokenSource struct { conf *Config } +func getMetricsHeaderValue(conf *Config, credSource baseCredentialSource) string { + return fmt.Sprintf("gl-go/%s auth/%s google-byoid-sdk source/%s sa-impersonation/%t config-lifetime/%t", + goVersion(), + "unknown", + credSource.credentialSourceType(), + conf.ServiceAccountImpersonationURL != "", + conf.ServiceAccountImpersonationLifetimeSeconds != 0) +} + // Token allows tokenSource to conform to the oauth2.TokenSource interface. func (ts tokenSource) Token() (*oauth2.Token, error) { conf := ts.conf @@ -224,7 +208,7 @@ func (ts tokenSource) Token() (*oauth2.Token, error) { if err != nil { return nil, err } - stsRequest := stsTokenExchangeRequest{ + stsRequest := stsexchange.TokenExchangeRequest{ GrantType: "urn:ietf:params:oauth:grant-type:token-exchange", Audience: conf.Audience, Scope: conf.Scopes, @@ -234,7 +218,8 @@ func (ts tokenSource) Token() (*oauth2.Token, error) { } header := make(http.Header) header.Add("Content-Type", "application/x-www-form-urlencoded") - clientAuth := clientAuthentication{ + header.Add("x-goog-api-client", getMetricsHeaderValue(conf, credSource)) + clientAuth := stsexchange.ClientAuthentication{ AuthStyle: oauth2.AuthStyleInHeader, ClientID: conf.ClientID, ClientSecret: conf.ClientSecret, @@ -247,7 +232,7 @@ func (ts tokenSource) Token() (*oauth2.Token, error) { "userProject": conf.WorkforcePoolUserProject, } } - stsResp, err := exchangeToken(ts.ctx, conf.TokenURL, &stsRequest, clientAuth, header, options) + stsResp, err := stsexchange.ExchangeToken(ts.ctx, conf.TokenURL, &stsRequest, clientAuth, header, options) if err != nil { return nil, err } diff --git a/vendor/golang.org/x/oauth2/google/internal/externalaccount/executablecredsource.go b/vendor/golang.org/x/oauth2/google/internal/externalaccount/executablecredsource.go index 579bcce5f..6497dc022 100644 --- a/vendor/golang.org/x/oauth2/google/internal/externalaccount/executablecredsource.go +++ b/vendor/golang.org/x/oauth2/google/internal/externalaccount/executablecredsource.go @@ -233,6 +233,10 @@ func (cs executableCredentialSource) parseSubjectTokenFromSource(response []byte return "", tokenTypeError(source) } +func (cs executableCredentialSource) credentialSourceType() string { + return "executable" +} + func (cs executableCredentialSource) subjectToken() (string, error) { if token, err := cs.getTokenFromOutputFile(); token != "" || err != nil { return token, err diff --git a/vendor/golang.org/x/oauth2/google/internal/externalaccount/filecredsource.go b/vendor/golang.org/x/oauth2/google/internal/externalaccount/filecredsource.go index e953ddb47..f35f73c5c 100644 --- a/vendor/golang.org/x/oauth2/google/internal/externalaccount/filecredsource.go +++ b/vendor/golang.org/x/oauth2/google/internal/externalaccount/filecredsource.go @@ -19,6 +19,10 @@ type fileCredentialSource struct { Format format } +func (cs fileCredentialSource) credentialSourceType() string { + return "file" +} + func (cs fileCredentialSource) subjectToken() (string, error) { tokenFile, err := os.Open(cs.File) if err != nil { diff --git a/vendor/golang.org/x/oauth2/google/internal/externalaccount/header.go b/vendor/golang.org/x/oauth2/google/internal/externalaccount/header.go new file mode 100644 index 000000000..1d5aad2e2 --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/internal/externalaccount/header.go @@ -0,0 +1,64 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package externalaccount + +import ( + "runtime" + "strings" + "unicode" +) + +var ( + // version is a package internal global variable for testing purposes. + version = runtime.Version +) + +// versionUnknown is only used when the runtime version cannot be determined. +const versionUnknown = "UNKNOWN" + +// goVersion returns a Go runtime version derived from the runtime environment +// that is modified to be suitable for reporting in a header, meaning it has no +// whitespace. If it is unable to determine the Go runtime version, it returns +// versionUnknown. +func goVersion() string { + const develPrefix = "devel +" + + s := version() + if strings.HasPrefix(s, develPrefix) { + s = s[len(develPrefix):] + if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { + s = s[:p] + } + return s + } else if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { + s = s[:p] + } + + notSemverRune := func(r rune) bool { + return !strings.ContainsRune("0123456789.", r) + } + + if strings.HasPrefix(s, "go1") { + s = s[2:] + var prerelease string + if p := strings.IndexFunc(s, notSemverRune); p >= 0 { + s, prerelease = s[:p], s[p:] + } + if strings.HasSuffix(s, ".") { + s += "0" + } else if strings.Count(s, ".") < 2 { + s += ".0" + } + if prerelease != "" { + // Some release candidates already have a dash in them. + if !strings.HasPrefix(prerelease, "-") { + prerelease = "-" + prerelease + } + s += prerelease + } + return s + } + return "UNKNOWN" +} diff --git a/vendor/golang.org/x/oauth2/google/internal/externalaccount/urlcredsource.go b/vendor/golang.org/x/oauth2/google/internal/externalaccount/urlcredsource.go index 16dca6541..606bb4e80 100644 --- a/vendor/golang.org/x/oauth2/google/internal/externalaccount/urlcredsource.go +++ b/vendor/golang.org/x/oauth2/google/internal/externalaccount/urlcredsource.go @@ -23,6 +23,10 @@ type urlCredentialSource struct { ctx context.Context } +func (cs urlCredentialSource) credentialSourceType() string { + return "url" +} + func (cs urlCredentialSource) subjectToken() (string, error) { client := oauth2.NewClient(cs.ctx, nil) req, err := http.NewRequest("GET", cs.URL, nil) diff --git a/vendor/golang.org/x/oauth2/google/internal/externalaccountauthorizeduser/externalaccountauthorizeduser.go b/vendor/golang.org/x/oauth2/google/internal/externalaccountauthorizeduser/externalaccountauthorizeduser.go new file mode 100644 index 000000000..cb5820707 --- /dev/null +++ b/vendor/golang.org/x/oauth2/google/internal/externalaccountauthorizeduser/externalaccountauthorizeduser.go @@ -0,0 +1,114 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package externalaccountauthorizeduser + +import ( + "context" + "errors" + "time" + + "golang.org/x/oauth2" + "golang.org/x/oauth2/google/internal/stsexchange" +) + +// now aliases time.Now for testing. +var now = func() time.Time { + return time.Now().UTC() +} + +var tokenValid = func(token oauth2.Token) bool { + return token.Valid() +} + +type Config struct { + // Audience is the Secure Token Service (STS) audience which contains the resource name for the workforce pool and + // the provider identifier in that pool. + Audience string + // RefreshToken is the optional OAuth 2.0 refresh token. If specified, credentials can be refreshed. + RefreshToken string + // TokenURL is the optional STS token exchange endpoint for refresh. Must be specified for refresh, can be left as + // None if the token can not be refreshed. + TokenURL string + // TokenInfoURL is the optional STS endpoint URL for token introspection. + TokenInfoURL string + // ClientID is only required in conjunction with ClientSecret, as described above. + ClientID string + // ClientSecret is currently only required if token_info endpoint also needs to be called with the generated GCP + // access token. When provided, STS will be called with additional basic authentication using client_id as username + // and client_secret as password. + ClientSecret string + // Token is the OAuth2.0 access token. Can be nil if refresh information is provided. + Token string + // Expiry is the optional expiration datetime of the OAuth 2.0 access token. + Expiry time.Time + // RevokeURL is the optional STS endpoint URL for revoking tokens. + RevokeURL string + // QuotaProjectID is the optional project ID used for quota and billing. This project may be different from the + // project used to create the credentials. + QuotaProjectID string + Scopes []string +} + +func (c *Config) canRefresh() bool { + return c.ClientID != "" && c.ClientSecret != "" && c.RefreshToken != "" && c.TokenURL != "" +} + +func (c *Config) TokenSource(ctx context.Context) (oauth2.TokenSource, error) { + var token oauth2.Token + if c.Token != "" && !c.Expiry.IsZero() { + token = oauth2.Token{ + AccessToken: c.Token, + Expiry: c.Expiry, + TokenType: "Bearer", + } + } + if !tokenValid(token) && !c.canRefresh() { + return nil, errors.New("oauth2/google: Token should be created with fields to make it valid (`token` and `expiry`), or fields to allow it to refresh (`refresh_token`, `token_url`, `client_id`, `client_secret`).") + } + + ts := tokenSource{ + ctx: ctx, + conf: c, + } + + return oauth2.ReuseTokenSource(&token, ts), nil +} + +type tokenSource struct { + ctx context.Context + conf *Config +} + +func (ts tokenSource) Token() (*oauth2.Token, error) { + conf := ts.conf + if !conf.canRefresh() { + return nil, errors.New("oauth2/google: The credentials do not contain the necessary fields need to refresh the access token. You must specify refresh_token, token_url, client_id, and client_secret.") + } + + clientAuth := stsexchange.ClientAuthentication{ + AuthStyle: oauth2.AuthStyleInHeader, + ClientID: conf.ClientID, + ClientSecret: conf.ClientSecret, + } + + stsResponse, err := stsexchange.RefreshAccessToken(ts.ctx, conf.TokenURL, conf.RefreshToken, clientAuth, nil) + if err != nil { + return nil, err + } + if stsResponse.ExpiresIn < 0 { + return nil, errors.New("oauth2/google: got invalid expiry from security token service") + } + + if stsResponse.RefreshToken != "" { + conf.RefreshToken = stsResponse.RefreshToken + } + + token := &oauth2.Token{ + AccessToken: stsResponse.AccessToken, + Expiry: now().Add(time.Duration(stsResponse.ExpiresIn) * time.Second), + TokenType: "Bearer", + } + return token, nil +} diff --git a/vendor/golang.org/x/oauth2/google/internal/externalaccount/clientauth.go b/vendor/golang.org/x/oauth2/google/internal/stsexchange/clientauth.go similarity index 88% rename from vendor/golang.org/x/oauth2/google/internal/externalaccount/clientauth.go rename to vendor/golang.org/x/oauth2/google/internal/stsexchange/clientauth.go index 99987ce29..ebd520eac 100644 --- a/vendor/golang.org/x/oauth2/google/internal/externalaccount/clientauth.go +++ b/vendor/golang.org/x/oauth2/google/internal/stsexchange/clientauth.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package externalaccount +package stsexchange import ( "encoding/base64" @@ -12,8 +12,8 @@ import ( "golang.org/x/oauth2" ) -// clientAuthentication represents an OAuth client ID and secret and the mechanism for passing these credentials as stated in rfc6749#2.3.1. -type clientAuthentication struct { +// ClientAuthentication represents an OAuth client ID and secret and the mechanism for passing these credentials as stated in rfc6749#2.3.1. +type ClientAuthentication struct { // AuthStyle can be either basic or request-body AuthStyle oauth2.AuthStyle ClientID string @@ -23,7 +23,7 @@ type clientAuthentication struct { // InjectAuthentication is used to add authentication to a Secure Token Service exchange // request. It modifies either the passed url.Values or http.Header depending on the desired // authentication format. -func (c *clientAuthentication) InjectAuthentication(values url.Values, headers http.Header) { +func (c *ClientAuthentication) InjectAuthentication(values url.Values, headers http.Header) { if c.ClientID == "" || c.ClientSecret == "" || values == nil || headers == nil { return } diff --git a/vendor/golang.org/x/oauth2/google/internal/externalaccount/sts_exchange.go b/vendor/golang.org/x/oauth2/google/internal/stsexchange/sts_exchange.go similarity index 68% rename from vendor/golang.org/x/oauth2/google/internal/externalaccount/sts_exchange.go rename to vendor/golang.org/x/oauth2/google/internal/stsexchange/sts_exchange.go index e6fcae5fc..1a0bebd15 100644 --- a/vendor/golang.org/x/oauth2/google/internal/externalaccount/sts_exchange.go +++ b/vendor/golang.org/x/oauth2/google/internal/stsexchange/sts_exchange.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package externalaccount +package stsexchange import ( "context" @@ -18,14 +18,17 @@ import ( "golang.org/x/oauth2" ) -// exchangeToken performs an oauth2 token exchange with the provided endpoint. +func defaultHeader() http.Header { + header := make(http.Header) + header.Add("Content-Type", "application/x-www-form-urlencoded") + return header +} + +// ExchangeToken performs an oauth2 token exchange with the provided endpoint. // The first 4 fields are all mandatory. headers can be used to pass additional // headers beyond the bare minimum required by the token exchange. options can // be used to pass additional JSON-structured options to the remote server. -func exchangeToken(ctx context.Context, endpoint string, request *stsTokenExchangeRequest, authentication clientAuthentication, headers http.Header, options map[string]interface{}) (*stsTokenExchangeResponse, error) { - - client := oauth2.NewClient(ctx, nil) - +func ExchangeToken(ctx context.Context, endpoint string, request *TokenExchangeRequest, authentication ClientAuthentication, headers http.Header, options map[string]interface{}) (*Response, error) { data := url.Values{} data.Set("audience", request.Audience) data.Set("grant_type", "urn:ietf:params:oauth:grant-type:token-exchange") @@ -41,13 +44,28 @@ func exchangeToken(ctx context.Context, endpoint string, request *stsTokenExchan data.Set("options", string(opts)) } + return makeRequest(ctx, endpoint, data, authentication, headers) +} + +func RefreshAccessToken(ctx context.Context, endpoint string, refreshToken string, authentication ClientAuthentication, headers http.Header) (*Response, error) { + data := url.Values{} + data.Set("grant_type", "refresh_token") + data.Set("refresh_token", refreshToken) + + return makeRequest(ctx, endpoint, data, authentication, headers) +} + +func makeRequest(ctx context.Context, endpoint string, data url.Values, authentication ClientAuthentication, headers http.Header) (*Response, error) { + if headers == nil { + headers = defaultHeader() + } + client := oauth2.NewClient(ctx, nil) authentication.InjectAuthentication(data, headers) encodedData := data.Encode() req, err := http.NewRequest("POST", endpoint, strings.NewReader(encodedData)) if err != nil { return nil, fmt.Errorf("oauth2/google: failed to properly build http request: %v", err) - } req = req.WithContext(ctx) for key, list := range headers { @@ -71,7 +89,7 @@ func exchangeToken(ctx context.Context, endpoint string, request *stsTokenExchan if c := resp.StatusCode; c < 200 || c > 299 { return nil, fmt.Errorf("oauth2/google: status code %d: %s", c, body) } - var stsResp stsTokenExchangeResponse + var stsResp Response err = json.Unmarshal(body, &stsResp) if err != nil { return nil, fmt.Errorf("oauth2/google: failed to unmarshal response body from Secure Token Server: %v", err) @@ -81,8 +99,8 @@ func exchangeToken(ctx context.Context, endpoint string, request *stsTokenExchan return &stsResp, nil } -// stsTokenExchangeRequest contains fields necessary to make an oauth2 token exchange. -type stsTokenExchangeRequest struct { +// TokenExchangeRequest contains fields necessary to make an oauth2 token exchange. +type TokenExchangeRequest struct { ActingParty struct { ActorToken string ActorTokenType string @@ -96,8 +114,8 @@ type stsTokenExchangeRequest struct { SubjectTokenType string } -// stsTokenExchangeResponse is used to decode the remote server response during an oauth2 token exchange. -type stsTokenExchangeResponse struct { +// Response is used to decode the remote server response during an oauth2 token exchange. +type Response struct { AccessToken string `json:"access_token"` IssuedTokenType string `json:"issued_token_type"` TokenType string `json:"token_type"` diff --git a/vendor/golang.org/x/oauth2/internal/token.go b/vendor/golang.org/x/oauth2/internal/token.go index 58901bda5..e83ddeef0 100644 --- a/vendor/golang.org/x/oauth2/internal/token.go +++ b/vendor/golang.org/x/oauth2/internal/token.go @@ -18,6 +18,7 @@ import ( "strconv" "strings" "sync" + "sync/atomic" "time" ) @@ -115,41 +116,60 @@ const ( AuthStyleInHeader AuthStyle = 2 ) -// authStyleCache is the set of tokenURLs we've successfully used via +// LazyAuthStyleCache is a backwards compatibility compromise to let Configs +// have a lazily-initialized AuthStyleCache. +// +// The two users of this, oauth2.Config and oauth2/clientcredentials.Config, +// both would ideally just embed an unexported AuthStyleCache but because both +// were historically allowed to be copied by value we can't retroactively add an +// uncopyable Mutex to them. +// +// We could use an atomic.Pointer, but that was added recently enough (in Go +// 1.18) that we'd break Go 1.17 users where the tests as of 2023-08-03 +// still pass. By using an atomic.Value, it supports both Go 1.17 and +// copying by value, even if that's not ideal. +type LazyAuthStyleCache struct { + v atomic.Value // of *AuthStyleCache +} + +func (lc *LazyAuthStyleCache) Get() *AuthStyleCache { + if c, ok := lc.v.Load().(*AuthStyleCache); ok { + return c + } + c := new(AuthStyleCache) + if !lc.v.CompareAndSwap(nil, c) { + c = lc.v.Load().(*AuthStyleCache) + } + return c +} + +// AuthStyleCache is the set of tokenURLs we've successfully used via // RetrieveToken and which style auth we ended up using. // It's called a cache, but it doesn't (yet?) shrink. It's expected that // the set of OAuth2 servers a program contacts over time is fixed and // small. -var authStyleCache struct { - sync.Mutex - m map[string]AuthStyle // keyed by tokenURL -} - -// ResetAuthCache resets the global authentication style cache used -// for AuthStyleUnknown token requests. -func ResetAuthCache() { - authStyleCache.Lock() - defer authStyleCache.Unlock() - authStyleCache.m = nil +type AuthStyleCache struct { + mu sync.Mutex + m map[string]AuthStyle // keyed by tokenURL } // lookupAuthStyle reports which auth style we last used with tokenURL // when calling RetrieveToken and whether we have ever done so. -func lookupAuthStyle(tokenURL string) (style AuthStyle, ok bool) { - authStyleCache.Lock() - defer authStyleCache.Unlock() - style, ok = authStyleCache.m[tokenURL] +func (c *AuthStyleCache) lookupAuthStyle(tokenURL string) (style AuthStyle, ok bool) { + c.mu.Lock() + defer c.mu.Unlock() + style, ok = c.m[tokenURL] return } // setAuthStyle adds an entry to authStyleCache, documented above. -func setAuthStyle(tokenURL string, v AuthStyle) { - authStyleCache.Lock() - defer authStyleCache.Unlock() - if authStyleCache.m == nil { - authStyleCache.m = make(map[string]AuthStyle) +func (c *AuthStyleCache) setAuthStyle(tokenURL string, v AuthStyle) { + c.mu.Lock() + defer c.mu.Unlock() + if c.m == nil { + c.m = make(map[string]AuthStyle) } - authStyleCache.m[tokenURL] = v + c.m[tokenURL] = v } // newTokenRequest returns a new *http.Request to retrieve a new token @@ -189,10 +209,10 @@ func cloneURLValues(v url.Values) url.Values { return v2 } -func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string, v url.Values, authStyle AuthStyle) (*Token, error) { +func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string, v url.Values, authStyle AuthStyle, styleCache *AuthStyleCache) (*Token, error) { needsAuthStyleProbe := authStyle == 0 if needsAuthStyleProbe { - if style, ok := lookupAuthStyle(tokenURL); ok { + if style, ok := styleCache.lookupAuthStyle(tokenURL); ok { authStyle = style needsAuthStyleProbe = false } else { @@ -222,7 +242,7 @@ func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string, token, err = doTokenRoundTrip(ctx, req) } if needsAuthStyleProbe && err == nil { - setAuthStyle(tokenURL, authStyle) + styleCache.setAuthStyle(tokenURL, authStyle) } // Don't overwrite `RefreshToken` with an empty value // if this was a token refreshing request. diff --git a/vendor/golang.org/x/oauth2/oauth2.go b/vendor/golang.org/x/oauth2/oauth2.go index 9085fabe3..90a2c3d6d 100644 --- a/vendor/golang.org/x/oauth2/oauth2.go +++ b/vendor/golang.org/x/oauth2/oauth2.go @@ -58,6 +58,10 @@ type Config struct { // Scope specifies optional requested permissions. Scopes []string + + // authStyleCache caches which auth style to use when Endpoint.AuthStyle is + // the zero value (AuthStyleAutoDetect). + authStyleCache internal.LazyAuthStyleCache } // A TokenSource is anything that can return a token. @@ -71,8 +75,9 @@ type TokenSource interface { // Endpoint represents an OAuth 2.0 provider's authorization and token // endpoint URLs. type Endpoint struct { - AuthURL string - TokenURL string + AuthURL string + DeviceAuthURL string + TokenURL string // AuthStyle optionally specifies how the endpoint wants the // client ID & client secret sent. The zero value means to @@ -139,15 +144,19 @@ func SetAuthURLParam(key, value string) AuthCodeOption { // AuthCodeURL returns a URL to OAuth 2.0 provider's consent page // that asks for permissions for the required scopes explicitly. // -// State is a token to protect the user from CSRF attacks. You must -// always provide a non-empty string and validate that it matches the -// state query parameter on your redirect callback. -// See http://tools.ietf.org/html/rfc6749#section-10.12 for more info. +// State is an opaque value used by the client to maintain state between the +// request and callback. The authorization server includes this value when +// redirecting the user agent back to the client. // // Opts may include AccessTypeOnline or AccessTypeOffline, as well // as ApprovalForce. -// It can also be used to pass the PKCE challenge. -// See https://www.oauth.com/oauth2-servers/pkce/ for more info. +// +// To protect against CSRF attacks, opts should include a PKCE challenge +// (S256ChallengeOption). Not all servers support PKCE. An alternative is to +// generate a random state parameter and verify it after exchange. +// See https://datatracker.ietf.org/doc/html/rfc6749#section-10.12 (predating +// PKCE), https://www.oauth.com/oauth2-servers/pkce/ and +// https://www.ietf.org/archive/id/draft-ietf-oauth-v2-1-09.html#name-cross-site-request-forgery (describing both approaches) func (c *Config) AuthCodeURL(state string, opts ...AuthCodeOption) string { var buf bytes.Buffer buf.WriteString(c.Endpoint.AuthURL) @@ -162,7 +171,6 @@ func (c *Config) AuthCodeURL(state string, opts ...AuthCodeOption) string { v.Set("scope", strings.Join(c.Scopes, " ")) } if state != "" { - // TODO(light): Docs say never to omit state; don't allow empty. v.Set("state", state) } for _, opt := range opts { @@ -207,10 +215,11 @@ func (c *Config) PasswordCredentialsToken(ctx context.Context, username, passwor // The provided context optionally controls which HTTP client is used. See the HTTPClient variable. // // The code will be in the *http.Request.FormValue("code"). Before -// calling Exchange, be sure to validate FormValue("state"). +// calling Exchange, be sure to validate FormValue("state") if you are +// using it to protect against CSRF attacks. // -// Opts may include the PKCE verifier code if previously used in AuthCodeURL. -// See https://www.oauth.com/oauth2-servers/pkce/ for more info. +// If using PKCE to protect against CSRF attacks, opts should include a +// VerifierOption. func (c *Config) Exchange(ctx context.Context, code string, opts ...AuthCodeOption) (*Token, error) { v := url.Values{ "grant_type": {"authorization_code"}, diff --git a/vendor/golang.org/x/oauth2/pkce.go b/vendor/golang.org/x/oauth2/pkce.go new file mode 100644 index 000000000..50593b6df --- /dev/null +++ b/vendor/golang.org/x/oauth2/pkce.go @@ -0,0 +1,68 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +package oauth2 + +import ( + "crypto/rand" + "crypto/sha256" + "encoding/base64" + "net/url" +) + +const ( + codeChallengeKey = "code_challenge" + codeChallengeMethodKey = "code_challenge_method" + codeVerifierKey = "code_verifier" +) + +// GenerateVerifier generates a PKCE code verifier with 32 octets of randomness. +// This follows recommendations in RFC 7636. +// +// A fresh verifier should be generated for each authorization. +// S256ChallengeOption(verifier) should then be passed to Config.AuthCodeURL +// (or Config.DeviceAccess) and VerifierOption(verifier) to Config.Exchange +// (or Config.DeviceAccessToken). +func GenerateVerifier() string { + // "RECOMMENDED that the output of a suitable random number generator be + // used to create a 32-octet sequence. The octet sequence is then + // base64url-encoded to produce a 43-octet URL-safe string to use as the + // code verifier." + // https://datatracker.ietf.org/doc/html/rfc7636#section-4.1 + data := make([]byte, 32) + if _, err := rand.Read(data); err != nil { + panic(err) + } + return base64.RawURLEncoding.EncodeToString(data) +} + +// VerifierOption returns a PKCE code verifier AuthCodeOption. It should be +// passed to Config.Exchange or Config.DeviceAccessToken only. +func VerifierOption(verifier string) AuthCodeOption { + return setParam{k: codeVerifierKey, v: verifier} +} + +// S256ChallengeFromVerifier returns a PKCE code challenge derived from verifier with method S256. +// +// Prefer to use S256ChallengeOption where possible. +func S256ChallengeFromVerifier(verifier string) string { + sha := sha256.Sum256([]byte(verifier)) + return base64.RawURLEncoding.EncodeToString(sha[:]) +} + +// S256ChallengeOption derives a PKCE code challenge derived from verifier with +// method S256. It should be passed to Config.AuthCodeURL or Config.DeviceAccess +// only. +func S256ChallengeOption(verifier string) AuthCodeOption { + return challengeOption{ + challenge_method: "S256", + challenge: S256ChallengeFromVerifier(verifier), + } +} + +type challengeOption struct{ challenge_method, challenge string } + +func (p challengeOption) setValue(m url.Values) { + m.Set(codeChallengeMethodKey, p.challenge_method) + m.Set(codeChallengeKey, p.challenge) +} diff --git a/vendor/golang.org/x/oauth2/token.go b/vendor/golang.org/x/oauth2/token.go index 5ffce9764..5bbb33217 100644 --- a/vendor/golang.org/x/oauth2/token.go +++ b/vendor/golang.org/x/oauth2/token.go @@ -164,7 +164,7 @@ func tokenFromInternal(t *internal.Token) *Token { // This token is then mapped from *internal.Token into an *oauth2.Token which is returned along // with an error.. func retrieveToken(ctx context.Context, c *Config, v url.Values) (*Token, error) { - tk, err := internal.RetrieveToken(ctx, c.ClientID, c.ClientSecret, c.Endpoint.TokenURL, v, internal.AuthStyle(c.Endpoint.AuthStyle)) + tk, err := internal.RetrieveToken(ctx, c.ClientID, c.ClientSecret, c.Endpoint.TokenURL, v, internal.AuthStyle(c.Endpoint.AuthStyle), c.authStyleCache.Get()) if err != nil { if rErr, ok := err.(*internal.RetrieveError); ok { return nil, (*RetrieveError)(rErr) diff --git a/vendor/golang.org/x/sys/cpu/asm_aix_ppc64.s b/vendor/golang.org/x/sys/cpu/asm_aix_ppc64.s index db9171c2e..269e173ca 100644 --- a/vendor/golang.org/x/sys/cpu/asm_aix_ppc64.s +++ b/vendor/golang.org/x/sys/cpu/asm_aix_ppc64.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/cpu/cpu_aix.go b/vendor/golang.org/x/sys/cpu/cpu_aix.go index 8aaeef545..9bf0c32eb 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_aix.go +++ b/vendor/golang.org/x/sys/cpu/cpu_aix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix -// +build aix package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_arm64.s b/vendor/golang.org/x/sys/cpu/cpu_arm64.s index c61f95a05..fcb9a3888 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_arm64.s +++ b/vendor/golang.org/x/sys/cpu/cpu_arm64.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go index ccf542a73..a8acd3e32 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go b/vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go index 0af2f2484..c8ae6ddc1 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go b/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go index fa7cdb9bc..910728fb1 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (386 || amd64 || amd64p32) && gc -// +build 386 amd64 amd64p32 -// +build gc package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go index 2aff31891..7f1946780 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gccgo -// +build gccgo package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go b/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go index 4bfbda619..9526d2ce3 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gccgo -// +build gccgo package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c b/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c index 6cc73109f..3f73a05dc 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c +++ b/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (386 || amd64 || amd64p32) && gccgo -// +build 386 amd64 amd64p32 -// +build gccgo #include #include diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go b/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go index 863d415ab..99c60fe9f 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (386 || amd64 || amd64p32) && gccgo -// +build 386 amd64 amd64p32 -// +build gccgo package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux.go b/vendor/golang.org/x/sys/cpu/cpu_linux.go index 159a686f6..743eb5435 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_linux.go +++ b/vendor/golang.org/x/sys/cpu/cpu_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !386 && !amd64 && !amd64p32 && !arm64 -// +build !386,!amd64,!amd64p32,!arm64 package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go b/vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go index 6000db4cd..4686c1d54 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips64 || mips64le) -// +build linux -// +build mips64 mips64le package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go b/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go index f4992b1a5..cd63e7335 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go +++ b/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x -// +build linux,!arm,!arm64,!mips64,!mips64le,!ppc64,!ppc64le,!s390x package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go b/vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go index 021356d6d..197188e67 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (ppc64 || ppc64le) -// +build linux -// +build ppc64 ppc64le package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_loong64.go b/vendor/golang.org/x/sys/cpu/cpu_loong64.go index 0f57b05bd..558635850 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_loong64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_loong64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build loong64 -// +build loong64 package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_mips64x.go b/vendor/golang.org/x/sys/cpu/cpu_mips64x.go index f4063c664..fedb00cc4 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_mips64x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_mips64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build mips64 || mips64le -// +build mips64 mips64le package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_mipsx.go b/vendor/golang.org/x/sys/cpu/cpu_mipsx.go index 07c4e36d8..ffb4ec7eb 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_mipsx.go +++ b/vendor/golang.org/x/sys/cpu/cpu_mipsx.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build mips || mipsle -// +build mips mipsle package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_other_arm.go b/vendor/golang.org/x/sys/cpu/cpu_other_arm.go index d7b4fb4cc..e9ecf2a45 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_other_arm.go +++ b/vendor/golang.org/x/sys/cpu/cpu_other_arm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !linux && arm -// +build !linux,arm package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go index f3cde129b..5341e7f88 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !linux && !netbsd && !openbsd && arm64 -// +build !linux,!netbsd,!openbsd,arm64 package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go b/vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go index 0dafe9644..5f8f2419a 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build !linux && (mips64 || mips64le) -// +build !linux -// +build mips64 mips64le package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go b/vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go index 060d46b6e..89608fba2 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build !aix && !linux && (ppc64 || ppc64le) -// +build !aix -// +build !linux -// +build ppc64 ppc64le package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_other_riscv64.go b/vendor/golang.org/x/sys/cpu/cpu_other_riscv64.go index dd10eb79f..5ab87808f 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_other_riscv64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_other_riscv64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !linux && riscv64 -// +build !linux,riscv64 package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_ppc64x.go b/vendor/golang.org/x/sys/cpu/cpu_ppc64x.go index 4e8acd165..c14f12b14 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_ppc64x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_ppc64x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64 || ppc64le -// +build ppc64 ppc64le package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_riscv64.go b/vendor/golang.org/x/sys/cpu/cpu_riscv64.go index ff7da60eb..7f0c79c00 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_riscv64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_riscv64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build riscv64 -// +build riscv64 package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_s390x.s b/vendor/golang.org/x/sys/cpu/cpu_s390x.s index 96f81e209..1fb4b7013 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_s390x.s +++ b/vendor/golang.org/x/sys/cpu/cpu_s390x.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/cpu/cpu_wasm.go b/vendor/golang.org/x/sys/cpu/cpu_wasm.go index 7747d888a..384787ea3 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_wasm.go +++ b/vendor/golang.org/x/sys/cpu/cpu_wasm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build wasm -// +build wasm package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_x86.go b/vendor/golang.org/x/sys/cpu/cpu_x86.go index 2dcde8285..c29f5e4c5 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_x86.go +++ b/vendor/golang.org/x/sys/cpu/cpu_x86.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || amd64 || amd64p32 -// +build 386 amd64 amd64p32 package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_x86.s b/vendor/golang.org/x/sys/cpu/cpu_x86.s index 39acab2ff..7d7ba33ef 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_x86.s +++ b/vendor/golang.org/x/sys/cpu/cpu_x86.s @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (386 || amd64 || amd64p32) && gc -// +build 386 amd64 amd64p32 -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/cpu/endian_big.go b/vendor/golang.org/x/sys/cpu/endian_big.go index 93ce03a34..7fe04b0a1 100644 --- a/vendor/golang.org/x/sys/cpu/endian_big.go +++ b/vendor/golang.org/x/sys/cpu/endian_big.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64 -// +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64 package cpu diff --git a/vendor/golang.org/x/sys/cpu/endian_little.go b/vendor/golang.org/x/sys/cpu/endian_little.go index 55db853ef..48eccc4c7 100644 --- a/vendor/golang.org/x/sys/cpu/endian_little.go +++ b/vendor/golang.org/x/sys/cpu/endian_little.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh || wasm -// +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh wasm package cpu diff --git a/vendor/golang.org/x/sys/cpu/proc_cpuinfo_linux.go b/vendor/golang.org/x/sys/cpu/proc_cpuinfo_linux.go index d87bd6b3e..4cd64c704 100644 --- a/vendor/golang.org/x/sys/cpu/proc_cpuinfo_linux.go +++ b/vendor/golang.org/x/sys/cpu/proc_cpuinfo_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && arm64 -// +build linux,arm64 package cpu diff --git a/vendor/golang.org/x/sys/cpu/runtime_auxv_go121.go b/vendor/golang.org/x/sys/cpu/runtime_auxv_go121.go index b975ea2a0..4c9788ea8 100644 --- a/vendor/golang.org/x/sys/cpu/runtime_auxv_go121.go +++ b/vendor/golang.org/x/sys/cpu/runtime_auxv_go121.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build go1.21 -// +build go1.21 package cpu diff --git a/vendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go b/vendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go index 96134157a..1b9ccb091 100644 --- a/vendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go +++ b/vendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go @@ -9,7 +9,6 @@ // gccgo's libgo and thus must not used a CGo method. //go:build aix && gccgo -// +build aix,gccgo package cpu diff --git a/vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go b/vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go index 904be42ff..e8b6cdbe9 100644 --- a/vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go +++ b/vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go @@ -7,7 +7,6 @@ // (See golang.org/issue/32102) //go:build aix && ppc64 && gc -// +build aix,ppc64,gc package cpu diff --git a/vendor/golang.org/x/sys/plan9/pwd_go15_plan9.go b/vendor/golang.org/x/sys/plan9/pwd_go15_plan9.go index c9b69937a..73687de74 100644 --- a/vendor/golang.org/x/sys/plan9/pwd_go15_plan9.go +++ b/vendor/golang.org/x/sys/plan9/pwd_go15_plan9.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build go1.5 -// +build go1.5 package plan9 diff --git a/vendor/golang.org/x/sys/plan9/pwd_plan9.go b/vendor/golang.org/x/sys/plan9/pwd_plan9.go index 98bf56b73..fb9458218 100644 --- a/vendor/golang.org/x/sys/plan9/pwd_plan9.go +++ b/vendor/golang.org/x/sys/plan9/pwd_plan9.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !go1.5 -// +build !go1.5 package plan9 diff --git a/vendor/golang.org/x/sys/plan9/race.go b/vendor/golang.org/x/sys/plan9/race.go index 62377d2ff..c02d9ed33 100644 --- a/vendor/golang.org/x/sys/plan9/race.go +++ b/vendor/golang.org/x/sys/plan9/race.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 && race -// +build plan9,race package plan9 diff --git a/vendor/golang.org/x/sys/plan9/race0.go b/vendor/golang.org/x/sys/plan9/race0.go index f8da30876..7b15e15f6 100644 --- a/vendor/golang.org/x/sys/plan9/race0.go +++ b/vendor/golang.org/x/sys/plan9/race0.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 && !race -// +build plan9,!race package plan9 diff --git a/vendor/golang.org/x/sys/plan9/str.go b/vendor/golang.org/x/sys/plan9/str.go index 55fa8d025..ba3e8ff8a 100644 --- a/vendor/golang.org/x/sys/plan9/str.go +++ b/vendor/golang.org/x/sys/plan9/str.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 -// +build plan9 package plan9 diff --git a/vendor/golang.org/x/sys/plan9/syscall.go b/vendor/golang.org/x/sys/plan9/syscall.go index 67e5b0115..d631fd664 100644 --- a/vendor/golang.org/x/sys/plan9/syscall.go +++ b/vendor/golang.org/x/sys/plan9/syscall.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build plan9 -// +build plan9 // Package plan9 contains an interface to the low-level operating system // primitives. OS details vary depending on the underlying system, and diff --git a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go index 3f40b9bd7..f780d5c80 100644 --- a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go +++ b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build plan9 && 386 -// +build plan9,386 package plan9 diff --git a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go index 0e6a96aa4..7de61065f 100644 --- a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go +++ b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build plan9 && amd64 -// +build plan9,amd64 package plan9 diff --git a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_arm.go b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_arm.go index 244c501b7..ea85780f0 100644 --- a/vendor/golang.org/x/sys/plan9/zsyscall_plan9_arm.go +++ b/vendor/golang.org/x/sys/plan9/zsyscall_plan9_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build plan9 && arm -// +build plan9,arm package plan9 diff --git a/vendor/golang.org/x/sys/unix/aliases.go b/vendor/golang.org/x/sys/unix/aliases.go index abc89c104..e7d3df4bd 100644 --- a/vendor/golang.org/x/sys/unix/aliases.go +++ b/vendor/golang.org/x/sys/unix/aliases.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos) && go1.9 -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos -// +build go1.9 package unix diff --git a/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s b/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s index db9171c2e..269e173ca 100644 --- a/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s +++ b/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_386.s b/vendor/golang.org/x/sys/unix/asm_bsd_386.s index e0fcd9b3d..a4fcef0e0 100644 --- a/vendor/golang.org/x/sys/unix/asm_bsd_386.s +++ b/vendor/golang.org/x/sys/unix/asm_bsd_386.s @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (freebsd || netbsd || openbsd) && gc -// +build freebsd netbsd openbsd -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s b/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s index 2b99c349a..1e63615c5 100644 --- a/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s +++ b/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && gc -// +build darwin dragonfly freebsd netbsd openbsd -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_arm.s b/vendor/golang.org/x/sys/unix/asm_bsd_arm.s index d702d4adc..6496c3100 100644 --- a/vendor/golang.org/x/sys/unix/asm_bsd_arm.s +++ b/vendor/golang.org/x/sys/unix/asm_bsd_arm.s @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (freebsd || netbsd || openbsd) && gc -// +build freebsd netbsd openbsd -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s b/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s index fe36a7391..4fd1f54da 100644 --- a/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s +++ b/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (darwin || freebsd || netbsd || openbsd) && gc -// +build darwin freebsd netbsd openbsd -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s b/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s index e5b9a8489..42f7eb9e4 100644 --- a/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s +++ b/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (darwin || freebsd || netbsd || openbsd) && gc -// +build darwin freebsd netbsd openbsd -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s b/vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s index d560019ea..f8902667e 100644 --- a/vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s +++ b/vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (darwin || freebsd || netbsd || openbsd) && gc -// +build darwin freebsd netbsd openbsd -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_linux_386.s b/vendor/golang.org/x/sys/unix/asm_linux_386.s index 8fd101d07..3b4734870 100644 --- a/vendor/golang.org/x/sys/unix/asm_linux_386.s +++ b/vendor/golang.org/x/sys/unix/asm_linux_386.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_linux_amd64.s b/vendor/golang.org/x/sys/unix/asm_linux_amd64.s index 7ed38e43c..67e29f317 100644 --- a/vendor/golang.org/x/sys/unix/asm_linux_amd64.s +++ b/vendor/golang.org/x/sys/unix/asm_linux_amd64.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_linux_arm.s b/vendor/golang.org/x/sys/unix/asm_linux_arm.s index 8ef1d5140..d6ae269ce 100644 --- a/vendor/golang.org/x/sys/unix/asm_linux_arm.s +++ b/vendor/golang.org/x/sys/unix/asm_linux_arm.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_linux_arm64.s b/vendor/golang.org/x/sys/unix/asm_linux_arm64.s index 98ae02760..01e5e253c 100644 --- a/vendor/golang.org/x/sys/unix/asm_linux_arm64.s +++ b/vendor/golang.org/x/sys/unix/asm_linux_arm64.s @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && arm64 && gc -// +build linux -// +build arm64 -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_linux_loong64.s b/vendor/golang.org/x/sys/unix/asm_linux_loong64.s index 565357288..2abf12f6e 100644 --- a/vendor/golang.org/x/sys/unix/asm_linux_loong64.s +++ b/vendor/golang.org/x/sys/unix/asm_linux_loong64.s @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && loong64 && gc -// +build linux -// +build loong64 -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s b/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s index 21231d2ce..f84bae712 100644 --- a/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s +++ b/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips64 || mips64le) && gc -// +build linux -// +build mips64 mips64le -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s b/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s index 6783b26c6..f08f62807 100644 --- a/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s +++ b/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips || mipsle) && gc -// +build linux -// +build mips mipsle -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s b/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s index 19d498934..bdfc024d2 100644 --- a/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s +++ b/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (ppc64 || ppc64le) && gc -// +build linux -// +build ppc64 ppc64le -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s b/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s index e42eb81d5..2e8c99612 100644 --- a/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s +++ b/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build riscv64 && gc -// +build riscv64 -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_linux_s390x.s b/vendor/golang.org/x/sys/unix/asm_linux_s390x.s index c46aab339..2c394b11e 100644 --- a/vendor/golang.org/x/sys/unix/asm_linux_s390x.s +++ b/vendor/golang.org/x/sys/unix/asm_linux_s390x.s @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && s390x && gc -// +build linux -// +build s390x -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s b/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s index 5e7a1169c..fab586a2c 100644 --- a/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s +++ b/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s b/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s index f8c5394c1..f949ec547 100644 --- a/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s +++ b/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gc -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/asm_zos_s390x.s b/vendor/golang.org/x/sys/unix/asm_zos_s390x.s index 3b54e1858..2f67ba86d 100644 --- a/vendor/golang.org/x/sys/unix/asm_zos_s390x.s +++ b/vendor/golang.org/x/sys/unix/asm_zos_s390x.s @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build zos && s390x && gc -// +build zos -// +build s390x -// +build gc #include "textflag.h" diff --git a/vendor/golang.org/x/sys/unix/cap_freebsd.go b/vendor/golang.org/x/sys/unix/cap_freebsd.go index 0b7c6adb8..a08657890 100644 --- a/vendor/golang.org/x/sys/unix/cap_freebsd.go +++ b/vendor/golang.org/x/sys/unix/cap_freebsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build freebsd -// +build freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/constants.go b/vendor/golang.org/x/sys/unix/constants.go index 394a3965b..6fb7cb77d 100644 --- a/vendor/golang.org/x/sys/unix/constants.go +++ b/vendor/golang.org/x/sys/unix/constants.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package unix diff --git a/vendor/golang.org/x/sys/unix/dev_aix_ppc.go b/vendor/golang.org/x/sys/unix/dev_aix_ppc.go index 65a998508..d78513461 100644 --- a/vendor/golang.org/x/sys/unix/dev_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/dev_aix_ppc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix && ppc -// +build aix,ppc // Functions to access/create device major and minor numbers matching the // encoding used by AIX. diff --git a/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go b/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go index 8fc08ad0a..623a5e697 100644 --- a/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix && ppc64 -// +build aix,ppc64 // Functions to access/create device major and minor numbers matching the // encoding used AIX. diff --git a/vendor/golang.org/x/sys/unix/dev_zos.go b/vendor/golang.org/x/sys/unix/dev_zos.go index a388e59a0..bb6a64fe9 100644 --- a/vendor/golang.org/x/sys/unix/dev_zos.go +++ b/vendor/golang.org/x/sys/unix/dev_zos.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build zos && s390x -// +build zos,s390x // Functions to access/create device major and minor numbers matching the // encoding used by z/OS. diff --git a/vendor/golang.org/x/sys/unix/dirent.go b/vendor/golang.org/x/sys/unix/dirent.go index 2499f977b..1ebf11782 100644 --- a/vendor/golang.org/x/sys/unix/dirent.go +++ b/vendor/golang.org/x/sys/unix/dirent.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package unix diff --git a/vendor/golang.org/x/sys/unix/endian_big.go b/vendor/golang.org/x/sys/unix/endian_big.go index a52026557..1095fd31d 100644 --- a/vendor/golang.org/x/sys/unix/endian_big.go +++ b/vendor/golang.org/x/sys/unix/endian_big.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // //go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64 -// +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64 package unix diff --git a/vendor/golang.org/x/sys/unix/endian_little.go b/vendor/golang.org/x/sys/unix/endian_little.go index b0f2bc4ae..b9f0e277b 100644 --- a/vendor/golang.org/x/sys/unix/endian_little.go +++ b/vendor/golang.org/x/sys/unix/endian_little.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // //go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh -// +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh package unix diff --git a/vendor/golang.org/x/sys/unix/env_unix.go b/vendor/golang.org/x/sys/unix/env_unix.go index 29ccc4d13..a96da71f4 100644 --- a/vendor/golang.org/x/sys/unix/env_unix.go +++ b/vendor/golang.org/x/sys/unix/env_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos // Unix environment variables. diff --git a/vendor/golang.org/x/sys/unix/epoll_zos.go b/vendor/golang.org/x/sys/unix/epoll_zos.go index cedaf7e02..7753fddea 100644 --- a/vendor/golang.org/x/sys/unix/epoll_zos.go +++ b/vendor/golang.org/x/sys/unix/epoll_zos.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build zos && s390x -// +build zos,s390x package unix diff --git a/vendor/golang.org/x/sys/unix/fcntl.go b/vendor/golang.org/x/sys/unix/fcntl.go index e9b991258..58c6bfc70 100644 --- a/vendor/golang.org/x/sys/unix/fcntl.go +++ b/vendor/golang.org/x/sys/unix/fcntl.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build dragonfly || freebsd || linux || netbsd || openbsd -// +build dragonfly freebsd linux netbsd openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go b/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go index 29d44808b..13b4acd5c 100644 --- a/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go +++ b/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) || (linux && ppc) -// +build linux,386 linux,arm linux,mips linux,mipsle linux,ppc package unix diff --git a/vendor/golang.org/x/sys/unix/fdset.go b/vendor/golang.org/x/sys/unix/fdset.go index a8068f94f..9e83d18cd 100644 --- a/vendor/golang.org/x/sys/unix/fdset.go +++ b/vendor/golang.org/x/sys/unix/fdset.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package unix diff --git a/vendor/golang.org/x/sys/unix/fstatfs_zos.go b/vendor/golang.org/x/sys/unix/fstatfs_zos.go index e377cc9f4..c8bde601e 100644 --- a/vendor/golang.org/x/sys/unix/fstatfs_zos.go +++ b/vendor/golang.org/x/sys/unix/fstatfs_zos.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build zos && s390x -// +build zos,s390x package unix diff --git a/vendor/golang.org/x/sys/unix/gccgo.go b/vendor/golang.org/x/sys/unix/gccgo.go index b06f52d74..aca5721dd 100644 --- a/vendor/golang.org/x/sys/unix/gccgo.go +++ b/vendor/golang.org/x/sys/unix/gccgo.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gccgo && !aix && !hurd -// +build gccgo,!aix,!hurd package unix diff --git a/vendor/golang.org/x/sys/unix/gccgo_c.c b/vendor/golang.org/x/sys/unix/gccgo_c.c index f98a1c542..d468b7b47 100644 --- a/vendor/golang.org/x/sys/unix/gccgo_c.c +++ b/vendor/golang.org/x/sys/unix/gccgo_c.c @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gccgo && !aix && !hurd -// +build gccgo,!aix,!hurd #include #include diff --git a/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go b/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go index e60e49a3d..972d61bd7 100644 --- a/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build gccgo && linux && amd64 -// +build gccgo,linux,amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/ifreq_linux.go b/vendor/golang.org/x/sys/unix/ifreq_linux.go index 15721a510..848840ae4 100644 --- a/vendor/golang.org/x/sys/unix/ifreq_linux.go +++ b/vendor/golang.org/x/sys/unix/ifreq_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux -// +build linux package unix diff --git a/vendor/golang.org/x/sys/unix/ioctl_signed.go b/vendor/golang.org/x/sys/unix/ioctl_signed.go index 7def9580e..5b0759bd8 100644 --- a/vendor/golang.org/x/sys/unix/ioctl_signed.go +++ b/vendor/golang.org/x/sys/unix/ioctl_signed.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || solaris -// +build aix solaris package unix diff --git a/vendor/golang.org/x/sys/unix/ioctl_unsigned.go b/vendor/golang.org/x/sys/unix/ioctl_unsigned.go index 649913d1e..20f470b9d 100644 --- a/vendor/golang.org/x/sys/unix/ioctl_unsigned.go +++ b/vendor/golang.org/x/sys/unix/ioctl_unsigned.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd -// +build darwin dragonfly freebsd hurd linux netbsd openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ioctl_zos.go b/vendor/golang.org/x/sys/unix/ioctl_zos.go index cdc21bf76..c8b2a750f 100644 --- a/vendor/golang.org/x/sys/unix/ioctl_zos.go +++ b/vendor/golang.org/x/sys/unix/ioctl_zos.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build zos && s390x -// +build zos,s390x package unix diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index 47fa6a7eb..cbe24150a 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -663,7 +663,6 @@ echo '// mkerrors.sh' "$@" echo '// Code generated by the command above; see README.md. DO NOT EDIT.' echo echo "//go:build ${GOARCH} && ${GOOS}" -echo "// +build ${GOARCH},${GOOS}" echo go tool cgo -godefs -- "$@" _const.go >_error.out cat _error.out | grep -vf _error.grep | grep -vf _signal.grep diff --git a/vendor/golang.org/x/sys/unix/mmap_nomremap.go b/vendor/golang.org/x/sys/unix/mmap_nomremap.go index ca0513632..4b68e5978 100644 --- a/vendor/golang.org/x/sys/unix/mmap_nomremap.go +++ b/vendor/golang.org/x/sys/unix/mmap_nomremap.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || openbsd || solaris -// +build aix darwin dragonfly freebsd openbsd solaris package unix diff --git a/vendor/golang.org/x/sys/unix/mremap.go b/vendor/golang.org/x/sys/unix/mremap.go index fa93d0aa9..fd45fe529 100644 --- a/vendor/golang.org/x/sys/unix/mremap.go +++ b/vendor/golang.org/x/sys/unix/mremap.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux || netbsd -// +build linux netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/pagesize_unix.go b/vendor/golang.org/x/sys/unix/pagesize_unix.go index 53f1b4c5b..4d0a3430e 100644 --- a/vendor/golang.org/x/sys/unix/pagesize_unix.go +++ b/vendor/golang.org/x/sys/unix/pagesize_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris // For Unix, get the pagesize from the runtime. diff --git a/vendor/golang.org/x/sys/unix/pledge_openbsd.go b/vendor/golang.org/x/sys/unix/pledge_openbsd.go index eb48294b2..6a09af53e 100644 --- a/vendor/golang.org/x/sys/unix/pledge_openbsd.go +++ b/vendor/golang.org/x/sys/unix/pledge_openbsd.go @@ -8,54 +8,31 @@ import ( "errors" "fmt" "strconv" - "syscall" - "unsafe" ) // Pledge implements the pledge syscall. // -// The pledge syscall does not accept execpromises on OpenBSD releases -// before 6.3. -// -// execpromises must be empty when Pledge is called on OpenBSD -// releases predating 6.3, otherwise an error will be returned. +// This changes both the promises and execpromises; use PledgePromises or +// PledgeExecpromises to only change the promises or execpromises +// respectively. // // For more information see pledge(2). func Pledge(promises, execpromises string) error { - maj, min, err := majmin() - if err != nil { + if err := pledgeAvailable(); err != nil { return err } - err = pledgeAvailable(maj, min, execpromises) + pptr, err := BytePtrFromString(promises) if err != nil { return err } - pptr, err := syscall.BytePtrFromString(promises) + exptr, err := BytePtrFromString(execpromises) if err != nil { return err } - // This variable will hold either a nil unsafe.Pointer or - // an unsafe.Pointer to a string (execpromises). - var expr unsafe.Pointer - - // If we're running on OpenBSD > 6.2, pass execpromises to the syscall. - if maj > 6 || (maj == 6 && min > 2) { - exptr, err := syscall.BytePtrFromString(execpromises) - if err != nil { - return err - } - expr = unsafe.Pointer(exptr) - } - - _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(unsafe.Pointer(pptr)), uintptr(expr), 0) - if e != 0 { - return e - } - - return nil + return pledge(pptr, exptr) } // PledgePromises implements the pledge syscall. @@ -64,30 +41,16 @@ func Pledge(promises, execpromises string) error { // // For more information see pledge(2). func PledgePromises(promises string) error { - maj, min, err := majmin() - if err != nil { - return err - } - - err = pledgeAvailable(maj, min, "") - if err != nil { + if err := pledgeAvailable(); err != nil { return err } - // This variable holds the execpromises and is always nil. - var expr unsafe.Pointer - - pptr, err := syscall.BytePtrFromString(promises) + pptr, err := BytePtrFromString(promises) if err != nil { return err } - _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(unsafe.Pointer(pptr)), uintptr(expr), 0) - if e != 0 { - return e - } - - return nil + return pledge(pptr, nil) } // PledgeExecpromises implements the pledge syscall. @@ -96,30 +59,16 @@ func PledgePromises(promises string) error { // // For more information see pledge(2). func PledgeExecpromises(execpromises string) error { - maj, min, err := majmin() - if err != nil { + if err := pledgeAvailable(); err != nil { return err } - err = pledgeAvailable(maj, min, execpromises) + exptr, err := BytePtrFromString(execpromises) if err != nil { return err } - // This variable holds the promises and is always nil. - var pptr unsafe.Pointer - - exptr, err := syscall.BytePtrFromString(execpromises) - if err != nil { - return err - } - - _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(pptr), uintptr(unsafe.Pointer(exptr)), 0) - if e != 0 { - return e - } - - return nil + return pledge(nil, exptr) } // majmin returns major and minor version number for an OpenBSD system. @@ -147,16 +96,15 @@ func majmin() (major int, minor int, err error) { // pledgeAvailable checks for availability of the pledge(2) syscall // based on the running OpenBSD version. -func pledgeAvailable(maj, min int, execpromises string) error { - // If OpenBSD <= 5.9, pledge is not available. - if (maj == 5 && min != 9) || maj < 5 { - return fmt.Errorf("pledge syscall is not available on OpenBSD %d.%d", maj, min) +func pledgeAvailable() error { + maj, min, err := majmin() + if err != nil { + return err } - // If OpenBSD <= 6.2 and execpromises is not empty, - // return an error - execpromises is not available before 6.3 - if (maj < 6 || (maj == 6 && min <= 2)) && execpromises != "" { - return fmt.Errorf("cannot use execpromises on OpenBSD %d.%d", maj, min) + // Require OpenBSD 6.4 as a minimum. + if maj < 6 || (maj == 6 && min <= 3) { + return fmt.Errorf("cannot call Pledge on OpenBSD %d.%d", maj, min) } return nil diff --git a/vendor/golang.org/x/sys/unix/ptrace_darwin.go b/vendor/golang.org/x/sys/unix/ptrace_darwin.go index 463c3eff7..3f0975f3d 100644 --- a/vendor/golang.org/x/sys/unix/ptrace_darwin.go +++ b/vendor/golang.org/x/sys/unix/ptrace_darwin.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin && !ios -// +build darwin,!ios package unix diff --git a/vendor/golang.org/x/sys/unix/ptrace_ios.go b/vendor/golang.org/x/sys/unix/ptrace_ios.go index ed0509a01..a4d35db5d 100644 --- a/vendor/golang.org/x/sys/unix/ptrace_ios.go +++ b/vendor/golang.org/x/sys/unix/ptrace_ios.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ios -// +build ios package unix diff --git a/vendor/golang.org/x/sys/unix/race.go b/vendor/golang.org/x/sys/unix/race.go index 6f6c5fec5..714d2aae7 100644 --- a/vendor/golang.org/x/sys/unix/race.go +++ b/vendor/golang.org/x/sys/unix/race.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (darwin && race) || (linux && race) || (freebsd && race) -// +build darwin,race linux,race freebsd,race package unix diff --git a/vendor/golang.org/x/sys/unix/race0.go b/vendor/golang.org/x/sys/unix/race0.go index 706e1322a..4a9f6634c 100644 --- a/vendor/golang.org/x/sys/unix/race0.go +++ b/vendor/golang.org/x/sys/unix/race0.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || (darwin && !race) || (linux && !race) || (freebsd && !race) || netbsd || openbsd || solaris || dragonfly || zos -// +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly zos package unix diff --git a/vendor/golang.org/x/sys/unix/readdirent_getdents.go b/vendor/golang.org/x/sys/unix/readdirent_getdents.go index 4d6257569..dbd2b6ccb 100644 --- a/vendor/golang.org/x/sys/unix/readdirent_getdents.go +++ b/vendor/golang.org/x/sys/unix/readdirent_getdents.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || dragonfly || freebsd || linux || netbsd || openbsd -// +build aix dragonfly freebsd linux netbsd openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/readdirent_getdirentries.go b/vendor/golang.org/x/sys/unix/readdirent_getdirentries.go index 2a4ba47c4..130398b6b 100644 --- a/vendor/golang.org/x/sys/unix/readdirent_getdirentries.go +++ b/vendor/golang.org/x/sys/unix/readdirent_getdirentries.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin -// +build darwin package unix diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go index 3865943f6..c3a62dbb1 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos // Socket control messages diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go index 0840fe4a5..4a1eab37e 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || freebsd || linux || netbsd || openbsd || solaris || zos -// +build aix darwin freebsd linux netbsd openbsd solaris zos package unix diff --git a/vendor/golang.org/x/sys/unix/syscall.go b/vendor/golang.org/x/sys/unix/syscall.go index 63e8c8383..5ea74da98 100644 --- a/vendor/golang.org/x/sys/unix/syscall.go +++ b/vendor/golang.org/x/sys/unix/syscall.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos // Package unix contains an interface to the low-level operating system // primitives. OS details vary depending on the underlying system, and diff --git a/vendor/golang.org/x/sys/unix/syscall_aix.go b/vendor/golang.org/x/sys/unix/syscall_aix.go index e94e6cdac..67ce6cef2 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix -// +build aix // Aix system calls. // This file is compiled as ordinary Go code, @@ -107,7 +106,8 @@ func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { if n > 0 { sl += _Socklen(n) + 1 } - if sa.raw.Path[0] == '@' { + if sa.raw.Path[0] == '@' || (sa.raw.Path[0] == 0 && sl > 3) { + // Check sl > 3 so we don't change unnamed socket behavior. sa.raw.Path[0] = 0 // Don't count trailing NUL for abstract address. sl-- diff --git a/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go b/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go index f2871fa95..1fdaa4760 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix && ppc -// +build aix,ppc package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go index 75718ec0f..c87f9a9f4 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix && ppc64 -// +build aix,ppc64 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_bsd.go b/vendor/golang.org/x/sys/unix/syscall_bsd.go index 4217de518..6f328e3a5 100644 --- a/vendor/golang.org/x/sys/unix/syscall_bsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd // BSD system call wrappers shared by *BSD based systems // including OS X (Darwin) and FreeBSD. Like the other diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go index b37310ce9..0eaecf5fc 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && darwin -// +build amd64,darwin package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go index d51ec9963..f36c6707c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 && darwin -// +build arm64,darwin package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go b/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go index 53c96641f..16dc69937 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin && go1.12 -// +build darwin,go1.12 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go index 4e2d32120..14bab6b2d 100644 --- a/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && dragonfly -// +build amd64,dragonfly package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go index b8da51004..3967bca77 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 && freebsd -// +build 386,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go index 47155c483..eff19ada2 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && freebsd -// +build amd64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go index 08932093f..4f24b517a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm && freebsd -// +build arm,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go index d151a0d0e..ac30759ec 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 && freebsd -// +build arm64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go index d5cd64b37..aab725ca7 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build riscv64 && freebsd -// +build riscv64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_hurd.go b/vendor/golang.org/x/sys/unix/syscall_hurd.go index 381fd4673..ba46651f8 100644 --- a/vendor/golang.org/x/sys/unix/syscall_hurd.go +++ b/vendor/golang.org/x/sys/unix/syscall_hurd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build hurd -// +build hurd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_hurd_386.go b/vendor/golang.org/x/sys/unix/syscall_hurd_386.go index 7cf54a3e4..df89f9e6b 100644 --- a/vendor/golang.org/x/sys/unix/syscall_hurd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_hurd_386.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 && hurd -// +build 386,hurd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_illumos.go b/vendor/golang.org/x/sys/unix/syscall_illumos.go index 87db5a6a8..a863f7052 100644 --- a/vendor/golang.org/x/sys/unix/syscall_illumos.go +++ b/vendor/golang.org/x/sys/unix/syscall_illumos.go @@ -5,7 +5,6 @@ // illumos system calls not present on Solaris. //go:build amd64 && illumos -// +build amd64,illumos package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index fb4e50224..a5e1c10e3 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -417,7 +417,8 @@ func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { if n > 0 { sl += _Socklen(n) + 1 } - if sa.raw.Path[0] == '@' { + if sa.raw.Path[0] == '@' || (sa.raw.Path[0] == 0 && sl > 3) { + // Check sl > 3 so we don't change unnamed socket behavior. sa.raw.Path[0] = 0 // Don't count trailing NUL for abstract address. sl-- @@ -2482,3 +2483,5 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { } return attr, nil } + +//sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_386.go index c7d9945ea..506dafa7b 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_386.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 && linux -// +build 386,linux package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_alarm.go b/vendor/golang.org/x/sys/unix/syscall_linux_alarm.go index 08086ac6a..38d55641b 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_alarm.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_alarm.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (386 || amd64 || mips || mipsle || mips64 || mipsle || ppc64 || ppc64le || ppc || s390x || sparc64) -// +build linux -// +build 386 amd64 mips mipsle mips64 mipsle ppc64 ppc64le ppc s390x sparc64 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go index 70601ce36..d557cf8de 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && linux -// +build amd64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go index 8b0f0f3aa..facdb83b2 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && linux && gc -// +build amd64,linux,gc package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go index da2986415..cd2dd797f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm && linux -// +build arm,linux package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go index f5266689a..cf2ee6c75 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 && linux -// +build arm64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_gc.go b/vendor/golang.org/x/sys/unix/syscall_linux_gc.go index 2b1168d7d..ffc4c2b63 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_gc.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_gc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && gc -// +build linux,gc package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go index 9843fb489..9ebfdcf44 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && gc && 386 -// +build linux,gc,386 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go index a6008fccd..5f2b57c4c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm && gc && linux -// +build arm,gc,linux package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go index 7740af242..d1a3ad826 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && gccgo && 386 -// +build linux,gccgo,386 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go index e16a12299..f2f67423e 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && gccgo && arm -// +build linux,gccgo,arm package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go b/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go index f6ab02ec1..3d0e98451 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build loong64 && linux -// +build loong64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go index 93fe59d25..70963a95a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips64 || mips64le) -// +build linux -// +build mips64 mips64le package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go index aae7f0ffd..c218ebd28 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (mips || mipsle) -// +build linux -// +build mips mipsle package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go index 66eff19a3..e6c48500c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && ppc -// +build linux,ppc package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go index 806aa2574..7286a9aa8 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (ppc64 || ppc64le) -// +build linux -// +build ppc64 ppc64le package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go index 5e6ceee12..6f5a28894 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build riscv64 && linux -// +build riscv64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go index 2f89e8f5d..66f31210d 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build s390x && linux -// +build s390x,linux package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go index 7ca064ae7..11d1f1698 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build sparc64 && linux -// +build sparc64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go index 5199d282f..7a5eb5743 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 && netbsd -// +build 386,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go index 70a9c52e9..62d8957ae 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && netbsd -// +build amd64,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go index 3eb5942f9..ce6a06885 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm && netbsd -// +build arm,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go index fc6ccfd81..d46d689d1 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 && netbsd -// +build arm64,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go index 6f34479b5..d2882ee04 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -137,18 +137,13 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e } func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { - var _p0 unsafe.Pointer + var bufptr *Statfs_t var bufsize uintptr if len(buf) > 0 { - _p0 = unsafe.Pointer(&buf[0]) + bufptr = &buf[0] bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf)) } - r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags)) - n = int(r0) - if e1 != 0 { - err = e1 - } - return + return getfsstat(bufptr, bufsize, flags) } //sysnb getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) @@ -326,4 +321,7 @@ func Uname(uname *Utsname) error { //sys write(fd int, p []byte) (n int, err error) //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) //sys munmap(addr uintptr, length uintptr) (err error) +//sys getfsstat(stat *Statfs_t, bufsize uintptr, flags int) (n int, err error) //sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) +//sys pledge(promises *byte, execpromises *byte) (err error) +//sys unveil(path *byte, flags *byte) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go index 6baabcdcb..9ddc89f4f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build 386 && openbsd -// +build 386,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go index bab25360e..70a3c96ee 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && openbsd -// +build amd64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go index 8eed3c4d4..265caa87f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm && openbsd -// +build arm,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go index 483dde99d..ac4fda171 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build arm64 && openbsd -// +build arm64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_libc.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_libc.go index 04aa43f41..0a451e6dd 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_libc.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_libc.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build openbsd -// +build openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_ppc64.go index c2796139c..30a308cbb 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_ppc64.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_ppc64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build ppc64 && openbsd -// +build ppc64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_riscv64.go index 23199a7ff..ea954330f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_riscv64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build riscv64 && openbsd -// +build riscv64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/golang.org/x/sys/unix/syscall_solaris.go index b99cfa134..60c8142d4 100644 --- a/vendor/golang.org/x/sys/unix/syscall_solaris.go +++ b/vendor/golang.org/x/sys/unix/syscall_solaris.go @@ -128,7 +128,8 @@ func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { if n > 0 { sl += _Socklen(n) + 1 } - if sa.raw.Path[0] == '@' { + if sa.raw.Path[0] == '@' || (sa.raw.Path[0] == 0 && sl > 3) { + // Check sl > 3 so we don't change unnamed socket behavior. sa.raw.Path[0] = 0 // Don't count trailing NUL for abstract address. sl-- diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go index 0bd25ef81..e02d8ceae 100644 --- a/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build amd64 && solaris -// +build amd64,solaris package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go index f6eda2705..77081de8c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_unix_gc.go b/vendor/golang.org/x/sys/unix/syscall_unix_gc.go index b6919ca58..05c95bccf 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix_gc.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix_gc.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. //go:build (darwin || dragonfly || freebsd || (linux && !ppc64 && !ppc64le) || netbsd || openbsd || solaris) && gc -// +build darwin dragonfly freebsd linux,!ppc64,!ppc64le netbsd openbsd solaris -// +build gc package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go index f6f707acf..23f39b7af 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go @@ -3,9 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux && (ppc64le || ppc64) && gc -// +build linux -// +build ppc64le ppc64 -// +build gc package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go index 4596d041c..d99d05f1b 100644 --- a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build zos && s390x -// +build zos,s390x package unix diff --git a/vendor/golang.org/x/sys/unix/sysvshm_linux.go b/vendor/golang.org/x/sys/unix/sysvshm_linux.go index 2c3a4437f..4fcd38de2 100644 --- a/vendor/golang.org/x/sys/unix/sysvshm_linux.go +++ b/vendor/golang.org/x/sys/unix/sysvshm_linux.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build linux -// +build linux package unix diff --git a/vendor/golang.org/x/sys/unix/sysvshm_unix.go b/vendor/golang.org/x/sys/unix/sysvshm_unix.go index 5bb41d17b..79a84f18b 100644 --- a/vendor/golang.org/x/sys/unix/sysvshm_unix.go +++ b/vendor/golang.org/x/sys/unix/sysvshm_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build (darwin && !ios) || linux -// +build darwin,!ios linux package unix diff --git a/vendor/golang.org/x/sys/unix/sysvshm_unix_other.go b/vendor/golang.org/x/sys/unix/sysvshm_unix_other.go index 71bddefdb..9eb0db664 100644 --- a/vendor/golang.org/x/sys/unix/sysvshm_unix_other.go +++ b/vendor/golang.org/x/sys/unix/sysvshm_unix_other.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin && !ios -// +build darwin,!ios package unix diff --git a/vendor/golang.org/x/sys/unix/timestruct.go b/vendor/golang.org/x/sys/unix/timestruct.go index 616b1b284..7997b1902 100644 --- a/vendor/golang.org/x/sys/unix/timestruct.go +++ b/vendor/golang.org/x/sys/unix/timestruct.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package unix diff --git a/vendor/golang.org/x/sys/unix/unveil_openbsd.go b/vendor/golang.org/x/sys/unix/unveil_openbsd.go index 168d5ae77..cb7e598ce 100644 --- a/vendor/golang.org/x/sys/unix/unveil_openbsd.go +++ b/vendor/golang.org/x/sys/unix/unveil_openbsd.go @@ -4,39 +4,48 @@ package unix -import ( - "syscall" - "unsafe" -) +import "fmt" // Unveil implements the unveil syscall. // For more information see unveil(2). // Note that the special case of blocking further // unveil calls is handled by UnveilBlock. func Unveil(path string, flags string) error { - pathPtr, err := syscall.BytePtrFromString(path) - if err != nil { + if err := supportsUnveil(); err != nil { return err } - flagsPtr, err := syscall.BytePtrFromString(flags) + pathPtr, err := BytePtrFromString(path) if err != nil { return err } - _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(unsafe.Pointer(pathPtr)), uintptr(unsafe.Pointer(flagsPtr)), 0) - if e != 0 { - return e + flagsPtr, err := BytePtrFromString(flags) + if err != nil { + return err } - return nil + return unveil(pathPtr, flagsPtr) } // UnveilBlock blocks future unveil calls. // For more information see unveil(2). func UnveilBlock() error { - // Both pointers must be nil. - var pathUnsafe, flagsUnsafe unsafe.Pointer - _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(pathUnsafe), uintptr(flagsUnsafe), 0) - if e != 0 { - return e + if err := supportsUnveil(); err != nil { + return err } + return unveil(nil, nil) +} + +// supportsUnveil checks for availability of the unveil(2) system call based +// on the running OpenBSD version. +func supportsUnveil() error { + maj, min, err := majmin() + if err != nil { + return err + } + + // unveil is not available before 6.4 + if maj < 6 || (maj == 6 && min <= 3) { + return fmt.Errorf("cannot call Unveil on OpenBSD %d.%d", maj, min) + } + return nil } diff --git a/vendor/golang.org/x/sys/unix/xattr_bsd.go b/vendor/golang.org/x/sys/unix/xattr_bsd.go index f5f8e9f36..e16879396 100644 --- a/vendor/golang.org/x/sys/unix/xattr_bsd.go +++ b/vendor/golang.org/x/sys/unix/xattr_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build freebsd || netbsd -// +build freebsd netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go index ca9799b79..2fb219d78 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc && aix -// +build ppc,aix // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -maix32 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go index 200c8c26f..b0e6f5c85 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64 && aix -// +build ppc64,aix // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -maix64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index 143007627..e40fa8524 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && darwin -// +build amd64,darwin // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index ab044a742..bb02aa6c0 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && darwin -// +build arm64,darwin // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go index 17bba0e44..c0e0f8694 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && dragonfly -// +build amd64,dragonfly // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go index f8c2c5138..6c6923906 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && freebsd -// +build 386,freebsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m32 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go index 96310c3be..dd9163f8e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && freebsd -// +build amd64,freebsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go index 777b69def..493a2a793 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && freebsd -// +build arm,freebsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go index c557ac2db..8b437b307 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && freebsd -// +build arm64,freebsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_riscv64.go index 341b4d962..67c02dd57 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build riscv64 && freebsd -// +build riscv64,freebsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index f9c7f479b..9c00cbf51 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -1,7 +1,6 @@ // Code generated by mkmerge; DO NOT EDIT. //go:build linux -// +build linux package unix @@ -481,10 +480,14 @@ const ( BPF_FROM_BE = 0x8 BPF_FROM_LE = 0x0 BPF_FS_MAGIC = 0xcafe4a11 + BPF_F_AFTER = 0x10 BPF_F_ALLOW_MULTI = 0x2 BPF_F_ALLOW_OVERRIDE = 0x1 BPF_F_ANY_ALIGNMENT = 0x2 - BPF_F_KPROBE_MULTI_RETURN = 0x1 + BPF_F_BEFORE = 0x8 + BPF_F_ID = 0x20 + BPF_F_LINK = 0x2000 + BPF_F_NETFILTER_IP_DEFRAG = 0x1 BPF_F_QUERY_EFFECTIVE = 0x1 BPF_F_REPLACE = 0x4 BPF_F_SLEEPABLE = 0x10 @@ -521,6 +524,7 @@ const ( BPF_MAJOR_VERSION = 0x1 BPF_MAXINSNS = 0x1000 BPF_MEM = 0x60 + BPF_MEMSX = 0x80 BPF_MEMWORDS = 0x10 BPF_MINOR_VERSION = 0x1 BPF_MISC = 0x7 @@ -776,6 +780,8 @@ const ( DEVLINK_GENL_MCGRP_CONFIG_NAME = "config" DEVLINK_GENL_NAME = "devlink" DEVLINK_GENL_VERSION = 0x1 + DEVLINK_PORT_FN_CAP_IPSEC_CRYPTO = 0x4 + DEVLINK_PORT_FN_CAP_IPSEC_PACKET = 0x8 DEVLINK_PORT_FN_CAP_MIGRATABLE = 0x2 DEVLINK_PORT_FN_CAP_ROCE = 0x1 DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX = 0x14 @@ -1698,6 +1704,7 @@ const ( KEXEC_ON_CRASH = 0x1 KEXEC_PRESERVE_CONTEXT = 0x2 KEXEC_SEGMENT_MAX = 0x10 + KEXEC_UPDATE_ELFCOREHDR = 0x4 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CAPABILITIES = 0x1f KEYCTL_CAPS0_BIG_KEY = 0x10 @@ -2275,6 +2282,7 @@ const ( PERF_MEM_LVLNUM_PMEM = 0xe PERF_MEM_LVLNUM_RAM = 0xd PERF_MEM_LVLNUM_SHIFT = 0x21 + PERF_MEM_LVLNUM_UNC = 0x8 PERF_MEM_LVL_HIT = 0x2 PERF_MEM_LVL_IO = 0x1000 PERF_MEM_LVL_L1 = 0x8 @@ -3461,6 +3469,7 @@ const ( XDP_PACKET_HEADROOM = 0x100 XDP_PGOFF_RX_RING = 0x0 XDP_PGOFF_TX_RING = 0x80000000 + XDP_PKT_CONTD = 0x1 XDP_RING_NEED_WAKEUP = 0x1 XDP_RX_RING = 0x2 XDP_SHARED_UMEM = 0x1 @@ -3473,6 +3482,7 @@ const ( XDP_UMEM_REG = 0x4 XDP_UMEM_UNALIGNED_CHUNK_FLAG = 0x1 XDP_USE_NEED_WAKEUP = 0x8 + XDP_USE_SG = 0x10 XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XFS_SUPER_MAGIC = 0x58465342 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index 30aee00a5..4920821cf 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && linux -// +build 386,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/386/include -m32 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 8ebfa5127..a0c1e4112 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && linux -// +build amd64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/amd64/include -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 271a21cdc..c63985560 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && linux -// +build arm,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/arm/include _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 910c330a3..47cc62e25 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && linux -// +build arm64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/arm64/include -fsigned-char _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index a640798c9..27ac4a09e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build loong64 && linux -// +build loong64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/loong64/include _const.go @@ -119,6 +118,7 @@ const ( IXOFF = 0x1000 IXON = 0x400 LASX_CTX_MAGIC = 0x41535801 + LBT_CTX_MAGIC = 0x42540001 LSX_CTX_MAGIC = 0x53580001 MAP_ANON = 0x20 MAP_ANONYMOUS = 0x20 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index 0d5925d34..54694642a 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips && linux -// +build mips,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/mips/include _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index d72a00e0b..3adb81d75 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips64 && linux -// +build mips64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/mips64/include _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index 02ba129f8..2dfe98f0d 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips64le && linux -// +build mips64le,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/mips64le/include _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 8daa6dd96..f5398f84f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mipsle && linux -// +build mipsle,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/mipsle/include _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 63c8fa2f7..c54f152d6 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc && linux -// +build ppc,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/ppc/include _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index 930799ec1..76057dc72 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64 && linux -// +build ppc64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/ppc64/include _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index 8605a7dd7..e0c3725e2 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64le && linux -// +build ppc64le,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/ppc64le/include _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 95a016f1c..18f2813ed 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build riscv64 && linux -// +build riscv64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/riscv64/include _const.go @@ -228,6 +227,9 @@ const ( PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCXFERUNIT = 0x744e PR_SET_PTRACER_ANY = 0xffffffffffffffff + PTRACE_GETFDPIC = 0x21 + PTRACE_GETFDPIC_EXEC = 0x0 + PTRACE_GETFDPIC_INTERP = 0x1 RLIMIT_AS = 0x9 RLIMIT_MEMLOCK = 0x8 RLIMIT_NOFILE = 0x7 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 1ae0108f5..11619d4ec 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build s390x && linux -// +build s390x,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/s390x/include -fsigned-char _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index 1bb7c6333..396d994da 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build sparc64 && linux -// +build sparc64,linux // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -Wall -Werror -static -I/tmp/sparc64/include _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go index 72f7420d2..130085df4 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && netbsd -// +build 386,netbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m32 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go index 8d4eb0c08..84769a1a3 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && netbsd -// +build amd64,netbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go index 9eef9749f..602ded003 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && netbsd -// +build arm,netbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -marm _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go index 3b62ba192..efc0406ee 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && netbsd -// +build arm64,netbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go index af20e474b..5a6500f83 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && openbsd -// +build 386,openbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m32 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go index 6015fcb2b..a5aeeb979 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && openbsd -// +build amd64,openbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go index 8d44955e4..0e9748a72 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && openbsd -// +build arm,openbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm64.go index ae16fe754..4f4449abc 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && openbsd -// +build arm64,openbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_mips64.go index 03d90fe35..76a363f0f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_mips64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips64 && openbsd -// +build mips64,openbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_ppc64.go index 8e2c51b1e..43ca0cdfd 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64 && openbsd -// +build ppc64,openbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_riscv64.go index 13d403031..b1b8bb200 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build riscv64 && openbsd -// +build riscv64,openbsd // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go index 1afee6a08..d2ddd3176 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && solaris -// +build amd64,solaris // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs -- -m64 _const.go diff --git a/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go index fc7d0506f..4dfd2e051 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build zos && s390x -// +build zos,s390x // Hand edited based on zerrors_linux_s390x.go // TODO: auto-generate. diff --git a/vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go b/vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go index 97f20ca28..586317c78 100644 --- a/vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go +++ b/vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go @@ -1,8 +1,6 @@ // Code generated by linux/mkall.go generatePtracePair("arm", "arm64"). DO NOT EDIT. //go:build linux && (arm || arm64) -// +build linux -// +build arm arm64 package unix diff --git a/vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go b/vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go index 0b5f79430..d7c881be7 100644 --- a/vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go +++ b/vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go @@ -1,8 +1,6 @@ // Code generated by linux/mkall.go generatePtracePair("mips", "mips64"). DO NOT EDIT. //go:build linux && (mips || mips64) -// +build linux -// +build mips mips64 package unix diff --git a/vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go b/vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go index 2807f7e64..2d2de5d29 100644 --- a/vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go +++ b/vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go @@ -1,8 +1,6 @@ // Code generated by linux/mkall.go generatePtracePair("mipsle", "mips64le"). DO NOT EDIT. //go:build linux && (mipsle || mips64le) -// +build linux -// +build mipsle mips64le package unix diff --git a/vendor/golang.org/x/sys/unix/zptrace_x86_linux.go b/vendor/golang.org/x/sys/unix/zptrace_x86_linux.go index 281ea64e3..5adc79fb5 100644 --- a/vendor/golang.org/x/sys/unix/zptrace_x86_linux.go +++ b/vendor/golang.org/x/sys/unix/zptrace_x86_linux.go @@ -1,8 +1,6 @@ // Code generated by linux/mkall.go generatePtracePair("386", "amd64"). DO NOT EDIT. //go:build linux && (386 || amd64) -// +build linux -// +build 386 amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go index d1d1d2331..6ea64a3c0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build aix && ppc -// +build aix,ppc package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go index f99a18adc..99ee4399a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build aix && ppc64 -// +build aix,ppc64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go index c4d50ae50..b68a78362 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build aix && ppc64 && gc -// +build aix,ppc64,gc package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go index 6903d3b09..0a87450bf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build aix && ppc64 && gccgo -// +build aix,ppc64,gccgo package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 1cad561e9..ccb02f240 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build darwin && amd64 -// +build darwin,amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index b18edbd0e..1b40b997b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build darwin && arm64 -// +build darwin,arm64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go index 0c67df64a..aad65fc79 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build dragonfly && amd64 -// +build dragonfly,amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go index e6e05d145..c0096391a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build freebsd && 386 -// +build freebsd,386 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go index 7508accac..7664df749 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build freebsd && amd64 -// +build freebsd,amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go index 7b56aead4..ae099182c 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build freebsd && arm -// +build freebsd,arm package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go index cc623dcaa..11fd5d45b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build freebsd && arm64 -// +build freebsd,arm64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go index 581849197..c3d2d6530 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build freebsd && riscv64 -// +build freebsd,riscv64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go index 6be25cd19..c698cbc01 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build illumos && amd64 -// +build illumos,amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 1ff3aec74..faca7a557 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -1,7 +1,6 @@ // Code generated by mkmerge; DO NOT EDIT. //go:build linux -// +build linux package unix @@ -2195,3 +2194,13 @@ func schedGetattr(pid int, attr *SchedAttr, size uint, flags uint) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) { + _, _, e1 := Syscall6(SYS_CACHESTAT, uintptr(fd), uintptr(unsafe.Pointer(crange)), uintptr(unsafe.Pointer(cstat)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go index 07b549cc2..4def3e9fc 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && 386 -// +build linux,386 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index 5f481bf83..fef2bc8ba 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && amd64 -// +build linux,amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go index 824cd52c7..a9fd76a88 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && arm -// +build linux,arm package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go index e77aecfe9..460065028 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && arm64 -// +build linux,arm64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go index 806ffd1e1..c8987d264 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && loong64 -// +build linux,loong64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go index 961a3afb7..921f43061 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && mips -// +build linux,mips package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go index ed05005e9..44f067829 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && mips64 -// +build linux,mips64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go index d365b718f..e7fa0abf0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && mips64le -// +build linux,mips64le package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go index c3f1b8bbd..8c5125675 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && mipsle -// +build linux,mipsle package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go index a6574cf98..7392fd45e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && ppc -// +build linux,ppc package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index f40990264..41180434e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && ppc64 -// +build linux,ppc64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index 9dfcc2997..40c6ce7ae 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && ppc64le -// +build linux,ppc64le package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go index 0ab4f2ed7..2cfe34adb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && riscv64 -// +build linux,riscv64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index 6cde32237..61e6f0709 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && s390x -// +build linux,s390x package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go index 5253d65bf..834b84204 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build linux && sparc64 -// +build linux,sparc64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go index 2df3c5bac..e91ebc14a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build netbsd && 386 -// +build netbsd,386 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go index a60556bab..be28babbc 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build netbsd && amd64 -// +build netbsd,amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go index 9f788917a..fb587e826 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build netbsd && arm -// +build netbsd,arm package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go index 82a4cb2dc..d576438bb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build netbsd && arm64 -// +build netbsd,arm64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 66b3b6456..88bfc2885 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build openbsd && 386 -// +build openbsd,386 package unix @@ -2213,6 +2212,21 @@ var libc_munmap_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getfsstat(stat *Statfs_t, bufsize uintptr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_getfsstat_trampoline_addr, uintptr(unsafe.Pointer(stat)), uintptr(bufsize), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getfsstat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getfsstat getfsstat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -2229,3 +2243,33 @@ func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error var libc_utimensat_trampoline_addr uintptr //go:cgo_import_dynamic libc_utimensat utimensat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pledge(promises *byte, execpromises *byte) (err error) { + _, _, e1 := syscall_syscall(libc_pledge_trampoline_addr, uintptr(unsafe.Pointer(promises)), uintptr(unsafe.Pointer(execpromises)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pledge_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pledge pledge "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unveil(path *byte, flags *byte) (err error) { + _, _, e1 := syscall_syscall(libc_unveil_trampoline_addr, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(flags)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unveil_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unveil unveil "libc.so" + + diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s index 3dcacd30d..4cbeff171 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -668,7 +668,22 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $4 DATA ·libc_munmap_trampoline_addr(SB)/4, $libc_munmap_trampoline<>(SB) +TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getfsstat(SB) +GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $4 +DATA ·libc_getfsstat_trampoline_addr(SB)/4, $libc_getfsstat_trampoline<>(SB) + TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_utimensat(SB) GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $4 DATA ·libc_utimensat_trampoline_addr(SB)/4, $libc_utimensat_trampoline<>(SB) + +TEXT libc_pledge_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pledge(SB) +GLOBL ·libc_pledge_trampoline_addr(SB), RODATA, $4 +DATA ·libc_pledge_trampoline_addr(SB)/4, $libc_pledge_trampoline<>(SB) + +TEXT libc_unveil_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_unveil(SB) +GLOBL ·libc_unveil_trampoline_addr(SB), RODATA, $4 +DATA ·libc_unveil_trampoline_addr(SB)/4, $libc_unveil_trampoline<>(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index c5c4cc112..b8a67b99a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build openbsd && amd64 -// +build openbsd,amd64 package unix @@ -2213,6 +2212,21 @@ var libc_munmap_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getfsstat(stat *Statfs_t, bufsize uintptr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_getfsstat_trampoline_addr, uintptr(unsafe.Pointer(stat)), uintptr(bufsize), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getfsstat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getfsstat getfsstat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -2229,3 +2243,33 @@ func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error var libc_utimensat_trampoline_addr uintptr //go:cgo_import_dynamic libc_utimensat utimensat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pledge(promises *byte, execpromises *byte) (err error) { + _, _, e1 := syscall_syscall(libc_pledge_trampoline_addr, uintptr(unsafe.Pointer(promises)), uintptr(unsafe.Pointer(execpromises)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pledge_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pledge pledge "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unveil(path *byte, flags *byte) (err error) { + _, _, e1 := syscall_syscall(libc_unveil_trampoline_addr, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(flags)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unveil_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unveil unveil "libc.so" + + diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s index 2763620b0..1123f2757 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -668,7 +668,22 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8 DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB) +TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getfsstat(SB) +GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getfsstat_trampoline_addr(SB)/8, $libc_getfsstat_trampoline<>(SB) + TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_utimensat(SB) GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8 DATA ·libc_utimensat_trampoline_addr(SB)/8, $libc_utimensat_trampoline<>(SB) + +TEXT libc_pledge_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pledge(SB) +GLOBL ·libc_pledge_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pledge_trampoline_addr(SB)/8, $libc_pledge_trampoline<>(SB) + +TEXT libc_unveil_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_unveil(SB) +GLOBL ·libc_unveil_trampoline_addr(SB), RODATA, $8 +DATA ·libc_unveil_trampoline_addr(SB)/8, $libc_unveil_trampoline<>(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index 93bfbb328..af50a65c0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build openbsd && arm -// +build openbsd,arm package unix @@ -2213,6 +2212,21 @@ var libc_munmap_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getfsstat(stat *Statfs_t, bufsize uintptr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_getfsstat_trampoline_addr, uintptr(unsafe.Pointer(stat)), uintptr(bufsize), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getfsstat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getfsstat getfsstat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -2229,3 +2243,33 @@ func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error var libc_utimensat_trampoline_addr uintptr //go:cgo_import_dynamic libc_utimensat utimensat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pledge(promises *byte, execpromises *byte) (err error) { + _, _, e1 := syscall_syscall(libc_pledge_trampoline_addr, uintptr(unsafe.Pointer(promises)), uintptr(unsafe.Pointer(execpromises)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pledge_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pledge pledge "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unveil(path *byte, flags *byte) (err error) { + _, _, e1 := syscall_syscall(libc_unveil_trampoline_addr, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(flags)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unveil_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unveil unveil "libc.so" + + diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s index c92231404..82badae39 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -668,7 +668,22 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $4 DATA ·libc_munmap_trampoline_addr(SB)/4, $libc_munmap_trampoline<>(SB) +TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getfsstat(SB) +GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $4 +DATA ·libc_getfsstat_trampoline_addr(SB)/4, $libc_getfsstat_trampoline<>(SB) + TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_utimensat(SB) GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $4 DATA ·libc_utimensat_trampoline_addr(SB)/4, $libc_utimensat_trampoline<>(SB) + +TEXT libc_pledge_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pledge(SB) +GLOBL ·libc_pledge_trampoline_addr(SB), RODATA, $4 +DATA ·libc_pledge_trampoline_addr(SB)/4, $libc_pledge_trampoline<>(SB) + +TEXT libc_unveil_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_unveil(SB) +GLOBL ·libc_unveil_trampoline_addr(SB), RODATA, $4 +DATA ·libc_unveil_trampoline_addr(SB)/4, $libc_unveil_trampoline<>(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index a107b8fda..8fb4ff36a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build openbsd && arm64 -// +build openbsd,arm64 package unix @@ -2213,6 +2212,21 @@ var libc_munmap_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getfsstat(stat *Statfs_t, bufsize uintptr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_getfsstat_trampoline_addr, uintptr(unsafe.Pointer(stat)), uintptr(bufsize), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getfsstat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getfsstat getfsstat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -2229,3 +2243,33 @@ func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error var libc_utimensat_trampoline_addr uintptr //go:cgo_import_dynamic libc_utimensat utimensat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pledge(promises *byte, execpromises *byte) (err error) { + _, _, e1 := syscall_syscall(libc_pledge_trampoline_addr, uintptr(unsafe.Pointer(promises)), uintptr(unsafe.Pointer(execpromises)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pledge_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pledge pledge "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unveil(path *byte, flags *byte) (err error) { + _, _, e1 := syscall_syscall(libc_unveil_trampoline_addr, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(flags)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unveil_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unveil unveil "libc.so" + + diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s index a6bc32c92..24d7eecb9 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -668,7 +668,22 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8 DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB) +TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getfsstat(SB) +GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getfsstat_trampoline_addr(SB)/8, $libc_getfsstat_trampoline<>(SB) + TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_utimensat(SB) GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8 DATA ·libc_utimensat_trampoline_addr(SB)/8, $libc_utimensat_trampoline<>(SB) + +TEXT libc_pledge_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pledge(SB) +GLOBL ·libc_pledge_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pledge_trampoline_addr(SB)/8, $libc_pledge_trampoline<>(SB) + +TEXT libc_unveil_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_unveil(SB) +GLOBL ·libc_unveil_trampoline_addr(SB), RODATA, $8 +DATA ·libc_unveil_trampoline_addr(SB)/8, $libc_unveil_trampoline<>(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index c427de509..f469a83ee 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build openbsd && mips64 -// +build openbsd,mips64 package unix @@ -2213,6 +2212,21 @@ var libc_munmap_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getfsstat(stat *Statfs_t, bufsize uintptr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_getfsstat_trampoline_addr, uintptr(unsafe.Pointer(stat)), uintptr(bufsize), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getfsstat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getfsstat getfsstat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -2229,3 +2243,33 @@ func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error var libc_utimensat_trampoline_addr uintptr //go:cgo_import_dynamic libc_utimensat utimensat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pledge(promises *byte, execpromises *byte) (err error) { + _, _, e1 := syscall_syscall(libc_pledge_trampoline_addr, uintptr(unsafe.Pointer(promises)), uintptr(unsafe.Pointer(execpromises)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pledge_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pledge pledge "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unveil(path *byte, flags *byte) (err error) { + _, _, e1 := syscall_syscall(libc_unveil_trampoline_addr, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(flags)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unveil_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unveil unveil "libc.so" + + diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s index b4e7bceab..9a498a067 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -668,7 +668,22 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8 DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB) +TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getfsstat(SB) +GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getfsstat_trampoline_addr(SB)/8, $libc_getfsstat_trampoline<>(SB) + TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_utimensat(SB) GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8 DATA ·libc_utimensat_trampoline_addr(SB)/8, $libc_utimensat_trampoline<>(SB) + +TEXT libc_pledge_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pledge(SB) +GLOBL ·libc_pledge_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pledge_trampoline_addr(SB)/8, $libc_pledge_trampoline<>(SB) + +TEXT libc_unveil_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_unveil(SB) +GLOBL ·libc_unveil_trampoline_addr(SB), RODATA, $8 +DATA ·libc_unveil_trampoline_addr(SB)/8, $libc_unveil_trampoline<>(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 60c1a99ae..c26ca2e1a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build openbsd && ppc64 -// +build openbsd,ppc64 package unix @@ -2213,6 +2212,21 @@ var libc_munmap_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getfsstat(stat *Statfs_t, bufsize uintptr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_getfsstat_trampoline_addr, uintptr(unsafe.Pointer(stat)), uintptr(bufsize), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getfsstat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getfsstat getfsstat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -2229,3 +2243,33 @@ func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error var libc_utimensat_trampoline_addr uintptr //go:cgo_import_dynamic libc_utimensat utimensat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pledge(promises *byte, execpromises *byte) (err error) { + _, _, e1 := syscall_syscall(libc_pledge_trampoline_addr, uintptr(unsafe.Pointer(promises)), uintptr(unsafe.Pointer(execpromises)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pledge_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pledge pledge "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unveil(path *byte, flags *byte) (err error) { + _, _, e1 := syscall_syscall(libc_unveil_trampoline_addr, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(flags)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unveil_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unveil unveil "libc.so" + + diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s index ca3f76600..1f224aa41 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -801,8 +801,26 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8 DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB) +TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getfsstat(SB) + RET +GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getfsstat_trampoline_addr(SB)/8, $libc_getfsstat_trampoline<>(SB) + TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_utimensat(SB) RET GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8 DATA ·libc_utimensat_trampoline_addr(SB)/8, $libc_utimensat_trampoline<>(SB) + +TEXT libc_pledge_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_pledge(SB) + RET +GLOBL ·libc_pledge_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pledge_trampoline_addr(SB)/8, $libc_pledge_trampoline<>(SB) + +TEXT libc_unveil_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_unveil(SB) + RET +GLOBL ·libc_unveil_trampoline_addr(SB), RODATA, $8 +DATA ·libc_unveil_trampoline_addr(SB)/8, $libc_unveil_trampoline<>(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 52eba360f..bcc920dd2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build openbsd && riscv64 -// +build openbsd,riscv64 package unix @@ -2213,6 +2212,21 @@ var libc_munmap_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getfsstat(stat *Statfs_t, bufsize uintptr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_getfsstat_trampoline_addr, uintptr(unsafe.Pointer(stat)), uintptr(bufsize), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getfsstat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getfsstat getfsstat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -2229,3 +2243,33 @@ func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error var libc_utimensat_trampoline_addr uintptr //go:cgo_import_dynamic libc_utimensat utimensat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pledge(promises *byte, execpromises *byte) (err error) { + _, _, e1 := syscall_syscall(libc_pledge_trampoline_addr, uintptr(unsafe.Pointer(promises)), uintptr(unsafe.Pointer(execpromises)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pledge_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pledge pledge "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unveil(path *byte, flags *byte) (err error) { + _, _, e1 := syscall_syscall(libc_unveil_trampoline_addr, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(flags)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unveil_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unveil unveil "libc.so" + + diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s index 477a7d5b2..87a79c709 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -668,7 +668,22 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8 DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB) +TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getfsstat(SB) +GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getfsstat_trampoline_addr(SB)/8, $libc_getfsstat_trampoline<>(SB) + TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_utimensat(SB) GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8 DATA ·libc_utimensat_trampoline_addr(SB)/8, $libc_utimensat_trampoline<>(SB) + +TEXT libc_pledge_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pledge(SB) +GLOBL ·libc_pledge_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pledge_trampoline_addr(SB)/8, $libc_pledge_trampoline<>(SB) + +TEXT libc_unveil_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_unveil(SB) +GLOBL ·libc_unveil_trampoline_addr(SB), RODATA, $8 +DATA ·libc_unveil_trampoline_addr(SB)/8, $libc_unveil_trampoline<>(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go index b40189464..829b87feb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build solaris && amd64 -// +build solaris,amd64 package unix diff --git a/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go index 1d8fe1d4b..94f011238 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build zos && s390x -// +build zos,s390x package unix diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_386.go index 55e048471..3a58ae819 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build 386 && openbsd -// +build 386,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go index d2243cf83..dcb7a0eb7 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build amd64 && openbsd -// +build amd64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm.go index 82dc51bd8..db5a7bf13 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build arm && openbsd -// +build arm,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm64.go index cbdda1a4a..7be575a77 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build arm64 && openbsd -// +build arm64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_mips64.go index f55eae1a8..d6e3174c6 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_mips64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build mips64 && openbsd -// +build mips64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_ppc64.go index e44054470..ee97157d0 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build ppc64 && openbsd -// +build ppc64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_riscv64.go index a0db82fce..35c3b91d0 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build riscv64 && openbsd -// +build riscv64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go index f8298ff9b..5edda7687 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && darwin -// +build amd64,darwin package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go index 5eb433bbf..0dc9e8b4d 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && darwin -// +build arm64,darwin package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go index 703675c0c..308ddf3a1 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && dragonfly -// +build amd64,dragonfly package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go index 4e0d96107..418664e3d 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && freebsd -// +build 386,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go index 01636b838..34d0b86d7 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && freebsd -// +build amd64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go index ad99bc106..b71cf45e2 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && freebsd -// +build arm,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm64.go index 89dcc4274..e32df1c1e 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && freebsd -// +build arm64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_riscv64.go index ee37aaa0c..15ad6111f 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build riscv64 && freebsd -// +build riscv64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 9862853d3..fcf3ecbdd 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && linux -// +build 386,linux package unix @@ -448,4 +447,5 @@ const ( SYS_FUTEX_WAITV = 449 SYS_SET_MEMPOLICY_HOME_NODE = 450 SYS_CACHESTAT = 451 + SYS_FCHMODAT2 = 452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 8901f0f4e..f56dc2504 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && linux -// +build amd64,linux package unix @@ -370,4 +369,6 @@ const ( SYS_FUTEX_WAITV = 449 SYS_SET_MEMPOLICY_HOME_NODE = 450 SYS_CACHESTAT = 451 + SYS_FCHMODAT2 = 452 + SYS_MAP_SHADOW_STACK = 453 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index 6902c37ee..974bf2467 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && linux -// +build arm,linux package unix @@ -412,4 +411,5 @@ const ( SYS_FUTEX_WAITV = 449 SYS_SET_MEMPOLICY_HOME_NODE = 450 SYS_CACHESTAT = 451 + SYS_FCHMODAT2 = 452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index a6d3dff81..39a2739e2 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && linux -// +build arm64,linux package unix @@ -315,4 +314,5 @@ const ( SYS_FUTEX_WAITV = 449 SYS_SET_MEMPOLICY_HOME_NODE = 450 SYS_CACHESTAT = 451 + SYS_FCHMODAT2 = 452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go index b18f3f710..cf9c9d77e 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build loong64 && linux -// +build loong64,linux package unix @@ -309,4 +308,5 @@ const ( SYS_FUTEX_WAITV = 449 SYS_SET_MEMPOLICY_HOME_NODE = 450 SYS_CACHESTAT = 451 + SYS_FCHMODAT2 = 452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index 0302e5e3d..10b7362ef 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips && linux -// +build mips,linux package unix @@ -432,4 +431,5 @@ const ( SYS_FUTEX_WAITV = 4449 SYS_SET_MEMPOLICY_HOME_NODE = 4450 SYS_CACHESTAT = 4451 + SYS_FCHMODAT2 = 4452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 6693ba4a0..cd4d8b4fd 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips64 && linux -// +build mips64,linux package unix @@ -362,4 +361,5 @@ const ( SYS_FUTEX_WAITV = 5449 SYS_SET_MEMPOLICY_HOME_NODE = 5450 SYS_CACHESTAT = 5451 + SYS_FCHMODAT2 = 5452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index fd93f4987..2c0efca81 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips64le && linux -// +build mips64le,linux package unix @@ -362,4 +361,5 @@ const ( SYS_FUTEX_WAITV = 5449 SYS_SET_MEMPOLICY_HOME_NODE = 5450 SYS_CACHESTAT = 5451 + SYS_FCHMODAT2 = 5452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index 760ddcadc..a72e31d39 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mipsle && linux -// +build mipsle,linux package unix @@ -432,4 +431,5 @@ const ( SYS_FUTEX_WAITV = 4449 SYS_SET_MEMPOLICY_HOME_NODE = 4450 SYS_CACHESTAT = 4451 + SYS_FCHMODAT2 = 4452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index cff2b2555..c7d1e3747 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc && linux -// +build ppc,linux package unix @@ -439,4 +438,5 @@ const ( SYS_FUTEX_WAITV = 449 SYS_SET_MEMPOLICY_HOME_NODE = 450 SYS_CACHESTAT = 451 + SYS_FCHMODAT2 = 452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index a4b2405d0..f4d4838c8 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64 && linux -// +build ppc64,linux package unix @@ -411,4 +410,5 @@ const ( SYS_FUTEX_WAITV = 449 SYS_SET_MEMPOLICY_HOME_NODE = 450 SYS_CACHESTAT = 451 + SYS_FCHMODAT2 = 452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index aca54b4e3..b64f0e591 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64le && linux -// +build ppc64le,linux package unix @@ -411,4 +410,5 @@ const ( SYS_FUTEX_WAITV = 449 SYS_SET_MEMPOLICY_HOME_NODE = 450 SYS_CACHESTAT = 451 + SYS_FCHMODAT2 = 452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index 9d1738d64..95711195a 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build riscv64 && linux -// +build riscv64,linux package unix @@ -316,4 +315,5 @@ const ( SYS_FUTEX_WAITV = 449 SYS_SET_MEMPOLICY_HOME_NODE = 450 SYS_CACHESTAT = 451 + SYS_FCHMODAT2 = 452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 022878dc8..f94e943bc 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build s390x && linux -// +build s390x,linux package unix @@ -377,4 +376,5 @@ const ( SYS_FUTEX_WAITV = 449 SYS_SET_MEMPOLICY_HOME_NODE = 450 SYS_CACHESTAT = 451 + SYS_FCHMODAT2 = 452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 4100a761c..ba0c2bc51 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build sparc64 && linux -// +build sparc64,linux package unix @@ -390,4 +389,5 @@ const ( SYS_FUTEX_WAITV = 449 SYS_SET_MEMPOLICY_HOME_NODE = 450 SYS_CACHESTAT = 451 + SYS_FCHMODAT2 = 452 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go index 3a6699eba..b2aa8cd49 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && netbsd -// +build 386,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go index 5677cd4f1..524a1b1c9 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && netbsd -// +build amd64,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go index e784cb6db..d59b943ac 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && netbsd -// +build arm,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm64.go index bd4952efa..31e771d53 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; DO NOT EDIT. //go:build arm64 && netbsd -// +build arm64,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go index 597733813..9fd77c6cb 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && openbsd -// +build 386,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go index 16af29189..af10af28c 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && openbsd -// +build amd64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go index f59b18a97..cc2028af4 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && openbsd -// +build arm,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm64.go index 721ef5910..c06dd4415 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && openbsd -// +build arm64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_mips64.go index 01c43a01f..9ddbf3e08 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_mips64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips64 && openbsd -// +build mips64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_ppc64.go index f258cfa24..19a6ee413 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64 && openbsd -// +build ppc64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_riscv64.go index 07919e0ec..05192a782 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build riscv64 && openbsd -// +build riscv64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go index 073daad43..b2e308581 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build zos && s390x -// +build zos,s390x package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go index 7a8161c1d..3e6d57cae 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc && aix -// +build ppc,aix package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go index 07ed733c5..3a219bdce 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64 && aix -// +build ppc64,aix package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index 690cefc3d..091d107f3 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && darwin -// +build amd64,darwin package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index 5bffc10ea..28ff4ef74 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && darwin -// +build arm64,darwin package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go index d0ba8e9b8..30e405bb4 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && dragonfly -// +build amd64,dragonfly package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go index 29dc48337..6cbd094a3 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && freebsd -// +build 386,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index 0a89b2890..7c03b6ee7 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && freebsd -// +build amd64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go index c8666bb15..422107ee8 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && freebsd -// +build arm,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go index 88fb48a88..505a12acf 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && freebsd -// +build arm64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go index 698dc975e..cc986c790 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build riscv64 && freebsd -// +build riscv64,freebsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 18aa70b42..997bcd55a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -1,7 +1,6 @@ // Code generated by mkmerge; DO NOT EDIT. //go:build linux -// +build linux package unix @@ -5883,3 +5882,15 @@ type SchedAttr struct { } const SizeofSchedAttr = 0x38 + +type Cachestat_t struct { + Cache uint64 + Dirty uint64 + Writeback uint64 + Evicted uint64 + Recently_evicted uint64 +} +type CachestatRange struct { + Off uint64 + Len uint64 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index 6d8acbcc5..438a30aff 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && linux -// +build 386,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index 59293c688..adceca355 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && linux -// +build amd64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index 40cfa38c2..eeaa00a37 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && linux -// +build arm,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index 055bc4216..6739aa91d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && linux -// +build arm64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go index f28affbc6..9920ef631 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build loong64 && linux -// +build loong64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index 9d71e7ccd..2923b799a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips && linux -// +build mips,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index fd5ccd332..ce2750ee4 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips64 && linux -// +build mips64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index 7704de77a..3038811d7 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips64le && linux -// +build mips64le,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index df00b8757..efc6fed18 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mipsle && linux -// +build mipsle,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go index 0942840db..9a654b75a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc && linux -// +build ppc,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index 034874395..40d358e33 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64 && linux -// +build ppc64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index bad067047..148c6ceb8 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64le && linux -// +build ppc64le,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index 1b4c97c32..72ba81543 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build riscv64 && linux -// +build riscv64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index aa268d025..71e765508 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build s390x && linux -// +build s390x,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go index 444045b6c..4abbdb9de 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build sparc64 && linux -// +build sparc64,linux package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go index 9bc4c8f9d..f22e7947d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && netbsd -// +build 386,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go index bb05f655d..066a7d83d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && netbsd -// +build amd64,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go index db40e3a19..439548ec9 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && netbsd -// +build arm,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm64.go index 11121151c..16085d3bb 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && netbsd -// +build arm64,netbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go index 26eba23b7..afd13a3af 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build 386 && openbsd -// +build 386,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go index 5a5479886..5d97f1f9b 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && openbsd -// +build amd64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go index be58c4e1f..34871cdc1 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm && openbsd -// +build arm,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go index 52338266c..5911bceb3 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build arm64 && openbsd -// +build arm64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go index 605cfdb12..e4f24f3bc 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build mips64 && openbsd -// +build mips64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_ppc64.go index d6724c010..ca50a7930 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_ppc64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build ppc64 && openbsd -// +build ppc64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_riscv64.go index ddfd27a43..d7d7f7902 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_riscv64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build riscv64 && openbsd -// +build riscv64,openbsd package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go index 0400747c6..14160576d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go @@ -2,7 +2,6 @@ // Code generated by the command above; see README.md. DO NOT EDIT. //go:build amd64 && solaris -// +build amd64,solaris package unix diff --git a/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go index aec1efcb3..54f31be63 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build zos && s390x -// +build zos,s390x // Hand edited based on ztypes_linux_s390x.go // TODO: auto-generate. diff --git a/vendor/golang.org/x/sys/windows/aliases.go b/vendor/golang.org/x/sys/windows/aliases.go index a20ebea63..ce2d713d6 100644 --- a/vendor/golang.org/x/sys/windows/aliases.go +++ b/vendor/golang.org/x/sys/windows/aliases.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows && go1.9 -// +build windows,go1.9 package windows diff --git a/vendor/golang.org/x/sys/windows/empty.s b/vendor/golang.org/x/sys/windows/empty.s index fdbbbcd31..ba64caca5 100644 --- a/vendor/golang.org/x/sys/windows/empty.s +++ b/vendor/golang.org/x/sys/windows/empty.s @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !go1.12 -// +build !go1.12 // This file is here to allow bodyless functions with go:linkname for Go 1.11 // and earlier (see https://golang.org/issue/23311). diff --git a/vendor/golang.org/x/sys/windows/eventlog.go b/vendor/golang.org/x/sys/windows/eventlog.go index 2cd60645e..6c366955d 100644 --- a/vendor/golang.org/x/sys/windows/eventlog.go +++ b/vendor/golang.org/x/sys/windows/eventlog.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package windows diff --git a/vendor/golang.org/x/sys/windows/mksyscall.go b/vendor/golang.org/x/sys/windows/mksyscall.go index 8563f79c5..dbcdb090c 100644 --- a/vendor/golang.org/x/sys/windows/mksyscall.go +++ b/vendor/golang.org/x/sys/windows/mksyscall.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build generate -// +build generate package windows diff --git a/vendor/golang.org/x/sys/windows/race.go b/vendor/golang.org/x/sys/windows/race.go index 9196b089c..0f1bdc386 100644 --- a/vendor/golang.org/x/sys/windows/race.go +++ b/vendor/golang.org/x/sys/windows/race.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows && race -// +build windows,race package windows diff --git a/vendor/golang.org/x/sys/windows/race0.go b/vendor/golang.org/x/sys/windows/race0.go index 7bae4817a..0c78da78b 100644 --- a/vendor/golang.org/x/sys/windows/race0.go +++ b/vendor/golang.org/x/sys/windows/race0.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows && !race -// +build windows,!race package windows diff --git a/vendor/golang.org/x/sys/windows/service.go b/vendor/golang.org/x/sys/windows/service.go index c44a1b963..a9dc6308d 100644 --- a/vendor/golang.org/x/sys/windows/service.go +++ b/vendor/golang.org/x/sys/windows/service.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package windows diff --git a/vendor/golang.org/x/sys/windows/str.go b/vendor/golang.org/x/sys/windows/str.go index 4fc01434e..6a4f9ce6a 100644 --- a/vendor/golang.org/x/sys/windows/str.go +++ b/vendor/golang.org/x/sys/windows/str.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows package windows diff --git a/vendor/golang.org/x/sys/windows/syscall.go b/vendor/golang.org/x/sys/windows/syscall.go index 8732cdb95..e85ed6b9c 100644 --- a/vendor/golang.org/x/sys/windows/syscall.go +++ b/vendor/golang.org/x/sys/windows/syscall.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build windows -// +build windows // Package windows contains an interface to the low-level operating system // primitives. OS details vary depending on the underlying system, and diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index 35cfc57ca..fb6cfd046 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -233,6 +233,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) = userenv.CreateEnvironmentBlock //sys DestroyEnvironmentBlock(block *uint16) (err error) = userenv.DestroyEnvironmentBlock //sys getTickCount64() (ms uint64) = kernel32.GetTickCount64 +//sys GetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) //sys SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) //sys GetFileAttributes(name *uint16) (attrs uint32, err error) [failretval==INVALID_FILE_ATTRIBUTES] = kernel32.GetFileAttributesW //sys SetFileAttributes(name *uint16, attrs uint32) (err error) = kernel32.SetFileAttributesW @@ -969,7 +970,8 @@ func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, int32, error) { if n > 0 { sl += int32(n) + 1 } - if sa.raw.Path[0] == '@' { + if sa.raw.Path[0] == '@' || (sa.raw.Path[0] == 0 && sl > 3) { + // Check sl > 3 so we don't change unnamed socket behavior. sa.raw.Path[0] = 0 // Don't count trailing NUL for abstract address. sl-- diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index b88dc7c85..359780f6a 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -1094,7 +1094,33 @@ const ( SOMAXCONN = 0x7fffffff - TCP_NODELAY = 1 + TCP_NODELAY = 1 + TCP_EXPEDITED_1122 = 2 + TCP_KEEPALIVE = 3 + TCP_MAXSEG = 4 + TCP_MAXRT = 5 + TCP_STDURG = 6 + TCP_NOURG = 7 + TCP_ATMARK = 8 + TCP_NOSYNRETRIES = 9 + TCP_TIMESTAMPS = 10 + TCP_OFFLOAD_PREFERENCE = 11 + TCP_CONGESTION_ALGORITHM = 12 + TCP_DELAY_FIN_ACK = 13 + TCP_MAXRTMS = 14 + TCP_FASTOPEN = 15 + TCP_KEEPCNT = 16 + TCP_KEEPIDLE = TCP_KEEPALIVE + TCP_KEEPINTVL = 17 + TCP_FAIL_CONNECT_ON_ICMP_ERROR = 18 + TCP_ICMP_ERROR_INFO = 19 + + UDP_NOCHECKSUM = 1 + UDP_SEND_MSG_SIZE = 2 + UDP_RECV_MAX_COALESCED_SIZE = 3 + UDP_CHECKSUM_COVERAGE = 20 + + UDP_COALESCED_INFO = 3 SHUT_RD = 0 SHUT_WR = 1 diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 8b1688de4..db6282e00 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -253,6 +253,7 @@ var ( procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW") procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle") procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx") + procGetFileTime = modkernel32.NewProc("GetFileTime") procGetFileType = modkernel32.NewProc("GetFileType") procGetFinalPathNameByHandleW = modkernel32.NewProc("GetFinalPathNameByHandleW") procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW") @@ -2185,6 +2186,14 @@ func GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, return } +func GetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) { + r1, _, e1 := syscall.Syscall6(procGetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func GetFileType(filehandle Handle) (n uint32, err error) { r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0) n = uint32(r0) diff --git a/vendor/golang.org/x/term/term_unix.go b/vendor/golang.org/x/term/term_unix.go index 62c2b3f41..1ad0ddfe3 100644 --- a/vendor/golang.org/x/term/term_unix.go +++ b/vendor/golang.org/x/term/term_unix.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package term diff --git a/vendor/golang.org/x/term/term_unix_bsd.go b/vendor/golang.org/x/term/term_unix_bsd.go index 853b3d698..9dbf54629 100644 --- a/vendor/golang.org/x/term/term_unix_bsd.go +++ b/vendor/golang.org/x/term/term_unix_bsd.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || netbsd || openbsd -// +build darwin dragonfly freebsd netbsd openbsd package term diff --git a/vendor/golang.org/x/term/term_unix_other.go b/vendor/golang.org/x/term/term_unix_other.go index 1e8955c93..1b36de799 100644 --- a/vendor/golang.org/x/term/term_unix_other.go +++ b/vendor/golang.org/x/term/term_unix_other.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build aix || linux || solaris || zos -// +build aix linux solaris zos package term diff --git a/vendor/golang.org/x/term/term_unsupported.go b/vendor/golang.org/x/term/term_unsupported.go index f1df85065..3c409e588 100644 --- a/vendor/golang.org/x/term/term_unsupported.go +++ b/vendor/golang.org/x/term/term_unsupported.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !zos && !windows && !solaris && !plan9 -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!zos,!windows,!solaris,!plan9 package term diff --git a/vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go b/vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go index 8a7392c4a..784bb8808 100644 --- a/vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go +++ b/vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build go1.10 -// +build go1.10 package bidirule diff --git a/vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go b/vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go index bb0a92001..8e1e94395 100644 --- a/vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go +++ b/vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !go1.10 -// +build !go1.10 package bidirule diff --git a/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go b/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go index 42fa8d72c..d2bd71181 100644 --- a/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go +++ b/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.10 && !go1.13 -// +build go1.10,!go1.13 package bidi diff --git a/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go b/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go index 56a0e1ea2..f76bdca27 100644 --- a/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go +++ b/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.13 && !go1.14 -// +build go1.13,!go1.14 package bidi diff --git a/vendor/golang.org/x/text/unicode/bidi/tables12.0.0.go b/vendor/golang.org/x/text/unicode/bidi/tables12.0.0.go index baacf32b4..3aa2c3bdf 100644 --- a/vendor/golang.org/x/text/unicode/bidi/tables12.0.0.go +++ b/vendor/golang.org/x/text/unicode/bidi/tables12.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.14 && !go1.16 -// +build go1.14,!go1.16 package bidi diff --git a/vendor/golang.org/x/text/unicode/bidi/tables13.0.0.go b/vendor/golang.org/x/text/unicode/bidi/tables13.0.0.go index ffadb7beb..a71375790 100644 --- a/vendor/golang.org/x/text/unicode/bidi/tables13.0.0.go +++ b/vendor/golang.org/x/text/unicode/bidi/tables13.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.16 && !go1.21 -// +build go1.16,!go1.21 package bidi diff --git a/vendor/golang.org/x/text/unicode/bidi/tables15.0.0.go b/vendor/golang.org/x/text/unicode/bidi/tables15.0.0.go index 92cce5802..f15746f7d 100644 --- a/vendor/golang.org/x/text/unicode/bidi/tables15.0.0.go +++ b/vendor/golang.org/x/text/unicode/bidi/tables15.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.21 -// +build go1.21 package bidi diff --git a/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go b/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go index f517fdb20..c164d3791 100644 --- a/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go +++ b/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build !go1.10 -// +build !go1.10 package bidi diff --git a/vendor/golang.org/x/text/unicode/norm/tables10.0.0.go b/vendor/golang.org/x/text/unicode/norm/tables10.0.0.go index f5a078827..1af161c75 100644 --- a/vendor/golang.org/x/text/unicode/norm/tables10.0.0.go +++ b/vendor/golang.org/x/text/unicode/norm/tables10.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.10 && !go1.13 -// +build go1.10,!go1.13 package norm diff --git a/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go b/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go index cb7239c43..eb73ecc37 100644 --- a/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go +++ b/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.13 && !go1.14 -// +build go1.13,!go1.14 package norm diff --git a/vendor/golang.org/x/text/unicode/norm/tables12.0.0.go b/vendor/golang.org/x/text/unicode/norm/tables12.0.0.go index 11b273300..276cb8d8c 100644 --- a/vendor/golang.org/x/text/unicode/norm/tables12.0.0.go +++ b/vendor/golang.org/x/text/unicode/norm/tables12.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.14 && !go1.16 -// +build go1.14,!go1.16 package norm diff --git a/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go b/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go index f65785e8a..0cceffd73 100644 --- a/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go +++ b/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.16 && !go1.21 -// +build go1.16,!go1.21 package norm diff --git a/vendor/golang.org/x/text/unicode/norm/tables15.0.0.go b/vendor/golang.org/x/text/unicode/norm/tables15.0.0.go index e1858b879..b0819e42d 100644 --- a/vendor/golang.org/x/text/unicode/norm/tables15.0.0.go +++ b/vendor/golang.org/x/text/unicode/norm/tables15.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build go1.21 -// +build go1.21 package norm diff --git a/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go b/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go index 0175eae50..bf65457d9 100644 --- a/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go +++ b/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go @@ -1,7 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. //go:build !go1.10 -// +build !go1.10 package norm diff --git a/vendor/google.golang.org/appengine/.travis.yml b/vendor/google.golang.org/appengine/.travis.yml deleted file mode 100644 index 6d03f4d36..000000000 --- a/vendor/google.golang.org/appengine/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: go - -go_import_path: google.golang.org/appengine - -install: - - ./travis_install.sh - -script: - - ./travis_test.sh - -matrix: - include: - - go: 1.9.x - env: GOAPP=true - - go: 1.10.x - env: GOAPP=false - - go: 1.11.x - env: GO111MODULE=on diff --git a/vendor/google.golang.org/appengine/CONTRIBUTING.md b/vendor/google.golang.org/appengine/CONTRIBUTING.md index ffc298520..289693613 100644 --- a/vendor/google.golang.org/appengine/CONTRIBUTING.md +++ b/vendor/google.golang.org/appengine/CONTRIBUTING.md @@ -19,14 +19,12 @@ ## Running system tests -Download and install the [Go App Engine SDK](https://cloud.google.com/appengine/docs/go/download). Make sure the `go_appengine` dir is in your `PATH`. - Set the `APPENGINE_DEV_APPSERVER` environment variable to `/path/to/go_appengine/dev_appserver.py`. -Run tests with `goapp test`: +Run tests with `go test`: ``` -goapp test -v google.golang.org/appengine/... +go test -v google.golang.org/appengine/... ``` ## Contributor License Agreements diff --git a/vendor/google.golang.org/appengine/README.md b/vendor/google.golang.org/appengine/README.md index 9fdbacd3c..5ccddd999 100644 --- a/vendor/google.golang.org/appengine/README.md +++ b/vendor/google.golang.org/appengine/README.md @@ -1,6 +1,6 @@ # Go App Engine packages -[![Build Status](https://travis-ci.org/golang/appengine.svg)](https://travis-ci.org/golang/appengine) +[![CI Status](https://github.com/golang/appengine/actions/workflows/ci.yml/badge.svg)](https://github.com/golang/appengine/actions/workflows/ci.yml) This repository supports the Go runtime on *App Engine standard*. It provides APIs for interacting with App Engine services. @@ -51,7 +51,7 @@ code importing `appengine/datastore` will now need to import `google.golang.org/ Most App Engine services are available with exactly the same API. A few APIs were cleaned up, and there are some differences: -* `appengine.Context` has been replaced with the `Context` type from `golang.org/x/net/context`. +* `appengine.Context` has been replaced with the `Context` type from `context`. * Logging methods that were on `appengine.Context` are now functions in `google.golang.org/appengine/log`. * `appengine.Timeout` has been removed. Use `context.WithTimeout` instead. * `appengine.Datacenter` now takes a `context.Context` argument. @@ -72,7 +72,7 @@ A few APIs were cleaned up, and there are some differences: * `appengine/socket` is not required on App Engine flexible environment / Managed VMs. Use the standard `net` package instead. -## Key Encode/Decode compatibiltiy to help with datastore library migrations +## Key Encode/Decode compatibility to help with datastore library migrations Key compatibility updates have been added to help customers transition from google.golang.org/appengine/datastore to cloud.google.com/go/datastore. The `EnableKeyConversion` enables automatic conversion from a key encoded with cloud.google.com/go/datastore to google.golang.org/appengine/datastore key type. diff --git a/vendor/google.golang.org/appengine/appengine.go b/vendor/google.golang.org/appengine/appengine.go index 8c9697674..35ba9c896 100644 --- a/vendor/google.golang.org/appengine/appengine.go +++ b/vendor/google.golang.org/appengine/appengine.go @@ -9,10 +9,10 @@ package appengine // import "google.golang.org/appengine" import ( + "context" "net/http" "github.com/golang/protobuf/proto" - "golang.org/x/net/context" "google.golang.org/appengine/internal" ) @@ -35,18 +35,18 @@ import ( // // Main is designed so that the app's main package looks like this: // -// package main +// package main // -// import ( -// "google.golang.org/appengine" +// import ( +// "google.golang.org/appengine" // -// _ "myapp/package0" -// _ "myapp/package1" -// ) +// _ "myapp/package0" +// _ "myapp/package1" +// ) // -// func main() { -// appengine.Main() -// } +// func main() { +// appengine.Main() +// } // // The "myapp/packageX" packages are expected to register HTTP handlers // in their init functions. @@ -54,6 +54,9 @@ func Main() { internal.Main() } +// Middleware wraps an http handler so that it can make GAE API calls +var Middleware func(http.Handler) http.Handler = internal.Middleware + // IsDevAppServer reports whether the App Engine app is running in the // development App Server. func IsDevAppServer() bool { diff --git a/vendor/google.golang.org/appengine/appengine_vm.go b/vendor/google.golang.org/appengine/appengine_vm.go index f4b645aad..6e1d041cd 100644 --- a/vendor/google.golang.org/appengine/appengine_vm.go +++ b/vendor/google.golang.org/appengine/appengine_vm.go @@ -2,19 +2,19 @@ // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. +//go:build !appengine // +build !appengine package appengine import ( - "golang.org/x/net/context" - - "google.golang.org/appengine/internal" + "context" ) // BackgroundContext returns a context not associated with a request. -// This should only be used when not servicing a request. -// This only works in App Engine "flexible environment". +// +// Deprecated: App Engine no longer has a special background context. +// Just use context.Background(). func BackgroundContext() context.Context { - return internal.BackgroundContext() + return context.Background() } diff --git a/vendor/google.golang.org/appengine/identity.go b/vendor/google.golang.org/appengine/identity.go index b8dcf8f36..1202fc1a5 100644 --- a/vendor/google.golang.org/appengine/identity.go +++ b/vendor/google.golang.org/appengine/identity.go @@ -5,10 +5,9 @@ package appengine import ( + "context" "time" - "golang.org/x/net/context" - "google.golang.org/appengine/internal" pb "google.golang.org/appengine/internal/app_identity" modpb "google.golang.org/appengine/internal/modules" diff --git a/vendor/google.golang.org/appengine/internal/api.go b/vendor/google.golang.org/appengine/internal/api.go index 721053c20..0569f5dd4 100644 --- a/vendor/google.golang.org/appengine/internal/api.go +++ b/vendor/google.golang.org/appengine/internal/api.go @@ -2,12 +2,14 @@ // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. +//go:build !appengine // +build !appengine package internal import ( "bytes" + "context" "errors" "fmt" "io/ioutil" @@ -24,7 +26,6 @@ import ( "time" "github.com/golang/protobuf/proto" - netcontext "golang.org/x/net/context" basepb "google.golang.org/appengine/internal/base" logpb "google.golang.org/appengine/internal/log" @@ -32,8 +33,7 @@ import ( ) const ( - apiPath = "/rpc_http" - defaultTicketSuffix = "/default.20150612t184001.0" + apiPath = "/rpc_http" ) var ( @@ -65,21 +65,22 @@ var ( IdleConnTimeout: 90 * time.Second, }, } - - defaultTicketOnce sync.Once - defaultTicket string - backgroundContextOnce sync.Once - backgroundContext netcontext.Context ) -func apiURL() *url.URL { +func apiURL(ctx context.Context) *url.URL { host, port := "appengine.googleapis.internal", "10001" if h := os.Getenv("API_HOST"); h != "" { host = h } + if hostOverride := ctx.Value(apiHostOverrideKey); hostOverride != nil { + host = hostOverride.(string) + } if p := os.Getenv("API_PORT"); p != "" { port = p } + if portOverride := ctx.Value(apiPortOverrideKey); portOverride != nil { + port = portOverride.(string) + } return &url.URL{ Scheme: "http", Host: host + ":" + port, @@ -87,82 +88,97 @@ func apiURL() *url.URL { } } -func handleHTTP(w http.ResponseWriter, r *http.Request) { - c := &context{ - req: r, - outHeader: w.Header(), - apiURL: apiURL(), - } - r = r.WithContext(withContext(r.Context(), c)) - c.req = r - - stopFlushing := make(chan int) +// Middleware wraps an http handler so that it can make GAE API calls +func Middleware(next http.Handler) http.Handler { + return handleHTTPMiddleware(executeRequestSafelyMiddleware(next)) +} - // Patch up RemoteAddr so it looks reasonable. - if addr := r.Header.Get(userIPHeader); addr != "" { - r.RemoteAddr = addr - } else if addr = r.Header.Get(remoteAddrHeader); addr != "" { - r.RemoteAddr = addr - } else { - // Should not normally reach here, but pick a sensible default anyway. - r.RemoteAddr = "127.0.0.1" - } - // The address in the headers will most likely be of these forms: - // 123.123.123.123 - // 2001:db8::1 - // net/http.Request.RemoteAddr is specified to be in "IP:port" form. - if _, _, err := net.SplitHostPort(r.RemoteAddr); err != nil { - // Assume the remote address is only a host; add a default port. - r.RemoteAddr = net.JoinHostPort(r.RemoteAddr, "80") - } +func handleHTTPMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + c := &aeContext{ + req: r, + outHeader: w.Header(), + } + r = r.WithContext(withContext(r.Context(), c)) + c.req = r + + stopFlushing := make(chan int) + + // Patch up RemoteAddr so it looks reasonable. + if addr := r.Header.Get(userIPHeader); addr != "" { + r.RemoteAddr = addr + } else if addr = r.Header.Get(remoteAddrHeader); addr != "" { + r.RemoteAddr = addr + } else { + // Should not normally reach here, but pick a sensible default anyway. + r.RemoteAddr = "127.0.0.1" + } + // The address in the headers will most likely be of these forms: + // 123.123.123.123 + // 2001:db8::1 + // net/http.Request.RemoteAddr is specified to be in "IP:port" form. + if _, _, err := net.SplitHostPort(r.RemoteAddr); err != nil { + // Assume the remote address is only a host; add a default port. + r.RemoteAddr = net.JoinHostPort(r.RemoteAddr, "80") + } - // Start goroutine responsible for flushing app logs. - // This is done after adding c to ctx.m (and stopped before removing it) - // because flushing logs requires making an API call. - go c.logFlusher(stopFlushing) + if logToLogservice() { + // Start goroutine responsible for flushing app logs. + // This is done after adding c to ctx.m (and stopped before removing it) + // because flushing logs requires making an API call. + go c.logFlusher(stopFlushing) + } - executeRequestSafely(c, r) - c.outHeader = nil // make sure header changes aren't respected any more + next.ServeHTTP(c, r) + c.outHeader = nil // make sure header changes aren't respected any more - stopFlushing <- 1 // any logging beyond this point will be dropped + flushed := make(chan struct{}) + if logToLogservice() { + stopFlushing <- 1 // any logging beyond this point will be dropped - // Flush any pending logs asynchronously. - c.pendingLogs.Lock() - flushes := c.pendingLogs.flushes - if len(c.pendingLogs.lines) > 0 { - flushes++ - } - c.pendingLogs.Unlock() - flushed := make(chan struct{}) - go func() { - defer close(flushed) - // Force a log flush, because with very short requests we - // may not ever flush logs. - c.flushLog(true) - }() - w.Header().Set(logFlushHeader, strconv.Itoa(flushes)) + // Flush any pending logs asynchronously. + c.pendingLogs.Lock() + flushes := c.pendingLogs.flushes + if len(c.pendingLogs.lines) > 0 { + flushes++ + } + c.pendingLogs.Unlock() + go func() { + defer close(flushed) + // Force a log flush, because with very short requests we + // may not ever flush logs. + c.flushLog(true) + }() + w.Header().Set(logFlushHeader, strconv.Itoa(flushes)) + } - // Avoid nil Write call if c.Write is never called. - if c.outCode != 0 { - w.WriteHeader(c.outCode) - } - if c.outBody != nil { - w.Write(c.outBody) - } - // Wait for the last flush to complete before returning, - // otherwise the security ticket will not be valid. - <-flushed + // Avoid nil Write call if c.Write is never called. + if c.outCode != 0 { + w.WriteHeader(c.outCode) + } + if c.outBody != nil { + w.Write(c.outBody) + } + if logToLogservice() { + // Wait for the last flush to complete before returning, + // otherwise the security ticket will not be valid. + <-flushed + } + }) } -func executeRequestSafely(c *context, r *http.Request) { - defer func() { - if x := recover(); x != nil { - logf(c, 4, "%s", renderPanic(x)) // 4 == critical - c.outCode = 500 - } - }() +func executeRequestSafelyMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + defer func() { + if x := recover(); x != nil { + c := w.(*aeContext) + logf(c, 4, "%s", renderPanic(x)) // 4 == critical + c.outCode = 500 + } + }() - http.DefaultServeMux.ServeHTTP(c, r) + next.ServeHTTP(w, r) + }) } func renderPanic(x interface{}) string { @@ -204,9 +220,9 @@ func renderPanic(x interface{}) string { return string(buf) } -// context represents the context of an in-flight HTTP request. +// aeContext represents the aeContext of an in-flight HTTP request. // It implements the appengine.Context and http.ResponseWriter interfaces. -type context struct { +type aeContext struct { req *http.Request outCode int @@ -218,8 +234,6 @@ type context struct { lines []*logpb.UserAppLogLine flushes int } - - apiURL *url.URL } var contextKey = "holds a *context" @@ -227,8 +241,8 @@ var contextKey = "holds a *context" // jointContext joins two contexts in a superficial way. // It takes values and timeouts from a base context, and only values from another context. type jointContext struct { - base netcontext.Context - valuesOnly netcontext.Context + base context.Context + valuesOnly context.Context } func (c jointContext) Deadline() (time.Time, bool) { @@ -252,94 +266,54 @@ func (c jointContext) Value(key interface{}) interface{} { // fromContext returns the App Engine context or nil if ctx is not // derived from an App Engine context. -func fromContext(ctx netcontext.Context) *context { - c, _ := ctx.Value(&contextKey).(*context) +func fromContext(ctx context.Context) *aeContext { + c, _ := ctx.Value(&contextKey).(*aeContext) return c } -func withContext(parent netcontext.Context, c *context) netcontext.Context { - ctx := netcontext.WithValue(parent, &contextKey, c) +func withContext(parent context.Context, c *aeContext) context.Context { + ctx := context.WithValue(parent, &contextKey, c) if ns := c.req.Header.Get(curNamespaceHeader); ns != "" { ctx = withNamespace(ctx, ns) } return ctx } -func toContext(c *context) netcontext.Context { - return withContext(netcontext.Background(), c) +func toContext(c *aeContext) context.Context { + return withContext(context.Background(), c) } -func IncomingHeaders(ctx netcontext.Context) http.Header { +func IncomingHeaders(ctx context.Context) http.Header { if c := fromContext(ctx); c != nil { return c.req.Header } return nil } -func ReqContext(req *http.Request) netcontext.Context { +func ReqContext(req *http.Request) context.Context { return req.Context() } -func WithContext(parent netcontext.Context, req *http.Request) netcontext.Context { +func WithContext(parent context.Context, req *http.Request) context.Context { return jointContext{ base: parent, valuesOnly: req.Context(), } } -// DefaultTicket returns a ticket used for background context or dev_appserver. -func DefaultTicket() string { - defaultTicketOnce.Do(func() { - if IsDevAppServer() { - defaultTicket = "testapp" + defaultTicketSuffix - return - } - appID := partitionlessAppID() - escAppID := strings.Replace(strings.Replace(appID, ":", "_", -1), ".", "_", -1) - majVersion := VersionID(nil) - if i := strings.Index(majVersion, "."); i > 0 { - majVersion = majVersion[:i] - } - defaultTicket = fmt.Sprintf("%s/%s.%s.%s", escAppID, ModuleName(nil), majVersion, InstanceID()) - }) - return defaultTicket -} - -func BackgroundContext() netcontext.Context { - backgroundContextOnce.Do(func() { - // Compute background security ticket. - ticket := DefaultTicket() - - c := &context{ - req: &http.Request{ - Header: http.Header{ - ticketHeader: []string{ticket}, - }, - }, - apiURL: apiURL(), - } - backgroundContext = toContext(c) - - // TODO(dsymonds): Wire up the shutdown handler to do a final flush. - go c.logFlusher(make(chan int)) - }) - - return backgroundContext -} - // RegisterTestRequest registers the HTTP request req for testing, such that -// any API calls are sent to the provided URL. It returns a closure to delete -// the registration. +// any API calls are sent to the provided URL. // It should only be used by aetest package. -func RegisterTestRequest(req *http.Request, apiURL *url.URL, decorate func(netcontext.Context) netcontext.Context) (*http.Request, func()) { - c := &context{ - req: req, - apiURL: apiURL, - } - ctx := withContext(decorate(req.Context()), c) - req = req.WithContext(ctx) - c.req = req - return req, func() {} +func RegisterTestRequest(req *http.Request, apiURL *url.URL, appID string) *http.Request { + ctx := req.Context() + ctx = withAPIHostOverride(ctx, apiURL.Hostname()) + ctx = withAPIPortOverride(ctx, apiURL.Port()) + ctx = WithAppIDOverride(ctx, appID) + + // use the unregistered request as a placeholder so that withContext can read the headers + c := &aeContext{req: req} + c.req = req.WithContext(withContext(ctx, c)) + return c.req } var errTimeout = &CallError{ @@ -348,7 +322,7 @@ var errTimeout = &CallError{ Timeout: true, } -func (c *context) Header() http.Header { return c.outHeader } +func (c *aeContext) Header() http.Header { return c.outHeader } // Copied from $GOROOT/src/pkg/net/http/transfer.go. Some response status // codes do not permit a response body (nor response entity headers such as @@ -365,7 +339,7 @@ func bodyAllowedForStatus(status int) bool { return true } -func (c *context) Write(b []byte) (int, error) { +func (c *aeContext) Write(b []byte) (int, error) { if c.outCode == 0 { c.WriteHeader(http.StatusOK) } @@ -376,7 +350,7 @@ func (c *context) Write(b []byte) (int, error) { return len(b), nil } -func (c *context) WriteHeader(code int) { +func (c *aeContext) WriteHeader(code int) { if c.outCode != 0 { logf(c, 3, "WriteHeader called multiple times on request.") // error level return @@ -384,10 +358,11 @@ func (c *context) WriteHeader(code int) { c.outCode = code } -func (c *context) post(body []byte, timeout time.Duration) (b []byte, err error) { +func post(ctx context.Context, body []byte, timeout time.Duration) (b []byte, err error) { + apiURL := apiURL(ctx) hreq := &http.Request{ Method: "POST", - URL: c.apiURL, + URL: apiURL, Header: http.Header{ apiEndpointHeader: apiEndpointHeaderValue, apiMethodHeader: apiMethodHeaderValue, @@ -396,13 +371,16 @@ func (c *context) post(body []byte, timeout time.Duration) (b []byte, err error) }, Body: ioutil.NopCloser(bytes.NewReader(body)), ContentLength: int64(len(body)), - Host: c.apiURL.Host, - } - if info := c.req.Header.Get(dapperHeader); info != "" { - hreq.Header.Set(dapperHeader, info) + Host: apiURL.Host, } - if info := c.req.Header.Get(traceHeader); info != "" { - hreq.Header.Set(traceHeader, info) + c := fromContext(ctx) + if c != nil { + if info := c.req.Header.Get(dapperHeader); info != "" { + hreq.Header.Set(dapperHeader, info) + } + if info := c.req.Header.Get(traceHeader); info != "" { + hreq.Header.Set(traceHeader, info) + } } tr := apiHTTPClient.Transport.(*http.Transport) @@ -444,7 +422,7 @@ func (c *context) post(body []byte, timeout time.Duration) (b []byte, err error) return hrespBody, nil } -func Call(ctx netcontext.Context, service, method string, in, out proto.Message) error { +func Call(ctx context.Context, service, method string, in, out proto.Message) error { if ns := NamespaceFromContext(ctx); ns != "" { if fn, ok := NamespaceMods[service]; ok { fn(in, ns) @@ -463,15 +441,11 @@ func Call(ctx netcontext.Context, service, method string, in, out proto.Message) } c := fromContext(ctx) - if c == nil { - // Give a good error message rather than a panic lower down. - return errNotAppEngineContext - } // Apply transaction modifications if we're in a transaction. if t := transactionFromContext(ctx); t != nil { if t.finished { - return errors.New("transaction context has expired") + return errors.New("transaction aeContext has expired") } applyTransaction(in, &t.transaction) } @@ -487,20 +461,13 @@ func Call(ctx netcontext.Context, service, method string, in, out proto.Message) return err } - ticket := c.req.Header.Get(ticketHeader) - // Use a test ticket under test environment. - if ticket == "" { - if appid := ctx.Value(&appIDOverrideKey); appid != nil { - ticket = appid.(string) + defaultTicketSuffix + ticket := "" + if c != nil { + ticket = c.req.Header.Get(ticketHeader) + if dri := c.req.Header.Get(devRequestIdHeader); IsDevAppServer() && dri != "" { + ticket = dri } } - // Fall back to use background ticket when the request ticket is not available in Flex or dev_appserver. - if ticket == "" { - ticket = DefaultTicket() - } - if dri := c.req.Header.Get(devRequestIdHeader); IsDevAppServer() && dri != "" { - ticket = dri - } req := &remotepb.Request{ ServiceName: &service, Method: &method, @@ -512,7 +479,7 @@ func Call(ctx netcontext.Context, service, method string, in, out proto.Message) return err } - hrespBody, err := c.post(hreqBody, timeout) + hrespBody, err := post(ctx, hreqBody, timeout) if err != nil { return err } @@ -549,11 +516,11 @@ func Call(ctx netcontext.Context, service, method string, in, out proto.Message) return proto.Unmarshal(res.Response, out) } -func (c *context) Request() *http.Request { +func (c *aeContext) Request() *http.Request { return c.req } -func (c *context) addLogLine(ll *logpb.UserAppLogLine) { +func (c *aeContext) addLogLine(ll *logpb.UserAppLogLine) { // Truncate long log lines. // TODO(dsymonds): Check if this is still necessary. const lim = 8 << 10 @@ -575,18 +542,20 @@ var logLevelName = map[int64]string{ 4: "CRITICAL", } -func logf(c *context, level int64, format string, args ...interface{}) { +func logf(c *aeContext, level int64, format string, args ...interface{}) { if c == nil { - panic("not an App Engine context") + panic("not an App Engine aeContext") } s := fmt.Sprintf(format, args...) s = strings.TrimRight(s, "\n") // Remove any trailing newline characters. - c.addLogLine(&logpb.UserAppLogLine{ - TimestampUsec: proto.Int64(time.Now().UnixNano() / 1e3), - Level: &level, - Message: &s, - }) - // Only duplicate log to stderr if not running on App Engine second generation + if logToLogservice() { + c.addLogLine(&logpb.UserAppLogLine{ + TimestampUsec: proto.Int64(time.Now().UnixNano() / 1e3), + Level: &level, + Message: &s, + }) + } + // Log to stdout if not deployed if !IsSecondGen() { log.Print(logLevelName[level] + ": " + s) } @@ -594,7 +563,7 @@ func logf(c *context, level int64, format string, args ...interface{}) { // flushLog attempts to flush any pending logs to the appserver. // It should not be called concurrently. -func (c *context) flushLog(force bool) (flushed bool) { +func (c *aeContext) flushLog(force bool) (flushed bool) { c.pendingLogs.Lock() // Grab up to 30 MB. We can get away with up to 32 MB, but let's be cautious. n, rem := 0, 30<<20 @@ -655,7 +624,7 @@ const ( forceFlushInterval = 60 * time.Second ) -func (c *context) logFlusher(stop <-chan int) { +func (c *aeContext) logFlusher(stop <-chan int) { lastFlush := time.Now() tick := time.NewTicker(flushInterval) for { @@ -673,6 +642,12 @@ func (c *context) logFlusher(stop <-chan int) { } } -func ContextForTesting(req *http.Request) netcontext.Context { - return toContext(&context{req: req}) +func ContextForTesting(req *http.Request) context.Context { + return toContext(&aeContext{req: req}) +} + +func logToLogservice() bool { + // TODO: replace logservice with json structured logs to $LOG_DIR/app.log.json + // where $LOG_DIR is /var/log in prod and some tmpdir in dev + return os.Getenv("LOG_TO_LOGSERVICE") != "0" } diff --git a/vendor/google.golang.org/appengine/internal/api_classic.go b/vendor/google.golang.org/appengine/internal/api_classic.go index f0f40b2e3..87c33c798 100644 --- a/vendor/google.golang.org/appengine/internal/api_classic.go +++ b/vendor/google.golang.org/appengine/internal/api_classic.go @@ -2,11 +2,13 @@ // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. +//go:build appengine // +build appengine package internal import ( + "context" "errors" "fmt" "net/http" @@ -17,20 +19,19 @@ import ( basepb "appengine_internal/base" "github.com/golang/protobuf/proto" - netcontext "golang.org/x/net/context" ) var contextKey = "holds an appengine.Context" // fromContext returns the App Engine context or nil if ctx is not // derived from an App Engine context. -func fromContext(ctx netcontext.Context) appengine.Context { +func fromContext(ctx context.Context) appengine.Context { c, _ := ctx.Value(&contextKey).(appengine.Context) return c } // This is only for classic App Engine adapters. -func ClassicContextFromContext(ctx netcontext.Context) (appengine.Context, error) { +func ClassicContextFromContext(ctx context.Context) (appengine.Context, error) { c := fromContext(ctx) if c == nil { return nil, errNotAppEngineContext @@ -38,8 +39,8 @@ func ClassicContextFromContext(ctx netcontext.Context) (appengine.Context, error return c, nil } -func withContext(parent netcontext.Context, c appengine.Context) netcontext.Context { - ctx := netcontext.WithValue(parent, &contextKey, c) +func withContext(parent context.Context, c appengine.Context) context.Context { + ctx := context.WithValue(parent, &contextKey, c) s := &basepb.StringProto{} c.Call("__go__", "GetNamespace", &basepb.VoidProto{}, s, nil) @@ -50,7 +51,7 @@ func withContext(parent netcontext.Context, c appengine.Context) netcontext.Cont return ctx } -func IncomingHeaders(ctx netcontext.Context) http.Header { +func IncomingHeaders(ctx context.Context) http.Header { if c := fromContext(ctx); c != nil { if req, ok := c.Request().(*http.Request); ok { return req.Header @@ -59,11 +60,11 @@ func IncomingHeaders(ctx netcontext.Context) http.Header { return nil } -func ReqContext(req *http.Request) netcontext.Context { - return WithContext(netcontext.Background(), req) +func ReqContext(req *http.Request) context.Context { + return WithContext(context.Background(), req) } -func WithContext(parent netcontext.Context, req *http.Request) netcontext.Context { +func WithContext(parent context.Context, req *http.Request) context.Context { c := appengine.NewContext(req) return withContext(parent, c) } @@ -83,11 +84,11 @@ func (t *testingContext) Call(service, method string, _, _ appengine_internal.Pr } func (t *testingContext) Request() interface{} { return t.req } -func ContextForTesting(req *http.Request) netcontext.Context { - return withContext(netcontext.Background(), &testingContext{req: req}) +func ContextForTesting(req *http.Request) context.Context { + return withContext(context.Background(), &testingContext{req: req}) } -func Call(ctx netcontext.Context, service, method string, in, out proto.Message) error { +func Call(ctx context.Context, service, method string, in, out proto.Message) error { if ns := NamespaceFromContext(ctx); ns != "" { if fn, ok := NamespaceMods[service]; ok { fn(in, ns) @@ -144,8 +145,8 @@ func Call(ctx netcontext.Context, service, method string, in, out proto.Message) return err } -func handleHTTP(w http.ResponseWriter, r *http.Request) { - panic("handleHTTP called; this should be impossible") +func Middleware(next http.Handler) http.Handler { + panic("Middleware called; this should be impossible") } func logf(c appengine.Context, level int64, format string, args ...interface{}) { diff --git a/vendor/google.golang.org/appengine/internal/api_common.go b/vendor/google.golang.org/appengine/internal/api_common.go index e0c0b214b..5b95c13d9 100644 --- a/vendor/google.golang.org/appengine/internal/api_common.go +++ b/vendor/google.golang.org/appengine/internal/api_common.go @@ -5,20 +5,26 @@ package internal import ( + "context" "errors" "os" "github.com/golang/protobuf/proto" - netcontext "golang.org/x/net/context" ) +type ctxKey string + +func (c ctxKey) String() string { + return "appengine context key: " + string(c) +} + var errNotAppEngineContext = errors.New("not an App Engine context") -type CallOverrideFunc func(ctx netcontext.Context, service, method string, in, out proto.Message) error +type CallOverrideFunc func(ctx context.Context, service, method string, in, out proto.Message) error var callOverrideKey = "holds []CallOverrideFunc" -func WithCallOverride(ctx netcontext.Context, f CallOverrideFunc) netcontext.Context { +func WithCallOverride(ctx context.Context, f CallOverrideFunc) context.Context { // We avoid appending to any existing call override // so we don't risk overwriting a popped stack below. var cofs []CallOverrideFunc @@ -26,10 +32,10 @@ func WithCallOverride(ctx netcontext.Context, f CallOverrideFunc) netcontext.Con cofs = append(cofs, uf...) } cofs = append(cofs, f) - return netcontext.WithValue(ctx, &callOverrideKey, cofs) + return context.WithValue(ctx, &callOverrideKey, cofs) } -func callOverrideFromContext(ctx netcontext.Context) (CallOverrideFunc, netcontext.Context, bool) { +func callOverrideFromContext(ctx context.Context) (CallOverrideFunc, context.Context, bool) { cofs, _ := ctx.Value(&callOverrideKey).([]CallOverrideFunc) if len(cofs) == 0 { return nil, nil, false @@ -37,7 +43,7 @@ func callOverrideFromContext(ctx netcontext.Context) (CallOverrideFunc, netconte // We found a list of overrides; grab the last, and reconstitute a // context that will hide it. f := cofs[len(cofs)-1] - ctx = netcontext.WithValue(ctx, &callOverrideKey, cofs[:len(cofs)-1]) + ctx = context.WithValue(ctx, &callOverrideKey, cofs[:len(cofs)-1]) return f, ctx, true } @@ -45,23 +51,35 @@ type logOverrideFunc func(level int64, format string, args ...interface{}) var logOverrideKey = "holds a logOverrideFunc" -func WithLogOverride(ctx netcontext.Context, f logOverrideFunc) netcontext.Context { - return netcontext.WithValue(ctx, &logOverrideKey, f) +func WithLogOverride(ctx context.Context, f logOverrideFunc) context.Context { + return context.WithValue(ctx, &logOverrideKey, f) } var appIDOverrideKey = "holds a string, being the full app ID" -func WithAppIDOverride(ctx netcontext.Context, appID string) netcontext.Context { - return netcontext.WithValue(ctx, &appIDOverrideKey, appID) +func WithAppIDOverride(ctx context.Context, appID string) context.Context { + return context.WithValue(ctx, &appIDOverrideKey, appID) +} + +var apiHostOverrideKey = ctxKey("holds a string, being the alternate API_HOST") + +func withAPIHostOverride(ctx context.Context, apiHost string) context.Context { + return context.WithValue(ctx, apiHostOverrideKey, apiHost) +} + +var apiPortOverrideKey = ctxKey("holds a string, being the alternate API_PORT") + +func withAPIPortOverride(ctx context.Context, apiPort string) context.Context { + return context.WithValue(ctx, apiPortOverrideKey, apiPort) } var namespaceKey = "holds the namespace string" -func withNamespace(ctx netcontext.Context, ns string) netcontext.Context { - return netcontext.WithValue(ctx, &namespaceKey, ns) +func withNamespace(ctx context.Context, ns string) context.Context { + return context.WithValue(ctx, &namespaceKey, ns) } -func NamespaceFromContext(ctx netcontext.Context) string { +func NamespaceFromContext(ctx context.Context) string { // If there's no namespace, return the empty string. ns, _ := ctx.Value(&namespaceKey).(string) return ns @@ -70,14 +88,14 @@ func NamespaceFromContext(ctx netcontext.Context) string { // FullyQualifiedAppID returns the fully-qualified application ID. // This may contain a partition prefix (e.g. "s~" for High Replication apps), // or a domain prefix (e.g. "example.com:"). -func FullyQualifiedAppID(ctx netcontext.Context) string { +func FullyQualifiedAppID(ctx context.Context) string { if id, ok := ctx.Value(&appIDOverrideKey).(string); ok { return id } return fullyQualifiedAppID(ctx) } -func Logf(ctx netcontext.Context, level int64, format string, args ...interface{}) { +func Logf(ctx context.Context, level int64, format string, args ...interface{}) { if f, ok := ctx.Value(&logOverrideKey).(logOverrideFunc); ok { f(level, format, args...) return @@ -90,7 +108,7 @@ func Logf(ctx netcontext.Context, level int64, format string, args ...interface{ } // NamespacedContext wraps a Context to support namespaces. -func NamespacedContext(ctx netcontext.Context, namespace string) netcontext.Context { +func NamespacedContext(ctx context.Context, namespace string) context.Context { return withNamespace(ctx, namespace) } diff --git a/vendor/google.golang.org/appengine/internal/identity.go b/vendor/google.golang.org/appengine/internal/identity.go index 9b4134e42..0f95aa91d 100644 --- a/vendor/google.golang.org/appengine/internal/identity.go +++ b/vendor/google.golang.org/appengine/internal/identity.go @@ -5,9 +5,8 @@ package internal import ( + "context" "os" - - netcontext "golang.org/x/net/context" ) var ( @@ -23,7 +22,7 @@ var ( // AppID is the implementation of the wrapper function of the same name in // ../identity.go. See that file for commentary. -func AppID(c netcontext.Context) string { +func AppID(c context.Context) string { return appID(FullyQualifiedAppID(c)) } @@ -35,7 +34,7 @@ func IsStandard() bool { return appengineStandard || IsSecondGen() } -// IsStandard is the implementation of the wrapper function of the same name in +// IsSecondGen is the implementation of the wrapper function of the same name in // ../appengine.go. See that file for commentary. func IsSecondGen() bool { // Second-gen runtimes set $GAE_ENV so we use that to check if we're on a second-gen runtime. diff --git a/vendor/google.golang.org/appengine/internal/identity_classic.go b/vendor/google.golang.org/appengine/internal/identity_classic.go index 4e979f45e..5ad3548bf 100644 --- a/vendor/google.golang.org/appengine/internal/identity_classic.go +++ b/vendor/google.golang.org/appengine/internal/identity_classic.go @@ -2,21 +2,22 @@ // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. +//go:build appengine // +build appengine package internal import ( - "appengine" + "context" - netcontext "golang.org/x/net/context" + "appengine" ) func init() { appengineStandard = true } -func DefaultVersionHostname(ctx netcontext.Context) string { +func DefaultVersionHostname(ctx context.Context) string { c := fromContext(ctx) if c == nil { panic(errNotAppEngineContext) @@ -24,12 +25,12 @@ func DefaultVersionHostname(ctx netcontext.Context) string { return appengine.DefaultVersionHostname(c) } -func Datacenter(_ netcontext.Context) string { return appengine.Datacenter() } -func ServerSoftware() string { return appengine.ServerSoftware() } -func InstanceID() string { return appengine.InstanceID() } -func IsDevAppServer() bool { return appengine.IsDevAppServer() } +func Datacenter(_ context.Context) string { return appengine.Datacenter() } +func ServerSoftware() string { return appengine.ServerSoftware() } +func InstanceID() string { return appengine.InstanceID() } +func IsDevAppServer() bool { return appengine.IsDevAppServer() } -func RequestID(ctx netcontext.Context) string { +func RequestID(ctx context.Context) string { c := fromContext(ctx) if c == nil { panic(errNotAppEngineContext) @@ -37,14 +38,14 @@ func RequestID(ctx netcontext.Context) string { return appengine.RequestID(c) } -func ModuleName(ctx netcontext.Context) string { +func ModuleName(ctx context.Context) string { c := fromContext(ctx) if c == nil { panic(errNotAppEngineContext) } return appengine.ModuleName(c) } -func VersionID(ctx netcontext.Context) string { +func VersionID(ctx context.Context) string { c := fromContext(ctx) if c == nil { panic(errNotAppEngineContext) @@ -52,7 +53,7 @@ func VersionID(ctx netcontext.Context) string { return appengine.VersionID(c) } -func fullyQualifiedAppID(ctx netcontext.Context) string { +func fullyQualifiedAppID(ctx context.Context) string { c := fromContext(ctx) if c == nil { panic(errNotAppEngineContext) diff --git a/vendor/google.golang.org/appengine/internal/identity_flex.go b/vendor/google.golang.org/appengine/internal/identity_flex.go index d5e2e7b5e..4201b6b58 100644 --- a/vendor/google.golang.org/appengine/internal/identity_flex.go +++ b/vendor/google.golang.org/appengine/internal/identity_flex.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. +//go:build appenginevm // +build appenginevm package internal diff --git a/vendor/google.golang.org/appengine/internal/identity_vm.go b/vendor/google.golang.org/appengine/internal/identity_vm.go index 5d8067263..18ddda3a4 100644 --- a/vendor/google.golang.org/appengine/internal/identity_vm.go +++ b/vendor/google.golang.org/appengine/internal/identity_vm.go @@ -2,17 +2,17 @@ // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. +//go:build !appengine // +build !appengine package internal import ( + "context" "log" "net/http" "os" "strings" - - netcontext "golang.org/x/net/context" ) // These functions are implementations of the wrapper functions @@ -24,7 +24,7 @@ const ( hDatacenter = "X-AppEngine-Datacenter" ) -func ctxHeaders(ctx netcontext.Context) http.Header { +func ctxHeaders(ctx context.Context) http.Header { c := fromContext(ctx) if c == nil { return nil @@ -32,15 +32,15 @@ func ctxHeaders(ctx netcontext.Context) http.Header { return c.Request().Header } -func DefaultVersionHostname(ctx netcontext.Context) string { +func DefaultVersionHostname(ctx context.Context) string { return ctxHeaders(ctx).Get(hDefaultVersionHostname) } -func RequestID(ctx netcontext.Context) string { +func RequestID(ctx context.Context) string { return ctxHeaders(ctx).Get(hRequestLogId) } -func Datacenter(ctx netcontext.Context) string { +func Datacenter(ctx context.Context) string { if dc := ctxHeaders(ctx).Get(hDatacenter); dc != "" { return dc } @@ -71,7 +71,7 @@ func ServerSoftware() string { // TODO(dsymonds): Remove the metadata fetches. -func ModuleName(_ netcontext.Context) string { +func ModuleName(_ context.Context) string { if s := os.Getenv("GAE_MODULE_NAME"); s != "" { return s } @@ -81,7 +81,7 @@ func ModuleName(_ netcontext.Context) string { return string(mustGetMetadata("instance/attributes/gae_backend_name")) } -func VersionID(_ netcontext.Context) string { +func VersionID(_ context.Context) string { if s1, s2 := os.Getenv("GAE_MODULE_VERSION"), os.Getenv("GAE_MINOR_VERSION"); s1 != "" && s2 != "" { return s1 + "." + s2 } @@ -112,7 +112,7 @@ func partitionlessAppID() string { return string(mustGetMetadata("instance/attributes/gae_project")) } -func fullyQualifiedAppID(_ netcontext.Context) string { +func fullyQualifiedAppID(_ context.Context) string { if s := os.Getenv("GAE_APPLICATION"); s != "" { return s } @@ -130,5 +130,5 @@ func fullyQualifiedAppID(_ netcontext.Context) string { } func IsDevAppServer() bool { - return os.Getenv("RUN_WITH_DEVAPPSERVER") != "" + return os.Getenv("RUN_WITH_DEVAPPSERVER") != "" || os.Getenv("GAE_ENV") == "localdev" } diff --git a/vendor/google.golang.org/appengine/internal/main.go b/vendor/google.golang.org/appengine/internal/main.go index 1e765312f..afd0ae84f 100644 --- a/vendor/google.golang.org/appengine/internal/main.go +++ b/vendor/google.golang.org/appengine/internal/main.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. +//go:build appengine // +build appengine package internal diff --git a/vendor/google.golang.org/appengine/internal/main_vm.go b/vendor/google.golang.org/appengine/internal/main_vm.go index ddb79a333..86a8caf06 100644 --- a/vendor/google.golang.org/appengine/internal/main_vm.go +++ b/vendor/google.golang.org/appengine/internal/main_vm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. +//go:build !appengine // +build !appengine package internal @@ -29,7 +30,7 @@ func Main() { if IsDevAppServer() { host = "127.0.0.1" } - if err := http.ListenAndServe(host+":"+port, http.HandlerFunc(handleHTTP)); err != nil { + if err := http.ListenAndServe(host+":"+port, Middleware(http.DefaultServeMux)); err != nil { log.Fatalf("http.ListenAndServe: %v", err) } } diff --git a/vendor/google.golang.org/appengine/internal/transaction.go b/vendor/google.golang.org/appengine/internal/transaction.go index 9006ae653..2ae8ab9fa 100644 --- a/vendor/google.golang.org/appengine/internal/transaction.go +++ b/vendor/google.golang.org/appengine/internal/transaction.go @@ -7,11 +7,11 @@ package internal // This file implements hooks for applying datastore transactions. import ( + "context" "errors" "reflect" "github.com/golang/protobuf/proto" - netcontext "golang.org/x/net/context" basepb "google.golang.org/appengine/internal/base" pb "google.golang.org/appengine/internal/datastore" @@ -38,13 +38,13 @@ func applyTransaction(pb proto.Message, t *pb.Transaction) { var transactionKey = "used for *Transaction" -func transactionFromContext(ctx netcontext.Context) *transaction { +func transactionFromContext(ctx context.Context) *transaction { t, _ := ctx.Value(&transactionKey).(*transaction) return t } -func withTransaction(ctx netcontext.Context, t *transaction) netcontext.Context { - return netcontext.WithValue(ctx, &transactionKey, t) +func withTransaction(ctx context.Context, t *transaction) context.Context { + return context.WithValue(ctx, &transactionKey, t) } type transaction struct { @@ -54,7 +54,7 @@ type transaction struct { var ErrConcurrentTransaction = errors.New("internal: concurrent transaction") -func RunTransactionOnce(c netcontext.Context, f func(netcontext.Context) error, xg bool, readOnly bool, previousTransaction *pb.Transaction) (*pb.Transaction, error) { +func RunTransactionOnce(c context.Context, f func(context.Context) error, xg bool, readOnly bool, previousTransaction *pb.Transaction) (*pb.Transaction, error) { if transactionFromContext(c) != nil { return nil, errors.New("nested transactions are not supported") } diff --git a/vendor/google.golang.org/appengine/namespace.go b/vendor/google.golang.org/appengine/namespace.go index 21860ca08..6f169be48 100644 --- a/vendor/google.golang.org/appengine/namespace.go +++ b/vendor/google.golang.org/appengine/namespace.go @@ -5,11 +5,10 @@ package appengine import ( + "context" "fmt" "regexp" - "golang.org/x/net/context" - "google.golang.org/appengine/internal" ) diff --git a/vendor/google.golang.org/appengine/socket/socket_classic.go b/vendor/google.golang.org/appengine/socket/socket_classic.go index 0ad50e2d3..20e594052 100644 --- a/vendor/google.golang.org/appengine/socket/socket_classic.go +++ b/vendor/google.golang.org/appengine/socket/socket_classic.go @@ -2,11 +2,13 @@ // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. +//go:build appengine // +build appengine package socket import ( + "context" "fmt" "io" "net" @@ -14,7 +16,6 @@ import ( "time" "github.com/golang/protobuf/proto" - "golang.org/x/net/context" "google.golang.org/appengine/internal" pb "google.golang.org/appengine/internal/socket" diff --git a/vendor/google.golang.org/appengine/socket/socket_vm.go b/vendor/google.golang.org/appengine/socket/socket_vm.go index c804169a1..fa0ec8386 100644 --- a/vendor/google.golang.org/appengine/socket/socket_vm.go +++ b/vendor/google.golang.org/appengine/socket/socket_vm.go @@ -2,15 +2,15 @@ // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. +//go:build !appengine // +build !appengine package socket import ( + "context" "net" "time" - - "golang.org/x/net/context" ) // Dial connects to the address addr on the network protocol. diff --git a/vendor/google.golang.org/appengine/timeout.go b/vendor/google.golang.org/appengine/timeout.go index 05642a992..fcf3ad0a5 100644 --- a/vendor/google.golang.org/appengine/timeout.go +++ b/vendor/google.golang.org/appengine/timeout.go @@ -4,7 +4,7 @@ package appengine -import "golang.org/x/net/context" +import "context" // IsTimeoutError reports whether err is a timeout error. func IsTimeoutError(err error) bool { diff --git a/vendor/google.golang.org/appengine/travis_install.sh b/vendor/google.golang.org/appengine/travis_install.sh deleted file mode 100644 index 785b62f46..000000000 --- a/vendor/google.golang.org/appengine/travis_install.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -e - -if [[ $GO111MODULE == "on" ]]; then - go get . -else - go get -u -v $(go list -f '{{join .Imports "\n"}}{{"\n"}}{{join .TestImports "\n"}}' ./... | sort | uniq | grep -v appengine) -fi - -if [[ $GOAPP == "true" ]]; then - mkdir /tmp/sdk - curl -o /tmp/sdk.zip "https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.68.zip" - unzip -q /tmp/sdk.zip -d /tmp/sdk - # NOTE: Set the following env vars in the test script: - # export PATH="$PATH:/tmp/sdk/go_appengine" - # export APPENGINE_DEV_APPSERVER=/tmp/sdk/go_appengine/dev_appserver.py -fi - diff --git a/vendor/google.golang.org/appengine/travis_test.sh b/vendor/google.golang.org/appengine/travis_test.sh deleted file mode 100644 index d4390f045..000000000 --- a/vendor/google.golang.org/appengine/travis_test.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -e - -go version -go test -v google.golang.org/appengine/... -go test -v -race google.golang.org/appengine/... -if [[ $GOAPP == "true" ]]; then - export PATH="$PATH:/tmp/sdk/go_appengine" - export APPENGINE_DEV_APPSERVER=/tmp/sdk/go_appengine/dev_appserver.py - goapp version - goapp test -v google.golang.org/appengine/... -fi diff --git a/vendor/google.golang.org/appengine/urlfetch/urlfetch.go b/vendor/google.golang.org/appengine/urlfetch/urlfetch.go index 6ffe1e6d9..6c0d72418 100644 --- a/vendor/google.golang.org/appengine/urlfetch/urlfetch.go +++ b/vendor/google.golang.org/appengine/urlfetch/urlfetch.go @@ -7,6 +7,7 @@ package urlfetch // import "google.golang.org/appengine/urlfetch" import ( + "context" "errors" "fmt" "io" @@ -18,7 +19,6 @@ import ( "time" "github.com/golang/protobuf/proto" - "golang.org/x/net/context" "google.golang.org/appengine/internal" pb "google.golang.org/appengine/internal/urlfetch" @@ -44,11 +44,10 @@ type Transport struct { var _ http.RoundTripper = (*Transport)(nil) // Client returns an *http.Client using a default urlfetch Transport. This -// client will have the default deadline of 5 seconds, and will check the -// validity of SSL certificates. +// client will check the validity of SSL certificates. // -// Any deadline of the provided context will be used for requests through this client; -// if the client does not have a deadline then a 5 second default is used. +// Any deadline of the provided context will be used for requests through this client. +// If the client does not have a deadline, then an App Engine default of 60 second is used. func Client(ctx context.Context) *http.Client { return &http.Client{ Transport: &Transport{ diff --git a/vendor/modules.txt b/vendor/modules.txt index 60714b657..31b7abd5d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -148,6 +148,34 @@ github.com/aws/aws-sdk-go/service/sts/stsiface # github.com/beorn7/perks v1.0.1 ## explicit; go 1.11 github.com/beorn7/perks/quantile +# github.com/brightbox/gobrightbox/v2 v2.2.0 +## explicit; go 1.20 +github.com/brightbox/gobrightbox/v2 +github.com/brightbox/gobrightbox/v2/clientcredentials +github.com/brightbox/gobrightbox/v2/endpoint +github.com/brightbox/gobrightbox/v2/enums/accountstatus +github.com/brightbox/gobrightbox/v2/enums/arch +github.com/brightbox/gobrightbox/v2/enums/balancingpolicy +github.com/brightbox/gobrightbox/v2/enums/cloudipstatus +github.com/brightbox/gobrightbox/v2/enums/collaborationstatus +github.com/brightbox/gobrightbox/v2/enums/databaseserverstatus +github.com/brightbox/gobrightbox/v2/enums/databasesnapshotstatus +github.com/brightbox/gobrightbox/v2/enums/filesystemtype +github.com/brightbox/gobrightbox/v2/enums/healthchecktype +github.com/brightbox/gobrightbox/v2/enums/imagestatus +github.com/brightbox/gobrightbox/v2/enums/listenerprotocol +github.com/brightbox/gobrightbox/v2/enums/loadbalancerstatus +github.com/brightbox/gobrightbox/v2/enums/mode +github.com/brightbox/gobrightbox/v2/enums/permissionsgroup +github.com/brightbox/gobrightbox/v2/enums/proxyprotocol +github.com/brightbox/gobrightbox/v2/enums/serverstatus +github.com/brightbox/gobrightbox/v2/enums/servertypestatus +github.com/brightbox/gobrightbox/v2/enums/sourcetrigger +github.com/brightbox/gobrightbox/v2/enums/sourcetype +github.com/brightbox/gobrightbox/v2/enums/storagetype +github.com/brightbox/gobrightbox/v2/enums/transportprotocol +github.com/brightbox/gobrightbox/v2/enums/volumestatus +github.com/brightbox/gobrightbox/v2/enums/volumetype # github.com/cespare/xxhash/v2 v2.2.0 ## explicit; go 1.11 github.com/cespare/xxhash/v2 @@ -629,8 +657,8 @@ go.uber.org/zap/zapcore # go4.org v0.0.0-20201209231011-d4a079459e60 ## explicit; go 1.13 go4.org/errorutil -# golang.org/x/crypto v0.14.0 -## explicit; go 1.17 +# golang.org/x/crypto v0.15.0 +## explicit; go 1.18 golang.org/x/crypto/bcrypt golang.org/x/crypto/blowfish golang.org/x/crypto/cast5 @@ -655,8 +683,8 @@ golang.org/x/crypto/ssh golang.org/x/crypto/ssh/agent golang.org/x/crypto/ssh/internal/bcrypt_pbkdf golang.org/x/crypto/ssh/terminal -# golang.org/x/net v0.17.0 -## explicit; go 1.17 +# golang.org/x/net v0.18.0 +## explicit; go 1.18 golang.org/x/net/context golang.org/x/net/http/httpguts golang.org/x/net/http2 @@ -666,29 +694,32 @@ golang.org/x/net/internal/socks golang.org/x/net/internal/timeseries golang.org/x/net/proxy golang.org/x/net/trace -# golang.org/x/oauth2 v0.11.0 +# golang.org/x/oauth2 v0.14.0 ## explicit; go 1.18 golang.org/x/oauth2 golang.org/x/oauth2/authhandler +golang.org/x/oauth2/clientcredentials golang.org/x/oauth2/google golang.org/x/oauth2/google/internal/externalaccount +golang.org/x/oauth2/google/internal/externalaccountauthorizeduser +golang.org/x/oauth2/google/internal/stsexchange golang.org/x/oauth2/internal golang.org/x/oauth2/jws golang.org/x/oauth2/jwt # golang.org/x/sync v0.3.0 ## explicit; go 1.17 golang.org/x/sync/semaphore -# golang.org/x/sys v0.13.0 -## explicit; go 1.17 +# golang.org/x/sys v0.14.0 +## explicit; go 1.18 golang.org/x/sys/cpu golang.org/x/sys/plan9 golang.org/x/sys/unix golang.org/x/sys/windows -# golang.org/x/term v0.13.0 -## explicit; go 1.17 +# golang.org/x/term v0.14.0 +## explicit; go 1.18 golang.org/x/term -# golang.org/x/text v0.13.0 -## explicit; go 1.17 +# golang.org/x/text v0.14.0 +## explicit; go 1.18 golang.org/x/text/encoding golang.org/x/text/encoding/internal golang.org/x/text/encoding/internal/identifier @@ -725,7 +756,7 @@ google.golang.org/api/transport google.golang.org/api/transport/grpc google.golang.org/api/transport/http google.golang.org/api/transport/http/internal/propagation -# google.golang.org/appengine v1.6.7 +# google.golang.org/appengine v1.6.8 ## explicit; go 1.11 google.golang.org/appengine google.golang.org/appengine/internal