From 4d1fa655b1175db4b306b5364cbbff55e4176f53 Mon Sep 17 00:00:00 2001
From: Adrian Riobo
### Mergo in the wild
-- [moby/moby](https://github.com/moby/moby)
-- [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes)
-- [vmware/dispatch](https://github.com/vmware/dispatch)
-- [Shopify/themekit](https://github.com/Shopify/themekit)
-- [imdario/zas](https://github.com/imdario/zas)
-- [matcornic/hermes](https://github.com/matcornic/hermes)
-- [OpenBazaar/openbazaar-go](https://github.com/OpenBazaar/openbazaar-go)
-- [kataras/iris](https://github.com/kataras/iris)
-- [michaelsauter/crane](https://github.com/michaelsauter/crane)
-- [go-task/task](https://github.com/go-task/task)
-- [sensu/uchiwa](https://github.com/sensu/uchiwa)
-- [ory/hydra](https://github.com/ory/hydra)
-- [sisatech/vcli](https://github.com/sisatech/vcli)
-- [dairycart/dairycart](https://github.com/dairycart/dairycart)
-- [projectcalico/felix](https://github.com/projectcalico/felix)
-- [resin-os/balena](https://github.com/resin-os/balena)
-- [go-kivik/kivik](https://github.com/go-kivik/kivik)
-- [Telefonica/govice](https://github.com/Telefonica/govice)
-- [supergiant/supergiant](supergiant/supergiant)
-- [SergeyTsalkov/brooce](https://github.com/SergeyTsalkov/brooce)
-- [soniah/dnsmadeeasy](https://github.com/soniah/dnsmadeeasy)
-- [ohsu-comp-bio/funnel](https://github.com/ohsu-comp-bio/funnel)
-- [EagerIO/Stout](https://github.com/EagerIO/Stout)
-- [lynndylanhurley/defsynth-api](https://github.com/lynndylanhurley/defsynth-api)
-- [russross/canvasassignments](https://github.com/russross/canvasassignments)
-- [rdegges/cryptly-api](https://github.com/rdegges/cryptly-api)
-- [casualjim/exeggutor](https://github.com/casualjim/exeggutor)
-- [divshot/gitling](https://github.com/divshot/gitling)
-- [RWJMurphy/gorl](https://github.com/RWJMurphy/gorl)
-- [andrerocker/deploy42](https://github.com/andrerocker/deploy42)
-- [elwinar/rambler](https://github.com/elwinar/rambler)
-- [tmaiaroto/gopartman](https://github.com/tmaiaroto/gopartman)
-- [jfbus/impressionist](https://github.com/jfbus/impressionist)
-- [Jmeyering/zealot](https://github.com/Jmeyering/zealot)
-- [godep-migrator/rigger-host](https://github.com/godep-migrator/rigger-host)
-- [Dronevery/MultiwaySwitch-Go](https://github.com/Dronevery/MultiwaySwitch-Go)
-- [thoas/picfit](https://github.com/thoas/picfit)
-- [mantasmatelis/whooplist-server](https://github.com/mantasmatelis/whooplist-server)
-- [jnuthong/item_search](https://github.com/jnuthong/item_search)
-- [bukalapak/snowboard](https://github.com/bukalapak/snowboard)
-- [containerssh/containerssh](https://github.com/containerssh/containerssh)
-- [goreleaser/goreleaser](https://github.com/goreleaser/goreleaser)
-- [tjpnz/structbot](https://github.com/tjpnz/structbot)
+Mergo is used by [thousands](https://deps.dev/go/dario.cat%2Fmergo/v1.0.0/dependents) [of](https://deps.dev/go/github.com%2Fimdario%2Fmergo/v0.3.16/dependents) [projects](https://deps.dev/go/github.com%2Fimdario%2Fmergo/v0.3.12), including:
+
+* [containerd/containerd](https://github.com/containerd/containerd)
+* [datadog/datadog-agent](https://github.com/datadog/datadog-agent)
+* [docker/cli/](https://github.com/docker/cli/)
+* [goreleaser/goreleaser](https://github.com/goreleaser/goreleaser)
+* [go-micro/go-micro](https://github.com/go-micro/go-micro)
+* [grafana/loki](https://github.com/grafana/loki)
+* [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes)
+* [masterminds/sprig](github.com/Masterminds/sprig)
+* [moby/moby](https://github.com/moby/moby)
+* [slackhq/nebula](https://github.com/slackhq/nebula)
+* [volcano-sh/volcano](https://github.com/volcano-sh/volcano)
## Install
@@ -141,6 +118,39 @@ if err := mergo.Merge(&dst, src, mergo.WithOverride); err != nil {
}
```
+If you need to override pointers, so the source pointer's value is assigned to the destination's pointer, you must use `WithoutDereference`:
+
+```go
+package main
+
+import (
+ "fmt"
+
+ "dario.cat/mergo"
+)
+
+type Foo struct {
+ A *string
+ B int64
+}
+
+func main() {
+ first := "first"
+ second := "second"
+ src := Foo{
+ A: &first,
+ B: 2,
+ }
+
+ dest := Foo{
+ A: &second,
+ B: 1,
+ }
+
+ mergo.Merge(&dest, src, mergo.WithOverride, mergo.WithoutDereference)
+}
+```
+
Additionally, you can map a `map[string]interface{}` to a struct (and otherwise, from struct to map), following the same restrictions as in `Merge()`. Keys are capitalized to find each corresponding exported field.
```go
diff --git a/vendor/dario.cat/mergo/map.go b/vendor/dario.cat/mergo/map.go
index b50d5c2a4..759b4f74f 100644
--- a/vendor/dario.cat/mergo/map.go
+++ b/vendor/dario.cat/mergo/map.go
@@ -58,7 +58,7 @@ func deepMap(dst, src reflect.Value, visited map[uintptr]*visit, depth int, conf
}
fieldName := field.Name
fieldName = changeInitialCase(fieldName, unicode.ToLower)
- if v, ok := dstMap[fieldName]; !ok || (isEmptyValue(reflect.ValueOf(v), !config.ShouldNotDereference) || overwrite) {
+ if _, ok := dstMap[fieldName]; !ok || (!isEmptyValue(reflect.ValueOf(src.Field(i).Interface()), !config.ShouldNotDereference) && overwrite) || config.overwriteWithEmptyValue {
dstMap[fieldName] = src.Field(i).Interface()
}
}
diff --git a/vendor/dario.cat/mergo/merge.go b/vendor/dario.cat/mergo/merge.go
index 0ef9b2138..fd47c95b2 100644
--- a/vendor/dario.cat/mergo/merge.go
+++ b/vendor/dario.cat/mergo/merge.go
@@ -269,7 +269,7 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
if err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1, config); err != nil {
return
}
- } else {
+ } else if src.Elem().Kind() != reflect.Struct {
if overwriteWithEmptySrc || (overwrite && !src.IsNil()) || dst.IsNil() {
dst.Set(src)
}
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/awsapi/selectorec2.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/awsapi/selectorec2.go
deleted file mode 100644
index 8523d2915..000000000
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/awsapi/selectorec2.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package awsapi
-
-import (
- "context"
- "github.com/aws/aws-sdk-go-v2/service/ec2"
-)
-
-type SelectorInterface interface {
- ec2.DescribeInstanceTypeOfferingsAPIClient
- ec2.DescribeInstanceTypesAPIClient
- DescribeAvailabilityZones(ctx context.Context, params *ec2.DescribeAvailabilityZonesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeAvailabilityZonesOutput, error)
-}
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/LICENSE b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/LICENSE
similarity index 100%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/LICENSE
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/LICENSE
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/NOTICE b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/NOTICE
similarity index 100%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/NOTICE
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/NOTICE
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/awsapi/selectorec2.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/awsapi/selectorec2.go
new file mode 100644
index 000000000..ea8d681b6
--- /dev/null
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/awsapi/selectorec2.go
@@ -0,0 +1,26 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package awsapi
+
+import (
+ "context"
+
+ "github.com/aws/aws-sdk-go-v2/service/ec2"
+)
+
+type SelectorInterface interface {
+ ec2.DescribeInstanceTypeOfferingsAPIClient
+ ec2.DescribeInstanceTypesAPIClient
+ DescribeAvailabilityZones(ctx context.Context, params *ec2.DescribeAvailabilityZonesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeAvailabilityZonesOutput, error)
+}
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/bytequantity/bytequantity.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/bytequantity/bytequantity.go
similarity index 78%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/bytequantity/bytequantity.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/bytequantity/bytequantity.go
index b442a2cd6..b907ae12b 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/bytequantity/bytequantity.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/bytequantity/bytequantity.go
@@ -1,15 +1,14 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package bytequantity
@@ -22,7 +21,7 @@ import (
)
const (
- /// Examples: 1mb, 1 gb, 1.0tb, 1mib, 2g, 2.001 t
+ /// Examples: 1mb, 1 gb, 1.0tb, 1mib, 2g, 2.001 t.
byteQuantityRegex = `^([0-9]+\.?[0-9]{0,3})[ ]?(mi?b?|gi?b?|ti?b?)?$`
mib = "MiB"
gib = "GiB"
@@ -33,7 +32,7 @@ const (
maxTiB = math.MaxUint64 / tbConvert
)
-// ByteQuantity is a data type representing a byte quantity
+// ByteQuantity is a data type representing a byte quantity.
type ByteQuantity struct {
Quantity uint64
}
@@ -54,7 +53,7 @@ func ParseToByteQuantity(byteQuantityStr string) (ByteQuantity, error) {
}
quantity := uint64(0)
switch strings.ToLower(string(unit[0])) {
- //mib
+ // mib
case "m":
inputDecSplit := strings.Split(quantityStr, ".")
if len(inputDecSplit) == 2 {
@@ -72,9 +71,9 @@ func ParseToByteQuantity(byteQuantityStr string) (ByteQuantity, error) {
if err != nil {
return ByteQuantity{}, err
}
- //gib
+ // gib
case "g":
- quantityDec, err := strconv.ParseFloat(quantityStr, 10)
+ quantityDec, err := strconv.ParseFloat(quantityStr, 64)
if err != nil {
return ByteQuantity{}, err
}
@@ -82,9 +81,9 @@ func ParseToByteQuantity(byteQuantityStr string) (ByteQuantity, error) {
return ByteQuantity{}, fmt.Errorf("error GiB value is too large")
}
quantity = uint64(quantityDec * gbConvert)
- //tib
+ // tib
case "t":
- quantityDec, err := strconv.ParseFloat(quantityStr, 10)
+ quantityDec, err := strconv.ParseFloat(quantityStr, 64)
if err != nil {
return ByteQuantity{}, err
}
@@ -101,53 +100,53 @@ func ParseToByteQuantity(byteQuantityStr string) (ByteQuantity, error) {
}, nil
}
-// FromTiB returns a byte quantity of the passed in tebibytes quantity
+// FromTiB returns a byte quantity of the passed in tebibytes quantity.
func FromTiB(tib uint64) ByteQuantity {
return ByteQuantity{
Quantity: tib * tbConvert,
}
}
-// FromGiB returns a byte quantity of the passed in gibibytes quantity
+// FromGiB returns a byte quantity of the passed in gibibytes quantity.
func FromGiB(gib uint64) ByteQuantity {
return ByteQuantity{
Quantity: gib * gbConvert,
}
}
-// FromMiB returns a byte quantity of the passed in mebibytes quantity
+// FromMiB returns a byte quantity of the passed in mebibytes quantity.
func FromMiB(mib uint64) ByteQuantity {
return ByteQuantity{
Quantity: mib,
}
}
-// StringMiB returns a byte quantity in a mebibytes string representation
+// StringMiB returns a byte quantity in a mebibytes string representation.
func (bq ByteQuantity) StringMiB() string {
return fmt.Sprintf("%.0f %s", bq.MiB(), mib)
}
-// StringGiB returns a byte quantity in a gibibytes string representation
+// StringGiB returns a byte quantity in a gibibytes string representation.
func (bq ByteQuantity) StringGiB() string {
return fmt.Sprintf("%.3f %s", bq.GiB(), gib)
}
-// StringTiB returns a byte quantity in a tebibytes string representation
+// StringTiB returns a byte quantity in a tebibytes string representation.
func (bq ByteQuantity) StringTiB() string {
return fmt.Sprintf("%.3f %s", bq.TiB(), tib)
}
-// MiB returns a byte quantity in mebibytes
+// MiB returns a byte quantity in mebibytes.
func (bq ByteQuantity) MiB() float64 {
return float64(bq.Quantity)
}
-// GiB returns a byte quantity in gibibytes
+// GiB returns a byte quantity in gibibytes.
func (bq ByteQuantity) GiB() float64 {
return float64(bq.Quantity) * 1 / gbConvert
}
-// TiB returns a byte quantity in tebibytes
+// TiB returns a byte quantity in tebibytes.
func (bq ByteQuantity) TiB() float64 {
return float64(bq.Quantity) * 1 / tbConvert
}
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/ec2pricing/ec2pricing.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/ec2pricing/ec2pricing.go
similarity index 68%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/ec2pricing/ec2pricing.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/ec2pricing/ec2pricing.go
index 18e7f5fc1..ddef1af4b 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/ec2pricing/ec2pricing.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/ec2pricing/ec2pricing.go
@@ -1,20 +1,21 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package ec2pricing
import (
"context"
+ "fmt"
+ "log"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
@@ -29,17 +30,16 @@ const (
serviceCode = "AmazonEC2"
)
-var (
- DefaultSpotDaysBack = 30
-)
+var DefaultSpotDaysBack = 30
-// EC2Pricing is the public struct to interface with AWS pricing APIs
+// EC2Pricing is the public struct to interface with AWS pricing APIs.
type EC2Pricing struct {
ODPricing *OnDemandPricing
SpotPricing *SpotPricing
+ logger *log.Logger
}
-// EC2PricingIface is the EC2Pricing interface mainly used to mock out ec2pricing during testing
+// EC2PricingIface is the EC2Pricing interface mainly used to mock out ec2pricing during testing.
type EC2PricingIface interface {
GetOnDemandInstanceTypeCost(ctx context.Context, instanceType ec2types.InstanceType) (float64, error)
GetSpotInstanceTypeNDayAvgCost(ctx context.Context, instanceType ec2types.InstanceType, availabilityZones []string, days int) (float64, error)
@@ -48,46 +48,57 @@ type EC2PricingIface interface {
OnDemandCacheCount() int
SpotCacheCount() int
Save() error
+ SetLogger(*log.Logger)
}
// use us-east-1 since pricing only has endpoints in us-east-1 and ap-south-1
// TODO: In the future we may want to allow the client to select which endpoint is used through some mechanism
-// but that would likely happen through overriding this entire function as its signature is fixed
+//
+// but that would likely happen through overriding this entire function as its signature is fixed
func modifyPricingRegion(opt *pricing.Options) {
opt.Region = "us-east-1"
}
-// New creates an instance of instance-selector EC2Pricing
+// New creates an instance of instance-selector EC2Pricing.
func New(ctx context.Context, cfg aws.Config) (*EC2Pricing, error) {
- pricingClient := pricing.NewFromConfig(cfg, modifyPricingRegion)
- ec2Client := ec2.NewFromConfig(cfg)
- return &EC2Pricing{
- ODPricing: LoadODCacheOrNew(ctx, pricingClient, cfg.Region, 0, ""),
- SpotPricing: LoadSpotCacheOrNew(ctx, ec2Client, cfg.Region, 0, "", DefaultSpotDaysBack),
- }, nil
+ return NewWithCache(ctx, cfg, 0, "")
}
func NewWithCache(ctx context.Context, cfg aws.Config, ttl time.Duration, cacheDir string) (*EC2Pricing, error) {
pricingClient := pricing.NewFromConfig(cfg, modifyPricingRegion)
ec2Client := ec2.NewFromConfig(cfg)
+ odPricingCache, err := LoadODCacheOrNew(ctx, pricingClient, cfg.Region, ttl, cacheDir)
+ if err != nil {
+ return nil, fmt.Errorf("unable to initialize the OD pricing cache: %w", err)
+ }
+ spotPricingCache, err := LoadSpotCacheOrNew(ctx, ec2Client, cfg.Region, ttl, cacheDir, DefaultSpotDaysBack)
+ if err != nil {
+ return nil, fmt.Errorf("unable to initialize the spot pricing cache: %w", err)
+ }
return &EC2Pricing{
- ODPricing: LoadODCacheOrNew(ctx, pricingClient, cfg.Region, ttl, cacheDir),
- SpotPricing: LoadSpotCacheOrNew(ctx, ec2Client, cfg.Region, ttl, cacheDir, DefaultSpotDaysBack),
+ ODPricing: odPricingCache,
+ SpotPricing: spotPricingCache,
}, nil
}
-// OnDemandCacheCount returns the number of items in the OD cache
+func (p *EC2Pricing) SetLogger(logger *log.Logger) {
+ p.logger = logger
+ p.ODPricing.SetLogger(logger)
+ p.SpotPricing.SetLogger(logger)
+}
+
+// OnDemandCacheCount returns the number of items in the OD cache.
func (p *EC2Pricing) OnDemandCacheCount() int {
return p.ODPricing.Count()
}
-// SpotCacheCount returns the number of items in the spot cache
+// SpotCacheCount returns the number of items in the spot cache.
func (p *EC2Pricing) SpotCacheCount() int {
return p.SpotPricing.Count()
}
// GetSpotInstanceTypeNDayAvgCost retrieves the spot price history for a given AZ from the past N days and averages the price
-// Passing an empty list for availabilityZones will retrieve avg cost for all AZs in the current AWSSession's region
+// Passing an empty list for availabilityZones will retrieve avg cost for all AZs in the current AWSSession's region.
func (p *EC2Pricing) GetSpotInstanceTypeNDayAvgCost(ctx context.Context, instanceType ec2types.InstanceType, availabilityZones []string, days int) (float64, error) {
if len(availabilityZones) == 0 {
return p.SpotPricing.Get(ctx, instanceType, "", days)
@@ -108,17 +119,17 @@ func (p *EC2Pricing) GetSpotInstanceTypeNDayAvgCost(ctx context.Context, instanc
return costs[0], nil
}
-// GetOnDemandInstanceTypeCost retrieves the on-demand hourly cost for the specified instance type
+// GetOnDemandInstanceTypeCost retrieves the on-demand hourly cost for the specified instance type.
func (p *EC2Pricing) GetOnDemandInstanceTypeCost(ctx context.Context, instanceType ec2types.InstanceType) (float64, error) {
return p.ODPricing.Get(ctx, instanceType)
}
-// RefreshOnDemandCache makes a bulk request to the pricing api to retrieve all instance type pricing and stores them in a local cache
+// RefreshOnDemandCache makes a bulk request to the pricing api to retrieve all instance type pricing and stores them in a local cache.
func (p *EC2Pricing) RefreshOnDemandCache(ctx context.Context) error {
return p.ODPricing.Refresh(ctx)
}
-// RefreshSpotCache makes a bulk request to the ec2 api to retrieve all spot instance type pricing and stores them in a local cache
+// RefreshSpotCache makes a bulk request to the ec2 api to retrieve all spot instance type pricing and stores them in a local cache.
func (p *EC2Pricing) RefreshSpotCache(ctx context.Context, days int) error {
return p.SpotPricing.Refresh(ctx, days)
}
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/ec2pricing/odpricing.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/ec2pricing/odpricing.go
similarity index 72%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/ec2pricing/odpricing.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/ec2pricing/odpricing.go
index 19cde3c7c..eb234103b 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/ec2pricing/odpricing.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/ec2pricing/odpricing.go
@@ -1,15 +1,14 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package ec2pricing
@@ -18,19 +17,17 @@ import (
"encoding/json"
"errors"
"fmt"
- "io/ioutil"
+ "io"
"log"
"os"
"path/filepath"
"strconv"
- "strings"
"sync"
"time"
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
"github.com/aws/aws-sdk-go-v2/service/pricing"
pricingtypes "github.com/aws/aws-sdk-go-v2/service/pricing/types"
- "github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/mitchellh/go-homedir"
"github.com/patrickmn/go-cache"
"go.uber.org/multierr"
@@ -46,6 +43,7 @@ type OnDemandPricing struct {
DirectoryPath string
cache *cache.Cache
pricingClient pricing.GetProductsAPIClient
+ logger *log.Logger
sync.RWMutex
}
@@ -86,17 +84,10 @@ type PriceDimensionInfo struct {
PricePerUnit map[string]string `json:"pricePerUnit"`
}
-func LoadODCacheOrNew(ctx context.Context, pricingClient pricing.GetProductsAPIClient, region string, fullRefreshTTL time.Duration, directoryPath string) *OnDemandPricing {
+func LoadODCacheOrNew(ctx context.Context, pricingClient pricing.GetProductsAPIClient, region string, fullRefreshTTL time.Duration, directoryPath string) (*OnDemandPricing, error) {
expandedDirPath, err := homedir.Expand(directoryPath)
if err != nil {
- log.Printf("Unable to load on-demand pricing cache directory %s: %v", expandedDirPath, err)
- return &OnDemandPricing{
- Region: region,
- FullRefreshTTL: 0,
- DirectoryPath: directoryPath,
- cache: cache.New(fullRefreshTTL, fullRefreshTTL),
- pricingClient: pricingClient,
- }
+ return nil, fmt.Errorf("unable to load on-demand pricing cache directory %s: %w", expandedDirPath, err)
}
odPricing := &OnDemandPricing{
Region: region,
@@ -104,22 +95,25 @@ func LoadODCacheOrNew(ctx context.Context, pricingClient pricing.GetProductsAPIC
DirectoryPath: expandedDirPath,
pricingClient: pricingClient,
cache: cache.New(fullRefreshTTL, fullRefreshTTL),
+ logger: log.New(io.Discard, "", 0),
}
if fullRefreshTTL <= 0 {
- odPricing.Clear()
- return odPricing
+ if err := odPricing.Clear(); err != nil {
+ return nil, fmt.Errorf("unable to clear od pricing cache due to ttl <= 0 %w", err)
+ }
+ return odPricing, nil
}
// Start the cache refresh job
- go odCacheRefreshJob(ctx, odPricing)
+ go odPricing.odCacheRefreshJob(ctx)
odCache, err := loadODCacheFrom(fullRefreshTTL, region, expandedDirPath)
+ if err != nil && !errors.Is(err, os.ErrNotExist) {
+ return nil, fmt.Errorf("an on-demand pricing cache file could not be loaded: %v", err)
+ }
if err != nil {
- if !errors.Is(err, os.ErrNotExist) {
- log.Printf("An on-demand pricing cache file could not be loaded: %v", err)
- }
- return odPricing
+ odCache = cache.New(0, 0)
}
odPricing.cache = odCache
- return odPricing
+ return odPricing, nil
}
func loadODCacheFrom(itemTTL time.Duration, region string, expandedDirPath string) (*cache.Cache, error) {
@@ -140,18 +134,22 @@ func getODCacheFilePath(region string, directoryPath string) string {
return filepath.Join(directoryPath, fmt.Sprintf("%s-%s", region, ODCacheFileName))
}
-func odCacheRefreshJob(ctx context.Context, odPricing *OnDemandPricing) {
- if odPricing.FullRefreshTTL <= 0 {
+func (c *OnDemandPricing) odCacheRefreshJob(ctx context.Context) {
+ if c.FullRefreshTTL <= 0 {
return
}
- refreshTicker := time.NewTicker(odPricing.FullRefreshTTL)
+ refreshTicker := time.NewTicker(c.FullRefreshTTL)
for range refreshTicker.C {
- if err := odPricing.Refresh(ctx); err != nil {
- log.Println(err)
+ if err := c.Refresh(ctx); err != nil {
+ c.logger.Printf("Periodic OD Cache Refresh Error: %v", err)
}
}
}
+func (c *OnDemandPricing) SetLogger(logger *log.Logger) {
+ c.logger = logger
+}
+
func (c *OnDemandPricing) Refresh(ctx context.Context) error {
c.Lock()
defer c.Unlock()
@@ -182,7 +180,7 @@ func (c *OnDemandPricing) Get(ctx context.Context, instanceType ec2types.Instanc
return costs[string(instanceType)], nil
}
-// Count of items in the cache
+// Count of items in the cache.
func (c *OnDemandPricing) Count() int {
return c.cache.ItemCount()
}
@@ -195,23 +193,31 @@ func (c *OnDemandPricing) Save() error {
if err != nil {
return err
}
- if err := os.Mkdir(c.DirectoryPath, 0755); err != nil && !errors.Is(err, os.ErrExist) {
+ if err := os.Mkdir(c.DirectoryPath, 0o755); err != nil && !errors.Is(err, os.ErrExist) {
return err
}
- return ioutil.WriteFile(getODCacheFilePath(c.Region, c.DirectoryPath), cacheBytes, 0644)
+ return os.WriteFile(getODCacheFilePath(c.Region, c.DirectoryPath), cacheBytes, 0600)
}
func (c *OnDemandPricing) Clear() error {
c.Lock()
defer c.Unlock()
c.cache.Flush()
- return os.Remove(getODCacheFilePath(c.Region, c.DirectoryPath))
+ if err := os.Remove(getODCacheFilePath(c.Region, c.DirectoryPath)); err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ return nil
}
// fetchOnDemandPricing makes a bulk request to the pricing api to retrieve all instance type pricing if the instanceType is the empty string
//
// or, if instanceType is specified, it can request a specific instance type pricing
func (c *OnDemandPricing) fetchOnDemandPricing(ctx context.Context, instanceType ec2types.InstanceType) (map[string]float64, error) {
+ start := time.Now()
+ calls := 0
+ defer func() {
+ c.logger.Printf("Took %s and %d calls to collect OD pricing", time.Since(start), calls)
+ }()
odPricing := map[string]float64{}
productInput := pricing.GetProductsInput{
ServiceCode: c.StringMe(serviceCode),
@@ -222,9 +228,10 @@ func (c *OnDemandPricing) fetchOnDemandPricing(ctx context.Context, instanceType
p := pricing.NewGetProductsPaginator(c.pricingClient, &productInput)
for p.HasMorePages() {
+ calls++
pricingOutput, err := p.NextPage(ctx)
if err != nil {
- return nil, fmt.Errorf("failed to get a page, %w", err)
+ return nil, fmt.Errorf("failed to get next OD pricing page, %w", err)
}
for _, priceDoc := range pricingOutput.PriceList {
@@ -240,8 +247,8 @@ func (c *OnDemandPricing) fetchOnDemandPricing(ctx context.Context, instanceType
}
// StringMe takes an interface and returns a pointer to a string value
-// If the underlying interface kind is not string or *string then nil is returned
-func (*OnDemandPricing) StringMe(i interface{}) *string {
+// If the underlying interface kind is not string or *string then nil is returned.
+func (c *OnDemandPricing) StringMe(i interface{}) *string {
if i == nil {
return nil
}
@@ -251,17 +258,16 @@ func (*OnDemandPricing) StringMe(i interface{}) *string {
case string:
return &v
default:
- log.Printf("%s cannot be converted to a string", i)
+ c.logger.Printf("%s cannot be converted to a string", i)
return nil
}
}
func (c *OnDemandPricing) getProductsInputFilters(instanceType ec2types.InstanceType) []pricingtypes.Filter {
- regionDescription := c.getRegionForPricingAPI()
filters := []pricingtypes.Filter{
{Type: pricingtypes.FilterTypeTermMatch, Field: c.StringMe("ServiceCode"), Value: c.StringMe(serviceCode)},
{Type: pricingtypes.FilterTypeTermMatch, Field: c.StringMe("operatingSystem"), Value: c.StringMe("linux")},
- {Type: pricingtypes.FilterTypeTermMatch, Field: c.StringMe("location"), Value: c.StringMe(regionDescription)},
+ {Type: pricingtypes.FilterTypeTermMatch, Field: c.StringMe("regionCode"), Value: c.StringMe(c.Region)},
{Type: pricingtypes.FilterTypeTermMatch, Field: c.StringMe("capacitystatus"), Value: c.StringMe("used")},
{Type: pricingtypes.FilterTypeTermMatch, Field: c.StringMe("preInstalledSw"), Value: c.StringMe("NA")},
{Type: pricingtypes.FilterTypeTermMatch, Field: c.StringMe("tenancy"), Value: c.StringMe("shared")},
@@ -272,31 +278,7 @@ func (c *OnDemandPricing) getProductsInputFilters(instanceType ec2types.Instance
return filters
}
-// getRegionForPricingAPI attempts to retrieve the region description based on the AWS session used to create
-// the ec2pricing struct. It then uses the endpoints package in the aws sdk to retrieve the region description
-// This is necessary because the pricing API uses the region description rather than a region ID
-func (c *OnDemandPricing) getRegionForPricingAPI() string {
- endpointResolver := endpoints.DefaultResolver()
- partitions := endpointResolver.(endpoints.EnumPartitions).Partitions()
-
- // use us-east-1 as the default
- regionDescription := "US East (N. Virginia)"
- for _, partition := range partitions {
- regions := partition.Regions()
- if region, ok := regions[c.Region]; ok {
- regionDescription = region.Description()
- }
- }
-
- // endpoints package returns European regions with the word "Europe," but the pricing API expects the word "EU."
- // This formatting mismatch is only present with European regions.
- // So replace "Europe" with "EU" if it exists in the regionDescription string.
- regionDescription = strings.ReplaceAll(regionDescription, "Europe", "EU")
-
- return regionDescription
-}
-
-// parseOndemandUnitPrice takes a priceList from the pricing API and parses its weirdness
+// parseOndemandUnitPrice takes a priceList from the pricing API and parses its weirdness.
func (c *OnDemandPricing) parseOndemandUnitPrice(priceList string) (string, float64, error) {
var productPriceList PricingList
err := json.Unmarshal([]byte(priceList), &productPriceList)
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/ec2pricing/spotpricing.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/ec2pricing/spotpricing.go
similarity index 78%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/ec2pricing/spotpricing.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/ec2pricing/spotpricing.go
index cbf56e9fc..be3b1fda8 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/ec2pricing/spotpricing.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/ec2pricing/spotpricing.go
@@ -1,15 +1,14 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package ec2pricing
@@ -18,6 +17,7 @@ import (
"encoding/gob"
"errors"
"fmt"
+ "io"
"log"
"math"
"os"
@@ -44,6 +44,7 @@ type SpotPricing struct {
DirectoryPath string
cache *cache.Cache
ec2Client ec2.DescribeSpotPriceHistoryAPIClient
+ logger *log.Logger
sync.RWMutex
}
@@ -53,17 +54,10 @@ type spotPricingEntry struct {
Zone string
}
-func LoadSpotCacheOrNew(ctx context.Context, ec2Client ec2.DescribeSpotPriceHistoryAPIClient, region string, fullRefreshTTL time.Duration, directoryPath string, days int) *SpotPricing {
+func LoadSpotCacheOrNew(ctx context.Context, ec2Client ec2.DescribeSpotPriceHistoryAPIClient, region string, fullRefreshTTL time.Duration, directoryPath string, days int) (*SpotPricing, error) {
expandedDirPath, err := homedir.Expand(directoryPath)
if err != nil {
- log.Printf("Unable to load spot pricing cache directory %s: %v", expandedDirPath, err)
- return &SpotPricing{
- Region: region,
- FullRefreshTTL: 0,
- DirectoryPath: directoryPath,
- cache: cache.New(fullRefreshTTL, fullRefreshTTL),
- ec2Client: ec2Client,
- }
+ return nil, fmt.Errorf("unable to load spot pricing cache directory %s: %w", expandedDirPath, err)
}
spotPricing := &SpotPricing{
Region: region,
@@ -71,23 +65,26 @@ func LoadSpotCacheOrNew(ctx context.Context, ec2Client ec2.DescribeSpotPriceHist
DirectoryPath: expandedDirPath,
ec2Client: ec2Client,
cache: cache.New(fullRefreshTTL, fullRefreshTTL),
+ logger: log.New(io.Discard, "", 0),
}
if fullRefreshTTL <= 0 {
- spotPricing.Clear()
- return spotPricing
+ if err := spotPricing.Clear(); err != nil {
+ return nil, err
+ }
+ return spotPricing, nil
}
gob.Register([]*spotPricingEntry{})
// Start the cache refresh job
- go spotCacheRefreshJob(ctx, spotPricing, days)
+ go spotPricing.spotCacheRefreshJob(ctx, days)
spotCache, err := loadSpotCacheFrom(fullRefreshTTL, region, expandedDirPath)
+ if err != nil && !os.IsNotExist(err) {
+ return nil, fmt.Errorf("a spot pricing cache file could not be loaded: %w", err)
+ }
if err != nil {
- if !errors.Is(err, os.ErrNotExist) {
- log.Printf("A spot pricing cache file could not be loaded: %v", err)
- }
- return spotPricing
+ spotCache = cache.New(0, 0)
}
spotPricing.cache = spotCache
- return spotPricing
+ return spotPricing, nil
}
func loadSpotCacheFrom(itemTTL time.Duration, region string, expandedDirPath string) (*cache.Cache, error) {
@@ -109,18 +106,22 @@ func getSpotCacheFilePath(region string, directoryPath string) string {
return filepath.Join(directoryPath, fmt.Sprintf("%s-%s", region, SpotCacheFileName))
}
-func spotCacheRefreshJob(ctx context.Context, spotPricing *SpotPricing, days int) {
- if spotPricing.FullRefreshTTL <= 0 {
+func (c *SpotPricing) spotCacheRefreshJob(ctx context.Context, days int) {
+ if c.FullRefreshTTL <= 0 {
return
}
- refreshTicker := time.NewTicker(spotPricing.FullRefreshTTL)
+ refreshTicker := time.NewTicker(c.FullRefreshTTL)
for range refreshTicker.C {
- if err := spotPricing.Refresh(ctx, days); err != nil {
- log.Println(err)
+ if err := c.Refresh(ctx, days); err != nil {
+ c.logger.Printf("Periodic Spot Cache Refresh Error: %v", err)
}
}
}
+func (c *SpotPricing) SetLogger(logger *log.Logger) {
+ c.logger = logger
+}
+
func (c *SpotPricing) Refresh(ctx context.Context, days int) error {
c.Lock()
defer c.Unlock()
@@ -210,7 +211,7 @@ func (c *SpotPricing) filterOn(zone string, pricingEntries []*spotPricingEntry)
return filtered
}
-// Count of items in the cache
+// Count of items in the cache.
func (c *SpotPricing) Count() int {
return c.cache.ItemCount()
}
@@ -219,7 +220,7 @@ func (c *SpotPricing) Save() error {
if c.FullRefreshTTL <= 0 || c.Count() == 0 {
return nil
}
- if err := os.Mkdir(c.DirectoryPath, 0755); err != nil && !errors.Is(err, os.ErrExist) {
+ if err := os.Mkdir(c.DirectoryPath, 0o755); err != nil && !errors.Is(err, os.ErrExist) {
return err
}
file, err := os.Create(getSpotCacheFilePath(c.Region, c.DirectoryPath))
@@ -235,12 +236,20 @@ func (c *SpotPricing) Clear() error {
c.Lock()
defer c.Unlock()
c.cache.Flush()
- return os.Remove(getSpotCacheFilePath(c.Region, c.DirectoryPath))
+ if err := os.Remove(getSpotCacheFilePath(c.Region, c.DirectoryPath)); err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ return nil
}
// fetchSpotPricingTimeSeries makes a bulk request to the ec2 api to retrieve all spot instance type pricing for the past n days
-// If instanceType is empty, it will fetch for all instance types
+// If instanceType is empty, it will fetch for all instance types.
func (c *SpotPricing) fetchSpotPricingTimeSeries(ctx context.Context, instanceType ec2types.InstanceType, days int) (map[string][]*spotPricingEntry, error) {
+ start := time.Now()
+ calls := 0
+ defer func() {
+ c.logger.Printf("Took %s and %d calls to collect Spot pricing", time.Since(start), calls)
+ }()
spotTimeSeries := map[string][]*spotPricingEntry{}
endTime := time.Now().UTC()
startTime := endTime.Add(time.Hour * time.Duration(24*-1*days))
@@ -258,9 +267,10 @@ func (c *SpotPricing) fetchSpotPricingTimeSeries(ctx context.Context, instanceTy
// Iterate through the Amazon S3 object pages.
for p.HasMorePages() {
+ calls++
spotHistoryOutput, err := p.NextPage(ctx)
if err != nil {
- return nil, fmt.Errorf("failed to get a page, %w", err)
+ return nil, fmt.Errorf("failed to get a spot pricing page, %w", err)
}
for _, history := range spotHistoryOutput.SpotPriceHistory {
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/instancetypes/instancetypes.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/instancetypes/instancetypes.go
similarity index 58%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/instancetypes/instancetypes.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/instancetypes/instancetypes.go
index f38512d37..4b2c4033d 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/instancetypes/instancetypes.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/instancetypes/instancetypes.go
@@ -1,15 +1,14 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package instancetypes
@@ -18,7 +17,7 @@ import (
"encoding/json"
"errors"
"fmt"
- "io/ioutil"
+ "io"
"log"
"os"
"path/filepath"
@@ -30,11 +29,9 @@ import (
"github.com/patrickmn/go-cache"
)
-var (
- CacheFileName = "ec2-instance-types.json"
-)
+var CacheFileName = "ec2-instance-types.json"
-// Details hold all the information on an ec2 instance type
+// Details hold all the information on an ec2 instance type.
type Details struct {
ec2types.InstanceTypeInfo
OndemandPricePerHour *float64
@@ -48,46 +45,48 @@ type Provider struct {
lastFullRefresh *time.Time
ec2Client ec2.DescribeInstanceTypesAPIClient
cache *cache.Cache
+ logger *log.Logger
}
-func NewProvider(directoryPath string, region string, ttl time.Duration, ec2Client ec2.DescribeInstanceTypesAPIClient) *Provider {
- expandedDirPath, err := homedir.Expand(directoryPath)
- if err != nil {
- log.Printf("Unable to expand instance type cache directory %s: %v", directoryPath, err)
- }
+// NewProvider creates a new Instance Types provider used to fetch Instance Type information from EC2.
+func NewProvider(region string, ec2Client ec2.DescribeInstanceTypesAPIClient) *Provider {
return &Provider{
Region: region,
- DirectoryPath: expandedDirPath,
- FullRefreshTTL: ttl,
+ DirectoryPath: "",
+ FullRefreshTTL: 0,
ec2Client: ec2Client,
- cache: cache.New(ttl, ttl),
+ cache: cache.New(0, 0),
+ logger: log.New(io.Discard, "", 0),
}
}
-func LoadFromOrNew(directoryPath string, region string, ttl time.Duration, ec2Client ec2.DescribeInstanceTypesAPIClient) *Provider {
+// NewProvider creates a new Instance Types provider used to fetch Instance Type information from EC2 and optionally cache.
+func LoadFromOrNew(directoryPath string, region string, ttl time.Duration, ec2Client ec2.DescribeInstanceTypesAPIClient) (*Provider, error) {
expandedDirPath, err := homedir.Expand(directoryPath)
if err != nil {
- log.Printf("Unable to load instance-type cache directory %s: %v", expandedDirPath, err)
- return NewProvider(directoryPath, region, ttl, ec2Client)
+ return nil, fmt.Errorf("unable to load instance-type cache directory %s: %w", expandedDirPath, err)
}
if ttl <= 0 {
- provider := NewProvider(directoryPath, region, ttl, ec2Client)
- provider.Clear()
- return provider
+ provider := NewProvider(region, ec2Client)
+ if err := provider.Clear(); err != nil {
+ return nil, err
+ }
+ return provider, nil
}
itCache, err := loadFrom(ttl, region, expandedDirPath)
+ if err != nil && !os.IsNotExist(err) {
+ return nil, fmt.Errorf("unable to load instance-type cache from %s: %w", expandedDirPath, err)
+ }
if err != nil {
- if !errors.Is(err, os.ErrNotExist) {
- log.Printf("Unable to load instance-type cache from %s: %v", expandedDirPath, err)
- }
- return NewProvider(directoryPath, region, ttl, ec2Client)
+ itCache = cache.New(0, 0)
}
return &Provider{
Region: region,
DirectoryPath: expandedDirPath,
ec2Client: ec2Client,
cache: itCache,
- }
+ logger: log.New(io.Discard, "", 0),
+ }, nil
}
func loadFrom(ttl time.Duration, region string, expandedDirPath string) (*cache.Cache, error) {
@@ -107,7 +106,17 @@ func getCacheFilePath(region string, expandedDirPath string) string {
return filepath.Join(expandedDirPath, fmt.Sprintf("%s-%s", region, CacheFileName))
}
+func (p *Provider) SetLogger(logger *log.Logger) {
+ p.logger = logger
+}
+
func (p *Provider) Get(ctx context.Context, instanceTypes []ec2types.InstanceType) ([]*Details, error) {
+ p.logger.Printf("Getting instance types %v", instanceTypes)
+ start := time.Now()
+ calls := 0
+ defer func() {
+ p.logger.Printf("Took %s and %d calls to collect Instance Types", time.Since(start), calls)
+ }()
instanceTypeDetails := []*Details{}
describeInstanceTypeOpts := &ec2.DescribeInstanceTypesInput{}
if len(instanceTypes) != 0 {
@@ -120,6 +129,10 @@ func (p *Provider) Get(ctx context.Context, instanceTypes []ec2types.InstanceTyp
describeInstanceTypeOpts.InstanceTypes = append(describeInstanceTypeOpts.InstanceTypes, instanceType)
}
}
+ // if we were able to retrieve all from cache, return here, else continue to do a remote lookup
+ if len(describeInstanceTypeOpts.InstanceTypes) == 0 {
+ return instanceTypeDetails, nil
+ }
} else if p.lastFullRefresh != nil && !p.isFullRefreshNeeded() {
for _, item := range p.cache.Items() {
instanceTypeDetails = append(instanceTypeDetails, item.Object.(*Details))
@@ -127,14 +140,14 @@ func (p *Provider) Get(ctx context.Context, instanceTypes []ec2types.InstanceTyp
return instanceTypeDetails, nil
}
- s := ec2.NewDescribeInstanceTypesPaginator(p.ec2Client, &ec2.DescribeInstanceTypesInput{})
+ s := ec2.NewDescribeInstanceTypesPaginator(p.ec2Client, describeInstanceTypeOpts)
for s.HasMorePages() {
+ calls++
instanceTypeOutput, err := s.NextPage(ctx)
if err != nil {
- return nil, fmt.Errorf("failed to get a page, %w", err)
+ return nil, fmt.Errorf("failed to get next instance types page, %w", err)
}
-
for _, instanceTypeInfo := range instanceTypeOutput.InstanceTypes {
itDetails := &Details{InstanceTypeInfo: instanceTypeInfo}
instanceTypeDetails = append(instanceTypeDetails, itDetails)
@@ -164,15 +177,18 @@ func (p *Provider) Save() error {
if err != nil {
return err
}
- if err := os.Mkdir(p.DirectoryPath, 0755); err != nil && !errors.Is(err, os.ErrExist) {
+ if err := os.Mkdir(p.DirectoryPath, 0o755); err != nil && !errors.Is(err, os.ErrExist) {
return err
}
- return ioutil.WriteFile(getCacheFilePath(p.Region, p.DirectoryPath), cacheBytes, 0644)
+ return os.WriteFile(getCacheFilePath(p.Region, p.DirectoryPath), cacheBytes, 0600)
}
func (p *Provider) Clear() error {
p.cache.Flush()
- return os.Remove(getCacheFilePath(p.Region, p.DirectoryPath))
+ if err := os.Remove(getCacheFilePath(p.Region, p.DirectoryPath)); err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ return nil
}
func (p *Provider) CacheCount() int {
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/aggregates.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/aggregates.go
similarity index 79%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/aggregates.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/aggregates.go
index b5f3e613b..6d3fb740b 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/aggregates.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/aggregates.go
@@ -1,36 +1,53 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package selector
import (
"context"
"fmt"
- "github.com/aws/amazon-ec2-instance-selector/v2/pkg/bytequantity"
+ "regexp"
+
"github.com/aws/aws-sdk-go-v2/service/ec2"
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
- "regexp"
+
+ "github.com/aws/amazon-ec2-instance-selector/v3/pkg/bytequantity"
)
const (
- // AggregateLowPercentile is the default lower percentile for resource ranges on similar instance type comparisons
+ // AggregateLowPercentile is the default lower percentile for resource ranges on similar instance type comparisons.
AggregateLowPercentile = 0.9
- // AggregateHighPercentile is the default upper percentile for resource ranges on similar instance type comparisons
+ // AggregateHighPercentile is the default upper percentile for resource ranges on similar instance type comparisons.
AggregateHighPercentile = 1.2
)
-// FiltersTransform can be implemented to provide custom transforms
+var baseAllowedInstanceTypesRE = regexp.MustCompile(`^[cmr][3-9][agi]?\..*$|^t[2-9][gi]?\..*$`)
+
+// FiltersTransform can be implemented to provide custom transforms.
type FiltersTransform interface {
Transform(context.Context, Filters) (Filters, error)
}
-// TransformFn is the func type definition for a FiltersTransform
+// TransformFn is the func type definition for a FiltersTransform.
type TransformFn func(context.Context, Filters) (Filters, error)
// Transform implements FiltersTransform interface on TransformFn
-// This allows any TransformFn to be passed into funcs accepting FiltersTransform interface
+// This allows any TransformFn to be passed into funcs accepting FiltersTransform interface.
func (fn TransformFn) Transform(ctx context.Context, filters Filters) (Filters, error) {
return fn(ctx, filters)
}
-// TransformBaseInstanceType transforms lower level filters based on the instanceTypeBase specs
+// TransformBaseInstanceType transforms lower level filters based on the instanceTypeBase specs.
func (itf Selector) TransformBaseInstanceType(ctx context.Context, filters Filters) (Filters, error) {
if filters.InstanceTypeBase == nil {
return filters, nil
@@ -82,7 +99,7 @@ func (itf Selector) TransformBaseInstanceType(ctx context.Context, filters Filte
return filters, nil
}
-// TransformFlexible transforms lower level filters based on a set of opinions
+// TransformFlexible transforms lower level filters based on a set of opinions.
func (itf Selector) TransformFlexible(ctx context.Context, filters Filters) (Filters, error) {
if filters.Flexible == nil {
return filters, nil
@@ -101,11 +118,7 @@ func (itf Selector) TransformFlexible(ctx context.Context, filters Filters) (Fil
}
if filters.AllowList == nil {
- baseAllowedInstanceTypes, err := regexp.Compile("^[cmr][3-9][ag]?\\..*$|^a[1-9]\\..*$|^t[2-9]\\..*$")
- if err != nil {
- return filters, err
- }
- filters.AllowList = baseAllowedInstanceTypes
+ filters.AllowList = baseAllowedInstanceTypesRE
}
if filters.VCpusRange == nil && filters.MemoryRange == nil {
@@ -116,7 +129,7 @@ func (itf Selector) TransformFlexible(ctx context.Context, filters Filters) (Fil
return filters, nil
}
-// TransformForService transforms lower level filters based on the service
+// TransformForService transforms lower level filters based on the service.
func (itf Selector) TransformForService(ctx context.Context, filters Filters) (Filters, error) {
return itf.ServiceRegistry.ExecuteTransforms(filters)
}
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/comparators.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/comparators.go
similarity index 86%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/comparators.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/comparators.go
index eb639ecf9..77cf8fc0b 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/comparators.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/comparators.go
@@ -1,20 +1,18 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package selector
import (
- "log"
"math"
"reflect"
"regexp"
@@ -30,7 +28,10 @@ const (
required = "required"
)
-var amdRegex = regexp.MustCompile("[a-zA-Z0-9]+a\\.[a-zA-Z0-9]")
+var (
+ networkPerfRE = regexp.MustCompile(`[0-9]+ Gigabit`)
+ generationRE = regexp.MustCompile(`[a-zA-Z]+([0-9]+)`)
+)
func isSupportedFromString(instanceTypeValue *string, target *string) bool {
if target == nil {
@@ -39,7 +40,7 @@ func isSupportedFromString(instanceTypeValue *string, target *string) bool {
if instanceTypeValue == nil {
return false
}
- return *instanceTypeValue == *target
+ return strings.EqualFold(*instanceTypeValue, *target)
}
func isSupportedFromStrings(instanceTypeValues []*string, target *string) bool {
@@ -81,7 +82,7 @@ func isSupportedUsageClassType(instanceTypeValue []ec2types.UsageClassType, targ
}
for _, potentialType := range instanceTypeValue {
- if potentialType == *target {
+ if strings.EqualFold(string(potentialType), string(*target)) {
return true
}
}
@@ -100,7 +101,7 @@ func isSupportedArchitectureType(instanceTypeValue []ec2types.ArchitectureType,
}
for _, potentialType := range instanceTypeValue {
- if potentialType == *target {
+ if strings.EqualFold(string(potentialType), string(*target)) {
return true
}
}
@@ -118,7 +119,7 @@ func isSupportedVirtualizationType(instanceTypeValue []ec2types.VirtualizationTy
return true
}
for _, potentialType := range instanceTypeValue {
- if potentialType == *target {
+ if strings.EqualFold(string(potentialType), string(*target)) {
return true
}
}
@@ -132,7 +133,7 @@ func isSupportedInstanceTypeHypervisorType(instanceTypeValue ec2types.InstanceTy
if reflect.ValueOf(*target).IsZero() {
return true
}
- if instanceTypeValue == *target {
+ if strings.EqualFold(string(instanceTypeValue), string(*target)) {
return true
}
return false
@@ -149,7 +150,7 @@ func isSupportedRootDeviceType(instanceTypeValue []ec2types.RootDeviceType, targ
return true
}
for _, potentialType := range instanceTypeValue {
- if potentialType == *target {
+ if strings.EqualFold(string(potentialType), string(*target)) {
return true
}
}
@@ -163,7 +164,7 @@ func isMatchingCpuArchitecture(instanceTypeValue CPUManufacturer, target *CPUMan
if reflect.ValueOf(*target).IsZero() {
return true
}
- if instanceTypeValue == *target {
+ if strings.EqualFold(string(instanceTypeValue), string(*target)) {
return true
}
return false
@@ -302,12 +303,7 @@ func getNetworkPerformance(networkPerformance *string) *int {
if networkPerformance == nil {
return aws.Int(-1)
}
- re, err := regexp.Compile(`[0-9]+ Gigabit`)
- if err != nil {
- log.Printf("Unable to compile regexp to parse network performance: %s\n", *networkPerformance)
- return nil
- }
- networkBandwidth := re.FindString(*networkPerformance)
+ networkBandwidth := networkPerfRE.FindString(*networkPerformance)
if networkBandwidth == "" {
return aws.Int(-1)
}
@@ -379,21 +375,24 @@ func getEBSOptimizedBaselineIOPS(ebsInfo *ec2types.EbsInfo) *int32 {
return ebsInfo.EbsOptimizedInfo.BaselineIops
}
-func getCPUManufacturer(instanceTypeInfo *ec2types.InstanceTypeInfo) CPUManufacturer {
- for _, it := range instanceTypeInfo.ProcessorInfo.SupportedArchitectures {
- if it == ec2types.ArchitectureTypeArm64 {
- return CPUManufacturerAWS
- }
+// getInstanceTypeGeneration returns the generation from an instance type name
+// i.e. c7i.xlarge -> 7
+// if any error occurs, 0 will be returned.
+func getInstanceTypeGeneration(instanceTypeName string) *int {
+ zero := 0
+ matches := generationRE.FindStringSubmatch(instanceTypeName)
+ if len(matches) < 2 {
+ return &zero
}
-
- if amdRegex.Match([]byte(instanceTypeInfo.InstanceType)) {
- return CPUManufacturerAMD
+ gen, err := strconv.Atoi(matches[1])
+ if err != nil {
+ return &zero
}
- return CPUManufacturerIntel
+ return &gen
}
// supportSyntaxToBool takes an instance spec field that uses ["unsupported", "supported", "required", or "default"]
-// and transforms it to a *bool to use in filter execution
+// and transforms it to a *bool to use in filter execution.
func supportSyntaxToBool(instanceTypeSupport *string) *bool {
if instanceTypeSupport == nil {
return nil
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/emr.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/emr.go
similarity index 92%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/emr.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/emr.go
index 212f16f61..3a04f751f 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/emr.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/emr.go
@@ -1,15 +1,14 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package selector
@@ -25,10 +24,10 @@ const (
fallbackVersion = "5.20.0"
)
-// EMR is a Service type for a custom service filter transform
+// EMR is a Service type for a custom service filter transform.
type EMR struct{}
-// Filters implements the Service interface contract for EMR
+// Filters implements the Service interface contract for EMR.
func (e EMR) Filters(version string) (Filters, error) {
filters := Filters{}
if version == "" {
@@ -53,7 +52,7 @@ func (e EMR) Filters(version string) (Filters, error) {
return filters, nil
}
-// getEMRInstanceTypes returns a list of instance types that emr supports
+// getEMRInstanceTypes returns a list of instance types that emr supports.
func (e EMR) getEMRInstanceTypes(version semver.Version) ([]string, error) {
instanceTypes := []string{}
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/bubbletea.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/bubbletea.go
similarity index 81%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/bubbletea.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/bubbletea.go
index 740768747..216cc8ee4 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/bubbletea.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/bubbletea.go
@@ -1,28 +1,28 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package outputs
import (
- "github.com/aws/amazon-ec2-instance-selector/v2/pkg/instancetypes"
- "github.com/aws/amazon-ec2-instance-selector/v2/pkg/sorter"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/termenv"
+
+ "github.com/aws/amazon-ec2-instance-selector/v3/pkg/instancetypes"
+ "github.com/aws/amazon-ec2-instance-selector/v3/pkg/sorter"
)
const (
- // can't get terminal dimensions on startup, so use this
+ // can't get terminal dimensions on startup, so use this.
initialDimensionVal = 30
instanceTypeKey = "instance type"
@@ -30,17 +30,15 @@ const (
)
const (
- // table states
+ // table states.
stateTable = "table"
stateVerbose = "verbose"
stateSorting = "sorting"
)
-var (
- controlsStyle = lipgloss.NewStyle().Faint(true)
-)
+var controlsStyle = lipgloss.NewStyle().Faint(true)
-// BubbleTeaModel is used to hold the state of the bubble tea TUI
+// BubbleTeaModel is used to hold the state of the bubble tea TUI.
type BubbleTeaModel struct {
// holds the output currentState of the model
currentState string
@@ -56,23 +54,23 @@ type BubbleTeaModel struct {
}
// NewBubbleTeaModel initializes a new bubble tea Model which represents
-// a stylized table to display instance types
+// a stylized table to display instance types.
func NewBubbleTeaModel(instanceTypes []*instancetypes.Details) BubbleTeaModel {
return BubbleTeaModel{
currentState: stateTable,
tableModel: *initTableModel(instanceTypes),
- verboseModel: *initVerboseModel(instanceTypes),
+ verboseModel: *initVerboseModel(),
sortingModel: *initSortingModel(instanceTypes),
}
}
-// Init is used by bubble tea to initialize a bubble tea table
+// Init is used by bubble tea to initialize a bubble tea table.
func (m BubbleTeaModel) Init() tea.Cmd {
return nil
}
// Update is used by bubble tea to update the state of the bubble
-// tea model based on user input
+// tea model based on user input.
func (m BubbleTeaModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
@@ -163,7 +161,7 @@ func (m BubbleTeaModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case tea.WindowSizeMsg:
// This is needed to handle a bug with bubble tea
// where resizing causes misprints (https://github.com/Evertras/bubble-table/issues/121)
- termenv.ClearScreen()
+ termenv.ClearScreen() //nolint:staticcheck
// handle screen resizing
m.tableModel = m.tableModel.resizeView(msg)
@@ -185,7 +183,7 @@ func (m BubbleTeaModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, cmd
}
-// View is used by bubble tea to render the bubble tea model
+// View is used by bubble tea to render the bubble tea model.
func (m BubbleTeaModel) View() string {
switch m.currentState {
case stateTable:
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/outputs.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/outputs.go
similarity index 90%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/outputs.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/outputs.go
index 319cf9fc8..a460f5f26 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/outputs.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/outputs.go
@@ -1,15 +1,14 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
// Package outputs provides types for implementing instance type output functions as well as prebuilt output functions.
package outputs
@@ -24,13 +23,13 @@ import (
"strings"
"text/tabwriter"
- "github.com/aws/amazon-ec2-instance-selector/v2/pkg/instancetypes"
+ "github.com/aws/amazon-ec2-instance-selector/v3/pkg/instancetypes"
)
const columnTag = "column"
// wideColumnsData stores the data that should be displayed on each column
-// of a wide output row
+// of a wide output row.
type wideColumnsData struct {
instanceName string `column:"Instance Type"`
vcpu int32 `column:"VCPUs"`
@@ -45,10 +44,10 @@ type wideColumnsData struct {
gpuMemory string `column:"GPU Mem (GiB)"`
gpuInfo string `column:"GPU Info"`
odPrice string `column:"On-Demand Price/Hr"`
- spotPrice string `column:"Spot Price/Hr (30d avg)"`
+ spotPrice string `column:"Spot Price/Hr"`
}
-// SimpleInstanceTypeOutput is an OutputFn which outputs a slice of instance type names
+// SimpleInstanceTypeOutput is an OutputFn which outputs a slice of instance type names.
func SimpleInstanceTypeOutput(instanceTypeInfoSlice []*instancetypes.Details) []string {
instanceTypeStrings := []string{}
for _, instanceTypeInfo := range instanceTypeInfoSlice {
@@ -57,7 +56,7 @@ func SimpleInstanceTypeOutput(instanceTypeInfoSlice []*instancetypes.Details) []
return instanceTypeStrings
}
-// VerboseInstanceTypeOutput is an OutputFn which outputs a slice of instance type names
+// VerboseInstanceTypeOutput is an OutputFn which outputs a slice of instance type names.
func VerboseInstanceTypeOutput(instanceTypeInfoSlice []*instancetypes.Details) []string {
output, err := json.MarshalIndent(instanceTypeInfoSlice, "", " ")
if err != nil {
@@ -70,7 +69,7 @@ func VerboseInstanceTypeOutput(instanceTypeInfoSlice []*instancetypes.Details) [
return []string{string(output)}
}
-// TableOutputShort is an OutputFn which returns a CLI table for easy reading
+// TableOutputShort is an OutputFn which returns a CLI table for easy reading.
func TableOutputShort(instanceTypeInfoSlice []*instancetypes.Details) []string {
if len(instanceTypeInfoSlice) == 0 {
return nil
@@ -106,7 +105,7 @@ func TableOutputShort(instanceTypeInfoSlice []*instancetypes.Details) []string {
return []string{buf.String()}
}
-// TableOutputWide is an OutputFn which returns a detailed CLI table for easy reading
+// TableOutputWide is an OutputFn which returns a detailed CLI table for easy reading.
func TableOutputWide(instanceTypeInfoSlice []*instancetypes.Details) []string {
if len(instanceTypeInfoSlice) == 0 {
return nil
@@ -157,7 +156,7 @@ func TableOutputWide(instanceTypeInfoSlice []*instancetypes.Details) []string {
return []string{buf.String()}
}
-// OneLineOutput is an output function which prints the instance type names on a single line separated by commas
+// OneLineOutput is an output function which prints the instance type names on a single line separated by commas.
func OneLineOutput(instanceTypeInfoSlice []*instancetypes.Details) []string {
instanceTypeNames := []string{}
for _, instanceType := range instanceTypeInfoSlice {
@@ -196,7 +195,7 @@ func reverse(s string) string {
}
// getWideColumnsData returns the column data necessary for a wide output for each of
-// the given instance types
+// the given instance types.
func getWideColumnsData(instanceTypes []*instancetypes.Details) []*wideColumnsData {
columnsData := []*wideColumnsData{}
@@ -254,7 +253,7 @@ func getWideColumnsData(instanceTypes []*instancetypes.Details) []*wideColumnsDa
}
// getUnderlyingValue returns the underlying value of the given
-// reflect.Value type
+// reflect.Value type.
func getUnderlyingValue(value reflect.Value) interface{} {
var val interface{}
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/sortingView.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/sortingView.go
similarity index 83%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/sortingView.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/sortingView.go
index 671b4d4e4..cca1a236d 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/sortingView.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/sortingView.go
@@ -1,15 +1,14 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package outputs
@@ -18,31 +17,32 @@ import (
"io"
"strings"
- "github.com/aws/amazon-ec2-instance-selector/v2/pkg/instancetypes"
- "github.com/aws/amazon-ec2-instance-selector/v2/pkg/sorter"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
+
+ "github.com/aws/amazon-ec2-instance-selector/v3/pkg/instancetypes"
+ "github.com/aws/amazon-ec2-instance-selector/v3/pkg/sorter"
)
const (
- // formatting
+ // formatting.
sortDirectionPadding = 2
sortingTitlePadding = 3
sortingFooterPadding = 2
- // controls
+ // controls.
sortingListControls = "Controls: ↑/↓ - up/down • enter - select filter • tab - toggle direction • esc - return to table • q - quit"
sortingTextControls = "Controls: ↑/↓ - up/down • tab - toggle direction • enter - enter json path"
- // sort direction text
+ // sort direction text.
ascendingText = "ASCENDING"
descendingText = "DESCENDING"
)
-// sortingModel holds the state for the sorting view
+// sortingModel holds the state for the sorting view.
type sortingModel struct {
// list which holds the available shorting shorthands
shorthandList list.Model
@@ -55,32 +55,32 @@ type sortingModel struct {
isDescending bool
}
-// format styles
+// format styles.
var (
- // list
+ // list.
listTitleStyle = lipgloss.NewStyle().Bold(true).Underline(true)
listItemStyle = lipgloss.NewStyle().PaddingLeft(4)
selectedItemStyle = lipgloss.NewStyle().PaddingLeft(2).Foreground(lipgloss.Color("170"))
- // text
+ // text.
descendingStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#0096FF"))
ascendingStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#DAF7A6"))
sortDirectionStyle = lipgloss.NewStyle().Bold(true).Underline(true).PaddingLeft(2)
)
-// implement Item interface for list
+// implement Item interface for list.
type item string
func (i item) FilterValue() string { return "" }
func (i item) Title() string { return string(i) }
func (i item) Description() string { return "" }
-// implement ItemDelegate for list
+// implement ItemDelegate for list.
type itemDelegate struct{}
-func (d itemDelegate) Height() int { return 1 }
-func (d itemDelegate) Spacing() int { return 0 }
-func (d itemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd { return nil }
+func (d itemDelegate) Height() int { return 1 }
+func (d itemDelegate) Spacing() int { return 0 }
+func (d itemDelegate) Update(_ tea.Msg, _ *list.Model) tea.Cmd { return nil }
func (d itemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item) {
i, ok := listItem.(item)
if !ok {
@@ -99,11 +99,11 @@ func (d itemDelegate) Render(w io.Writer, m list.Model, index int, listItem list
}
}
- fmt.Fprintf(w, fn(str))
+ fmt.Fprint(w, fn(str))
}
// initSortingModel initializes and returns a new tableModel based on the given
-// instance type details
+// instance type details.
func initSortingModel(instanceTypes []*instancetypes.Details) *sortingModel {
shorthandList := list.New(*createListItems(), itemDelegate{}, initialDimensionVal, initialDimensionVal)
shorthandList.Title = "Select sorting filter:"
@@ -126,7 +126,7 @@ func initSortingModel(instanceTypes []*instancetypes.Details) *sortingModel {
}
}
-// createListKeyMap creates a KeyMap with the controls for the shorthand list
+// createListKeyMap creates a KeyMap with the controls for the shorthand list.
func createListKeyMap() list.KeyMap {
return list.KeyMap{
CursorDown: key.NewBinding(
@@ -138,7 +138,7 @@ func createListKeyMap() list.KeyMap {
}
}
-// createListItems creates a list item for shorthand sorting flag
+// createListItems creates a list item for shorthand sorting flag.
func createListItems() *[]list.Item {
shorthandFlags := []string{
sorter.GPUCountField,
@@ -166,7 +166,7 @@ func createListItems() *[]list.Item {
// resizeSortingView will change the dimensions of the sorting view
// in order to accommodate the new window dimensions represented by
-// the given tea.WindowSizeMsg
+// the given tea.WindowSizeMsg.
func (m sortingModel) resizeView(msg tea.WindowSizeMsg) sortingModel {
shorthandList := &m.shorthandList
shorthandList.SetWidth(msg.Width)
@@ -189,7 +189,7 @@ func (m sortingModel) resizeView(msg tea.WindowSizeMsg) sortingModel {
return m
}
-// update updates the state of the sortingModel
+// update updates the state of the sortingModel.
func (m sortingModel) update(msg tea.Msg) (sortingModel, tea.Cmd) {
var cmd tea.Cmd
var cmds []tea.Cmd
@@ -227,7 +227,7 @@ func (m sortingModel) update(msg tea.Msg) (sortingModel, tea.Cmd) {
return m, tea.Batch(cmds...)
}
-// view returns a string representing the sorting view
+// view returns a string representing the sorting view.
func (m sortingModel) view() string {
outputStr := strings.Builder{}
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/tableView.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/tableView.go
similarity index 89%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/tableView.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/tableView.go
index 9dc05bcee..015007bc9 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/tableView.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/tableView.go
@@ -1,15 +1,14 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package outputs
@@ -18,21 +17,22 @@ import (
"reflect"
"strings"
- "github.com/aws/amazon-ec2-instance-selector/v2/pkg/instancetypes"
- "github.com/aws/amazon-ec2-instance-selector/v2/pkg/sorter"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/evertras/bubble-table/table"
+
+ "github.com/aws/amazon-ec2-instance-selector/v3/pkg/instancetypes"
+ "github.com/aws/amazon-ec2-instance-selector/v3/pkg/sorter"
)
const (
- // table formatting
+ // table formatting.
headerAndFooterPadding = 8
headerPadding = 2
- // controls
+ // controls.
tableControls = "Controls: ↑/↓ - up/down • ←/→ - left/right • shift + ←/→ - pg up/down • e - expand • f - filter • t - trim toggle • space - select • s - sort • q - quit"
ellipses = "..."
@@ -60,30 +60,28 @@ type tableModel struct {
canSelectRows bool
}
-var (
- customBorder = table.Border{
- Top: "─",
- Left: "│",
- Right: "│",
- Bottom: "─",
-
- TopRight: "╮",
- TopLeft: "╭",
- BottomRight: "╯",
- BottomLeft: "╰",
-
- TopJunction: "┬",
- LeftJunction: "├",
- RightJunction: "┤",
- BottomJunction: "┴",
- InnerJunction: "┼",
-
- InnerDivider: "│",
- }
-)
+var customBorder = table.Border{
+ Top: "─",
+ Left: "│",
+ Right: "│",
+ Bottom: "─",
+
+ TopRight: "╮",
+ TopLeft: "╭",
+ BottomRight: "╯",
+ BottomLeft: "╰",
+
+ TopJunction: "┬",
+ LeftJunction: "├",
+ RightJunction: "┤",
+ BottomJunction: "┴",
+ InnerJunction: "┼",
+
+ InnerDivider: "│",
+}
// initTableModel initializes and returns a new tableModel based on the given
-// instance type details
+// instance type details.
func initTableModel(instanceTypes []*instancetypes.Details) *tableModel {
table := createTable(instanceTypes)
@@ -97,7 +95,7 @@ func initTableModel(instanceTypes []*instancetypes.Details) *tableModel {
}
}
-// createFilterTextInput creates and styles a text input for filtering
+// createFilterTextInput creates and styles a text input for filtering.
func createFilterTextInput() textinput.Model {
filterTextInput := textinput.New()
filterTextInput.Prompt = "Filter: "
@@ -106,7 +104,7 @@ func createFilterTextInput() textinput.Model {
return filterTextInput
}
-// createRows creates a row for each instance type in the passed in list
+// createRows creates a row for each instance type in the passed in list.
func createRows(columnsData []*wideColumnsData, instanceTypes []*instancetypes.Details) *[]table.Row {
rows := []table.Row{}
@@ -139,7 +137,7 @@ func createRows(columnsData []*wideColumnsData, instanceTypes []*instancetypes.D
return &rows
}
-// maxColWidth finds the maximum width element in the given column
+// maxColWidth finds the maximum width element in the given column.
func maxColWidth(columnsData []*wideColumnsData, columnHeader string) int {
// default max width is the width of the header itself with padding
maxWidth := len(columnHeader) + headerPadding
@@ -171,7 +169,7 @@ func maxColWidth(columnsData []*wideColumnsData, columnHeader string) int {
}
// createColumns creates columns based on the tags in the wideColumnsData
-// struct
+// struct.
func createColumns(columnsData []*wideColumnsData) *[]table.Column {
columns := []table.Column{}
@@ -189,7 +187,7 @@ func createColumns(columnsData []*wideColumnsData) *[]table.Column {
return &columns
}
-// createTableKeyMap creates a KeyMap with the controls for the table
+// createTableKeyMap creates a KeyMap with the controls for the table.
func createTableKeyMap() *table.KeyMap {
keys := table.KeyMap{
RowDown: key.NewBinding(
@@ -216,7 +214,7 @@ func createTableKeyMap() *table.KeyMap {
}
// createTable creates an intractable table which contains information about all of
-// the given instance types
+// the given instance types.
func createTable(instanceTypes []*instancetypes.Details) table.Model {
// calculate and fetch all column data from instance types
columnsData := getWideColumnsData(instanceTypes)
@@ -241,7 +239,7 @@ func createTable(instanceTypes []*instancetypes.Details) table.Model {
}
// resizeView will change the dimensions of the table in order to accommodate
-// the new window dimensions represented by the given tea.WindowSizeMsg
+// the new window dimensions represented by the given tea.WindowSizeMsg.
func (m tableModel) resizeView(msg tea.WindowSizeMsg) tableModel {
// handle width changes
m.table = m.table.WithMaxTotalWidth(msg.Width)
@@ -266,7 +264,7 @@ func (m tableModel) resizeView(msg tea.WindowSizeMsg) tableModel {
return m
}
-// updateFooter updates the page and controls string in the table footer
+// updateFooter updates the page and controls string in the table footer.
func (m tableModel) updateFooter() tableModel {
controlsStr := tableControls
@@ -289,7 +287,7 @@ func (m tableModel) updateFooter() tableModel {
return m
}
-// update updates the state of the tableModel
+// update updates the state of the tableModel.
func (m tableModel) update(msg tea.Msg) (tableModel, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
@@ -364,7 +362,7 @@ func (m tableModel) update(msg tea.Msg) (tableModel, tea.Cmd) {
return m, cmd
}
-// view returns a string representing the table view
+// view returns a string representing the table view.
func (m tableModel) view() string {
outputStr := strings.Builder{}
@@ -379,7 +377,7 @@ func (m tableModel) view() string {
return outputStr.String()
}
-// sortTable sorts the table based on the sorting direction and sorting filter
+// sortTable sorts the table based on the sorting direction and sorting filter.
func (m tableModel) sortTable(sortFilter string, sortDirection string) (tableModel, error) {
instanceTypes, rowMap := m.getInstanceTypeFromRows()
_ = rowMap
@@ -408,7 +406,7 @@ func (m tableModel) sortTable(sortFilter string, sortDirection string) (tableMod
}
// getInstanceTypeFromRows goes through the rows of the table model and returns both a list of instance
-// types and a mapping of instances to rows
+// types and a mapping of instances to rows.
func (m tableModel) getInstanceTypeFromRows() ([]*instancetypes.Details, map[string]table.Row) {
instanceTypes := []*instancetypes.Details{}
rowMap := make(map[string]table.Row)
@@ -437,7 +435,7 @@ func (m tableModel) getInstanceTypeFromRows() ([]*instancetypes.Details, map[str
return instanceTypes, rowMap
}
-// getUnfilteredRows gets the rows in the given table model without any filtering applied
+// getUnfilteredRows gets the rows in the given table model without any filtering applied.
func (m tableModel) getUnfilteredRows() []table.Row {
m.table = m.table.Filtered(false)
rows := m.table.GetVisibleRows()
@@ -445,7 +443,7 @@ func (m tableModel) getUnfilteredRows() []table.Row {
return rows
}
-// trim will trim the table to only the selected rows
+// trim will trim the table to only the selected rows.
func (m tableModel) trim() tableModel {
// store current state of rows before trimming
m.originalRows = m.getUnfilteredRows()
@@ -461,7 +459,7 @@ func (m tableModel) trim() tableModel {
return m
}
-// untrim will return the table to the original rows
+// untrim will return the table to the original rows.
func (m tableModel) untrim() tableModel {
m.table = m.table.WithRows(m.originalRows)
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/verboseView.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/verboseView.go
similarity index 76%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/verboseView.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/verboseView.go
index 0852f73da..a2481b149 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs/verboseView.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs/verboseView.go
@@ -1,15 +1,14 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package outputs
@@ -18,7 +17,6 @@ import (
"math"
"strings"
- "github.com/aws/amazon-ec2-instance-selector/v2/pkg/instancetypes"
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
@@ -26,14 +24,14 @@ import (
)
const (
- // verbose view formatting
+ // verbose view formatting.
outlinePadding = 8
- // controls
+ // controls.
verboseControls = "Controls: ↑/↓ - up/down • esc - return to table • q - quit"
)
-// verboseModel represents the current state of the verbose view
+// verboseModel represents the current state of the verbose view.
type verboseModel struct {
// model for verbose output viewport
viewport viewport.Model
@@ -42,7 +40,7 @@ type verboseModel struct {
focusedInstanceName ec2types.InstanceType
}
-// styling for viewport
+// styling for viewport.
var (
titleStyle = func() lipgloss.Style {
b := lipgloss.RoundedBorder()
@@ -53,13 +51,13 @@ var (
infoStyle = func() lipgloss.Style {
b := lipgloss.RoundedBorder()
b.Left = "┤"
- return titleStyle.Copy().BorderStyle(b)
+ return titleStyle.BorderStyle(b)
}()
)
// initVerboseModel initializes and returns a new verboseModel based on the given
-// instance type details
-func initVerboseModel(instanceTypes []*instancetypes.Details) *verboseModel {
+// instance type details.
+func initVerboseModel() *verboseModel {
viewportModel := viewport.New(initialDimensionVal, initialDimensionVal)
viewportModel.MouseWheelEnabled = true
@@ -69,7 +67,7 @@ func initVerboseModel(instanceTypes []*instancetypes.Details) *verboseModel {
}
// resizeView will change the dimensions of the verbose viewport in order to accommodate
-// the new window dimensions represented by the given tea.WindowSizeMsg
+// the new window dimensions represented by the given tea.WindowSizeMsg.
func (m verboseModel) resizeView(msg tea.WindowSizeMsg) verboseModel {
// handle width changes
m.viewport.Width = msg.Width
@@ -86,7 +84,7 @@ func (m verboseModel) resizeView(msg tea.WindowSizeMsg) verboseModel {
return m
}
-// update updates the state of the verboseModel
+// update updates the state of the verboseModel.
func (m verboseModel) update(msg tea.Msg) (verboseModel, tea.Cmd) {
var cmd tea.Cmd
m.viewport, cmd = m.viewport.Update(msg)
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/selector.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/selector.go
similarity index 75%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/selector.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/selector.go
index 897864c34..4057d2f05 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/selector.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/selector.go
@@ -1,15 +1,14 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
// Package selector provides filtering logic for Amazon EC2 Instance Types based on declarative resource specfications.
package selector
@@ -17,6 +16,7 @@ package selector
import (
"context"
"fmt"
+ "io"
"log"
"reflect"
"regexp"
@@ -25,21 +25,20 @@ import (
"sync"
"time"
- "github.com/aws/amazon-ec2-instance-selector/v2/pkg/ec2pricing"
- "github.com/aws/amazon-ec2-instance-selector/v2/pkg/instancetypes"
- "github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/outputs"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/ec2"
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
"go.uber.org/multierr"
-)
-var (
- // Version is overridden at compilation with the version based on the git tag
- versionID = "dev"
+ "github.com/aws/amazon-ec2-instance-selector/v3/pkg/ec2pricing"
+ "github.com/aws/amazon-ec2-instance-selector/v3/pkg/instancetypes"
+ "github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs"
)
+// Version is overridden at compilation with the version based on the git tag
+var versionID = "dev"
+
const (
locationFilterKey = "location"
zoneIDLocationType = ec2types.LocationTypeAvailabilityZoneId
@@ -47,7 +46,7 @@ const (
regionNameLocationType = ec2types.LocationTypeRegion
sdkName = "instance-selector"
- // Filter Keys
+ // Filter Keys.
cpuArchitecture = "cpuArchitecture"
cpuManufacturer = "cpuManufacturer"
@@ -91,6 +90,7 @@ const (
freeTier = "freeTier"
autoRecovery = "autoRecovery"
dedicatedHosts = "dedicatedHosts"
+ generation = "generation"
cpuArchitectureAMD64 = "amd64"
@@ -99,26 +99,12 @@ const (
pricePerHour = "pricePerHour"
)
-// New creates an instance of Selector provided an aws session
+// New creates an instance of Selector provided an aws session.
func New(ctx context.Context, cfg aws.Config) (*Selector, error) {
- serviceRegistry := NewRegistry()
- serviceRegistry.RegisterAWSServices()
- ec2Client := ec2.NewFromConfig(cfg, func(options *ec2.Options) {
- options.APIOptions = append(options.APIOptions, middleware.AddUserAgentKeyValue(sdkName, versionID))
- })
- pricingClient, err := ec2pricing.New(ctx, cfg)
- if err != nil {
- return nil, err
- }
-
- return &Selector{
- EC2: ec2Client,
- EC2Pricing: pricingClient,
- InstanceTypesProvider: instancetypes.LoadFromOrNew("", cfg.Region, 0, ec2Client),
- ServiceRegistry: serviceRegistry,
- }, nil
+ return NewWithCache(ctx, cfg, 0, "")
}
+// NewWithCache creates an instance of Selector backed by an on-disk cache provided an aws session and cache configuration parameters.
func NewWithCache(ctx context.Context, cfg aws.Config, ttl time.Duration, cacheDir string) (*Selector, error) {
serviceRegistry := NewRegistry()
serviceRegistry.RegisterAWSServices()
@@ -130,59 +116,66 @@ func NewWithCache(ctx context.Context, cfg aws.Config, ttl time.Duration, cacheD
return nil, err
}
+ instanceTypeProvider, err := instancetypes.LoadFromOrNew(cacheDir, cfg.Region, ttl, ec2Client)
+ if err != nil {
+ return nil, fmt.Errorf("unable to initialize instance type provider: %w", err)
+ }
+
return &Selector{
EC2: ec2Client,
EC2Pricing: pricingClient,
- InstanceTypesProvider: instancetypes.LoadFromOrNew(cacheDir, cfg.Region, ttl, ec2Client),
+ InstanceTypesProvider: instanceTypeProvider,
ServiceRegistry: serviceRegistry,
+ Logger: log.New(io.Discard, "", 0),
}, nil
}
-func (itf Selector) Save() error {
- return multierr.Append(itf.EC2Pricing.Save(), itf.InstanceTypesProvider.Save())
+// SetLogger can be called to log more detailed logs about what selector is doing
+// including things like API timings
+// If SetLogger is not called, no logs will be displayed.
+func (s *Selector) SetLogger(logger *log.Logger) {
+ s.Logger = logger
+ s.InstanceTypesProvider.SetLogger(logger)
+ s.EC2Pricing.SetLogger(logger)
+}
+
+// Save persists the selector cache data to disk if caching is configured.
+func (s Selector) Save() error {
+ return multierr.Append(s.EC2Pricing.Save(), s.InstanceTypesProvider.Save())
}
// Filter accepts a Filters struct which is used to select the available instance types
-// matching the criteria within Filters and returns a simple list of instance type strings
-//
-// Deprecated: This function will be replaced with GetFilteredInstanceTypes() and
-// OutputInstanceTypes() in the next major version.
-func (itf Selector) Filter(ctx context.Context, filters Filters) ([]string, error) {
+// matching the criteria within Filters and returns a simple list of instance type strings.
+func (s Selector) Filter(ctx context.Context, filters Filters) ([]string, error) {
outputFn := InstanceTypesOutputFn(outputs.SimpleInstanceTypeOutput)
- output, _, err := itf.FilterWithOutput(ctx, filters, outputFn)
+ output, _, err := s.FilterWithOutput(ctx, filters, outputFn)
return output, err
}
// FilterVerbose accepts a Filters struct which is used to select the available instance types
-// matching the criteria within Filters and returns a list instanceTypeInfo
-//
-// Deprecated: This function will be replaced with GetFilteredInstanceTypes() in the next
-// major version.
-func (itf Selector) FilterVerbose(ctx context.Context, filters Filters) ([]*instancetypes.Details, error) {
- instanceTypeInfoSlice, err := itf.rawFilter(ctx, filters)
+// matching the criteria within Filters and returns a list instanceTypeInfo.
+func (s Selector) FilterVerbose(ctx context.Context, filters Filters) ([]*instancetypes.Details, error) {
+ instanceTypeInfoSlice, err := s.rawFilter(ctx, filters)
if err != nil {
return nil, err
}
- instanceTypeInfoSlice, _ = itf.truncateResults(filters.MaxResults, instanceTypeInfoSlice)
+ instanceTypeInfoSlice, _ = s.truncateResults(filters.MaxResults, instanceTypeInfoSlice)
return instanceTypeInfoSlice, nil
}
// FilterWithOutput accepts a Filters struct which is used to select the available instance types
-// matching the criteria within Filters and returns a list of strings based on the custom outputFn
-//
-// Deprecated: This function will be replaced with GetFilteredInstanceTypes() and
-// OutputInstanceTypes() in the next major version.
-func (itf Selector) FilterWithOutput(ctx context.Context, filters Filters, outputFn InstanceTypesOutput) ([]string, int, error) {
- instanceTypeInfoSlice, err := itf.rawFilter(ctx, filters)
+// matching the criteria within Filters and returns a list of strings based on the custom outputFn.
+func (s Selector) FilterWithOutput(ctx context.Context, filters Filters, outputFn InstanceTypesOutput) ([]string, int, error) {
+ instanceTypeInfoSlice, err := s.rawFilter(ctx, filters)
if err != nil {
return nil, 0, err
}
- instanceTypeInfoSlice, numOfItemsTruncated := itf.truncateResults(filters.MaxResults, instanceTypeInfoSlice)
+ instanceTypeInfoSlice, numOfItemsTruncated := s.truncateResults(filters.MaxResults, instanceTypeInfoSlice)
output := outputFn.Output(instanceTypeInfoSlice)
return output, numOfItemsTruncated, nil
}
-func (itf Selector) truncateResults(maxResults *int, instanceTypeInfoSlice []*instancetypes.Details) ([]*instancetypes.Details, int) {
+func (s Selector) truncateResults(maxResults *int, instanceTypeInfoSlice []*instancetypes.Details) ([]*instancetypes.Details, int) {
if maxResults == nil {
return instanceTypeInfoSlice, 0
}
@@ -194,11 +187,11 @@ func (itf Selector) truncateResults(maxResults *int, instanceTypeInfoSlice []*in
}
// AggregateFilterTransform takes higher level filters which are used to affect multiple raw filters in an opinionated way.
-func (itf Selector) AggregateFilterTransform(ctx context.Context, filters Filters) (Filters, error) {
+func (s Selector) AggregateFilterTransform(ctx context.Context, filters Filters) (Filters, error) {
transforms := []FiltersTransform{
- TransformFn(itf.TransformBaseInstanceType),
- TransformFn(itf.TransformFlexible),
- TransformFn(itf.TransformForService),
+ TransformFn(s.TransformBaseInstanceType),
+ TransformFn(s.TransformFlexible),
+ TransformFn(s.TransformForService),
}
var err error
for _, transform := range transforms {
@@ -211,9 +204,9 @@ func (itf Selector) AggregateFilterTransform(ctx context.Context, filters Filter
}
// rawFilter accepts a Filters struct which is used to select the available instance types
-// matching the criteria within Filters and returns the detailed specs of matching instance types
-func (itf Selector) rawFilter(ctx context.Context, filters Filters) ([]*instancetypes.Details, error) {
- filters, err := itf.AggregateFilterTransform(ctx, filters)
+// matching the criteria within Filters and returns the detailed specs of matching instance types.
+func (s Selector) rawFilter(ctx context.Context, filters Filters) ([]*instancetypes.Details, error) {
+ filters, err := s.AggregateFilterTransform(ctx, filters)
if err != nil {
return nil, err
}
@@ -231,12 +224,12 @@ func (itf Selector) rawFilter(ctx context.Context, filters Filters) ([]*instance
} else if filters.Region != nil {
locations = []string{*filters.Region}
}
- locationInstanceOfferings, err := itf.RetrieveInstanceTypesSupportedInLocations(ctx, locations)
+ locationInstanceOfferings, err := s.RetrieveInstanceTypesSupportedInLocations(ctx, locations)
if err != nil {
return nil, err
}
- instanceTypeDetails, err := itf.InstanceTypesProvider.Get(ctx, nil)
+ instanceTypeDetails, err := s.InstanceTypesProvider.Get(ctx, nil)
if err != nil {
return nil, err
}
@@ -247,33 +240,35 @@ func (itf Selector) rawFilter(ctx context.Context, filters Filters) ([]*instance
wg.Add(1)
go func(instanceTypeInfo instancetypes.Details) {
defer wg.Done()
- it, err := itf.prepareFilter(ctx, filters, instanceTypeInfo, availabilityZones, locationInstanceOfferings)
+ it, err := s.prepareFilter(ctx, filters, instanceTypeInfo, availabilityZones, locationInstanceOfferings)
if err != nil {
- log.Println(err)
+ s.Logger.Printf("Unable to prepare filter for %s, %v", instanceTypeInfo.InstanceType, err)
}
if it != nil {
instanceTypes <- it
}
}(*instanceTypeInfo)
}
- wg.Wait()
- close(instanceTypes)
+ go func() {
+ wg.Wait()
+ close(instanceTypes)
+ }()
for it := range instanceTypes {
filteredInstanceTypes = append(filteredInstanceTypes, it)
}
return sortInstanceTypeInfo(filteredInstanceTypes), nil
}
-func (itf Selector) prepareFilter(ctx context.Context, filters Filters, instanceTypeInfo instancetypes.Details, availabilityZones []string, locationInstanceOfferings map[ec2types.InstanceType]string) (*instancetypes.Details, error) {
+func (s Selector) prepareFilter(ctx context.Context, filters Filters, instanceTypeInfo instancetypes.Details, availabilityZones []string, locationInstanceOfferings map[ec2types.InstanceType]string) (*instancetypes.Details, error) {
instanceTypeName := instanceTypeInfo.InstanceType
isFpga := instanceTypeInfo.FpgaInfo != nil
var instanceTypeHourlyPriceForFilter float64 // Price used to filter based on usage class
var instanceTypeHourlyPriceOnDemand, instanceTypeHourlyPriceSpot *float64
// If prices are fetched, populate the fields irrespective of the price filters
- if itf.EC2Pricing.OnDemandCacheCount() > 0 {
- price, err := itf.EC2Pricing.GetOnDemandInstanceTypeCost(ctx, instanceTypeName)
+ if s.EC2Pricing.OnDemandCacheCount() > 0 {
+ price, err := s.EC2Pricing.GetOnDemandInstanceTypeCost(ctx, instanceTypeName)
if err != nil {
- log.Printf("Could not retrieve instantaneous hourly on-demand price for instance type %s - %s\n", instanceTypeName, err)
+ s.Logger.Printf("Could not retrieve instantaneous hourly on-demand price for instance type %s - %s\n", instanceTypeName, err)
} else {
instanceTypeHourlyPriceOnDemand = &price
instanceTypeInfo.OndemandPricePerHour = instanceTypeHourlyPriceOnDemand
@@ -287,10 +282,10 @@ func (itf Selector) prepareFilter(ctx context.Context, filters Filters, instance
}
}
- if itf.EC2Pricing.SpotCacheCount() > 0 && isSpotUsageClass {
- price, err := itf.EC2Pricing.GetSpotInstanceTypeNDayAvgCost(ctx, instanceTypeName, availabilityZones, 30)
+ if s.EC2Pricing.SpotCacheCount() > 0 && isSpotUsageClass {
+ price, err := s.EC2Pricing.GetSpotInstanceTypeNDayAvgCost(ctx, instanceTypeName, availabilityZones, 30)
if err != nil {
- log.Printf("Could not retrieve 30 day avg hourly spot price for instance type %s\n", instanceTypeName)
+ s.Logger.Printf("Could not retrieve 30 day avg hourly spot price for instance type %s\n", instanceTypeName)
} else {
instanceTypeHourlyPriceSpot = &price
instanceTypeInfo.SpotPrice = instanceTypeHourlyPriceSpot
@@ -308,11 +303,22 @@ func (itf Selector) prepareFilter(ctx context.Context, filters Filters, instance
eneaSupport := string(instanceTypeInfo.NetworkInfo.EnaSupport)
ebsOptimizedSupport := string(instanceTypeInfo.EbsInfo.EbsOptimizedSupport)
+ // If an empty slice is passed, treat the filter as nil
+ filterInstanceTypes := filters.InstanceTypes
+ if filterInstanceTypes != nil && len(*filterInstanceTypes) == 0 {
+ filterInstanceTypes = nil
+ }
+
+ var cpuManufacturerFilter *string
+ if filters.CPUManufacturer != nil {
+ cpuManufacturerFilter = aws.String(string(*filters.CPUManufacturer))
+ }
+
// filterToInstanceSpecMappingPairs is a map of filter name [key] to filter pair [value].
// A filter pair includes user input filter value and instance spec value retrieved from DescribeInstanceTypes
filterToInstanceSpecMappingPairs := map[string]filterPair{
cpuArchitecture: {filters.CPUArchitecture, instanceTypeInfo.ProcessorInfo.SupportedArchitectures},
- cpuManufacturer: {filters.CPUManufacturer, getCPUManufacturer(&instanceTypeInfo.InstanceTypeInfo)},
+ cpuManufacturer: {cpuManufacturerFilter, instanceTypeInfo.ProcessorInfo.Manufacturer},
usageClass: {filters.UsageClass, instanceTypeInfo.SupportedUsageClasses},
rootDeviceType: {filters.RootDeviceType, instanceTypeInfo.SupportedRootDeviceTypes},
hibernationSupported: {filters.HibernationSupported, instanceTypeInfo.HibernationSupported},
@@ -334,7 +340,7 @@ func (itf Selector) prepareFilter(ctx context.Context, filters Filters, instance
networkPerformance: {filters.NetworkPerformance, getNetworkPerformance(instanceTypeInfo.NetworkInfo.NetworkPerformance)},
networkEncryption: {filters.NetworkEncryption, instanceTypeInfo.NetworkInfo.EncryptionInTransitSupported},
ipv6: {filters.IPv6, instanceTypeInfo.NetworkInfo.Ipv6Supported},
- instanceTypes: {filters.InstanceTypes, instanceTypeInfo.InstanceType},
+ instanceTypes: {filterInstanceTypes, aws.String(string(instanceTypeInfo.InstanceType))},
virtualizationType: {filters.VirtualizationType, instanceTypeInfo.SupportedVirtualizationTypes},
pricePerHour: {filters.PricePerHour, &instanceTypeHourlyPriceForFilter},
instanceStorageRange: {filters.InstanceStorageRange, getInstanceStorage(instanceTypeInfo.InstanceStorageInfo)},
@@ -352,6 +358,7 @@ func (itf Selector) prepareFilter(ctx context.Context, filters Filters, instance
inferenceAcceleratorManufacturer: {filters.InferenceAcceleratorManufacturer, getInferenceAcceleratorManufacturers(instanceTypeInfo.InferenceAcceleratorInfo)},
inferenceAcceleratorModel: {filters.InferenceAcceleratorModel, getInferenceAcceleratorModels(instanceTypeInfo.InferenceAcceleratorInfo)},
dedicatedHosts: {filters.DedicatedHosts, instanceTypeInfo.DedicatedHostsSupported},
+ generation: {filters.Generation, getInstanceTypeGeneration(string(instanceTypeInfo.InstanceType))},
}
if isInDenyList(filters.DenyList, instanceTypeName) || !isInAllowList(filters.AllowList, instanceTypeName) {
@@ -363,7 +370,7 @@ func (itf Selector) prepareFilter(ctx context.Context, filters Filters, instance
}
var isInstanceSupported bool
- isInstanceSupported, err := itf.executeFilters(ctx, filterToInstanceSpecMappingPairs, instanceTypeName)
+ isInstanceSupported, err := s.executeFilters(ctx, filterToInstanceSpecMappingPairs, instanceTypeName)
if err != nil {
return nil, err
}
@@ -373,7 +380,7 @@ func (itf Selector) prepareFilter(ctx context.Context, filters Filters, instance
return &instanceTypeInfo, nil
}
-// sortInstanceTypeInfo will sort based on instance type info alpha-numerically
+// sortInstanceTypeInfo will sort based on instance type info alpha-numerically.
func sortInstanceTypeInfo(instanceTypeInfoSlice []*instancetypes.Details) []*instancetypes.Details {
if len(instanceTypeInfoSlice) < 2 {
return instanceTypeInfoSlice
@@ -388,9 +395,9 @@ func sortInstanceTypeInfo(instanceTypeInfoSlice []*instancetypes.Details) []*ins
// executeFilters accepts a mapping of filter name to filter pairs which are iterated through
// to determine if the instance type matches the filter values.
-func (itf Selector) executeFilters(ctx context.Context, filterToInstanceSpecMapping map[string]filterPair, instanceType ec2types.InstanceType) (bool, error) {
+func (s Selector) executeFilters(ctx context.Context, filterToInstanceSpecMapping map[string]filterPair, instanceType ec2types.InstanceType) (bool, error) {
verdict := make(chan bool, len(filterToInstanceSpecMapping)+1)
- errs := make(chan error)
+ errs := make(chan error, len(filterToInstanceSpecMapping))
ctx, cancel := context.WithCancel(ctx)
defer cancel()
var wg sync.WaitGroup
@@ -432,6 +439,8 @@ func (itf Selector) executeFilters(ctx context.Context, filterToInstanceSpecMapp
}
}
+// exec executes a specific filterPair (user value & instance spec) with a specific instance type
+// If the filterPair matches, true is returned.
func exec(instanceType ec2types.InstanceType, filterName string, filter filterPair) (bool, error) {
filterVal := filter.filterValue
instanceSpec := filter.instanceSpec
@@ -443,7 +452,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
instanceSpecType := reflect.ValueOf(instanceSpec).Type()
filterType := filterValReflection.Type()
filterDetailsMsg := fmt.Sprintf("filter (%s: %s => %s) corresponding to instance spec (%s => %s) for instance type %s", filterName, filterVal, filterType, instanceSpec, instanceSpecType, instanceType)
- invalidInstanceSpecTypeMsg := fmt.Sprintf("Unable to process for %s", filterDetailsMsg)
+ errInvalidInstanceSpec := fmt.Errorf("unable to process for %s", filterDetailsMsg)
// Determine appropriate filter comparator by switching on filter type
switch filter := filterVal.(type) {
@@ -458,7 +467,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *bool:
switch iSpec := instanceSpec.(type) {
@@ -467,7 +476,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *IntRangeFilter:
switch iSpec := instanceSpec.(type) {
@@ -475,12 +484,20 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
if !isSupportedWithRangeInt64(iSpec, filter) {
return false, nil
}
+ case *int32:
+ var iSpec64 *int64
+ if iSpec != nil {
+ iSpec64 = aws.Int64(int64(*iSpec))
+ }
+ if !isSupportedWithRangeInt64(iSpec64, filter) {
+ return false, nil
+ }
case *int:
if !isSupportedWithRangeInt(iSpec, filter) {
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *Int32RangeFilter:
switch iSpec := instanceSpec.(type) {
@@ -489,7 +506,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *Float64RangeFilter:
switch iSpec := instanceSpec.(type) {
@@ -498,7 +515,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *ByteQuantityRangeFilter:
mibRange := Uint64RangeFilter{
@@ -528,7 +545,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *float64:
switch iSpec := instanceSpec.(type) {
@@ -537,7 +554,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *ec2types.ArchitectureType:
switch iSpec := instanceSpec.(type) {
@@ -546,7 +563,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *ec2types.UsageClassType:
switch iSpec := instanceSpec.(type) {
@@ -555,7 +572,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *CPUManufacturer:
switch iSpec := instanceSpec.(type) {
@@ -564,7 +581,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *ec2types.VirtualizationType:
switch iSpec := instanceSpec.(type) {
@@ -573,7 +590,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *ec2types.InstanceTypeHypervisor:
switch iSpec := instanceSpec.(type) {
@@ -582,7 +599,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *ec2types.RootDeviceType:
switch iSpec := instanceSpec.(type) {
@@ -591,7 +608,7 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
case *[]string:
switch iSpec := instanceSpec.(type) {
@@ -607,24 +624,24 @@ func exec(instanceType ec2types.InstanceType, filterName string, filter filterPa
return false, nil
}
default:
- return false, fmt.Errorf(invalidInstanceSpecTypeMsg)
+ return false, errInvalidInstanceSpec
}
default:
- return false, fmt.Errorf("No filter handler found for %s", filterDetailsMsg)
+ return false, fmt.Errorf("no filter handler found for %s", filterDetailsMsg)
}
return true, nil
}
// RetrieveInstanceTypesSupportedInLocations returns a map of instance type -> AZ or Region for all instance types supported in the intersected locations passed in
// The location can be a zone-id (ie. use1-az1), a zone-name (us-east-1a), or a region name (us-east-1).
-// Note that zone names are not necessarily the same across accounts
-func (itf Selector) RetrieveInstanceTypesSupportedInLocations(ctx context.Context, locations []string) (map[ec2types.InstanceType]string, error) {
+// Note that zone names are not necessarily the same across accounts.
+func (s Selector) RetrieveInstanceTypesSupportedInLocations(ctx context.Context, locations []string) (map[ec2types.InstanceType]string, error) {
if len(locations) == 0 {
return nil, nil
}
availableInstanceTypes := map[ec2types.InstanceType]int{}
for _, location := range locations {
- locationType, err := itf.getLocationType(ctx, location)
+ locationType, err := s.getLocationType(ctx, location)
if err != nil {
return nil, err
}
@@ -639,12 +656,12 @@ func (itf Selector) RetrieveInstanceTypesSupportedInLocations(ctx context.Contex
},
}
- p := ec2.NewDescribeInstanceTypeOfferingsPaginator(itf.EC2, instanceTypeOfferingsInput)
+ p := ec2.NewDescribeInstanceTypeOfferingsPaginator(s.EC2, instanceTypeOfferingsInput)
for p.HasMorePages() {
instanceTypeOfferings, err := p.NextPage(ctx)
if err != nil {
- return nil, fmt.Errorf("Encountered an error when describing instance type offerings: %w", err)
+ return nil, fmt.Errorf("encountered an error when describing instance type offerings: %w", err)
}
for _, instanceType := range instanceTypeOfferings.InstanceTypeOfferings {
@@ -666,8 +683,8 @@ func (itf Selector) RetrieveInstanceTypesSupportedInLocations(ctx context.Contex
return availableInstanceTypesAllLocations, nil
}
-func (itf Selector) getLocationType(ctx context.Context, location string) (ec2types.LocationType, error) {
- azs, err := itf.EC2.DescribeAvailabilityZones(ctx, &ec2.DescribeAvailabilityZonesInput{})
+func (s Selector) getLocationType(ctx context.Context, location string) (ec2types.LocationType, error) {
+ azs, err := s.EC2.DescribeAvailabilityZones(ctx, &ec2.DescribeAvailabilityZonesInput{})
if err != nil {
return "", err
}
@@ -680,7 +697,7 @@ func (itf Selector) getLocationType(ctx context.Context, location string) (ec2ty
return zoneIDLocationType, nil
}
}
- return "", fmt.Errorf("The location passed in (%s) is not a valid zone-id, zone-name, or region name", location)
+ return "", fmt.Errorf("the location passed in (%s) is not a valid zone-id, zone-name, or region name", location)
}
func isSupportedInLocation(instanceOfferings map[ec2types.InstanceType]string, instanceType ec2types.InstanceType) bool {
diff --git a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/services.go b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/services.go
similarity index 73%
rename from vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/services.go
rename to vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/services.go
index b46495c0f..4a1cf0b5d 100644
--- a/vendor/github.com/aws/amazon-ec2-instance-selector/v2/pkg/selector/services.go
+++ b/vendor/github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/services.go
@@ -1,15 +1,14 @@
-// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may
-// not use this file except in compliance with the License. A copy of the
-// License is located at
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// http://aws.amazon.com/apache2.0/
-//
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package selector
@@ -17,36 +16,36 @@ import (
"fmt"
"strings"
- "github.com/imdario/mergo"
+ "dario.cat/mergo"
)
-// Service is used to write custom service filter transforms
+// Service is used to write custom service filter transforms.
type Service interface {
Filters(version string) (Filters, error)
}
-// ServiceFiltersFn is the func type definition for the Service interface
+// ServiceFiltersFn is the func type definition for the Service interface.
type ServiceFiltersFn func(version string) (Filters, error)
// Filters implements the Service interface on ServiceFiltersFn
-// This allows any ServiceFiltersFn to be passed into funcs accepting the Service interface
+// This allows any ServiceFiltersFn to be passed into funcs accepting the Service interface.
func (fn ServiceFiltersFn) Filters(version string) (Filters, error) {
return fn(version)
}
-// ServiceRegistry is used to register service filter transforms
+// ServiceRegistry is used to register service filter transforms.
type ServiceRegistry struct {
services map[string]*Service
}
-// NewRegistry creates a new instance of a ServiceRegistry
+// NewRegistry creates a new instance of a ServiceRegistry.
func NewRegistry() ServiceRegistry {
return ServiceRegistry{
services: make(map[string]*Service),
}
}
-// Register takes a service name and Service implementation that will be executed on an ExecuteTransforms call
+// Register takes a service name and Service implementation that will be executed on an ExecuteTransforms call.
func (sr *ServiceRegistry) Register(name string, service Service) {
if sr.services == nil {
sr.services = make(map[string]*Service)
@@ -57,13 +56,13 @@ func (sr *ServiceRegistry) Register(name string, service Service) {
sr.services[name] = &service
}
-// RegisterAWSServices registers the built-in AWS service filter transforms
+// RegisterAWSServices registers the built-in AWS service filter transforms.
func (sr *ServiceRegistry) RegisterAWSServices() {
sr.Register("emr", &EMR{})
}
// ExecuteTransforms will execute the ServiceRegistry's registered service filter transforms
-// Filters.Service will be parsed as
-
+
-
+
%s\n", cl.filename, cl.lineStart, cl.fragment) + fmt.Fprintf(p.w, "
%s\n", cl.filename, cl.lineStart, + html.EscapeString(string(cl.fragment))) } return nil } -func (*html) PrintFooter() error { return nil } +func (*htmlprinter) PrintFooter() error { return nil } func findLineBeg(file []byte, index int) int { for i := index; i >= 0; i-- { diff --git a/tools/vendor/github.com/golangci/dupl/printer/issuer.go b/tools/vendor/github.com/golangci/dupl/printer/issuer.go new file mode 100644 index 000000000..9b79f5705 --- /dev/null +++ b/tools/vendor/github.com/golangci/dupl/printer/issuer.go @@ -0,0 +1,56 @@ +package printer + +// Golangci-lint: altered version of plumbing.go + +import ( + "sort" + + "github.com/golangci/dupl/syntax" +) + +type Clone clone + +func (c Clone) Filename() string { + return c.filename +} + +func (c Clone) LineStart() int { + return c.lineStart +} + +func (c Clone) LineEnd() int { + return c.lineEnd +} + +type Issue struct { + From, To Clone +} + +type Issuer struct { + ReadFile +} + +func NewIssuer(fread ReadFile) *Issuer { + return &Issuer{fread} +} + +func (p *Issuer) MakeIssues(dups [][]*syntax.Node) ([]Issue, error) { + clones, err := prepareClonesInfo(p.ReadFile, dups) + if err != nil { + return nil, err + } + + sort.Sort(byNameAndLine(clones)) + + var issues []Issue + + for i, cl := range clones { + nextCl := clones[(i+1)%len(clones)] + issues = append(issues, Issue{ + From: Clone(cl), + To: Clone(nextCl), + }) + } + + return issues, nil +} diff --git a/tools/vendor/github.com/golangci/dupl/printer/plumbing.go b/tools/vendor/github.com/golangci/dupl/printer/plumbing.go index cf39d01b7..b0577ddd5 100644 --- a/tools/vendor/github.com/golangci/dupl/printer/plumbing.go +++ b/tools/vendor/github.com/golangci/dupl/printer/plumbing.go @@ -1,50 +1,36 @@ package printer import ( + "fmt" + "io" "sort" "github.com/golangci/dupl/syntax" ) -type Clone clone - -func (c Clone) Filename() string { - return c.filename -} - -func (c Clone) LineStart() int { - return c.lineStart -} - -func (c Clone) LineEnd() int { - return c.lineEnd -} - -type Issue struct { - From, To Clone -} - -type Plumbing struct { +type plumbing struct { + w io.Writer ReadFile } -func NewPlumbing(fread ReadFile) *Plumbing { - return &Plumbing{fread} +func NewPlumbing(w io.Writer, fread ReadFile) Printer { + return &plumbing{w, fread} } -func (p *Plumbing) MakeIssues(dups [][]*syntax.Node) ([]Issue, error) { +func (p *plumbing) PrintHeader() error { return nil } + +func (p *plumbing) PrintClones(dups [][]*syntax.Node) error { clones, err := prepareClonesInfo(p.ReadFile, dups) if err != nil { - return nil, err + return err } sort.Sort(byNameAndLine(clones)) - var issues []Issue for i, cl := range clones { nextCl := clones[(i+1)%len(clones)] - issues = append(issues, Issue{ - From: Clone(cl), - To: Clone(nextCl), - }) + fmt.Fprintf(p.w, "%s:%d-%d: duplicate of %s:%d-%d\n", cl.filename, cl.lineStart, cl.lineEnd, + nextCl.filename, nextCl.lineStart, nextCl.lineEnd) } - return issues, nil + return nil } + +func (p *plumbing) PrintFooter() error { return nil } diff --git a/tools/vendor/github.com/golangci/dupl/suffixtree/suffixtree.go b/tools/vendor/github.com/golangci/dupl/suffixtree/suffixtree.go index 738015025..871469e8d 100644 --- a/tools/vendor/github.com/golangci/dupl/suffixtree/suffixtree.go +++ b/tools/vendor/github.com/golangci/dupl/suffixtree/suffixtree.go @@ -41,7 +41,7 @@ func New() *STree { // Update refreshes the suffix tree to by new data. func (t *STree) Update(data ...Token) { t.data = append(t.data, data...) - for _ = range data { + for range data { t.update() t.s, t.start = t.canonize(t.s, t.start, t.end) t.end++ diff --git a/tools/vendor/github.com/golangci/dupl/syntax/syntax.go b/tools/vendor/github.com/golangci/dupl/syntax/syntax.go index e2c750afd..9b11d3119 100644 --- a/tools/vendor/github.com/golangci/dupl/syntax/syntax.go +++ b/tools/vendor/github.com/golangci/dupl/syntax/syntax.go @@ -6,6 +6,19 @@ import ( "github.com/golangci/dupl/suffixtree" ) +// To avoid "goroutine stack exceeds" with gigantic slices (Composite Literals). +// 10_000 => 0.89s +// 20_000 => 1.53s +// 30_000 => 2.57s +// 40_000 => 3.89s +// 50_000 => 5.58s +// 60_000 => 7.95s +// 70_000 => 10.15s +// 80_000 => 13.11s +// 90_000 => 16.62s +// 100_000 => 21.42s +const maxChildrenSerial = 10_000 + type Node struct { Type int Filename string @@ -40,7 +53,12 @@ func Serialize(n *Node) []*Node { func serial(n *Node, stream *[]*Node) int { *stream = append(*stream, n) var count int - for _, child := range n.Children { + for i, child := range n.Children { + // To avoid "goroutine stack exceeds" with gigantic slices (Composite Literals). + if i > maxChildrenSerial { + break + } + count += serial(child, stream) } n.Owns = count diff --git a/tools/vendor/github.com/golangci/golangci-lint/pkg/commands/run.go b/tools/vendor/github.com/golangci/golangci-lint/pkg/commands/run.go index 3aa467dae..57f3cdd99 100644 --- a/tools/vendor/github.com/golangci/golangci-lint/pkg/commands/run.go +++ b/tools/vendor/github.com/golangci/golangci-lint/pkg/commands/run.go @@ -186,6 +186,10 @@ func (c *runCommand) persistentPostRunE(_ *cobra.Command, _ []string) error { } func (c *runCommand) preRunE(_ *cobra.Command, args []string) error { + if c.cfg.GetConfigDir() != "" && c.cfg.Version != "" { + return errors.New("you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2") + } + dbManager, err := lintersdb.NewManager(c.log.Child(logutils.DebugKeyLintersDB), c.cfg, lintersdb.NewLinterBuilder(), lintersdb.NewPluginModuleBuilder(c.log), lintersdb.NewPluginGoBuilder(c.log)) if err != nil { diff --git a/tools/vendor/github.com/golangci/golangci-lint/pkg/config/config.go b/tools/vendor/github.com/golangci/golangci-lint/pkg/config/config.go index 4ddd89617..ee7a62b7e 100644 --- a/tools/vendor/github.com/golangci/golangci-lint/pkg/config/config.go +++ b/tools/vendor/github.com/golangci/golangci-lint/pkg/config/config.go @@ -20,6 +20,8 @@ type Config struct { cfgDir string // Path to the directory containing golangci-lint config file. basePath string // Path the root directory related to [Run.RelativePathMode]. + Version string `mapstructure:"version"` // From v2, to be able to detect v2 config file. + Run Run `mapstructure:"run"` Output Output `mapstructure:"output"` diff --git a/tools/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl/dupl.go b/tools/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl/dupl.go index d2bb3d8d8..6d1a9809c 100644 --- a/tools/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl/dupl.go +++ b/tools/vendor/github.com/golangci/golangci-lint/pkg/golinters/dupl/dupl.go @@ -5,7 +5,7 @@ import ( "go/token" "sync" - duplAPI "github.com/golangci/dupl" + duplAPI "github.com/golangci/dupl/lib" "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/pkg/config" @@ -45,7 +45,7 @@ func New(settings *config.DuplSettings) *goanalysis.Linter { return goanalysis.NewLinter( linterName, - "Tool for code clone detection", + "Detects duplicate fragments of code.", []*analysis.Analyzer{analyzer}, nil, ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { diff --git a/tools/vendor/github.com/securego/gosec/v2/action.yml b/tools/vendor/github.com/securego/gosec/v2/action.yml index 7aa2ea0da..edd7e7083 100644 --- a/tools/vendor/github.com/securego/gosec/v2/action.yml +++ b/tools/vendor/github.com/securego/gosec/v2/action.yml @@ -10,7 +10,7 @@ inputs: runs: using: 'docker' - image: 'docker://securego/gosec:2.22.0' + image: 'docker://securego/gosec:2.22.1' args: - ${{ inputs.args }} diff --git a/tools/vendor/golang.org/x/sync/errgroup/errgroup.go b/tools/vendor/golang.org/x/sync/errgroup/errgroup.go index b8322598a..a4ea5d14f 100644 --- a/tools/vendor/golang.org/x/sync/errgroup/errgroup.go +++ b/tools/vendor/golang.org/x/sync/errgroup/errgroup.go @@ -46,7 +46,7 @@ func (g *Group) done() { // returns a non-nil error or the first time Wait returns, whichever occurs // first. func WithContext(ctx context.Context) (*Group, context.Context) { - ctx, cancel := withCancelCause(ctx) + ctx, cancel := context.WithCancelCause(ctx) return &Group{cancel: cancel}, ctx } diff --git a/tools/vendor/golang.org/x/sync/errgroup/go120.go b/tools/vendor/golang.org/x/sync/errgroup/go120.go deleted file mode 100644 index f93c740b6..000000000 --- a/tools/vendor/golang.org/x/sync/errgroup/go120.go +++ /dev/null @@ -1,13 +0,0 @@ -// 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. - -//go:build go1.20 - -package errgroup - -import "context" - -func withCancelCause(parent context.Context) (context.Context, func(error)) { - return context.WithCancelCause(parent) -} diff --git a/tools/vendor/golang.org/x/sync/errgroup/pre_go120.go b/tools/vendor/golang.org/x/sync/errgroup/pre_go120.go deleted file mode 100644 index 88ce33434..000000000 --- a/tools/vendor/golang.org/x/sync/errgroup/pre_go120.go +++ /dev/null @@ -1,14 +0,0 @@ -// 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. - -//go:build !go1.20 - -package errgroup - -import "context" - -func withCancelCause(parent context.Context) (context.Context, func(error)) { - ctx, cancel := context.WithCancel(parent) - return ctx, func(error) { cancel() } -} diff --git a/tools/vendor/golang.org/x/tools/go/analysis/analysis.go b/tools/vendor/golang.org/x/tools/go/analysis/analysis.go index 3a73084a5..a7df4d1fe 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/analysis.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/analysis.go @@ -45,7 +45,7 @@ type Analyzer struct { // To pass analysis results between packages (and thus // potentially between address spaces), use Facts, which are // serializable. - Run func(*Pass) (interface{}, error) + Run func(*Pass) (any, error) // RunDespiteErrors allows the driver to invoke // the Run method of this analyzer even on a @@ -112,7 +112,7 @@ type Pass struct { // The map keys are the elements of Analysis.Required, // and the type of each corresponding value is the required // analysis's ResultType. - ResultOf map[*Analyzer]interface{} + ResultOf map[*Analyzer]any // ReadFile returns the contents of the named file. // @@ -186,7 +186,7 @@ type ObjectFact struct { // Reportf is a helper function that reports a Diagnostic using the // specified position and formatted error message. -func (pass *Pass) Reportf(pos token.Pos, format string, args ...interface{}) { +func (pass *Pass) Reportf(pos token.Pos, format string, args ...any) { msg := fmt.Sprintf(format, args...) pass.Report(Diagnostic{Pos: pos, Message: msg}) } @@ -201,7 +201,7 @@ type Range interface { // ReportRangef is a helper function that reports a Diagnostic using the // range provided. ast.Node values can be passed in as the range because // they satisfy the Range interface. -func (pass *Pass) ReportRangef(rng Range, format string, args ...interface{}) { +func (pass *Pass) ReportRangef(rng Range, format string, args ...any) { msg := fmt.Sprintf(format, args...) pass.Report(Diagnostic{Pos: rng.Pos(), End: rng.End(), Message: msg}) } diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/appends/appends.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/appends/appends.go index 6976f0d90..e554c3cc9 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/appends/appends.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/appends/appends.go @@ -29,7 +29,7 @@ var Analyzer = &analysis.Analyzer{ Run: run, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) nodeFilter := []ast.Node{ diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/asmdecl/asmdecl.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/asmdecl/asmdecl.go index a47ecbae7..436b03cb2 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/asmdecl/asmdecl.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/asmdecl/asmdecl.go @@ -150,7 +150,7 @@ var ( abiSuff = re(`^(.+)<(ABI.+)>$`) ) -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { // No work if no assembly files. var sfiles []string for _, fname := range pass.OtherFiles { @@ -226,7 +226,7 @@ Files: for lineno, line := range lines { lineno++ - badf := func(format string, args ...interface{}) { + badf := func(format string, args ...any) { pass.Reportf(analysisutil.LineStart(tf, lineno), "[%s] %s: %s", arch, fnName, fmt.Sprintf(format, args...)) } @@ -646,7 +646,7 @@ func asmParseDecl(pass *analysis.Pass, decl *ast.FuncDecl) map[string]*asmFunc { } // asmCheckVar checks a single variable reference. -func asmCheckVar(badf func(string, ...interface{}), fn *asmFunc, line, expr string, off int, v *asmVar, archDef *asmArch) { +func asmCheckVar(badf func(string, ...any), fn *asmFunc, line, expr string, off int, v *asmVar, archDef *asmArch) { m := asmOpcode.FindStringSubmatch(line) if m == nil { if !strings.HasPrefix(strings.TrimSpace(line), "//") { diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/buildssa/buildssa.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/buildssa/buildssa.go index f077ea282..f49fea517 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/buildssa/buildssa.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/buildssa/buildssa.go @@ -32,7 +32,7 @@ type SSA struct { SrcFuncs []*ssa.Function } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { // We must create a new Program for each Package because the // analysis API provides no place to hang a Program shared by // all Packages. Consequently, SSA Packages and Functions do not diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go index e7434e8fe..6c7a0df58 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go @@ -26,7 +26,7 @@ var Analyzer = &analysis.Analyzer{ Run: runBuildTag, } -func runBuildTag(pass *analysis.Pass) (interface{}, error) { +func runBuildTag(pass *analysis.Pass) (any, error) { for _, f := range pass.Files { checkGoFile(pass, f) } diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go index 4f3bb035d..d9189b5b6 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go @@ -55,7 +55,7 @@ func run(pass *analysis.Pass) (any, error) { return nil, nil } -func checkCgo(fset *token.FileSet, f *ast.File, info *types.Info, reportf func(token.Pos, string, ...interface{})) { +func checkCgo(fset *token.FileSet, f *ast.File, info *types.Info, reportf func(token.Pos, string, ...any)) { ast.Inspect(f, func(n ast.Node) bool { call, ok := n.(*ast.CallExpr) if !ok { diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go index f56c3e622..60c6afe49 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go @@ -51,7 +51,7 @@ func init() { // runUnkeyedLiteral checks if a composite literal is a struct literal with // unkeyed fields. -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) nodeFilter := []ast.Node{ diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock.go index a9f02ac62..49c14d498 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock.go @@ -36,7 +36,7 @@ var Analyzer = &analysis.Analyzer{ Run: run, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) var goversion string // effective file version ("" => unknown) @@ -378,7 +378,7 @@ var lockerType *types.Interface // Construct a sync.Locker interface type. func init() { - nullary := types.NewSignature(nil, nil, nil, false) // func() + nullary := types.NewSignatureType(nil, nil, nil, nil, nil, false) // func() methods := []*types.Func{ types.NewFunc(token.NoPos, nil, "Lock", nullary), types.NewFunc(token.NoPos, nil, "Unlock", nullary), diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go index d21adeee9..951aaed00 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go @@ -80,7 +80,7 @@ func (c *CFGs) FuncLit(lit *ast.FuncLit) *cfg.CFG { return c.funcLits[lit].cfg } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) // Because CFG construction consumes and produces noReturn diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/directive/directive.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/directive/directive.go index b20540238..bebec8914 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/directive/directive.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/directive/directive.go @@ -40,7 +40,7 @@ var Analyzer = &analysis.Analyzer{ Run: runDirective, } -func runDirective(pass *analysis.Pass) (interface{}, error) { +func runDirective(pass *analysis.Pass) (any, error) { for _, f := range pass.Files { checkGoFile(pass, f) } diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/fieldalignment/fieldalignment.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/fieldalignment/fieldalignment.go index 93fa39140..e2ddc83b6 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/fieldalignment/fieldalignment.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/fieldalignment/fieldalignment.go @@ -65,7 +65,7 @@ var Analyzer = &analysis.Analyzer{ Run: run, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) nodeFilter := []ast.Node{ (*ast.StructType)(nil), diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/findcall/findcall.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/findcall/findcall.go index 2671573d1..9db4de1c2 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/findcall/findcall.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/findcall/findcall.go @@ -38,7 +38,7 @@ func init() { Analyzer.Flags.StringVar(&name, "name", name, "name of the function to find") } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { for _, f := range pass.Files { ast.Inspect(f, func(n ast.Node) bool { if call, ok := n.(*ast.CallExpr); ok { diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/framepointer/framepointer.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/framepointer/framepointer.go index 8012de99d..ba94fd68e 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/framepointer/framepointer.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/framepointer/framepointer.go @@ -113,7 +113,7 @@ var arm64Branch = map[string]bool{ "RET": true, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { arch, ok := arches[build.Default.GOARCH] if !ok { return nil, nil diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/ifaceassert/ifaceassert.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/ifaceassert/ifaceassert.go index 5f07ed3ff..4022dbe7c 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/ifaceassert/ifaceassert.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/ifaceassert/ifaceassert.go @@ -52,7 +52,7 @@ func assertableTo(free *typeparams.Free, v, t types.Type) *types.Func { return nil } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) nodeFilter := []ast.Node{ (*ast.TypeAssertExpr)(nil), diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/inspect/inspect.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/inspect/inspect.go index 3b121cb0c..ee1972f56 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/inspect/inspect.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/inspect/inspect.go @@ -44,6 +44,6 @@ var Analyzer = &analysis.Analyzer{ ResultType: reflect.TypeOf(new(inspector.Inspector)), } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { return inspector.New(pass.Files), nil } diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go index d31812421..64df1b106 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go @@ -30,7 +30,7 @@ var Analyzer = &analysis.Analyzer{ Run: run, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) nodeFilter := []ast.Node{ diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go index f8a661aa5..a7fee1809 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go @@ -47,7 +47,7 @@ var contextPackage = "context" // containing the assignment, we assume that other uses exist. // // checkLostCancel analyzes a single named or literal function. -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { // Fast path: bypass check if file doesn't use context.WithCancel. if !analysisinternal.Imports(pass.Pkg, contextPackage) { return nil, nil diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go index 778f7f1f8..3ac2dcd49 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go @@ -30,7 +30,7 @@ var Analyzer = &analysis.Analyzer{ Run: run, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) nodeFilter := []ast.Node{ diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/nilness/nilness.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/nilness/nilness.go index faaf12a93..af61ae608 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/nilness/nilness.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/nilness/nilness.go @@ -28,7 +28,7 @@ var Analyzer = &analysis.Analyzer{ Requires: []*analysis.Analyzer{buildssa.Analyzer}, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { ssainput := pass.ResultOf[buildssa.Analyzer].(*buildssa.SSA) for _, fn := range ssainput.SrcFuncs { runFunc(pass, fn) @@ -37,7 +37,7 @@ func run(pass *analysis.Pass) (interface{}, error) { } func runFunc(pass *analysis.Pass, fn *ssa.Function) { - reportf := func(category string, pos token.Pos, format string, args ...interface{}) { + reportf := func(category string, pos token.Pos, format string, args ...any) { // We ignore nil-checking ssa.Instructions // that don't correspond to syntax. if pos.IsValid() { diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/pkgfact/pkgfact.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/pkgfact/pkgfact.go index 077c87808..31748795d 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/pkgfact/pkgfact.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/pkgfact/pkgfact.go @@ -53,7 +53,7 @@ type pairsFact []string func (f *pairsFact) AFact() {} func (f *pairsFact) String() string { return "pairs(" + strings.Join(*f, ", ") + ")" } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { result := make(map[string]string) // At each import, print the fact from the imported diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go index 81600a283..a28ed365d 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go @@ -924,9 +924,14 @@ func checkPrint(pass *analysis.Pass, call *ast.CallExpr, name string) { // The % in "abc 0.0%" couldn't be a formatting directive. s = strings.TrimSuffix(s, "%") if strings.Contains(s, "%") { - m := printFormatRE.FindStringSubmatch(s) - if m != nil { - pass.ReportRangef(call, "%s call has possible Printf formatting directive %s", name, m[0]) + for _, m := range printFormatRE.FindAllString(s, -1) { + // Allow %XX where XX are hex digits, + // as this is common in URLs. + if len(m) >= 3 && isHex(m[1]) && isHex(m[2]) { + continue + } + pass.ReportRangef(call, "%s call has possible Printf formatting directive %s", name, m) + break // report only the first one } } } @@ -992,3 +997,10 @@ func (ss stringSet) Set(flag string) error { // // Remove this after the 1.24 release. var suppressNonconstants bool + +// isHex reports whether b is a hex digit. +func isHex(b byte) bool { + return '0' <= b && b <= '9' || + 'A' <= b && b <= 'F' || + 'a' <= b && b <= 'f' +} diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/reflectvaluecompare/reflectvaluecompare.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/reflectvaluecompare/reflectvaluecompare.go index 72435b2fc..d0632dbda 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/reflectvaluecompare/reflectvaluecompare.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/reflectvaluecompare/reflectvaluecompare.go @@ -28,7 +28,7 @@ var Analyzer = &analysis.Analyzer{ Run: run, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) nodeFilter := []ast.Node{ diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/shadow/shadow.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/shadow/shadow.go index 30258c991..8f768bb76 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/shadow/shadow.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/shadow/shadow.go @@ -36,7 +36,7 @@ func init() { Analyzer.Flags.BoolVar(&strict, "strict", strict, "whether to be strict about shadowing; can be noisy") } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) spans := make(map[types.Object]span) diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/shift/shift.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/shift/shift.go index 46b5f6d68..57987b3d2 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/shift/shift.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/shift/shift.go @@ -34,7 +34,7 @@ var Analyzer = &analysis.Analyzer{ Run: run, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) // Do a complete pass to compute dead nodes. diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go index 28f51b1ec..a0bdf001a 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go @@ -66,7 +66,7 @@ var canonicalMethods = map[string]struct{ args, results []string }{ "WriteTo": {[]string{"=io.Writer"}, []string{"int64", "error"}}, // io.WriterTo } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) nodeFilter := []ast.Node{ diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/stringintconv/string.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/stringintconv/string.go index f56e6ecaa..a23721cd2 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/stringintconv/string.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/stringintconv/string.go @@ -70,7 +70,7 @@ func typeName(t types.Type) string { return "" } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) nodeFilter := []ast.Node{ (*ast.File)(nil), diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go index 4115ef769..d92650340 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go @@ -34,7 +34,7 @@ var Analyzer = &analysis.Analyzer{ Run: run, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) nodeFilter := []ast.Node{ diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/testinggoroutine/testinggoroutine.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/testinggoroutine/testinggoroutine.go index fef5a6014..f49ac4eb1 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/testinggoroutine/testinggoroutine.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/testinggoroutine/testinggoroutine.go @@ -36,7 +36,7 @@ var Analyzer = &analysis.Analyzer{ Run: run, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) if !analysisinternal.Imports(pass.Pkg, "testing") { diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/tests/tests.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/tests/tests.go index 285b34218..9f59006eb 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/tests/tests.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/tests/tests.go @@ -47,7 +47,7 @@ var acceptedFuzzTypes = []types.Type{ types.NewSlice(types.Universe.Lookup("byte").Type()), } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { for _, f := range pass.Files { if !strings.HasSuffix(pass.Fset.File(f.FileStart).Name(), "_test.go") { continue diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go index b810db7ee..fcf5fbd90 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go @@ -30,7 +30,7 @@ var Analyzer = &analysis.Analyzer{ Run: run, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) nodeFilter := []ast.Node{ diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go index fb5b944fa..57c6da64f 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go @@ -30,7 +30,7 @@ var Analyzer = &analysis.Analyzer{ Run: run, } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) nodeFilter := []ast.Node{ diff --git a/tools/vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go b/tools/vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go index d7cc1e6ae..932f1347e 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go @@ -85,7 +85,7 @@ func init() { "comma-separated list of names of methods of type func() string whose results must be used") } -func run(pass *analysis.Pass) (interface{}, error) { +func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) // Split functions into (pkg, name) pairs to save allocation later. @@ -130,9 +130,7 @@ func run(pass *analysis.Pass) (interface{}, error) { } // func() string -var sigNoArgsStringResult = types.NewSignature(nil, nil, - types.NewTuple(types.NewParam(token.NoPos, nil, "", types.Typ[types.String])), - false) +var sigNoArgsStringResult = types.NewSignatureType(nil, nil, nil, nil, types.NewTuple(types.NewParam(token.NoPos, nil, "", types.Typ[types.String])), false) type stringSetFlag map[string]bool diff --git a/tools/vendor/golang.org/x/tools/go/analysis/validate.go b/tools/vendor/golang.org/x/tools/go/analysis/validate.go index 4f2c40456..145393921 100644 --- a/tools/vendor/golang.org/x/tools/go/analysis/validate.go +++ b/tools/vendor/golang.org/x/tools/go/analysis/validate.go @@ -63,7 +63,7 @@ func Validate(analyzers []*Analyzer) error { return fmt.Errorf("fact type %s registered by two analyzers: %v, %v", t, a, prev) } - if t.Kind() != reflect.Ptr { + if t.Kind() != reflect.Pointer { return fmt.Errorf("%s: fact type %s is not a pointer", a, t) } factTypes[t] = a diff --git a/tools/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go b/tools/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go index 58934f766..5c8dbbb7a 100644 --- a/tools/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go +++ b/tools/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go @@ -183,7 +183,7 @@ type application struct { func (a *application) apply(parent ast.Node, name string, iter *iterator, n ast.Node) { // convert typed nil into untyped nil - if v := reflect.ValueOf(n); v.Kind() == reflect.Ptr && v.IsNil() { + if v := reflect.ValueOf(n); v.Kind() == reflect.Pointer && v.IsNil() { n = nil } diff --git a/tools/vendor/golang.org/x/tools/go/ast/astutil/util.go b/tools/vendor/golang.org/x/tools/go/ast/astutil/util.go index ca71e3e10..c820b2084 100644 --- a/tools/vendor/golang.org/x/tools/go/ast/astutil/util.go +++ b/tools/vendor/golang.org/x/tools/go/ast/astutil/util.go @@ -8,4 +8,6 @@ import "go/ast" // Unparen returns e with any enclosing parentheses stripped. // Deprecated: use [ast.Unparen]. +// +//go:fix inline func Unparen(e ast.Expr) ast.Expr { return ast.Unparen(e) } diff --git a/tools/vendor/golang.org/x/tools/go/buildutil/fakecontext.go b/tools/vendor/golang.org/x/tools/go/buildutil/fakecontext.go index 763d18809..1f75141d5 100644 --- a/tools/vendor/golang.org/x/tools/go/buildutil/fakecontext.go +++ b/tools/vendor/golang.org/x/tools/go/buildutil/fakecontext.go @@ -95,7 +95,7 @@ func (s byName) Less(i, j int) bool { return s[i].Name() < s[j].Name() } type fakeFileInfo string func (fi fakeFileInfo) Name() string { return string(fi) } -func (fakeFileInfo) Sys() interface{} { return nil } +func (fakeFileInfo) Sys() any { return nil } func (fakeFileInfo) ModTime() time.Time { return time.Time{} } func (fakeFileInfo) IsDir() bool { return false } func (fakeFileInfo) Size() int64 { return 0 } @@ -104,7 +104,7 @@ func (fakeFileInfo) Mode() os.FileMode { return 0644 } type fakeDirInfo string func (fd fakeDirInfo) Name() string { return string(fd) } -func (fakeDirInfo) Sys() interface{} { return nil } +func (fakeDirInfo) Sys() any { return nil } func (fakeDirInfo) ModTime() time.Time { return time.Time{} } func (fakeDirInfo) IsDir() bool { return true } func (fakeDirInfo) Size() int64 { return 0 } diff --git a/tools/vendor/golang.org/x/tools/go/buildutil/tags.go b/tools/vendor/golang.org/x/tools/go/buildutil/tags.go index 32c8d1424..410c8e72d 100644 --- a/tools/vendor/golang.org/x/tools/go/buildutil/tags.go +++ b/tools/vendor/golang.org/x/tools/go/buildutil/tags.go @@ -51,7 +51,7 @@ func (v *TagsFlag) Set(s string) error { return nil } -func (v *TagsFlag) Get() interface{} { return *v } +func (v *TagsFlag) Get() any { return *v } func splitQuotedFields(s string) ([]string, error) { // See $GOROOT/src/cmd/internal/quoted/quoted.go (Split) diff --git a/tools/vendor/golang.org/x/tools/go/internal/cgo/cgo.go b/tools/vendor/golang.org/x/tools/go/internal/cgo/cgo.go index 697974bb9..735efeb53 100644 --- a/tools/vendor/golang.org/x/tools/go/internal/cgo/cgo.go +++ b/tools/vendor/golang.org/x/tools/go/internal/cgo/cgo.go @@ -203,7 +203,7 @@ func envList(key, def string) []string { // stringList's arguments should be a sequence of string or []string values. // stringList flattens them into a single []string. -func stringList(args ...interface{}) []string { +func stringList(args ...any) []string { var x []string for _, arg := range args { switch arg := arg.(type) { diff --git a/tools/vendor/golang.org/x/tools/go/loader/loader.go b/tools/vendor/golang.org/x/tools/go/loader/loader.go index 2d4865f66..d06f95ad7 100644 --- a/tools/vendor/golang.org/x/tools/go/loader/loader.go +++ b/tools/vendor/golang.org/x/tools/go/loader/loader.go @@ -215,7 +215,7 @@ func (conf *Config) fset() *token.FileSet { // src specifies the parser input as a string, []byte, or io.Reader, and // filename is its apparent name. If src is nil, the contents of // filename are read from the file system. -func (conf *Config) ParseFile(filename string, src interface{}) (*ast.File, error) { +func (conf *Config) ParseFile(filename string, src any) (*ast.File, error) { // TODO(adonovan): use conf.build() etc like parseFiles does. return parser.ParseFile(conf.fset(), filename, src, conf.ParserMode) } diff --git a/tools/vendor/golang.org/x/tools/go/packages/packages.go b/tools/vendor/golang.org/x/tools/go/packages/packages.go index c3a59b8eb..6665a04c1 100644 --- a/tools/vendor/golang.org/x/tools/go/packages/packages.go +++ b/tools/vendor/golang.org/x/tools/go/packages/packages.go @@ -141,6 +141,8 @@ const ( LoadAllSyntax = LoadSyntax | NeedDeps // Deprecated: NeedExportsFile is a historical misspelling of NeedExportFile. + // + //go:fix inline NeedExportsFile = NeedExportFile ) @@ -161,7 +163,7 @@ type Config struct { // If the user provides a logger, debug logging is enabled. // If the GOPACKAGESDEBUG environment variable is set to true, // but the logger is nil, default to log.Printf. - Logf func(format string, args ...interface{}) + Logf func(format string, args ...any) // Dir is the directory in which to run the build system's query tool // that provides information about the packages. @@ -564,13 +566,13 @@ type ModuleError struct { } func init() { - packagesinternal.GetDepsErrors = func(p interface{}) []*packagesinternal.PackageError { + packagesinternal.GetDepsErrors = func(p any) []*packagesinternal.PackageError { return p.(*Package).depsErrors } - packagesinternal.SetModFile = func(config interface{}, value string) { + packagesinternal.SetModFile = func(config any, value string) { config.(*Config).modFile = value } - packagesinternal.SetModFlag = func(config interface{}, value string) { + packagesinternal.SetModFlag = func(config any, value string) { config.(*Config).modFlag = value } packagesinternal.TypecheckCgo = int(typecheckCgo) @@ -739,7 +741,7 @@ func newLoader(cfg *Config) *loader { if debug { ld.Config.Logf = log.Printf } else { - ld.Config.Logf = func(format string, args ...interface{}) {} + ld.Config.Logf = func(format string, args ...any) {} } } if ld.Config.Mode == 0 { diff --git a/tools/vendor/golang.org/x/tools/go/ssa/builder.go b/tools/vendor/golang.org/x/tools/go/ssa/builder.go index 4cd71260b..84ccbc092 100644 --- a/tools/vendor/golang.org/x/tools/go/ssa/builder.go +++ b/tools/vendor/golang.org/x/tools/go/ssa/builder.go @@ -82,6 +82,8 @@ import ( "runtime" "sync" + "slices" + "golang.org/x/tools/internal/typeparams" "golang.org/x/tools/internal/versions" ) @@ -559,7 +561,7 @@ func (sb *storebuf) emit(fn *Function) { // literal that may reference parts of the LHS. func (b *builder) assign(fn *Function, loc lvalue, e ast.Expr, isZero bool, sb *storebuf) { // Can we initialize it in place? - if e, ok := unparen(e).(*ast.CompositeLit); ok { + if e, ok := ast.Unparen(e).(*ast.CompositeLit); ok { // A CompositeLit never evaluates to a pointer, // so if the type of the location is a pointer, // an &-operation is implied. @@ -614,7 +616,7 @@ func (b *builder) assign(fn *Function, loc lvalue, e ast.Expr, isZero bool, sb * // expr lowers a single-result expression e to SSA form, emitting code // to fn and returning the Value defined by the expression. func (b *builder) expr(fn *Function, e ast.Expr) Value { - e = unparen(e) + e = ast.Unparen(e) tv := fn.info.Types[e] @@ -704,7 +706,7 @@ func (b *builder) expr0(fn *Function, e ast.Expr, tv types.TypeAndValue) Value { return y } // Call to "intrinsic" built-ins, e.g. new, make, panic. - if id, ok := unparen(e.Fun).(*ast.Ident); ok { + if id, ok := ast.Unparen(e.Fun).(*ast.Ident); ok { if obj, ok := fn.info.Uses[id].(*types.Builtin); ok { if v := b.builtin(fn, obj, e.Args, fn.typ(tv.Type), e.Lparen); v != nil { return v @@ -721,7 +723,7 @@ func (b *builder) expr0(fn *Function, e ast.Expr, tv types.TypeAndValue) Value { switch e.Op { case token.AND: // &X --- potentially escaping. addr := b.addr(fn, e.X, true) - if _, ok := unparen(e.X).(*ast.StarExpr); ok { + if _, ok := ast.Unparen(e.X).(*ast.StarExpr); ok { // &*p must panic if p is nil (http://golang.org/s/go12nil). // For simplicity, we'll just (suboptimally) rely // on the side effects of a load. @@ -1002,7 +1004,7 @@ func (b *builder) setCallFunc(fn *Function, e *ast.CallExpr, c *CallCommon) { c.pos = e.Lparen // Is this a method call? - if selector, ok := unparen(e.Fun).(*ast.SelectorExpr); ok { + if selector, ok := ast.Unparen(e.Fun).(*ast.SelectorExpr); ok { sel := fn.selection(selector) if sel != nil && sel.kind == types.MethodVal { obj := sel.obj.(*types.Func) @@ -1372,7 +1374,7 @@ func (b *builder) compLit(fn *Function, addr Value, e *ast.CompositeLit, isZero // An &-operation may be implied: // map[*struct{}]bool{&struct{}{}: true} wantAddr := false - if _, ok := unparen(e.Key).(*ast.CompositeLit); ok { + if _, ok := ast.Unparen(e.Key).(*ast.CompositeLit); ok { wantAddr = isPointerCore(t.Key()) } @@ -1547,9 +1549,9 @@ func (b *builder) typeSwitchStmt(fn *Function, s *ast.TypeSwitchStmt, label *lbl var x Value switch ass := s.Assign.(type) { case *ast.ExprStmt: // x.(type) - x = b.expr(fn, unparen(ass.X).(*ast.TypeAssertExpr).X) + x = b.expr(fn, ast.Unparen(ass.X).(*ast.TypeAssertExpr).X) case *ast.AssignStmt: // y := x.(type) - x = b.expr(fn, unparen(ass.Rhs[0]).(*ast.TypeAssertExpr).X) + x = b.expr(fn, ast.Unparen(ass.Rhs[0]).(*ast.TypeAssertExpr).X) } done := fn.newBasicBlock("typeswitch.done") @@ -1667,7 +1669,7 @@ func (b *builder) selectStmt(fn *Function, s *ast.SelectStmt, label *lblock) { } case *ast.AssignStmt: // x := <-ch - recv := unparen(comm.Rhs[0]).(*ast.UnaryExpr) + recv := ast.Unparen(comm.Rhs[0]).(*ast.UnaryExpr) st = &SelectState{ Dir: types.RecvOnly, Chan: b.expr(fn, recv.X), @@ -1678,7 +1680,7 @@ func (b *builder) selectStmt(fn *Function, s *ast.SelectStmt, label *lblock) { } case *ast.ExprStmt: // <-ch - recv := unparen(comm.X).(*ast.UnaryExpr) + recv := ast.Unparen(comm.X).(*ast.UnaryExpr) st = &SelectState{ Dir: types.RecvOnly, Chan: b.expr(fn, recv.X), @@ -2021,8 +2023,8 @@ func (b *builder) forStmtGo122(fn *Function, s *ast.ForStmt, label *lblock) { // Remove instructions for phi, load, and store. // lift() will remove the unused i_next *Alloc. isDead := func(i Instruction) bool { return dead[i] } - loop.Instrs = removeInstrsIf(loop.Instrs, isDead) - post.Instrs = removeInstrsIf(post.Instrs, isDead) + loop.Instrs = slices.DeleteFunc(loop.Instrs, isDead) + post.Instrs = slices.DeleteFunc(post.Instrs, isDead) } } diff --git a/tools/vendor/golang.org/x/tools/go/ssa/emit.go b/tools/vendor/golang.org/x/tools/go/ssa/emit.go index a3d41ad95..bca79adc4 100644 --- a/tools/vendor/golang.org/x/tools/go/ssa/emit.go +++ b/tools/vendor/golang.org/x/tools/go/ssa/emit.go @@ -81,7 +81,7 @@ func emitDebugRef(f *Function, e ast.Expr, v Value, isAddr bool) { panic("nil") } var obj types.Object - e = unparen(e) + e = ast.Unparen(e) if id, ok := e.(*ast.Ident); ok { if isBlankIdent(id) { return diff --git a/tools/vendor/golang.org/x/tools/go/ssa/lift.go b/tools/vendor/golang.org/x/tools/go/ssa/lift.go index aada3dc32..6138ca82e 100644 --- a/tools/vendor/golang.org/x/tools/go/ssa/lift.go +++ b/tools/vendor/golang.org/x/tools/go/ssa/lift.go @@ -43,6 +43,7 @@ import ( "go/token" "math/big" "os" + "slices" "golang.org/x/tools/internal/typeparams" ) @@ -105,23 +106,7 @@ func buildDomFrontier(fn *Function) domFrontier { } func removeInstr(refs []Instruction, instr Instruction) []Instruction { - return removeInstrsIf(refs, func(i Instruction) bool { return i == instr }) -} - -func removeInstrsIf(refs []Instruction, p func(Instruction) bool) []Instruction { - // TODO(taking): replace with go1.22 slices.DeleteFunc. - i := 0 - for _, ref := range refs { - if p(ref) { - continue - } - refs[i] = ref - i++ - } - for j := i; j != len(refs); j++ { - refs[j] = nil // aid GC - } - return refs[:i] + return slices.DeleteFunc(refs, func(i Instruction) bool { return i == instr }) } // lift replaces local and new Allocs accessed only with diff --git a/tools/vendor/golang.org/x/tools/go/ssa/mode.go b/tools/vendor/golang.org/x/tools/go/ssa/mode.go index 8381639a5..61c91452c 100644 --- a/tools/vendor/golang.org/x/tools/go/ssa/mode.go +++ b/tools/vendor/golang.org/x/tools/go/ssa/mode.go @@ -108,4 +108,4 @@ func (m *BuilderMode) Set(s string) error { } // Get returns m. -func (m BuilderMode) Get() interface{} { return m } +func (m BuilderMode) Get() any { return m } diff --git a/tools/vendor/golang.org/x/tools/go/ssa/print.go b/tools/vendor/golang.org/x/tools/go/ssa/print.go index 432c4b05b..8b92d0846 100644 --- a/tools/vendor/golang.org/x/tools/go/ssa/print.go +++ b/tools/vendor/golang.org/x/tools/go/ssa/print.go @@ -387,7 +387,7 @@ func (s *MapUpdate) String() string { func (s *DebugRef) String() string { p := s.Parent().Prog.Fset.Position(s.Pos()) - var descr interface{} + var descr any if s.object != nil { descr = s.object // e.g. "var x int" } else { diff --git a/tools/vendor/golang.org/x/tools/go/ssa/sanity.go b/tools/vendor/golang.org/x/tools/go/ssa/sanity.go index e35e4d793..97ef886e3 100644 --- a/tools/vendor/golang.org/x/tools/go/ssa/sanity.go +++ b/tools/vendor/golang.org/x/tools/go/ssa/sanity.go @@ -48,7 +48,7 @@ func mustSanityCheck(fn *Function, reporter io.Writer) { } } -func (s *sanity) diagnostic(prefix, format string, args ...interface{}) { +func (s *sanity) diagnostic(prefix, format string, args ...any) { fmt.Fprintf(s.reporter, "%s: function %s", prefix, s.fn) if s.block != nil { fmt.Fprintf(s.reporter, ", block %s", s.block) @@ -58,12 +58,12 @@ func (s *sanity) diagnostic(prefix, format string, args ...interface{}) { io.WriteString(s.reporter, "\n") } -func (s *sanity) errorf(format string, args ...interface{}) { +func (s *sanity) errorf(format string, args ...any) { s.insane = true s.diagnostic("Error", format, args...) } -func (s *sanity) warnf(format string, args ...interface{}) { +func (s *sanity) warnf(format string, args ...any) { s.diagnostic("Warning", format, args...) } diff --git a/tools/vendor/golang.org/x/tools/go/ssa/source.go b/tools/vendor/golang.org/x/tools/go/ssa/source.go index 055a6b1ef..d0cc1f486 100644 --- a/tools/vendor/golang.org/x/tools/go/ssa/source.go +++ b/tools/vendor/golang.org/x/tools/go/ssa/source.go @@ -153,7 +153,7 @@ func findNamedFunc(pkg *Package, pos token.Pos) *Function { // the ssa.Value.) func (f *Function) ValueForExpr(e ast.Expr) (value Value, isAddr bool) { if f.debugInfo() { // (opt) - e = unparen(e) + e = ast.Unparen(e) for _, b := range f.Blocks { for _, instr := range b.Instrs { if ref, ok := instr.(*DebugRef); ok { diff --git a/tools/vendor/golang.org/x/tools/go/ssa/util.go b/tools/vendor/golang.org/x/tools/go/ssa/util.go index 4a056cbe0..9a73984a6 100644 --- a/tools/vendor/golang.org/x/tools/go/ssa/util.go +++ b/tools/vendor/golang.org/x/tools/go/ssa/util.go @@ -35,8 +35,6 @@ func assert(p bool, msg string) { //// AST utilities -func unparen(e ast.Expr) ast.Expr { return ast.Unparen(e) } - // isBlankIdent returns true iff e is an Ident with name "_". // They have no associated types.Object, and thus no type. func isBlankIdent(e ast.Expr) bool { @@ -168,7 +166,7 @@ func declaredWithin(obj types.Object, fn *types.Func) bool { // returns a closure that prints the corresponding "end" message. // Call using 'defer logStack(...)()' to show builder stack on panic. // Don't forget trailing parens! -func logStack(format string, args ...interface{}) func() { +func logStack(format string, args ...any) func() { msg := fmt.Sprintf(format, args...) io.WriteString(os.Stderr, msg) io.WriteString(os.Stderr, "\n") @@ -195,7 +193,7 @@ func makeLen(T types.Type) *Builtin { lenParams := types.NewTuple(anonVar(T)) return &Builtin{ name: "len", - sig: types.NewSignature(nil, lenParams, lenResults, false), + sig: types.NewSignatureType(nil, nil, nil, lenParams, lenResults, false), } } diff --git a/tools/vendor/golang.org/x/tools/go/ssa/wrappers.go b/tools/vendor/golang.org/x/tools/go/ssa/wrappers.go index d09b4f250..aeb160eff 100644 --- a/tools/vendor/golang.org/x/tools/go/ssa/wrappers.go +++ b/tools/vendor/golang.org/x/tools/go/ssa/wrappers.go @@ -106,9 +106,7 @@ func (b *builder) buildWrapper(fn *Function) { var c Call c.Call.Value = &Builtin{ name: "ssa:wrapnilchk", - sig: types.NewSignature(nil, - types.NewTuple(anonVar(fn.method.recv), anonVar(tString), anonVar(tString)), - types.NewTuple(anonVar(fn.method.recv)), false), + sig: types.NewSignatureType(nil, nil, nil, types.NewTuple(anonVar(fn.method.recv), anonVar(tString), anonVar(tString)), types.NewTuple(anonVar(fn.method.recv)), false), } c.Call.Args = []Value{ v, @@ -262,7 +260,7 @@ func createThunk(prog *Program, sel *selection) *Function { } func changeRecv(s *types.Signature, recv *types.Var) *types.Signature { - return types.NewSignature(recv, s.Params(), s.Results(), s.Variadic()) + return types.NewSignatureType(recv, nil, nil, s.Params(), s.Results(), s.Variadic()) } // A local version of *types.Selection. diff --git a/tools/vendor/golang.org/x/tools/go/types/typeutil/map.go b/tools/vendor/golang.org/x/tools/go/types/typeutil/map.go index 43261147c..b6d542c64 100644 --- a/tools/vendor/golang.org/x/tools/go/types/typeutil/map.go +++ b/tools/vendor/golang.org/x/tools/go/types/typeutil/map.go @@ -389,8 +389,13 @@ func (hasher) hashTypeName(tname *types.TypeName) uint32 { // path, and whether or not it is a package-level typename. It // is rare for a package to define multiple local types with // the same name.) - hash := uintptr(unsafe.Pointer(tname)) - return uint32(hash ^ (hash >> 32)) + ptr := uintptr(unsafe.Pointer(tname)) + if unsafe.Sizeof(ptr) == 8 { + hash := uint64(ptr) + return uint32(hash ^ (hash >> 32)) + } else { + return uint32(ptr) + } } // shallowHash computes a hash of t without looking at any of its diff --git a/tools/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go b/tools/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go index abf708111..5eb7ac5a9 100644 --- a/tools/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go +++ b/tools/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go @@ -23,6 +23,8 @@ import ( "golang.org/x/tools/internal/typesinternal" ) +// Deprecated: this heuristic is ill-defined. +// TODO(adonovan): move to sole use in gopls/internal/cache. func TypeErrorEndPos(fset *token.FileSet, src []byte, start token.Pos) token.Pos { // Get the end position for the type error. file := fset.File(start) @@ -255,16 +257,16 @@ func AddImport(info *types.Info, file *ast.File, preferredName, pkgpath, member newName = fmt.Sprintf("%s%d", preferredName, i) } - // For now, keep it real simple: create a new import - // declaration before the first existing declaration (which - // must exist), including its comments, and let goimports tidy it up. + // Create a new import declaration either before the first existing + // declaration (which must exist), including its comments; or + // inside the declaration, if it is an import group. // // Use a renaming import whenever the preferred name is not // available, or the chosen name does not match the last // segment of its path. - newText := fmt.Sprintf("import %q\n\n", pkgpath) + newText := fmt.Sprintf("%q", pkgpath) if newName != preferredName || newName != pathpkg.Base(pkgpath) { - newText = fmt.Sprintf("import %s %q\n\n", newName, pkgpath) + newText = fmt.Sprintf("%s %q", newName, pkgpath) } decl0 := file.Decls[0] var before ast.Node = decl0 @@ -278,9 +280,17 @@ func AddImport(info *types.Info, file *ast.File, preferredName, pkgpath, member before = decl0.Doc } } + // If the first decl is an import group, add this new import at the end. + if gd, ok := before.(*ast.GenDecl); ok && gd.Tok == token.IMPORT && gd.Rparen.IsValid() { + pos = gd.Rparen + newText = "\t" + newText + "\n" + } else { + pos = before.Pos() + newText = "import " + newText + "\n\n" + } return newName, newName + ".", []analysis.TextEdit{{ - Pos: before.Pos(), - End: before.Pos(), + Pos: pos, + End: pos, NewText: []byte(newText), }} } @@ -409,18 +419,19 @@ func validateFix(fset *token.FileSet, fix *analysis.SuggestedFix) error { start := edit.Pos file := fset.File(start) if file == nil { - return fmt.Errorf("missing file info for pos (%v)", edit.Pos) + return fmt.Errorf("no token.File for TextEdit.Pos (%v)", edit.Pos) } if end := edit.End; end.IsValid() { if end < start { - return fmt.Errorf("pos (%v) > end (%v)", edit.Pos, edit.End) + return fmt.Errorf("TextEdit.Pos (%v) > TextEdit.End (%v)", edit.Pos, edit.End) } endFile := fset.File(end) if endFile == nil { - return fmt.Errorf("malformed end position %v", end) + return fmt.Errorf("no token.File for TextEdit.End (%v; File(start).FileEnd is %d)", end, file.Base()+file.Size()) } if endFile != file { - return fmt.Errorf("edit spans files %v and %v", file.Name(), endFile.Name()) + return fmt.Errorf("edit #%d spans files (%v and %v)", + i, file.Position(edit.Pos), endFile.Position(edit.End)) } } else { edit.End = start // update the SuggestedFix @@ -449,3 +460,30 @@ func validateFix(fset *token.FileSet, fix *analysis.SuggestedFix) error { return nil } + +// CanImport reports whether one package is allowed to import another. +// +// TODO(adonovan): allow customization of the accessibility relation +// (e.g. for Bazel). +func CanImport(from, to string) bool { + // TODO(adonovan): better segment hygiene. + if to == "internal" || strings.HasPrefix(to, "internal/") { + // Special case: only std packages may import internal/... + // We can't reliably know whether we're in std, so we + // use a heuristic on the first segment. + first, _, _ := strings.Cut(from, "/") + if strings.Contains(first, ".") { + return false // example.com/foo ∉ std + } + if first == "testdata" { + return false // testdata/foo ∉ std + } + } + if strings.HasSuffix(to, "/internal") { + return strings.HasPrefix(from, to[:len(to)-len("/internal")]) + } + if i := strings.LastIndex(to, "/internal/"); i >= 0 { + return strings.HasPrefix(from, to[:i]) + } + return true +} diff --git a/tools/vendor/golang.org/x/tools/internal/event/keys/keys.go b/tools/vendor/golang.org/x/tools/internal/event/keys/keys.go index a02206e30..4cfa51b61 100644 --- a/tools/vendor/golang.org/x/tools/internal/event/keys/keys.go +++ b/tools/vendor/golang.org/x/tools/internal/event/keys/keys.go @@ -32,7 +32,7 @@ func (k *Value) Format(w io.Writer, buf []byte, l label.Label) { } // Get can be used to get a label for the key from a label.Map. -func (k *Value) Get(lm label.Map) interface{} { +func (k *Value) Get(lm label.Map) any { if t := lm.Find(k); t.Valid() { return k.From(t) } @@ -40,10 +40,10 @@ func (k *Value) Get(lm label.Map) interface{} { } // From can be used to get a value from a Label. -func (k *Value) From(t label.Label) interface{} { return t.UnpackValue() } +func (k *Value) From(t label.Label) any { return t.UnpackValue() } // Of creates a new Label with this key and the supplied value. -func (k *Value) Of(value interface{}) label.Label { return label.OfValue(k, value) } +func (k *Value) Of(value any) label.Label { return label.OfValue(k, value) } // Tag represents a key for tagging labels that have no value. // These are used when the existence of the label is the entire information it diff --git a/tools/vendor/golang.org/x/tools/internal/event/label/label.go b/tools/vendor/golang.org/x/tools/internal/event/label/label.go index 0f526e1f9..7c00ca2a6 100644 --- a/tools/vendor/golang.org/x/tools/internal/event/label/label.go +++ b/tools/vendor/golang.org/x/tools/internal/event/label/label.go @@ -32,7 +32,7 @@ type Key interface { type Label struct { key Key packed uint64 - untyped interface{} + untyped any } // Map is the interface to a collection of Labels indexed by key. @@ -76,13 +76,13 @@ type mapChain struct { // OfValue creates a new label from the key and value. // This method is for implementing new key types, label creation should // normally be done with the Of method of the key. -func OfValue(k Key, value interface{}) Label { return Label{key: k, untyped: value} } +func OfValue(k Key, value any) Label { return Label{key: k, untyped: value} } // UnpackValue assumes the label was built using LabelOfValue and returns the value // that was passed to that constructor. // This method is for implementing new key types, for type safety normal // access should be done with the From method of the key. -func (t Label) UnpackValue() interface{} { return t.untyped } +func (t Label) UnpackValue() any { return t.untyped } // Of64 creates a new label from a key and a uint64. This is often // used for non uint64 values that can be packed into a uint64. diff --git a/tools/vendor/golang.org/x/tools/internal/gcimporter/bimport.go b/tools/vendor/golang.org/x/tools/internal/gcimporter/bimport.go index d79a605ed..734c46198 100644 --- a/tools/vendor/golang.org/x/tools/internal/gcimporter/bimport.go +++ b/tools/vendor/golang.org/x/tools/internal/gcimporter/bimport.go @@ -14,7 +14,7 @@ import ( "sync" ) -func errorf(format string, args ...interface{}) { +func errorf(format string, args ...any) { panic(fmt.Sprintf(format, args...)) } diff --git a/tools/vendor/golang.org/x/tools/internal/gcimporter/iexport.go b/tools/vendor/golang.org/x/tools/internal/gcimporter/iexport.go index 7dfc31a37..253d6493c 100644 --- a/tools/vendor/golang.org/x/tools/internal/gcimporter/iexport.go +++ b/tools/vendor/golang.org/x/tools/internal/gcimporter/iexport.go @@ -310,7 +310,7 @@ func IImportShallow(fset *token.FileSet, getPackages GetPackagesFunc, data []byt } // ReportFunc is the type of a function used to report formatted bugs. -type ReportFunc = func(string, ...interface{}) +type ReportFunc = func(string, ...any) // Current bundled export format version. Increase with each format change. // 0: initial implementation @@ -597,7 +597,7 @@ type filePositions struct { needed []uint64 // unordered list of needed file offsets } -func (p *iexporter) trace(format string, args ...interface{}) { +func (p *iexporter) trace(format string, args ...any) { if !trace { // Call sites should also be guarded, but having this check here allows // easily enabling/disabling debug trace statements. @@ -1583,6 +1583,6 @@ func (e internalError) Error() string { return "gcimporter: " + string(e) } // "internalErrorf" as the former is used for bugs, whose cause is // internal inconsistency, whereas the latter is used for ordinary // situations like bad input, whose cause is external. -func internalErrorf(format string, args ...interface{}) error { +func internalErrorf(format string, args ...any) error { return internalError(fmt.Sprintf(format, args...)) } diff --git a/tools/vendor/golang.org/x/tools/internal/gcimporter/iimport.go b/tools/vendor/golang.org/x/tools/internal/gcimporter/iimport.go index 129439271..bc6c9741e 100644 --- a/tools/vendor/golang.org/x/tools/internal/gcimporter/iimport.go +++ b/tools/vendor/golang.org/x/tools/internal/gcimporter/iimport.go @@ -400,7 +400,7 @@ type iimporter struct { indent int // for tracing support } -func (p *iimporter) trace(format string, args ...interface{}) { +func (p *iimporter) trace(format string, args ...any) { if !trace { // Call sites should also be guarded, but having this check here allows // easily enabling/disabling debug trace statements. diff --git a/tools/vendor/golang.org/x/tools/internal/gcimporter/ureader_yes.go b/tools/vendor/golang.org/x/tools/internal/gcimporter/ureader_yes.go index 522287d18..37b4a39e9 100644 --- a/tools/vendor/golang.org/x/tools/internal/gcimporter/ureader_yes.go +++ b/tools/vendor/golang.org/x/tools/internal/gcimporter/ureader_yes.go @@ -574,7 +574,7 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) { recv := types.NewVar(fn.Pos(), fn.Pkg(), "", named) typesinternal.SetVarKind(recv, typesinternal.RecvVar) - methods[i] = types.NewFunc(fn.Pos(), fn.Pkg(), fn.Name(), types.NewSignature(recv, sig.Params(), sig.Results(), sig.Variadic())) + methods[i] = types.NewFunc(fn.Pos(), fn.Pkg(), fn.Name(), types.NewSignatureType(recv, nil, nil, sig.Params(), sig.Results(), sig.Variadic())) } embeds := make([]types.Type, iface.NumEmbeddeds()) diff --git a/tools/vendor/golang.org/x/tools/internal/gopathwalk/walk.go b/tools/vendor/golang.org/x/tools/internal/gopathwalk/walk.go index 836151551..984b79c2a 100644 --- a/tools/vendor/golang.org/x/tools/internal/gopathwalk/walk.go +++ b/tools/vendor/golang.org/x/tools/internal/gopathwalk/walk.go @@ -22,7 +22,7 @@ import ( // Options controls the behavior of a Walk call. type Options struct { // If Logf is non-nil, debug logging is enabled through this function. - Logf func(format string, args ...interface{}) + Logf func(format string, args ...any) // Search module caches. Also disables legacy goimports ignore rules. ModulesEnabled bool @@ -81,7 +81,7 @@ func WalkSkip(roots []Root, add func(root Root, dir string), skip func(root Root // walkDir creates a walker and starts fastwalk with this walker. func walkDir(root Root, add func(Root, string), skip func(root Root, dir string) bool, opts Options) { if opts.Logf == nil { - opts.Logf = func(format string, args ...interface{}) {} + opts.Logf = func(format string, args ...any) {} } if _, err := os.Stat(root.Path); os.IsNotExist(err) { opts.Logf("skipping nonexistent directory: %v", root.Path) diff --git a/tools/vendor/golang.org/x/tools/internal/imports/fix.go b/tools/vendor/golang.org/x/tools/internal/imports/fix.go index bf6b0aadd..737a9bfae 100644 --- a/tools/vendor/golang.org/x/tools/internal/imports/fix.go +++ b/tools/vendor/golang.org/x/tools/internal/imports/fix.go @@ -559,7 +559,7 @@ func fixImportsDefault(fset *token.FileSet, f *ast.File, filename string, env *P return err } apply(fset, f, fixes) - return err + return nil } // getFixes gets the import fixes that need to be made to f in order to fix the imports. @@ -1030,7 +1030,7 @@ func (e *ProcessEnv) GetResolver() (Resolver, error) { // // For gopls, we can optionally explicitly choose a resolver type, since we // already know the view type. - if len(e.Env["GOMOD"]) == 0 && len(e.Env["GOWORK"]) == 0 { + if e.Env["GOMOD"] == "" && (e.Env["GOWORK"] == "" || e.Env["GOWORK"] == "off") { e.resolver = newGopathResolver(e) e.logf("created gopath resolver") } else if r, err := newModuleResolver(e, e.ModCache); err != nil { diff --git a/tools/vendor/golang.org/x/tools/internal/packagesinternal/packages.go b/tools/vendor/golang.org/x/tools/internal/packagesinternal/packages.go index 784605914..25ebab663 100644 --- a/tools/vendor/golang.org/x/tools/internal/packagesinternal/packages.go +++ b/tools/vendor/golang.org/x/tools/internal/packagesinternal/packages.go @@ -17,4 +17,4 @@ var TypecheckCgo int var DepsErrors int // must be set as a LoadMode to call GetDepsErrors var SetModFlag = func(config any, value string) {} -var SetModFile = func(config interface{}, value string) {} +var SetModFile = func(config any, value string) {} diff --git a/tools/vendor/golang.org/x/tools/internal/stdlib/deps.go b/tools/vendor/golang.org/x/tools/internal/stdlib/deps.go new file mode 100644 index 000000000..7cca431cd --- /dev/null +++ b/tools/vendor/golang.org/x/tools/internal/stdlib/deps.go @@ -0,0 +1,359 @@ +// Copyright 2025 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. + +// Code generated by generate.go. DO NOT EDIT. + +package stdlib + +type pkginfo struct { + name string + deps string // list of indices of dependencies, as varint-encoded deltas +} + +var deps = [...]pkginfo{ + {"archive/tar", "\x03k\x03E5\x01\v\x01#\x01\x01\x02\x05\t\x02\x01\x02\x02\v"}, + {"archive/zip", "\x02\x04a\a\x16\x0205\x01+\x05\x01\x10\x03\x02\r\x04"}, + {"bufio", "\x03k}E\x13"}, + {"bytes", "n+R\x03\fG\x02\x02"}, + {"cmp", ""}, + {"compress/bzip2", "\x02\x02\xe7\x01B"}, + {"compress/flate", "\x02l\x03z\r\x024\x01\x03"}, + {"compress/gzip", "\x02\x04a\a\x03\x15eT"}, + {"compress/lzw", "\x02l\x03z"}, + {"compress/zlib", "\x02\x04a\a\x03\x13\x01f"}, + {"container/heap", "\xae\x02"}, + {"container/list", ""}, + {"container/ring", ""}, + {"context", "n\\h\x01\f"}, + {"crypto", "\x84\x01gD"}, + {"crypto/aes", "\x10\n\a\x8e\x02"}, + {"crypto/cipher", "\x03\x1e\x01\x01\x1d\x11\x1d,Q"}, + {"crypto/des", "\x10\x13\x1d.,\x95\x01\x03"}, + {"crypto/dsa", "@\x04*}\x0e"}, + {"crypto/ecdh", "\x03\v\f\x0e\x04\x14\x04\r\x1d}"}, + {"crypto/ecdsa", "\x0e\x05\x03\x04\x01\x0e\x16\x01\x04\f\x01\x1d}\x0e\x04K\x01"}, + {"crypto/ed25519", "\x0e\x1c\x16\n\a\x1d}D"}, + {"crypto/elliptic", "0>}\x0e9"}, + {"crypto/fips140", " \x05\x91\x01"}, + {"crypto/hkdf", "-\x12\x01.\x16"}, + {"crypto/hmac", "\x1a\x14\x11\x01\x113"}, + {"crypto/internal/boring", "\x0e\x02\rg"}, + {"crypto/internal/boring/bbig", "\x1a\xdf\x01L"}, + {"crypto/internal/boring/bcache", "\xb3\x02\x12"}, + {"crypto/internal/boring/sig", ""}, + {"crypto/internal/cryptotest", "\x03\r\n)\x0e\x1a\x06\x13\x12#\a\t\x11\x11\x11\x1b\x01\f\f\x05\n"}, + {"crypto/internal/entropy", "E"}, + {"crypto/internal/fips140", ">0}9\f\x15"}, + {"crypto/internal/fips140/aes", "\x03\x1d\x03\x02\x13\x04\x01\x01\x05+\x8c\x015"}, + {"crypto/internal/fips140/aes/gcm", " \x01\x02\x02\x02\x11\x04\x01\x06+\x8a\x01"}, + {"crypto/internal/fips140/alias", "\xc5\x02"}, + {"crypto/internal/fips140/bigmod", "%\x17\x01\x06+\x8c\x01"}, + {"crypto/internal/fips140/check", " \x0e\x06\b\x02\xad\x01Z"}, + {"crypto/internal/fips140/check/checktest", "%\xff\x01!"}, + {"crypto/internal/fips140/drbg", "\x03\x1c\x01\x01\x04\x13\x04\b\x01)}\x0f8"}, + {"crypto/internal/fips140/ecdh", "\x03\x1d\x05\x02\t\f2}\x0f8"}, + {"crypto/internal/fips140/ecdsa", "\x03\x1d\x04\x01\x02\a\x02\x068}G"}, + {"crypto/internal/fips140/ed25519", "\x03\x1d\x05\x02\x04\v8\xc1\x01\x03"}, + {"crypto/internal/fips140/edwards25519", "%\a\f\x042\x8c\x018"}, + {"crypto/internal/fips140/edwards25519/field", "%\x13\x042\x8c\x01"}, + {"crypto/internal/fips140/hkdf", "\x03\x1d\x05\t\x06:"}, + {"crypto/internal/fips140/hmac", "\x03\x1d\x14\x01\x018"}, + {"crypto/internal/fips140/mlkem", "\x03\x1d\x05\x02\x0e\x03\x042"}, + {"crypto/internal/fips140/nistec", "%\f\a\x042\x8c\x01*\x0e\x13"}, + {"crypto/internal/fips140/nistec/fiat", "%\x136\x8c\x01"}, + {"crypto/internal/fips140/pbkdf2", "\x03\x1d\x05\t\x06:"}, + {"crypto/internal/fips140/rsa", "\x03\x1d\x04\x01\x02\r\x01\x01\x026}G"}, + {"crypto/internal/fips140/sha256", "\x03\x1d\x1c\x01\x06+\x8c\x01"}, + {"crypto/internal/fips140/sha3", "\x03\x1d\x18\x04\x011\x8c\x01K"}, + {"crypto/internal/fips140/sha512", "\x03\x1d\x1c\x01\x06+\x8c\x01"}, + {"crypto/internal/fips140/ssh", " \x05"}, + {"crypto/internal/fips140/subtle", "#\x19\xbe\x01"}, + {"crypto/internal/fips140/tls12", "\x03\x1d\x05\t\x06\x028"}, + {"crypto/internal/fips140/tls13", "\x03\x1d\x05\b\a\b2"}, + {"crypto/internal/fips140deps", ""}, + {"crypto/internal/fips140deps/byteorder", "\x9a\x01"}, + {"crypto/internal/fips140deps/cpu", "\xae\x01\a"}, + {"crypto/internal/fips140deps/godebug", "\xb6\x01"}, + {"crypto/internal/fips140hash", "5\x1a5\xc1\x01"}, + {"crypto/internal/fips140only", "'\r\x01\x01N25"}, + {"crypto/internal/fips140test", ""}, + {"crypto/internal/hpke", "\x0e\x01\x01\x03\x1a\x1d$,`M"}, + {"crypto/internal/impl", "\xb0\x02"}, + {"crypto/internal/randutil", "\xeb\x01\x12"}, + {"crypto/internal/sysrand", "\xd7\x01@\x1b\x01\f\x06"}, + {"crypto/internal/sysrand/internal/seccomp", "n"}, + {"crypto/md5", "\x0e2.\x16\x16`"}, + {"crypto/mlkem", "/"}, + {"crypto/pbkdf2", "2\r\x01.\x16"}, + {"crypto/rand", "\x1a\x06\a\x19\x04\x01)}\x0eL"}, + {"crypto/rc4", "#\x1d.\xc1\x01"}, + {"crypto/rsa", "\x0e\f\x01\t\x0f\f\x01\x04\x06\a\x1d\x03\x1325\r\x01"}, + {"crypto/sha1", "\x0e\f&.\x16\x16\x14L"}, + {"crypto/sha256", "\x0e\f\x1aP"}, + {"crypto/sha3", "\x0e'O\xc1\x01"}, + {"crypto/sha512", "\x0e\f\x1cN"}, + {"crypto/subtle", "8\x98\x01T"}, + {"crypto/tls", "\x03\b\x02\x01\x01\x01\x01\x02\x01\x01\x01\x03\x01\a\x01\v\x02\n\x01\b\x05\x03\x01\x01\x01\x01\x02\x01\x02\x01\x18\x02\x03\x13\x16\x14\b5\x16\x16\r\t\x01\x01\x01\x02\x01\f\x06\x02\x01"}, + {"crypto/tls/internal/fips140tls", " \x93\x02"}, + {"crypto/x509", "\x03\v\x01\x01\x01\x01\x01\x01\x01\x011\x03\x02\x01\x01\x02\x05\x01\x0e\x06\x02\x02\x03E5\x03\t\x01\x01\x01\a\x10\x05\t\x05\v\x01\x02\r\x02\x01\x01\x02\x03\x01"}, + {"crypto/x509/internal/macos", "\x03k'\x8f\x01\v\x10\x06"}, + {"crypto/x509/pkix", "d\x06\a\x88\x01F"}, + {"database/sql", "\x03\nK\x16\x03z\f\x06\"\x05\t\x02\x03\x01\f\x02\x02\x02"}, + {"database/sql/driver", "\ra\x03\xae\x01\x10\x10"}, + {"debug/buildinfo", "\x03X\x02\x01\x01\b\a\x03`\x18\x02\x01+\x10\x1e"}, + {"debug/dwarf", "\x03d\a\x03z1\x12\x01\x01"}, + {"debug/elf", "\x03\x06Q\r\a\x03`\x19\x01,\x18\x01\x15"}, + {"debug/gosym", "\x03d\n\xbd\x01\x01\x01\x02"}, + {"debug/macho", "\x03\x06Q\r\n`\x1a,\x18\x01"}, + {"debug/pe", "\x03\x06Q\r\a\x03`\x1a,\x18\x01\x15"}, + {"debug/plan9obj", "g\a\x03`\x1a,"}, + {"embed", "n+:\x18\x01S"}, + {"embed/internal/embedtest", ""}, + {"encoding", ""}, + {"encoding/ascii85", "\xeb\x01D"}, + {"encoding/asn1", "\x03k\x03\x87\x01\x01&\x0e\x02\x01\x0f\x03\x01"}, + {"encoding/base32", "\xeb\x01B\x02"}, + {"encoding/base64", "\x9a\x01QB\x02"}, + {"encoding/binary", "n}\r'\x0e\x05"}, + {"encoding/csv", "\x02\x01k\x03zE\x11\x02"}, + {"encoding/gob", "\x02`\x05\a\x03`\x1a\f\x01\x02\x1d\b\x13\x01\x0e\x02"}, + {"encoding/hex", "n\x03zB\x03"}, + {"encoding/json", "\x03\x01^\x04\b\x03z\r'\x0e\x02\x01\x02\x0f\x01\x01\x02"}, + {"encoding/pem", "\x03c\b}B\x03"}, + {"encoding/xml", "\x02\x01_\f\x03z4\x05\v\x01\x02\x0f\x02"}, + {"errors", "\xca\x01{"}, + {"expvar", "kK9\t\n\x15\r\t\x02\x03\x01\x10"}, + {"flag", "b\f\x03z,\b\x05\t\x02\x01\x0f"}, + {"fmt", "nE8\r\x1f\b\x0e\x02\x03\x11"}, + {"go/ast", "\x03\x01m\x0f\x01j\x03)\b\x0e\x02\x01"}, + {"go/ast/internal/tests", ""}, + {"go/build", "\x02\x01k\x03\x01\x03\x02\a\x02\x01\x17\x1e\x04\x02\t\x14\x12\x01+\x01\x04\x01\a\t\x02\x01\x11\x02\x02"}, + {"go/build/constraint", "n\xc1\x01\x01\x11\x02"}, + {"go/constant", "q\x10w\x01\x015\x01\x02\x11"}, + {"go/doc", "\x04m\x01\x06\t=-1\x11\x02\x01\x11\x02"}, + {"go/doc/comment", "\x03n\xbc\x01\x01\x01\x01\x11\x02"}, + {"go/format", "\x03n\x01\f\x01\x02jE"}, + {"go/importer", "t\a\x01\x01\x04\x01i9"}, + {"go/internal/gccgoimporter", "\x02\x01X\x13\x03\x05\v\x01g\x02,\x01\x05\x12\x01\v\b"}, + {"go/internal/gcimporter", "\x02o\x10\x01/\x05\x0e',\x16\x03\x02"}, + {"go/internal/srcimporter", "q\x01\x02\n\x03\x01i,\x01\x05\x13\x02\x13"}, + {"go/parser", "\x03k\x03\x01\x03\v\x01j\x01+\x06\x13"}, + {"go/printer", "q\x01\x03\x03\tj\r\x1f\x16\x02\x01\x02\n\x05\x02"}, + {"go/scanner", "\x03n\x10j2\x11\x01\x12\x02"}, + {"go/token", "\x04m\xbc\x01\x02\x03\x01\x0e\x02"}, + {"go/types", "\x03\x01\x06d\x03\x01\x04\b\x03\x02\x15\x1e\x06+\x04\x03\n%\a\t\x01\x01\x01\x02\x01\x0e\x02\x02"}, + {"go/version", "\xbb\x01u"}, + {"hash", "\xeb\x01"}, + {"hash/adler32", "n\x16\x16"}, + {"hash/crc32", "n\x16\x16\x14\x84\x01\x01"}, + {"hash/crc64", "n\x16\x16\x98\x01"}, + {"hash/fnv", "n\x16\x16`"}, + {"hash/maphash", "\x95\x01\x05\x1b\x03@M"}, + {"html", "\xb0\x02\x02\x11"}, + {"html/template", "\x03h\x06\x19,5\x01\v \x05\x01\x02\x03\r\x01\x02\v\x01\x03\x02"}, + {"image", "\x02l\x1f^\x0f5\x03\x01"}, + {"image/color", ""}, + {"image/color/palette", "\x8d\x01"}, + {"image/draw", "\x8c\x01\x01\x04"}, + {"image/gif", "\x02\x01\x05f\x03\x1b\x01\x01\x01\vQ"}, + {"image/internal/imageutil", "\x8c\x01"}, + {"image/jpeg", "\x02l\x1e\x01\x04Z"}, + {"image/png", "\x02\a^\n\x13\x02\x06\x01^D"}, + {"index/suffixarray", "\x03d\a}\r*\v\x01"}, + {"internal/abi", "\xb5\x01\x90\x01"}, + {"internal/asan", "\xc5\x02"}, + {"internal/bisect", "\xa4\x02\x0e\x01"}, + {"internal/buildcfg", "qG_\x06\x02\x05\v\x01"}, + {"internal/bytealg", "\xae\x01\x97\x01"}, + {"internal/byteorder", ""}, + {"internal/cfg", ""}, + {"internal/chacha8rand", "\x9a\x01\x1b\x90\x01"}, + {"internal/copyright", ""}, + {"internal/coverage", ""}, + {"internal/coverage/calloc", ""}, + {"internal/coverage/cfile", "k\x06\x17\x16\x01\x02\x01\x01\x01\x01\x01\x01\x01$\x01\x1e,\x06\a\v\x01\x03\f\x06"}, + {"internal/coverage/cformat", "\x04m-\x04I\f6\x01\x02\f"}, + {"internal/coverage/cmerge", "q-Z"}, + {"internal/coverage/decodecounter", "g\n-\v\x02@,\x18\x16"}, + {"internal/coverage/decodemeta", "\x02e\n\x17\x16\v\x02@,"}, + {"internal/coverage/encodecounter", "\x02e\n-\f\x01\x02>\f \x16"}, + {"internal/coverage/encodemeta", "\x02\x01d\n\x13\x04\x16\r\x02>,."}, + {"internal/coverage/pods", "\x04m-y\x06\x05\v\x02\x01"}, + {"internal/coverage/rtcov", "\xc5\x02"}, + {"internal/coverage/slicereader", "g\nzZ"}, + {"internal/coverage/slicewriter", "qz"}, + {"internal/coverage/stringtab", "q8\x04>"}, + {"internal/coverage/test", ""}, + {"internal/coverage/uleb128", ""}, + {"internal/cpu", "\xc5\x02"}, + {"internal/dag", "\x04m\xbc\x01\x03"}, + {"internal/diff", "\x03n\xbd\x01\x02"}, + {"internal/exportdata", "\x02\x01k\x03\x03]\x1a,\x01\x05\x12\x01\x02"}, + {"internal/filepathlite", "n+:\x19A"}, + {"internal/fmtsort", "\x04\x9b\x02\x0e"}, + {"internal/fuzz", "\x03\nA\x19\x04\x03\x03\x01\f\x0355\r\x02\x1d\x01\x05\x02\x05\v\x01\x02\x01\x01\v\x04\x02"}, + {"internal/goarch", ""}, + {"internal/godebug", "\x97\x01 {\x01\x12"}, + {"internal/godebugs", ""}, + {"internal/goexperiment", ""}, + {"internal/goos", ""}, + {"internal/goroot", "\x97\x02\x01\x05\x13\x02"}, + {"internal/gover", "\x04"}, + {"internal/goversion", ""}, + {"internal/itoa", ""}, + {"internal/lazyregexp", "\x97\x02\v\x0e\x02"}, + {"internal/lazytemplate", "\xeb\x01,\x19\x02\v"}, + {"internal/msan", "\xc5\x02"}, + {"internal/nettrace", ""}, + {"internal/obscuretestdata", "f\x85\x01,"}, + {"internal/oserror", "n"}, + {"internal/pkgbits", "\x03K\x19\a\x03\x05\vj\x0e\x1e\r\v\x01"}, + {"internal/platform", ""}, + {"internal/poll", "nO\x1a\x149\x0e\x01\x01\v\x06"}, + {"internal/profile", "\x03\x04g\x03z7\f\x01\x01\x0f"}, + {"internal/profilerecord", ""}, + {"internal/race", "\x95\x01\xb0\x01"}, + {"internal/reflectlite", "\x95\x01 3\x01P\x0e\x13\x12"}, + {"unsafe", ""}, + {"vendor/golang.org/x/crypto/chacha20", "\x10W\a\x8c\x01*&"}, + {"vendor/golang.org/x/crypto/chacha20poly1305", "\x10W\a\xd8\x01\x04\x01"}, + {"vendor/golang.org/x/crypto/cryptobyte", "d\n\x03\x88\x01& \n"}, + {"vendor/golang.org/x/crypto/cryptobyte/asn1", ""}, + {"vendor/golang.org/x/crypto/internal/alias", "\xc5\x02"}, + {"vendor/golang.org/x/crypto/internal/poly1305", "Q\x16\x93\x01"}, + {"vendor/golang.org/x/net/dns/dnsmessage", "n"}, + {"vendor/golang.org/x/net/http/httpguts", "\x81\x02\x14\x1b\x13\r"}, + {"vendor/golang.org/x/net/http/httpproxy", "n\x03\x90\x01\x15\x01\x19\x13\r"}, + {"vendor/golang.org/x/net/http2/hpack", "\x03k\x03zG"}, + {"vendor/golang.org/x/net/idna", "q\x87\x018\x13\x10\x02\x01"}, + {"vendor/golang.org/x/net/nettest", "\x03d\a\x03z\x11\x05\x16\x01\f\v\x01\x02\x02\x01\n"}, + {"vendor/golang.org/x/sys/cpu", "\x97\x02\r\v\x01\x15"}, + {"vendor/golang.org/x/text/secure/bidirule", "n\xd5\x01\x11\x01"}, + {"vendor/golang.org/x/text/transform", "\x03k}X"}, + {"vendor/golang.org/x/text/unicode/bidi", "\x03\bf~?\x15"}, + {"vendor/golang.org/x/text/unicode/norm", "g\nzG\x11\x11"}, + {"weak", "\x95\x01\x8f\x01!"}, +} diff --git a/tools/vendor/golang.org/x/tools/internal/stdlib/import.go b/tools/vendor/golang.org/x/tools/internal/stdlib/import.go new file mode 100644 index 000000000..f6909878a --- /dev/null +++ b/tools/vendor/golang.org/x/tools/internal/stdlib/import.go @@ -0,0 +1,89 @@ +// Copyright 2025 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 stdlib + +// This file provides the API for the import graph of the standard library. +// +// Be aware that the compiler-generated code for every package +// implicitly depends on package "runtime" and a handful of others +// (see runtimePkgs in GOROOT/src/cmd/internal/objabi/pkgspecial.go). + +import ( + "encoding/binary" + "iter" + "slices" + "strings" +) + +// Imports returns the sequence of packages directly imported by the +// named standard packages, in name order. +// The imports of an unknown package are the empty set. +// +// The graph is built into the application and may differ from the +// graph in the Go source tree being analyzed by the application. +func Imports(pkgs ...string) iter.Seq[string] { + return func(yield func(string) bool) { + for _, pkg := range pkgs { + if i, ok := find(pkg); ok { + var depIndex uint64 + for data := []byte(deps[i].deps); len(data) > 0; { + delta, n := binary.Uvarint(data) + depIndex += delta + if !yield(deps[depIndex].name) { + return + } + data = data[n:] + } + } + } + } +} + +// Dependencies returns the set of all dependencies of the named +// standard packages, including the initial package, +// in a deterministic topological order. +// The dependencies of an unknown package are the empty set. +// +// The graph is built into the application and may differ from the +// graph in the Go source tree being analyzed by the application. +func Dependencies(pkgs ...string) iter.Seq[string] { + return func(yield func(string) bool) { + for _, pkg := range pkgs { + if i, ok := find(pkg); ok { + var seen [1 + len(deps)/8]byte // bit set of seen packages + var visit func(i int) bool + visit = func(i int) bool { + bit := byte(1) << (i % 8) + if seen[i/8]&bit == 0 { + seen[i/8] |= bit + var depIndex uint64 + for data := []byte(deps[i].deps); len(data) > 0; { + delta, n := binary.Uvarint(data) + depIndex += delta + if !visit(int(depIndex)) { + return false + } + data = data[n:] + } + if !yield(deps[i].name) { + return false + } + } + return true + } + if !visit(i) { + return + } + } + } + } +} + +// find returns the index of pkg in the deps table. +func find(pkg string) (int, bool) { + return slices.BinarySearchFunc(deps[:], pkg, func(p pkginfo, n string) int { + return strings.Compare(p.name, n) + }) +} diff --git a/tools/vendor/golang.org/x/tools/internal/stdlib/manifest.go b/tools/vendor/golang.org/x/tools/internal/stdlib/manifest.go index 9f0b871ff..00776a31b 100644 --- a/tools/vendor/golang.org/x/tools/internal/stdlib/manifest.go +++ b/tools/vendor/golang.org/x/tools/internal/stdlib/manifest.go @@ -1,4 +1,4 @@ -// Copyright 2024 The Go Authors. All rights reserved. +// Copyright 2025 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. @@ -2151,6 +2151,8 @@ var PackageSymbols = map[string][]Symbol{ {"(Type).String", Method, 0}, {"(Version).GoString", Method, 0}, {"(Version).String", Method, 0}, + {"(VersionIndex).Index", Method, 24}, + {"(VersionIndex).IsHidden", Method, 24}, {"ARM_MAGIC_TRAMP_NUMBER", Const, 0}, {"COMPRESS_HIOS", Const, 6}, {"COMPRESS_HIPROC", Const, 6}, @@ -3834,6 +3836,7 @@ var PackageSymbols = map[string][]Symbol{ {"SymType", Type, 0}, {"SymVis", Type, 0}, {"Symbol", Type, 0}, + {"Symbol.HasVersion", Field, 24}, {"Symbol.Info", Field, 0}, {"Symbol.Library", Field, 13}, {"Symbol.Name", Field, 0}, @@ -3843,18 +3846,12 @@ var PackageSymbols = map[string][]Symbol{ {"Symbol.Value", Field, 0}, {"Symbol.Version", Field, 13}, {"Symbol.VersionIndex", Field, 24}, - {"Symbol.VersionScope", Field, 24}, - {"SymbolVersionScope", Type, 24}, {"Type", Type, 0}, {"VER_FLG_BASE", Const, 24}, {"VER_FLG_INFO", Const, 24}, {"VER_FLG_WEAK", Const, 24}, {"Version", Type, 0}, - {"VersionScopeGlobal", Const, 24}, - {"VersionScopeHidden", Const, 24}, - {"VersionScopeLocal", Const, 24}, - {"VersionScopeNone", Const, 24}, - {"VersionScopeSpecific", Const, 24}, + {"VersionIndex", Type, 24}, }, "debug/gosym": { {"(*DecodingError).Error", Method, 0}, @@ -7122,6 +7119,7 @@ var PackageSymbols = map[string][]Symbol{ {"FormatFileInfo", Func, 21}, {"Glob", Func, 16}, {"GlobFS", Type, 16}, + {"Lstat", Func, 25}, {"ModeAppend", Const, 16}, {"ModeCharDevice", Const, 16}, {"ModeDevice", Const, 16}, @@ -7146,6 +7144,8 @@ var PackageSymbols = map[string][]Symbol{ {"ReadDirFile", Type, 16}, {"ReadFile", Func, 16}, {"ReadFileFS", Type, 16}, + {"ReadLink", Func, 25}, + {"ReadLinkFS", Type, 25}, {"SkipAll", Var, 20}, {"SkipDir", Var, 16}, {"Stat", Func, 16}, @@ -9149,6 +9149,8 @@ var PackageSymbols = map[string][]Symbol{ {"(*ProcessState).SysUsage", Method, 0}, {"(*ProcessState).SystemTime", Method, 0}, {"(*ProcessState).UserTime", Method, 0}, + {"(*Root).Chmod", Method, 25}, + {"(*Root).Chown", Method, 25}, {"(*Root).Close", Method, 24}, {"(*Root).Create", Method, 24}, {"(*Root).FS", Method, 24}, @@ -16757,9 +16759,11 @@ var PackageSymbols = map[string][]Symbol{ }, "testing/fstest": { {"(MapFS).Glob", Method, 16}, + {"(MapFS).Lstat", Method, 25}, {"(MapFS).Open", Method, 16}, {"(MapFS).ReadDir", Method, 16}, {"(MapFS).ReadFile", Method, 16}, + {"(MapFS).ReadLink", Method, 25}, {"(MapFS).Stat", Method, 16}, {"(MapFS).Sub", Method, 16}, {"MapFS", Type, 16}, diff --git a/tools/vendor/golang.org/x/tools/internal/stdlib/stdlib.go b/tools/vendor/golang.org/x/tools/internal/stdlib/stdlib.go index 98904017f..3d96d3bf6 100644 --- a/tools/vendor/golang.org/x/tools/internal/stdlib/stdlib.go +++ b/tools/vendor/golang.org/x/tools/internal/stdlib/stdlib.go @@ -6,7 +6,7 @@ // Package stdlib provides a table of all exported symbols in the // standard library, along with the version at which they first -// appeared. +// appeared. It also provides the import graph of std packages. package stdlib import ( diff --git a/tools/vendor/golang.org/x/tools/internal/typeparams/normalize.go b/tools/vendor/golang.org/x/tools/internal/typeparams/normalize.go index 93c80fdc9..f49802b8e 100644 --- a/tools/vendor/golang.org/x/tools/internal/typeparams/normalize.go +++ b/tools/vendor/golang.org/x/tools/internal/typeparams/normalize.go @@ -120,7 +120,7 @@ type termSet struct { terms termlist } -func indentf(depth int, format string, args ...interface{}) { +func indentf(depth int, format string, args ...any) { fmt.Fprintf(os.Stderr, strings.Repeat(".", depth)+format+"\n", args...) } diff --git a/tools/vendor/golang.org/x/tools/internal/typesinternal/types.go b/tools/vendor/golang.org/x/tools/internal/typesinternal/types.go index 345348796..edf0347ec 100644 --- a/tools/vendor/golang.org/x/tools/internal/typesinternal/types.go +++ b/tools/vendor/golang.org/x/tools/internal/typesinternal/types.go @@ -32,12 +32,14 @@ func SetUsesCgo(conf *types.Config) bool { return true } -// ReadGo116ErrorData extracts additional information from types.Error values +// ErrorCodeStartEnd extracts additional information from types.Error values // generated by Go version 1.16 and later: the error code, start position, and // end position. If all positions are valid, start <= err.Pos <= end. // // If the data could not be read, the final result parameter will be false. -func ReadGo116ErrorData(err types.Error) (code ErrorCode, start, end token.Pos, ok bool) { +// +// TODO(adonovan): eliminate start/end when proposal #71803 is accepted. +func ErrorCodeStartEnd(err types.Error) (code ErrorCode, start, end token.Pos, ok bool) { var data [3]int // By coincidence all of these fields are ints, which simplifies things. v := reflect.ValueOf(err) diff --git a/tools/vendor/modules.txt b/tools/vendor/modules.txt index b124be6ac..820cdbe0d 100644 --- a/tools/vendor/modules.txt +++ b/tools/vendor/modules.txt @@ -43,8 +43,8 @@ github.com/GaijinEntertainment/go-exhaustruct/v3/internal/structure # github.com/Masterminds/semver/v3 v3.3.0 ## explicit; go 1.21 github.com/Masterminds/semver/v3 -# github.com/OpenPeeDeeP/depguard/v2 v2.2.0 -## explicit; go 1.20 +# github.com/OpenPeeDeeP/depguard/v2 v2.2.1 +## explicit; go 1.23.0 github.com/OpenPeeDeeP/depguard/v2 github.com/OpenPeeDeeP/depguard/v2/internal/utils # github.com/alecthomas/go-check-sumtype v0.3.1 @@ -219,10 +219,10 @@ github.com/golang/protobuf/ptypes github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes/duration github.com/golang/protobuf/ptypes/timestamp -# github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a -## explicit -github.com/golangci/dupl +# github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 +## explicit; go 1.22.0 github.com/golangci/dupl/job +github.com/golangci/dupl/lib github.com/golangci/dupl/printer github.com/golangci/dupl/suffixtree github.com/golangci/dupl/syntax @@ -233,7 +233,11 @@ github.com/golangci/go-printf-func-name/pkg/analyzer # github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d ## explicit; go 1.22.0 github.com/golangci/gofmt/gofmt +<<<<<<< HEAD # github.com/golangci/golangci-lint v1.64.5 +======= +# github.com/golangci/golangci-lint v1.64.8 +>>>>>>> 916eb401 (chore(deps): update module golang.org/x/net to v0.36.0 [security]) ## explicit; go 1.23.0 github.com/golangci/golangci-lint/cmd/golangci-lint github.com/golangci/golangci-lint/internal/cache @@ -681,8 +685,8 @@ github.com/sashamelentyev/interfacebloat/pkg/analyzer ## explicit; go 1.20 github.com/sashamelentyev/usestdlibvars/pkg/analyzer github.com/sashamelentyev/usestdlibvars/pkg/analyzer/internal/mapping -# github.com/securego/gosec/v2 v2.22.1 -## explicit; go 1.22.7 +# github.com/securego/gosec/v2 v2.22.2 +## explicit; go 1.23.0 github.com/securego/gosec/v2 github.com/securego/gosec/v2/analyzers github.com/securego/gosec/v2/cwe @@ -836,18 +840,18 @@ go.uber.org/zap/zapcore # golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac ## explicit; go 1.18 golang.org/x/exp/typeparams -# golang.org/x/mod v0.23.0 -## explicit; go 1.22.0 +# golang.org/x/mod v0.24.0 +## explicit; go 1.23.0 golang.org/x/mod/internal/lazyregexp golang.org/x/mod/modfile golang.org/x/mod/module golang.org/x/mod/semver -# golang.org/x/sync v0.11.0 -## explicit; go 1.18 +# golang.org/x/sync v0.12.0 +## explicit; go 1.23.0 golang.org/x/sync/errgroup golang.org/x/sync/semaphore -# golang.org/x/sys v0.30.0 -## explicit; go 1.18 +# golang.org/x/sys v0.31.0 +## explicit; go 1.23.0 golang.org/x/sys/unix golang.org/x/sys/windows # golang.org/x/text v0.22.0 @@ -868,8 +872,8 @@ golang.org/x/text/runes golang.org/x/text/transform golang.org/x/text/unicode/norm golang.org/x/text/width -# golang.org/x/tools v0.30.0 -## explicit; go 1.22.0 +# golang.org/x/tools v0.31.0 +## explicit; go 1.23.0 golang.org/x/tools/go/analysis golang.org/x/tools/go/analysis/passes/appends golang.org/x/tools/go/analysis/passes/asmdecl @@ -996,7 +1000,7 @@ gopkg.in/yaml.v2 # gopkg.in/yaml.v3 v3.0.1 ## explicit gopkg.in/yaml.v3 -# honnef.co/go/tools v0.6.0 +# honnef.co/go/tools v0.6.1 ## explicit; go 1.23 honnef.co/go/tools/analysis/callcheck honnef.co/go/tools/analysis/code diff --git a/vendor/go.uber.org/atomic/CHANGELOG.md b/vendor/go.uber.org/atomic/CHANGELOG.md index 5fe03f21b..6f87f33fa 100644 --- a/vendor/go.uber.org/atomic/CHANGELOG.md +++ b/vendor/go.uber.org/atomic/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.11.0] - 2023-05-02 +### Fixed +- Fix initialization of `Value` wrappers. + +### Added +- Add `String` method to `atomic.Pointer[T]` type allowing users to safely print +underlying values of pointers. + +[1.11.0]: https://github.com/uber-go/atomic/compare/v1.10.0...v1.11.0 + ## [1.10.0] - 2022-08-11 ### Added - Add `atomic.Float32` type for atomic operations on `float32`. diff --git a/vendor/go.uber.org/atomic/bool.go b/vendor/go.uber.org/atomic/bool.go index dfa2085f4..f0a2ddd14 100644 --- a/vendor/go.uber.org/atomic/bool.go +++ b/vendor/go.uber.org/atomic/bool.go @@ -1,6 +1,6 @@ // @generated Code generated by gen-atomicwrapper. -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/go.uber.org/atomic/duration.go b/vendor/go.uber.org/atomic/duration.go index 6f4157445..7c23868fc 100644 --- a/vendor/go.uber.org/atomic/duration.go +++ b/vendor/go.uber.org/atomic/duration.go @@ -1,6 +1,6 @@ // @generated Code generated by gen-atomicwrapper. -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/go.uber.org/atomic/error.go b/vendor/go.uber.org/atomic/error.go index 27b23ea16..b7e3f1291 100644 --- a/vendor/go.uber.org/atomic/error.go +++ b/vendor/go.uber.org/atomic/error.go @@ -1,6 +1,6 @@ // @generated Code generated by gen-atomicwrapper. -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -52,7 +52,17 @@ func (x *Error) Store(val error) { // CompareAndSwap is an atomic compare-and-swap for error values. func (x *Error) CompareAndSwap(old, new error) (swapped bool) { - return x.v.CompareAndSwap(packError(old), packError(new)) + if x.v.CompareAndSwap(packError(old), packError(new)) { + return true + } + + if old == _zeroError { + // If the old value is the empty value, then it's possible the + // underlying Value hasn't been set and is nil, so retry with nil. + return x.v.CompareAndSwap(nil, packError(new)) + } + + return false } // Swap atomically stores the given error and returns the old diff --git a/vendor/go.uber.org/atomic/float32.go b/vendor/go.uber.org/atomic/float32.go index 5d535a6d2..62c36334f 100644 --- a/vendor/go.uber.org/atomic/float32.go +++ b/vendor/go.uber.org/atomic/float32.go @@ -1,6 +1,6 @@ // @generated Code generated by gen-atomicwrapper. -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/go.uber.org/atomic/float64.go b/vendor/go.uber.org/atomic/float64.go index 11d5189a5..5bc11caab 100644 --- a/vendor/go.uber.org/atomic/float64.go +++ b/vendor/go.uber.org/atomic/float64.go @@ -1,6 +1,6 @@ // @generated Code generated by gen-atomicwrapper. -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/go.uber.org/atomic/int32.go b/vendor/go.uber.org/atomic/int32.go index b9a68f42c..5320eac10 100644 --- a/vendor/go.uber.org/atomic/int32.go +++ b/vendor/go.uber.org/atomic/int32.go @@ -1,6 +1,6 @@ // @generated Code generated by gen-atomicint. -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/go.uber.org/atomic/int64.go b/vendor/go.uber.org/atomic/int64.go index 78d260976..460821d00 100644 --- a/vendor/go.uber.org/atomic/int64.go +++ b/vendor/go.uber.org/atomic/int64.go @@ -1,6 +1,6 @@ // @generated Code generated by gen-atomicint. -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/go.uber.org/atomic/pointer_go118.go b/vendor/go.uber.org/atomic/pointer_go118.go index e0f47dba4..1fb6c03b2 100644 --- a/vendor/go.uber.org/atomic/pointer_go118.go +++ b/vendor/go.uber.org/atomic/pointer_go118.go @@ -18,43 +18,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -//go:build go1.18 && !go1.19 -// +build go1.18,!go1.19 +//go:build go1.18 +// +build go1.18 package atomic -import "unsafe" +import "fmt" -type Pointer[T any] struct { - _ nocmp // disallow non-atomic comparison - p UnsafePointer -} - -// NewPointer creates a new Pointer. -func NewPointer[T any](v *T) *Pointer[T] { - var p Pointer[T] - if v != nil { - p.p.Store(unsafe.Pointer(v)) - } - return &p -} - -// Load atomically loads the wrapped value. -func (p *Pointer[T]) Load() *T { - return (*T)(p.p.Load()) -} - -// Store atomically stores the passed value. -func (p *Pointer[T]) Store(val *T) { - p.p.Store(unsafe.Pointer(val)) -} - -// Swap atomically swaps the wrapped pointer and returns the old value. -func (p *Pointer[T]) Swap(val *T) (old *T) { - return (*T)(p.p.Swap(unsafe.Pointer(val))) -} - -// CompareAndSwap is an atomic compare-and-swap. -func (p *Pointer[T]) CompareAndSwap(old, new *T) (swapped bool) { - return p.p.CompareAndSwap(unsafe.Pointer(old), unsafe.Pointer(new)) +// String returns a human readable representation of a Pointer's underlying value. +func (p *Pointer[T]) String() string { + return fmt.Sprint(p.Load()) } diff --git a/vendor/go.uber.org/atomic/pointer_go118_pre119.go b/vendor/go.uber.org/atomic/pointer_go118_pre119.go new file mode 100644 index 000000000..e0f47dba4 --- /dev/null +++ b/vendor/go.uber.org/atomic/pointer_go118_pre119.go @@ -0,0 +1,60 @@ +// Copyright (c) 2022 Uber Technologies, Inc. +// +// 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. + +//go:build go1.18 && !go1.19 +// +build go1.18,!go1.19 + +package atomic + +import "unsafe" + +type Pointer[T any] struct { + _ nocmp // disallow non-atomic comparison + p UnsafePointer +} + +// NewPointer creates a new Pointer. +func NewPointer[T any](v *T) *Pointer[T] { + var p Pointer[T] + if v != nil { + p.p.Store(unsafe.Pointer(v)) + } + return &p +} + +// Load atomically loads the wrapped value. +func (p *Pointer[T]) Load() *T { + return (*T)(p.p.Load()) +} + +// Store atomically stores the passed value. +func (p *Pointer[T]) Store(val *T) { + p.p.Store(unsafe.Pointer(val)) +} + +// Swap atomically swaps the wrapped pointer and returns the old value. +func (p *Pointer[T]) Swap(val *T) (old *T) { + return (*T)(p.p.Swap(unsafe.Pointer(val))) +} + +// CompareAndSwap is an atomic compare-and-swap. +func (p *Pointer[T]) CompareAndSwap(old, new *T) (swapped bool) { + return p.p.CompareAndSwap(unsafe.Pointer(old), unsafe.Pointer(new)) +} diff --git a/vendor/go.uber.org/atomic/string.go b/vendor/go.uber.org/atomic/string.go index c4bea70f4..061466c5b 100644 --- a/vendor/go.uber.org/atomic/string.go +++ b/vendor/go.uber.org/atomic/string.go @@ -1,6 +1,6 @@ // @generated Code generated by gen-atomicwrapper. -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -42,24 +42,31 @@ func NewString(val string) *String { // Load atomically loads the wrapped string. func (x *String) Load() string { - if v := x.v.Load(); v != nil { - return v.(string) - } - return _zeroString + return unpackString(x.v.Load()) } // Store atomically stores the passed string. func (x *String) Store(val string) { - x.v.Store(val) + x.v.Store(packString(val)) } // CompareAndSwap is an atomic compare-and-swap for string values. func (x *String) CompareAndSwap(old, new string) (swapped bool) { - return x.v.CompareAndSwap(old, new) + if x.v.CompareAndSwap(packString(old), packString(new)) { + return true + } + + if old == _zeroString { + // If the old value is the empty value, then it's possible the + // underlying Value hasn't been set and is nil, so retry with nil. + return x.v.CompareAndSwap(nil, packString(new)) + } + + return false } // Swap atomically stores the given string and returns the old // value. func (x *String) Swap(val string) (old string) { - return x.v.Swap(val).(string) + return unpackString(x.v.Swap(packString(val))) } diff --git a/vendor/go.uber.org/atomic/string_ext.go b/vendor/go.uber.org/atomic/string_ext.go index 1f63dfd5b..019109c86 100644 --- a/vendor/go.uber.org/atomic/string_ext.go +++ b/vendor/go.uber.org/atomic/string_ext.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,18 @@ package atomic -//go:generate bin/gen-atomicwrapper -name=String -type=string -wrapped=Value -compareandswap -swap -file=string.go +//go:generate bin/gen-atomicwrapper -name=String -type=string -wrapped Value -pack packString -unpack unpackString -compareandswap -swap -file=string.go + +func packString(s string) interface{} { + return s +} + +func unpackString(v interface{}) string { + if s, ok := v.(string); ok { + return s + } + return "" +} // String returns the wrapped value. func (s *String) String() string { diff --git a/vendor/go.uber.org/atomic/time.go b/vendor/go.uber.org/atomic/time.go index 1660feb14..cc2a230c0 100644 --- a/vendor/go.uber.org/atomic/time.go +++ b/vendor/go.uber.org/atomic/time.go @@ -1,6 +1,6 @@ // @generated Code generated by gen-atomicwrapper. -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/go.uber.org/atomic/uint32.go b/vendor/go.uber.org/atomic/uint32.go index d6f04a96d..4adc294ac 100644 --- a/vendor/go.uber.org/atomic/uint32.go +++ b/vendor/go.uber.org/atomic/uint32.go @@ -1,6 +1,6 @@ // @generated Code generated by gen-atomicint. -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/go.uber.org/atomic/uint64.go b/vendor/go.uber.org/atomic/uint64.go index 2574bdd5e..0e2eddb30 100644 --- a/vendor/go.uber.org/atomic/uint64.go +++ b/vendor/go.uber.org/atomic/uint64.go @@ -1,6 +1,6 @@ // @generated Code generated by gen-atomicint. -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/go.uber.org/atomic/uintptr.go b/vendor/go.uber.org/atomic/uintptr.go index 81b275a7a..7d5b000d6 100644 --- a/vendor/go.uber.org/atomic/uintptr.go +++ b/vendor/go.uber.org/atomic/uintptr.go @@ -1,6 +1,6 @@ // @generated Code generated by gen-atomicint. -// Copyright (c) 2020-2022 Uber Technologies, Inc. +// Copyright (c) 2020-2023 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/golang.org/x/crypto/ssh/handshake.go b/vendor/golang.org/x/crypto/ssh/handshake.go index fef687db0..c9202b05d 100644 --- a/vendor/golang.org/x/crypto/ssh/handshake.go +++ b/vendor/golang.org/x/crypto/ssh/handshake.go @@ -25,6 +25,11 @@ const debugHandshake = false // quickly. const chanSize = 16 +// maxPendingPackets sets the maximum number of packets to queue while waiting +// for KEX to complete. This limits the total pending data to maxPendingPackets +// * maxPacket bytes, which is ~16.8MB. +const maxPendingPackets = 64 + // keyingTransport is a packet based transport that supports key // changes. It need not be thread-safe. It should pass through // msgNewKeys in both directions. @@ -73,11 +78,19 @@ type handshakeTransport struct { incoming chan []byte readError error - mu sync.Mutex - writeError error - sentInitPacket []byte - sentInitMsg *kexInitMsg - pendingPackets [][]byte // Used when a key exchange is in progress. + mu sync.Mutex + // Condition for the above mutex. It is used to notify a completed key + // exchange or a write failure. Writes can wait for this condition while a + // key exchange is in progress. + writeCond *sync.Cond + writeError error + sentInitPacket []byte + sentInitMsg *kexInitMsg + // Used to queue writes when a key exchange is in progress. The length is + // limited by pendingPacketsSize. Once full, writes will block until the key + // exchange is completed or an error occurs. If not empty, it is emptied + // all at once when the key exchange is completed in kexLoop. + pendingPackets [][]byte writePacketsLeft uint32 writeBytesLeft int64 userAuthComplete bool // whether the user authentication phase is complete @@ -134,6 +147,7 @@ func newHandshakeTransport(conn keyingTransport, config *Config, clientVersion, config: config, } + t.writeCond = sync.NewCond(&t.mu) t.resetReadThresholds() t.resetWriteThresholds() @@ -260,6 +274,7 @@ func (t *handshakeTransport) recordWriteError(err error) { defer t.mu.Unlock() if t.writeError == nil && err != nil { t.writeError = err + t.writeCond.Broadcast() } } @@ -363,6 +378,8 @@ write: } } t.pendingPackets = t.pendingPackets[:0] + // Unblock writePacket if waiting for KEX. + t.writeCond.Broadcast() t.mu.Unlock() } @@ -577,11 +594,20 @@ func (t *handshakeTransport) writePacket(p []byte) error { } if t.sentInitMsg != nil { - // Copy the packet so the writer can reuse the buffer. - cp := make([]byte, len(p)) - copy(cp, p) - t.pendingPackets = append(t.pendingPackets, cp) - return nil + if len(t.pendingPackets) < maxPendingPackets { + // Copy the packet so the writer can reuse the buffer. + cp := make([]byte, len(p)) + copy(cp, p) + t.pendingPackets = append(t.pendingPackets, cp) + return nil + } + for t.sentInitMsg != nil { + // Block and wait for KEX to complete or an error. + t.writeCond.Wait() + if t.writeError != nil { + return t.writeError + } + } } if t.writeBytesLeft > 0 { @@ -598,6 +624,7 @@ func (t *handshakeTransport) writePacket(p []byte) error { if err := t.pushPacket(p); err != nil { t.writeError = err + t.writeCond.Broadcast() } return nil diff --git a/vendor/golang.org/x/net/context/context.go b/vendor/golang.org/x/net/context/context.go index cf66309c4..db1c95fab 100644 --- a/vendor/golang.org/x/net/context/context.go +++ b/vendor/golang.org/x/net/context/context.go @@ -3,29 +3,31 @@ // license that can be found in the LICENSE file. // Package context defines the Context type, which carries deadlines, -// cancelation signals, and other request-scoped values across API boundaries +// cancellation signals, and other request-scoped values across API boundaries // and between processes. // As of Go 1.7 this package is available in the standard library under the -// name context. https://golang.org/pkg/context. +// name [context], and migrating to it can be done automatically with [go fix]. // -// Incoming requests to a server should create a Context, and outgoing calls to -// servers should accept a Context. The chain of function calls between must -// propagate the Context, optionally replacing it with a modified copy created -// using WithDeadline, WithTimeout, WithCancel, or WithValue. +// Incoming requests to a server should create a [Context], and outgoing +// calls to servers should accept a Context. The chain of function +// calls between them must propagate the Context, optionally replacing +// it with a derived Context created using [WithCancel], [WithDeadline], +// [WithTimeout], or [WithValue]. // // Programs that use Contexts should follow these rules to keep interfaces // consistent across packages and enable static analysis tools to check context // propagation: // // Do not store Contexts inside a struct type; instead, pass a Context -// explicitly to each function that needs it. The Context should be the first +// explicitly to each function that needs it. This is discussed further in +// https://go.dev/blog/context-and-structs. The Context should be the first // parameter, typically named ctx: // // func DoSomething(ctx context.Context, arg Arg) error { // // ... use ctx ... // } // -// Do not pass a nil Context, even if a function permits it. Pass context.TODO +// Do not pass a nil [Context], even if a function permits it. Pass [context.TODO] // if you are unsure about which Context to use. // // Use context Values only for request-scoped data that transits processes and @@ -34,9 +36,30 @@ // The same Context may be passed to functions running in different goroutines; // Contexts are safe for simultaneous use by multiple goroutines. // -// See http://blog.golang.org/context for example code for a server that uses +// See https://go.dev/blog/context for example code for a server that uses // Contexts. -package context // import "golang.org/x/net/context" +// +// [go fix]: https://go.dev/cmd/go#hdr-Update_packages_to_use_new_APIs +package context + +import ( + "context" // standard library's context, as of Go 1.7 + "time" +) + +// A Context carries a deadline, a cancellation signal, and other values across +// API boundaries. +// +// Context's methods may be called by multiple goroutines simultaneously. +type Context = context.Context + +// Canceled is the error returned by [Context.Err] when the context is canceled +// for some reason other than its deadline passing. +var Canceled = context.Canceled + +// DeadlineExceeded is the error returned by [Context.Err] when the context is canceled +// due to its deadline passing. +var DeadlineExceeded = context.DeadlineExceeded // Background returns a non-nil, empty Context. It is never canceled, has no // values, and has no deadline. It is typically used by the main function, @@ -49,8 +72,73 @@ func Background() Context { // TODO returns a non-nil, empty Context. Code should use context.TODO when // it's unclear which Context to use or it is not yet available (because the // surrounding function has not yet been extended to accept a Context -// parameter). TODO is recognized by static analysis tools that determine -// whether Contexts are propagated correctly in a program. +// parameter). func TODO() Context { return todo } + +var ( + background = context.Background() + todo = context.TODO() +) + +// A CancelFunc tells an operation to abandon its work. +// A CancelFunc does not wait for the work to stop. +// A CancelFunc may be called by multiple goroutines simultaneously. +// After the first call, subsequent calls to a CancelFunc do nothing. +type CancelFunc = context.CancelFunc + +// WithCancel returns a derived context that points to the parent context +// but has a new Done channel. The returned context's Done channel is closed +// when the returned cancel function is called or when the parent context's +// Done channel is closed, whichever happens first. +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this [Context] complete. +func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { + return context.WithCancel(parent) +} + +// WithDeadline returns a derived context that points to the parent context +// but has the deadline adjusted to be no later than d. If the parent's +// deadline is already earlier than d, WithDeadline(parent, d) is semantically +// equivalent to parent. The returned [Context.Done] channel is closed when +// the deadline expires, when the returned cancel function is called, +// or when the parent context's Done channel is closed, whichever happens first. +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this [Context] complete. +func WithDeadline(parent Context, d time.Time) (Context, CancelFunc) { + return context.WithDeadline(parent, d) +} + +// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this [Context] complete: +// +// func slowOperationWithTimeout(ctx context.Context) (Result, error) { +// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) +// defer cancel() // releases resources if slowOperation completes before timeout elapses +// return slowOperation(ctx) +// } +func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { + return context.WithTimeout(parent, timeout) +} + +// WithValue returns a derived context that points to the parent Context. +// In the derived context, the value associated with key is val. +// +// Use context Values only for request-scoped data that transits processes and +// APIs, not for passing optional parameters to functions. +// +// The provided key must be comparable and should not be of type +// string or any other built-in type to avoid collisions between +// packages using context. Users of WithValue should define their own +// types for keys. To avoid allocating when assigning to an +// interface{}, context keys often have concrete type +// struct{}. Alternatively, exported context key variables' static +// type should be a pointer or interface. +func WithValue(parent Context, key, val interface{}) Context { + return context.WithValue(parent, key, val) +} diff --git a/vendor/golang.org/x/net/context/go17.go b/vendor/golang.org/x/net/context/go17.go deleted file mode 100644 index 0c1b86793..000000000 --- a/vendor/golang.org/x/net/context/go17.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2016 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.7 - -package context - -import ( - "context" // standard library's context, as of Go 1.7 - "time" -) - -var ( - todo = context.TODO() - background = context.Background() -) - -// Canceled is the error returned by Context.Err when the context is canceled. -var Canceled = context.Canceled - -// DeadlineExceeded is the error returned by Context.Err when the context's -// deadline passes. -var DeadlineExceeded = context.DeadlineExceeded - -// WithCancel returns a copy of parent with a new Done channel. The returned -// context's Done channel is closed when the returned cancel function is called -// or when the parent context's Done channel is closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { - ctx, f := context.WithCancel(parent) - return ctx, f -} - -// WithDeadline returns a copy of the parent context with the deadline adjusted -// to be no later than d. If the parent's deadline is already earlier than d, -// WithDeadline(parent, d) is semantically equivalent to parent. The returned -// context's Done channel is closed when the deadline expires, when the returned -// cancel function is called, or when the parent context's Done channel is -// closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { - ctx, f := context.WithDeadline(parent, deadline) - return ctx, f -} - -// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete: -// -// func slowOperationWithTimeout(ctx context.Context) (Result, error) { -// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) -// defer cancel() // releases resources if slowOperation completes before timeout elapses -// return slowOperation(ctx) -// } -func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { - return WithDeadline(parent, time.Now().Add(timeout)) -} - -// WithValue returns a copy of parent in which the value associated with key is -// val. -// -// Use context Values only for request-scoped data that transits processes and -// APIs, not for passing optional parameters to functions. -func WithValue(parent Context, key interface{}, val interface{}) Context { - return context.WithValue(parent, key, val) -} diff --git a/vendor/golang.org/x/net/context/go19.go b/vendor/golang.org/x/net/context/go19.go deleted file mode 100644 index e31e35a90..000000000 --- a/vendor/golang.org/x/net/context/go19.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017 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.9 - -package context - -import "context" // standard library's context, as of Go 1.7 - -// A Context carries a deadline, a cancelation signal, and other values across -// API boundaries. -// -// Context's methods may be called by multiple goroutines simultaneously. -type Context = context.Context - -// A CancelFunc tells an operation to abandon its work. -// A CancelFunc does not wait for the work to stop. -// After the first call, subsequent calls to a CancelFunc do nothing. -type CancelFunc = context.CancelFunc diff --git a/vendor/golang.org/x/net/context/pre_go17.go b/vendor/golang.org/x/net/context/pre_go17.go deleted file mode 100644 index 065ff3dfa..000000000 --- a/vendor/golang.org/x/net/context/pre_go17.go +++ /dev/null @@ -1,300 +0,0 @@ -// 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. - -//go:build !go1.7 - -package context - -import ( - "errors" - "fmt" - "sync" - "time" -) - -// An emptyCtx is never canceled, has no values, and has no deadline. It is not -// struct{}, since vars of this type must have distinct addresses. -type emptyCtx int - -func (*emptyCtx) Deadline() (deadline time.Time, ok bool) { - return -} - -func (*emptyCtx) Done() <-chan struct{} { - return nil -} - -func (*emptyCtx) Err() error { - return nil -} - -func (*emptyCtx) Value(key interface{}) interface{} { - return nil -} - -func (e *emptyCtx) String() string { - switch e { - case background: - return "context.Background" - case todo: - return "context.TODO" - } - return "unknown empty Context" -} - -var ( - background = new(emptyCtx) - todo = new(emptyCtx) -) - -// Canceled is the error returned by Context.Err when the context is canceled. -var Canceled = errors.New("context canceled") - -// DeadlineExceeded is the error returned by Context.Err when the context's -// deadline passes. -var DeadlineExceeded = errors.New("context deadline exceeded") - -// WithCancel returns a copy of parent with a new Done channel. The returned -// context's Done channel is closed when the returned cancel function is called -// or when the parent context's Done channel is closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { - c := newCancelCtx(parent) - propagateCancel(parent, c) - return c, func() { c.cancel(true, Canceled) } -} - -// newCancelCtx returns an initialized cancelCtx. -func newCancelCtx(parent Context) *cancelCtx { - return &cancelCtx{ - Context: parent, - done: make(chan struct{}), - } -} - -// propagateCancel arranges for child to be canceled when parent is. -func propagateCancel(parent Context, child canceler) { - if parent.Done() == nil { - return // parent is never canceled - } - if p, ok := parentCancelCtx(parent); ok { - p.mu.Lock() - if p.err != nil { - // parent has already been canceled - child.cancel(false, p.err) - } else { - if p.children == nil { - p.children = make(map[canceler]bool) - } - p.children[child] = true - } - p.mu.Unlock() - } else { - go func() { - select { - case <-parent.Done(): - child.cancel(false, parent.Err()) - case <-child.Done(): - } - }() - } -} - -// parentCancelCtx follows a chain of parent references until it finds a -// *cancelCtx. This function understands how each of the concrete types in this -// package represents its parent. -func parentCancelCtx(parent Context) (*cancelCtx, bool) { - for { - switch c := parent.(type) { - case *cancelCtx: - return c, true - case *timerCtx: - return c.cancelCtx, true - case *valueCtx: - parent = c.Context - default: - return nil, false - } - } -} - -// removeChild removes a context from its parent. -func removeChild(parent Context, child canceler) { - p, ok := parentCancelCtx(parent) - if !ok { - return - } - p.mu.Lock() - if p.children != nil { - delete(p.children, child) - } - p.mu.Unlock() -} - -// A canceler is a context type that can be canceled directly. The -// implementations are *cancelCtx and *timerCtx. -type canceler interface { - cancel(removeFromParent bool, err error) - Done() <-chan struct{} -} - -// A cancelCtx can be canceled. When canceled, it also cancels any children -// that implement canceler. -type cancelCtx struct { - Context - - done chan struct{} // closed by the first cancel call. - - mu sync.Mutex - children map[canceler]bool // set to nil by the first cancel call - err error // set to non-nil by the first cancel call -} - -func (c *cancelCtx) Done() <-chan struct{} { - return c.done -} - -func (c *cancelCtx) Err() error { - c.mu.Lock() - defer c.mu.Unlock() - return c.err -} - -func (c *cancelCtx) String() string { - return fmt.Sprintf("%v.WithCancel", c.Context) -} - -// cancel closes c.done, cancels each of c's children, and, if -// removeFromParent is true, removes c from its parent's children. -func (c *cancelCtx) cancel(removeFromParent bool, err error) { - if err == nil { - panic("context: internal error: missing cancel error") - } - c.mu.Lock() - if c.err != nil { - c.mu.Unlock() - return // already canceled - } - c.err = err - close(c.done) - for child := range c.children { - // NOTE: acquiring the child's lock while holding parent's lock. - child.cancel(false, err) - } - c.children = nil - c.mu.Unlock() - - if removeFromParent { - removeChild(c.Context, c) - } -} - -// WithDeadline returns a copy of the parent context with the deadline adjusted -// to be no later than d. If the parent's deadline is already earlier than d, -// WithDeadline(parent, d) is semantically equivalent to parent. The returned -// context's Done channel is closed when the deadline expires, when the returned -// cancel function is called, or when the parent context's Done channel is -// closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { - if cur, ok := parent.Deadline(); ok && cur.Before(deadline) { - // The current deadline is already sooner than the new one. - return WithCancel(parent) - } - c := &timerCtx{ - cancelCtx: newCancelCtx(parent), - deadline: deadline, - } - propagateCancel(parent, c) - d := deadline.Sub(time.Now()) - if d <= 0 { - c.cancel(true, DeadlineExceeded) // deadline has already passed - return c, func() { c.cancel(true, Canceled) } - } - c.mu.Lock() - defer c.mu.Unlock() - if c.err == nil { - c.timer = time.AfterFunc(d, func() { - c.cancel(true, DeadlineExceeded) - }) - } - return c, func() { c.cancel(true, Canceled) } -} - -// A timerCtx carries a timer and a deadline. It embeds a cancelCtx to -// implement Done and Err. It implements cancel by stopping its timer then -// delegating to cancelCtx.cancel. -type timerCtx struct { - *cancelCtx - timer *time.Timer // Under cancelCtx.mu. - - deadline time.Time -} - -func (c *timerCtx) Deadline() (deadline time.Time, ok bool) { - return c.deadline, true -} - -func (c *timerCtx) String() string { - return fmt.Sprintf("%v.WithDeadline(%s [%s])", c.cancelCtx.Context, c.deadline, c.deadline.Sub(time.Now())) -} - -func (c *timerCtx) cancel(removeFromParent bool, err error) { - c.cancelCtx.cancel(false, err) - if removeFromParent { - // Remove this timerCtx from its parent cancelCtx's children. - removeChild(c.cancelCtx.Context, c) - } - c.mu.Lock() - if c.timer != nil { - c.timer.Stop() - c.timer = nil - } - c.mu.Unlock() -} - -// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete: -// -// func slowOperationWithTimeout(ctx context.Context) (Result, error) { -// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) -// defer cancel() // releases resources if slowOperation completes before timeout elapses -// return slowOperation(ctx) -// } -func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { - return WithDeadline(parent, time.Now().Add(timeout)) -} - -// WithValue returns a copy of parent in which the value associated with key is -// val. -// -// Use context Values only for request-scoped data that transits processes and -// APIs, not for passing optional parameters to functions. -func WithValue(parent Context, key interface{}, val interface{}) Context { - return &valueCtx{parent, key, val} -} - -// A valueCtx carries a key-value pair. It implements Value for that key and -// delegates all other calls to the embedded Context. -type valueCtx struct { - Context - key, val interface{} -} - -func (c *valueCtx) String() string { - return fmt.Sprintf("%v.WithValue(%#v, %#v)", c.Context, c.key, c.val) -} - -func (c *valueCtx) Value(key interface{}) interface{} { - if c.key == key { - return c.val - } - return c.Context.Value(key) -} diff --git a/vendor/golang.org/x/net/context/pre_go19.go b/vendor/golang.org/x/net/context/pre_go19.go deleted file mode 100644 index ec5a63803..000000000 --- a/vendor/golang.org/x/net/context/pre_go19.go +++ /dev/null @@ -1,109 +0,0 @@ -// 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. - -//go:build !go1.9 - -package context - -import "time" - -// A Context carries a deadline, a cancelation signal, and other values across -// API boundaries. -// -// Context's methods may be called by multiple goroutines simultaneously. -type Context interface { - // Deadline returns the time when work done on behalf of this context - // should be canceled. Deadline returns ok==false when no deadline is - // set. Successive calls to Deadline return the same results. - Deadline() (deadline time.Time, ok bool) - - // Done returns a channel that's closed when work done on behalf of this - // context should be canceled. Done may return nil if this context can - // never be canceled. Successive calls to Done return the same value. - // - // WithCancel arranges for Done to be closed when cancel is called; - // WithDeadline arranges for Done to be closed when the deadline - // expires; WithTimeout arranges for Done to be closed when the timeout - // elapses. - // - // Done is provided for use in select statements: - // - // // Stream generates values with DoSomething and sends them to out - // // until DoSomething returns an error or ctx.Done is closed. - // func Stream(ctx context.Context, out chan<- Value) error { - // for { - // v, err := DoSomething(ctx) - // if err != nil { - // return err - // } - // select { - // case <-ctx.Done(): - // return ctx.Err() - // case out <- v: - // } - // } - // } - // - // See http://blog.golang.org/pipelines for more examples of how to use - // a Done channel for cancelation. - Done() <-chan struct{} - - // Err returns a non-nil error value after Done is closed. Err returns - // Canceled if the context was canceled or DeadlineExceeded if the - // context's deadline passed. No other values for Err are defined. - // After Done is closed, successive calls to Err return the same value. - Err() error - - // Value returns the value associated with this context for key, or nil - // if no value is associated with key. Successive calls to Value with - // the same key returns the same result. - // - // Use context values only for request-scoped data that transits - // processes and API boundaries, not for passing optional parameters to - // functions. - // - // A key identifies a specific value in a Context. Functions that wish - // to store values in Context typically allocate a key in a global - // variable then use that key as the argument to context.WithValue and - // Context.Value. A key can be any type that supports equality; - // packages should define keys as an unexported type to avoid - // collisions. - // - // Packages that define a Context key should provide type-safe accessors - // for the values stores using that key: - // - // // Package user defines a User type that's stored in Contexts. - // package user - // - // import "golang.org/x/net/context" - // - // // User is the type of value stored in the Contexts. - // type User struct {...} - // - // // key is an unexported type for keys defined in this package. - // // This prevents collisions with keys defined in other packages. - // type key int - // - // // userKey is the key for user.User values in Contexts. It is - // // unexported; clients use user.NewContext and user.FromContext - // // instead of using this key directly. - // var userKey key = 0 - // - // // NewContext returns a new Context that carries value u. - // func NewContext(ctx context.Context, u *User) context.Context { - // return context.WithValue(ctx, userKey, u) - // } - // - // // FromContext returns the User value stored in ctx, if any. - // func FromContext(ctx context.Context) (*User, bool) { - // u, ok := ctx.Value(userKey).(*User) - // return u, ok - // } - Value(key interface{}) interface{} -} - -// A CancelFunc tells an operation to abandon its work. -// A CancelFunc does not wait for the work to stop. -// After the first call, subsequent calls to a CancelFunc do nothing. -type CancelFunc func() diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go index 7434b8784..b640deb0e 100644 --- a/vendor/golang.org/x/net/http2/server.go +++ b/vendor/golang.org/x/net/http2/server.go @@ -2233,25 +2233,25 @@ func (sc *serverConn) newStream(id, pusherID uint32, state streamState) *stream func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*responseWriter, *http.Request, error) { sc.serveG.check() - rp := requestParam{ - method: f.PseudoValue("method"), - scheme: f.PseudoValue("scheme"), - authority: f.PseudoValue("authority"), - path: f.PseudoValue("path"), - protocol: f.PseudoValue("protocol"), + rp := httpcommon.ServerRequestParam{ + Method: f.PseudoValue("method"), + Scheme: f.PseudoValue("scheme"), + Authority: f.PseudoValue("authority"), + Path: f.PseudoValue("path"), + Protocol: f.PseudoValue("protocol"), } // extended connect is disabled, so we should not see :protocol - if disableExtendedConnectProtocol && rp.protocol != "" { + if disableExtendedConnectProtocol && rp.Protocol != "" { return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol)) } - isConnect := rp.method == "CONNECT" + isConnect := rp.Method == "CONNECT" if isConnect { - if rp.protocol == "" && (rp.path != "" || rp.scheme != "" || rp.authority == "") { + if rp.Protocol == "" && (rp.Path != "" || rp.Scheme != "" || rp.Authority == "") { return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol)) } - } else if rp.method == "" || rp.path == "" || (rp.scheme != "https" && rp.scheme != "http") { + } else if rp.Method == "" || rp.Path == "" || (rp.Scheme != "https" && rp.Scheme != "http") { // See 8.1.2.6 Malformed Requests and Responses: // // Malformed requests or responses that are detected @@ -2265,15 +2265,16 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res return nil, nil, sc.countError("bad_path_method", streamError(f.StreamID, ErrCodeProtocol)) } - rp.header = make(http.Header) + header := make(http.Header) + rp.Header = header for _, hf := range f.RegularFields() { - rp.header.Add(sc.canonicalHeader(hf.Name), hf.Value) + header.Add(sc.canonicalHeader(hf.Name), hf.Value) } - if rp.authority == "" { - rp.authority = rp.header.Get("Host") + if rp.Authority == "" { + rp.Authority = header.Get("Host") } - if rp.protocol != "" { - rp.header.Set(":protocol", rp.protocol) + if rp.Protocol != "" { + header.Set(":protocol", rp.Protocol) } rw, req, err := sc.newWriterAndRequestNoBody(st, rp) @@ -2282,7 +2283,7 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res } bodyOpen := !f.StreamEnded() if bodyOpen { - if vv, ok := rp.header["Content-Length"]; ok { + if vv, ok := rp.Header["Content-Length"]; ok { if cl, err := strconv.ParseUint(vv[0], 10, 63); err == nil { req.ContentLength = int64(cl) } else { @@ -2298,84 +2299,38 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res return rw, req, nil } -type requestParam struct { - method string - scheme, authority, path string - protocol string - header http.Header -} - -func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp requestParam) (*responseWriter, *http.Request, error) { +func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp httpcommon.ServerRequestParam) (*responseWriter, *http.Request, error) { sc.serveG.check() var tlsState *tls.ConnectionState // nil if not scheme https - if rp.scheme == "https" { + if rp.Scheme == "https" { tlsState = sc.tlsState } - needsContinue := httpguts.HeaderValuesContainsToken(rp.header["Expect"], "100-continue") - if needsContinue { - rp.header.Del("Expect") - } - // Merge Cookie headers into one "; "-delimited value. - if cookies := rp.header["Cookie"]; len(cookies) > 1 { - rp.header.Set("Cookie", strings.Join(cookies, "; ")) - } - - // Setup Trailers - var trailer http.Header - for _, v := range rp.header["Trailer"] { - for _, key := range strings.Split(v, ",") { - key = http.CanonicalHeaderKey(textproto.TrimString(key)) - switch key { - case "Transfer-Encoding", "Trailer", "Content-Length": - // Bogus. (copy of http1 rules) - // Ignore. - default: - if trailer == nil { - trailer = make(http.Header) - } - trailer[key] = nil - } - } - } - delete(rp.header, "Trailer") - - var url_ *url.URL - var requestURI string - if rp.method == "CONNECT" && rp.protocol == "" { - url_ = &url.URL{Host: rp.authority} - requestURI = rp.authority // mimic HTTP/1 server behavior - } else { - var err error - url_, err = url.ParseRequestURI(rp.path) - if err != nil { - return nil, nil, sc.countError("bad_path", streamError(st.id, ErrCodeProtocol)) - } - requestURI = rp.path + res := httpcommon.NewServerRequest(rp) + if res.InvalidReason != "" { + return nil, nil, sc.countError(res.InvalidReason, streamError(st.id, ErrCodeProtocol)) } body := &requestBody{ conn: sc, stream: st, - needsContinue: needsContinue, + needsContinue: res.NeedsContinue, } - req := &http.Request{ - Method: rp.method, - URL: url_, + req := (&http.Request{ + Method: rp.Method, + URL: res.URL, RemoteAddr: sc.remoteAddrStr, - Header: rp.header, - RequestURI: requestURI, + Header: rp.Header, + RequestURI: res.RequestURI, Proto: "HTTP/2.0", ProtoMajor: 2, ProtoMinor: 0, TLS: tlsState, - Host: rp.authority, + Host: rp.Authority, Body: body, - Trailer: trailer, - } - req = req.WithContext(st.ctx) - + Trailer: res.Trailer, + }).WithContext(st.ctx) rw := sc.newResponseWriter(st, req) return rw, req, nil } @@ -3270,12 +3225,12 @@ func (sc *serverConn) startPush(msg *startPushRequest) { // we start in "half closed (remote)" for simplicity. // See further comments at the definition of stateHalfClosedRemote. promised := sc.newStream(promisedID, msg.parent.id, stateHalfClosedRemote) - rw, req, err := sc.newWriterAndRequestNoBody(promised, requestParam{ - method: msg.method, - scheme: msg.url.Scheme, - authority: msg.url.Host, - path: msg.url.RequestURI(), - header: cloneHeader(msg.header), // clone since handler runs concurrently with writing the PUSH_PROMISE + rw, req, err := sc.newWriterAndRequestNoBody(promised, httpcommon.ServerRequestParam{ + Method: msg.method, + Scheme: msg.url.Scheme, + Authority: msg.url.Host, + Path: msg.url.RequestURI(), + Header: cloneHeader(msg.header), // clone since handler runs concurrently with writing the PUSH_PROMISE }) if err != nil { // Should not happen, since we've already validated msg.url. diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index f2c166b61..f26356b9c 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -1286,6 +1286,19 @@ func (cc *ClientConn) responseHeaderTimeout() time.Duration { return 0 } +// actualContentLength returns a sanitized version of +// req.ContentLength, where 0 actually means zero (not unknown) and -1 +// means unknown. +func actualContentLength(req *http.Request) int64 { + if req.Body == nil || req.Body == http.NoBody { + return 0 + } + if req.ContentLength != 0 { + return req.ContentLength + } + return -1 +} + func (cc *ClientConn) decrStreamReservations() { cc.mu.Lock() defer cc.mu.Unlock() @@ -1310,7 +1323,7 @@ func (cc *ClientConn) roundTrip(req *http.Request, streamf func(*clientStream)) reqCancel: req.Cancel, isHead: req.Method == "HEAD", reqBody: req.Body, - reqBodyContentLength: httpcommon.ActualContentLength(req), + reqBodyContentLength: actualContentLength(req), trace: httptrace.ContextClientTrace(ctx), peerClosed: make(chan struct{}), abort: make(chan struct{}), @@ -1318,7 +1331,7 @@ func (cc *ClientConn) roundTrip(req *http.Request, streamf func(*clientStream)) donec: make(chan struct{}), } - cs.requestedGzip = httpcommon.IsRequestGzip(req, cc.t.disableCompression()) + cs.requestedGzip = httpcommon.IsRequestGzip(req.Method, req.Header, cc.t.disableCompression()) go cs.doRequest(req, streamf) @@ -1349,7 +1362,7 @@ func (cc *ClientConn) roundTrip(req *http.Request, streamf func(*clientStream)) } res.Request = req res.TLS = cc.tlsState - if res.Body == noBody && httpcommon.ActualContentLength(req) == 0 { + if res.Body == noBody && actualContentLength(req) == 0 { // If there isn't a request or response body still being // written, then wait for the stream to be closed before // RoundTrip returns. @@ -1596,12 +1609,7 @@ func (cs *clientStream) encodeAndWriteHeaders(req *http.Request) error { // sent by writeRequestBody below, along with any Trailers, // again in form HEADERS{1}, CONTINUATION{0,}) cc.hbuf.Reset() - res, err := httpcommon.EncodeHeaders(httpcommon.EncodeHeadersParam{ - Request: req, - AddGzipHeader: cs.requestedGzip, - PeerMaxHeaderListSize: cc.peerMaxHeaderListSize, - DefaultUserAgent: defaultUserAgent, - }, func(name, value string) { + res, err := encodeRequestHeaders(req, cs.requestedGzip, cc.peerMaxHeaderListSize, func(name, value string) { cc.writeHeader(name, value) }) if err != nil { @@ -1617,6 +1625,22 @@ func (cs *clientStream) encodeAndWriteHeaders(req *http.Request) error { return err } +func encodeRequestHeaders(req *http.Request, addGzipHeader bool, peerMaxHeaderListSize uint64, headerf func(name, value string)) (httpcommon.EncodeHeadersResult, error) { + return httpcommon.EncodeHeaders(req.Context(), httpcommon.EncodeHeadersParam{ + Request: httpcommon.Request{ + Header: req.Header, + Trailer: req.Trailer, + URL: req.URL, + Host: req.Host, + Method: req.Method, + ActualContentLength: actualContentLength(req), + }, + AddGzipHeader: addGzipHeader, + PeerMaxHeaderListSize: peerMaxHeaderListSize, + DefaultUserAgent: defaultUserAgent, + }, headerf) +} + // cleanupWriteRequest performs post-request tasks. // // If err (the result of writeRequest) is non-nil and the stream is not closed, @@ -2186,6 +2210,13 @@ func (rl *clientConnReadLoop) cleanup() { } cc.cond.Broadcast() cc.mu.Unlock() + + if !cc.seenSettings { + // If we have a pending request that wants extended CONNECT, + // let it continue and fail with the connection error. + cc.extendedConnectAllowed = true + close(cc.seenSettingsChan) + } } // countReadFrameError calls Transport.CountError with a string @@ -2278,9 +2309,6 @@ func (rl *clientConnReadLoop) run() error { if VerboseLogs { cc.vlogf("http2: Transport conn %p received error from processing frame %v: %v", cc, summarizeFrame(f), err) } - if !cc.seenSettings { - close(cc.seenSettingsChan) - } return err } } diff --git a/vendor/golang.org/x/net/internal/httpcommon/headermap.go b/vendor/golang.org/x/net/internal/httpcommon/headermap.go index ad3fbacd6..92483d8e4 100644 --- a/vendor/golang.org/x/net/internal/httpcommon/headermap.go +++ b/vendor/golang.org/x/net/internal/httpcommon/headermap.go @@ -5,7 +5,7 @@ package httpcommon import ( - "net/http" + "net/textproto" "sync" ) @@ -82,7 +82,7 @@ func buildCommonHeaderMaps() { commonLowerHeader = make(map[string]string, len(common)) commonCanonHeader = make(map[string]string, len(common)) for _, v := range common { - chk := http.CanonicalHeaderKey(v) + chk := textproto.CanonicalMIMEHeaderKey(v) commonLowerHeader[chk] = v commonCanonHeader[v] = chk } @@ -104,7 +104,7 @@ func CanonicalHeader(v string) string { if s, ok := commonCanonHeader[v]; ok { return s } - return http.CanonicalHeaderKey(v) + return textproto.CanonicalMIMEHeaderKey(v) } // CachedCanonicalHeader returns the canonical form of a well-known header name. diff --git a/vendor/golang.org/x/net/internal/httpcommon/request.go b/vendor/golang.org/x/net/internal/httpcommon/request.go index 343914773..4b7055317 100644 --- a/vendor/golang.org/x/net/internal/httpcommon/request.go +++ b/vendor/golang.org/x/net/internal/httpcommon/request.go @@ -5,10 +5,12 @@ package httpcommon import ( + "context" "errors" "fmt" - "net/http" "net/http/httptrace" + "net/textproto" + "net/url" "sort" "strconv" "strings" @@ -21,9 +23,21 @@ var ( ErrRequestHeaderListSize = errors.New("request header list larger than peer's advertised limit") ) +// Request is a subset of http.Request. +// It'd be simpler to pass an *http.Request, of course, but we can't depend on net/http +// without creating a dependency cycle. +type Request struct { + URL *url.URL + Method string + Host string + Header map[string][]string + Trailer map[string][]string + ActualContentLength int64 // 0 means 0, -1 means unknown +} + // EncodeHeadersParam is parameters to EncodeHeaders. type EncodeHeadersParam struct { - Request *http.Request + Request Request // AddGzipHeader indicates that an "accept-encoding: gzip" header should be // added to the request. @@ -47,11 +61,11 @@ type EncodeHeadersResult struct { // It validates a request and calls headerf with each pseudo-header and header // for the request. // The headerf function is called with the validated, canonicalized header name. -func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) (res EncodeHeadersResult, _ error) { +func EncodeHeaders(ctx context.Context, param EncodeHeadersParam, headerf func(name, value string)) (res EncodeHeadersResult, _ error) { req := param.Request // Check for invalid connection-level headers. - if err := checkConnHeaders(req); err != nil { + if err := checkConnHeaders(req.Header); err != nil { return res, err } @@ -73,7 +87,10 @@ func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) ( // isNormalConnect is true if this is a non-extended CONNECT request. isNormalConnect := false - protocol := req.Header.Get(":protocol") + var protocol string + if vv := req.Header[":protocol"]; len(vv) > 0 { + protocol = vv[0] + } if req.Method == "CONNECT" && protocol == "" { isNormalConnect = true } else if protocol != "" && req.Method != "CONNECT" { @@ -107,9 +124,7 @@ func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) ( return res, fmt.Errorf("invalid HTTP trailer %s", err) } - contentLength := ActualContentLength(req) - - trailers, err := commaSeparatedTrailers(req) + trailers, err := commaSeparatedTrailers(req.Trailer) if err != nil { return res, err } @@ -123,7 +138,7 @@ func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) ( f(":authority", host) m := req.Method if m == "" { - m = http.MethodGet + m = "GET" } f(":method", m) if !isNormalConnect { @@ -198,8 +213,8 @@ func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) ( f(k, v) } } - if shouldSendReqContentLength(req.Method, contentLength) { - f("content-length", strconv.FormatInt(contentLength, 10)) + if shouldSendReqContentLength(req.Method, req.ActualContentLength) { + f("content-length", strconv.FormatInt(req.ActualContentLength, 10)) } if param.AddGzipHeader { f("accept-encoding", "gzip") @@ -225,7 +240,7 @@ func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) ( } } - trace := httptrace.ContextClientTrace(req.Context()) + trace := httptrace.ContextClientTrace(ctx) // Header list size is ok. Write the headers. enumerateHeaders(func(name, value string) { @@ -243,19 +258,19 @@ func EncodeHeaders(param EncodeHeadersParam, headerf func(name, value string)) ( } }) - res.HasBody = contentLength != 0 + res.HasBody = req.ActualContentLength != 0 res.HasTrailers = trailers != "" return res, nil } // IsRequestGzip reports whether we should add an Accept-Encoding: gzip header // for a request. -func IsRequestGzip(req *http.Request, disableCompression bool) bool { +func IsRequestGzip(method string, header map[string][]string, disableCompression bool) bool { // TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere? if !disableCompression && - req.Header.Get("Accept-Encoding") == "" && - req.Header.Get("Range") == "" && - req.Method != "HEAD" { + len(header["Accept-Encoding"]) == 0 && + len(header["Range"]) == 0 && + method != "HEAD" { // Request gzip only, not deflate. Deflate is ambiguous and // not as universally supported anyway. // See: https://zlib.net/zlib_faq.html#faq39 @@ -280,22 +295,22 @@ func IsRequestGzip(req *http.Request, disableCompression bool) bool { // // Certain headers are special-cased as okay but not transmitted later. // For example, we allow "Transfer-Encoding: chunked", but drop the header when encoding. -func checkConnHeaders(req *http.Request) error { - if v := req.Header.Get("Upgrade"); v != "" { - return fmt.Errorf("invalid Upgrade request header: %q", req.Header["Upgrade"]) +func checkConnHeaders(h map[string][]string) error { + if vv := h["Upgrade"]; len(vv) > 0 && (vv[0] != "" && vv[0] != "chunked") { + return fmt.Errorf("invalid Upgrade request header: %q", vv) } - if vv := req.Header["Transfer-Encoding"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "chunked") { + if vv := h["Transfer-Encoding"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "chunked") { return fmt.Errorf("invalid Transfer-Encoding request header: %q", vv) } - if vv := req.Header["Connection"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && !asciiEqualFold(vv[0], "close") && !asciiEqualFold(vv[0], "keep-alive")) { + if vv := h["Connection"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && !asciiEqualFold(vv[0], "close") && !asciiEqualFold(vv[0], "keep-alive")) { return fmt.Errorf("invalid Connection request header: %q", vv) } return nil } -func commaSeparatedTrailers(req *http.Request) (string, error) { - keys := make([]string, 0, len(req.Trailer)) - for k := range req.Trailer { +func commaSeparatedTrailers(trailer map[string][]string) (string, error) { + keys := make([]string, 0, len(trailer)) + for k := range trailer { k = CanonicalHeader(k) switch k { case "Transfer-Encoding", "Trailer", "Content-Length": @@ -310,19 +325,6 @@ func commaSeparatedTrailers(req *http.Request) (string, error) { return "", nil } -// ActualContentLength returns a sanitized version of -// req.ContentLength, where 0 actually means zero (not unknown) and -1 -// means unknown. -func ActualContentLength(req *http.Request) int64 { - if req.Body == nil || req.Body == http.NoBody { - return 0 - } - if req.ContentLength != 0 { - return req.ContentLength - } - return -1 -} - // validPseudoPath reports whether v is a valid :path pseudo-header // value. It must be either: // @@ -340,7 +342,7 @@ func validPseudoPath(v string) bool { return (len(v) > 0 && v[0] == '/') || v == "*" } -func validateHeaders(hdrs http.Header) string { +func validateHeaders(hdrs map[string][]string) string { for k, vv := range hdrs { if !httpguts.ValidHeaderFieldName(k) && k != ":protocol" { return fmt.Sprintf("name %q", k) @@ -377,3 +379,89 @@ func shouldSendReqContentLength(method string, contentLength int64) bool { return false } } + +// ServerRequestParam is parameters to NewServerRequest. +type ServerRequestParam struct { + Method string + Scheme, Authority, Path string + Protocol string + Header map[string][]string +} + +// ServerRequestResult is the result of NewServerRequest. +type ServerRequestResult struct { + // Various http.Request fields. + URL *url.URL + RequestURI string + Trailer map[string][]string + + NeedsContinue bool // client provided an "Expect: 100-continue" header + + // If the request should be rejected, this is a short string suitable for passing + // to the http2 package's CountError function. + // It might be a bit odd to return errors this way rather than returing an error, + // but this ensures we don't forget to include a CountError reason. + InvalidReason string +} + +func NewServerRequest(rp ServerRequestParam) ServerRequestResult { + needsContinue := httpguts.HeaderValuesContainsToken(rp.Header["Expect"], "100-continue") + if needsContinue { + delete(rp.Header, "Expect") + } + // Merge Cookie headers into one "; "-delimited value. + if cookies := rp.Header["Cookie"]; len(cookies) > 1 { + rp.Header["Cookie"] = []string{strings.Join(cookies, "; ")} + } + + // Setup Trailers + var trailer map[string][]string + for _, v := range rp.Header["Trailer"] { + for _, key := range strings.Split(v, ",") { + key = textproto.CanonicalMIMEHeaderKey(textproto.TrimString(key)) + switch key { + case "Transfer-Encoding", "Trailer", "Content-Length": + // Bogus. (copy of http1 rules) + // Ignore. + default: + if trailer == nil { + trailer = make(map[string][]string) + } + trailer[key] = nil + } + } + } + delete(rp.Header, "Trailer") + + // "':authority' MUST NOT include the deprecated userinfo subcomponent + // for "http" or "https" schemed URIs." + // https://www.rfc-editor.org/rfc/rfc9113.html#section-8.3.1-2.3.8 + if strings.IndexByte(rp.Authority, '@') != -1 && (rp.Scheme == "http" || rp.Scheme == "https") { + return ServerRequestResult{ + InvalidReason: "userinfo_in_authority", + } + } + + var url_ *url.URL + var requestURI string + if rp.Method == "CONNECT" && rp.Protocol == "" { + url_ = &url.URL{Host: rp.Authority} + requestURI = rp.Authority // mimic HTTP/1 server behavior + } else { + var err error + url_, err = url.ParseRequestURI(rp.Path) + if err != nil { + return ServerRequestResult{ + InvalidReason: "bad_path", + } + } + requestURI = rp.Path + } + + return ServerRequestResult{ + URL: url_, + NeedsContinue: needsContinue, + RequestURI: requestURI, + Trailer: trailer, + } +} diff --git a/vendor/golang.org/x/net/proxy/per_host.go b/vendor/golang.org/x/net/proxy/per_host.go index d7d4b8b6e..32bdf435e 100644 --- a/vendor/golang.org/x/net/proxy/per_host.go +++ b/vendor/golang.org/x/net/proxy/per_host.go @@ -7,6 +7,7 @@ package proxy import ( "context" "net" + "net/netip" "strings" ) @@ -57,7 +58,8 @@ func (p *PerHost) DialContext(ctx context.Context, network, addr string) (c net. } func (p *PerHost) dialerForRequest(host string) Dialer { - if ip := net.ParseIP(host); ip != nil { + if nip, err := netip.ParseAddr(host); err == nil { + ip := net.IP(nip.AsSlice()) for _, net := range p.bypassNetworks { if net.Contains(ip) { return p.bypass @@ -108,8 +110,8 @@ func (p *PerHost) AddFromString(s string) { } continue } - if ip := net.ParseIP(host); ip != nil { - p.AddIP(ip) + if nip, err := netip.ParseAddr(host); err == nil { + p.AddIP(net.IP(nip.AsSlice())) continue } if strings.HasPrefix(host, "*.") { diff --git a/vendor/modules.txt b/vendor/modules.txt index 85bb6aed1..01300fd39 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -808,14 +808,14 @@ github.com/zclconf/go-cty/cty/convert github.com/zclconf/go-cty/cty/ctystrings github.com/zclconf/go-cty/cty/function github.com/zclconf/go-cty/cty/set -# go.uber.org/atomic v1.10.0 +# go.uber.org/atomic v1.11.0 ## explicit; go 1.18 go.uber.org/atomic # go.uber.org/multierr v1.11.0 ## explicit; go 1.19 go.uber.org/multierr -# golang.org/x/crypto v0.33.0 -## explicit; go 1.20 +# golang.org/x/crypto v0.35.0 +## explicit; go 1.23.0 golang.org/x/crypto/argon2 golang.org/x/crypto/blake2b golang.org/x/crypto/blowfish @@ -846,8 +846,8 @@ golang.org/x/exp/slog/internal/buffer # golang.org/x/mod v0.21.0 ## explicit; go 1.22.0 golang.org/x/mod/semver -# golang.org/x/net v0.35.0 -## explicit; go 1.18 +# golang.org/x/net v0.36.0 +## explicit; go 1.23.0 golang.org/x/net/context golang.org/x/net/http/httpguts golang.org/x/net/http2 From ab9d948885a60c61ff6465c985b9b5c661df0096 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 09:05:20 +0000 Subject: [PATCH 04/11] fix(deps): update patch updates --- .github/workflows/build-oci.yaml | 4 + go.mod | 32 +- go.sum | 64 +- oci/Containerfile | 6 +- tools/go.mod | 8 +- tools/go.sum | 16 +- .../ckaznocha/intrange/.golangci.yml | 15 +- .../github.com/ckaznocha/intrange/go.work | 4 +- .../github.com/ckaznocha/intrange/intrange.go | 99 +- .../ghostiam/protogetter/flake.lock | 61 + .../github.com/ghostiam/protogetter/flake.nix | 69 + .../ghostiam/protogetter/processor.go | 39 +- .../ghostiam/protogetter/protogetter.go | 1 + tools/vendor/modules.txt | 14 +- .../azure-sdk-for-go/sdk/azcore/CHANGELOG.md | 7 + .../sdk/azcore/internal/shared/constants.go | 2 +- .../aws/aws-sdk-go-v2/config/CHANGELOG.md | 4 + .../config/go_module_metadata.go | 2 +- .../aws-sdk-go-v2/credentials/CHANGELOG.md | 4 + .../credentials/go_module_metadata.go | 2 +- .../aws-sdk-go-v2/service/sso/CHANGELOG.md | 4 + .../aws-sdk-go-v2/service/sso/generated.json | 1 + .../service/sso/go_module_metadata.go | 2 +- .../service/ssooidc/CHANGELOG.md | 4 + .../service/ssooidc/generated.json | 1 + .../service/ssooidc/go_module_metadata.go | 2 +- .../aws-sdk-go-v2/service/sts/CHANGELOG.md | 4 + .../aws-sdk-go-v2/service/sts/generated.json | 1 + .../service/sts/go_module_metadata.go | 2 +- .../bubbletea/inputreader_other.go | 2 +- .../bubbletea/inputreader_windows.go | 18 +- .../github.com/charmbracelet/bubbletea/tea.go | 29 +- .../github.com/charmbracelet/bubbletea/tty.go | 9 +- .../v2/go/awsx/internal/pulumiUtilities.go | 4 +- .../github.com/pulumi/pulumi/sdk/v3/.version | 2 +- .../sdk/v3/go/auto/optrefresh/optrefresh.go | 9 + .../sdk/v3/go/auto/optrename/optrename.go | 66 + .../pulumi/pulumi/sdk/v3/go/auto/stack.go | 65 + .../pulumi/sdk/v3/go/common/apitype/policy.go | 1 + .../sdk/v3/go/common/apitype/service.go | 12 +- .../pulumi/sdk/v3/go/common/apitype/stacks.go | 16 +- .../pulumi/pulumi/sdk/v3/go/common/env/env.go | 10 +- .../sdk/v3/go/common/resource/config/crypt.go | 32 +- .../resource/plugin/langruntime_plugin.go | 20 +- .../v3/go/common/resource/plugin/plugin.go | 52 +- .../v3/go/common/resource/plugin/provider.go | 42 +- .../common/resource/plugin/provider_plugin.go | 59 +- .../common/resource/plugin/provider_server.go | 46 +- .../sdk/v3/go/common/util/cmdutil/args.go | 6 +- .../sdk/v3/go/common/util/cmdutil/exit.go | 101 +- .../go/common/util/errutil/format_exiterr.go | 34 + .../sdk/v3/go/common/workspace/plugins.go | 22 +- .../sdk/v3/go/common/workspace/templates.go | 116 +- .../pulumi/pulumi/sdk/v3/go/pulumi/context.go | 36 +- .../pulumi/pulumi/sdk/v3/go/pulumi/rpc.go | 50 +- .../pulumi/pulumi/sdk/v3/go/pulumi/run.go | 4 + .../pulumi/sdk/v3/proto/go/provider.pb.go | 1315 +++++++++-------- .../sdk/v3/proto/go/provider_grpc.pb.go | 74 +- .../sdk/v3/python/toolchain/toolchain.go | 19 +- .../pulumi/sdk/v3/python/toolchain/uv.go | 13 +- vendor/golang.org/x/crypto/ssh/messages.go | 2 + vendor/golang.org/x/crypto/ssh/tcpip.go | 2 +- vendor/golang.org/x/sync/errgroup/errgroup.go | 2 +- vendor/golang.org/x/sync/errgroup/go120.go | 13 - .../golang.org/x/sync/errgroup/pre_go120.go | 14 - vendor/modules.txt | 46 +- 66 files changed, 1825 insertions(+), 1012 deletions(-) create mode 100644 tools/vendor/github.com/ghostiam/protogetter/flake.lock create mode 100644 tools/vendor/github.com/ghostiam/protogetter/flake.nix create mode 100644 vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/optrename/optrename.go create mode 100644 vendor/github.com/pulumi/pulumi/sdk/v3/go/common/util/errutil/format_exiterr.go delete mode 100644 vendor/golang.org/x/sync/errgroup/go120.go delete mode 100644 vendor/golang.org/x/sync/errgroup/pre_go120.go diff --git a/.github/workflows/build-oci.yaml b/.github/workflows/build-oci.yaml index dea51258f..a421d33ec 100644 --- a/.github/workflows/build-oci.yaml +++ b/.github/workflows/build-oci.yaml @@ -38,7 +38,11 @@ jobs: make oci-save - name: Upload mapt artifacts for PR +<<<<<<< HEAD uses: actions/upload-artifact@v4 +======= + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 +>>>>>>> 7c60066b (fix(deps): update patch updates) with: name: mapt path: mapt* diff --git a/go.mod b/go.mod index c313e1bd7..e8f453354 100644 --- a/go.mod +++ b/go.mod @@ -8,25 +8,25 @@ require ( github.com/coocood/freecache v1.2.4 github.com/pulumi/pulumi-command/sdk v1.0.1 github.com/pulumi/pulumi-random/sdk/v4 v4.16.7 - github.com/pulumi/pulumi/sdk/v3 v3.152.0 + github.com/pulumi/pulumi/sdk/v3 v3.154.0 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.9.1 golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6 v6.3.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.9.0 github.com/aws/amazon-ec2-instance-selector/v3 v3.1.1 github.com/aws/aws-sdk-go-v2 v1.36.3 - github.com/aws/aws-sdk-go-v2/config v1.29.8 + github.com/aws/aws-sdk-go-v2/config v1.29.9 github.com/aws/aws-sdk-go-v2/service/ec2 v1.203.1 github.com/aws/aws-sdk-go-v2/service/s3 v1.53.1 github.com/pulumi/pulumi-aws-native/sdk v1.25.0 github.com/pulumi/pulumi-aws/sdk/v6 v6.69.0 - github.com/pulumi/pulumi-awsx/sdk/v2 v2.21.0 + github.com/pulumi/pulumi-awsx/sdk/v2 v2.21.1 github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.88.0 github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.88.0 github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.88.0 @@ -61,7 +61,7 @@ require ( github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/atotto/clipboard v0.1.4 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.61 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.62 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 // indirect @@ -69,14 +69,14 @@ require ( github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect github.com/aws/aws-sdk-go-v2/service/pricing v1.32.17 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.25.0 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.0 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.33.16 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.25.1 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.1 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.33.17 // indirect github.com/aws/smithy-go v1.22.3 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/charmbracelet/bubbles v0.20.0 // indirect - github.com/charmbracelet/bubbletea v1.3.3 // indirect + github.com/charmbracelet/bubbletea v1.3.4 // indirect github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect github.com/charmbracelet/lipgloss v1.1.0 // indirect github.com/charmbracelet/x/ansi v0.8.0 // indirect @@ -122,8 +122,8 @@ require ( github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/zclconf/go-cty v1.15.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/sync v0.11.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + golang.org/x/sync v0.12.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) @@ -168,11 +168,11 @@ require ( github.com/uber/jaeger-lib v2.4.1+incompatible // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect go.uber.org/atomic v1.11.0 // indirect - golang.org/x/crypto v0.35.0 // indirect - golang.org/x/net v0.36.0 // indirect - golang.org/x/sys v0.30.0 // indirect - golang.org/x/term v0.29.0 // indirect - golang.org/x/text v0.22.0 // indirect + golang.org/x/crypto v0.36.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/sys v0.31.0 // indirect + golang.org/x/term v0.30.0 // indirect + golang.org/x/text v0.23.0 // indirect google.golang.org/grpc v1.67.1 // indirect google.golang.org/protobuf v1.35.1 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect diff --git a/go.sum b/go.sum index d8520cff4..fd29c4156 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0 h1:g0EZJwz7xkXQiZAI5xi9f3WWFYBlX1CPTrR+NDToRkQ= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0/go.mod h1:XCW7KnZet0Opnr7HccfUw1PLc4CjHqpcaxW8DHklNkQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 h1:F0gBpfdPLGsw+nsgk6aqqkZS1jiixa5WwFe3fk/T3Ys= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2/go.mod h1:SqINnQ9lVVdRlyC8cd1lCI0SdX4n2paeABd2K8ggfnE= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= @@ -47,10 +47,10 @@ github.com/aws/aws-sdk-go-v2 v1.36.3 h1:mJoei2CxPutQVxaATCzDUjcZEjVRdpsiiXi2o38y github.com/aws/aws-sdk-go-v2 v1.36.3/go.mod h1:LLXuLpgzEbD766Z5ECcRmi8AzSwfZItDtmABVkRLGzg= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 h1:x6xsQXGSmW6frevwDA+vi/wqhp1ct18mVXYN08/93to= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2/go.mod h1:lPprDr1e6cJdyYeGXnRaJoP4Md+cDBvi2eOj00BlGmg= -github.com/aws/aws-sdk-go-v2/config v1.29.8 h1:RpwAfYcV2lr/yRc4lWhUM9JRPQqKgKWmou3LV7UfWP4= -github.com/aws/aws-sdk-go-v2/config v1.29.8/go.mod h1:t+G7Fq1OcO8cXTPPXzxQSnj/5Xzdc9jAAD3Xrn9/Mgo= -github.com/aws/aws-sdk-go-v2/credentials v1.17.61 h1:Hd/uX6Wo2iUW1JWII+rmyCD7MMhOe7ALwQXN6sKDd1o= -github.com/aws/aws-sdk-go-v2/credentials v1.17.61/go.mod h1:L7vaLkwHY1qgW0gG1zG0z/X0sQ5tpIY5iI13+j3qI80= +github.com/aws/aws-sdk-go-v2/config v1.29.9 h1:Kg+fAYNaJeGXp1vmjtidss8O2uXIsXwaRqsQJKXVr+0= +github.com/aws/aws-sdk-go-v2/config v1.29.9/go.mod h1:oU3jj2O53kgOU4TXq/yipt6ryiooYjlkqqVaZk7gY/U= +github.com/aws/aws-sdk-go-v2/credentials v1.17.62 h1:fvtQY3zFzYJ9CfixuAQ96IxDrBajbBWGqjNTCa79ocU= +github.com/aws/aws-sdk-go-v2/credentials v1.17.62/go.mod h1:ElETBxIQqcxej++Cs8GyPBbgMys5DgQPTwo7cUPDKt8= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 h1:x793wxmUWVDhshP8WW2mlnXuFrO4cOd3HLBroh1paFw= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30/go.mod h1:Jpne2tDnYiFascUEs2AWHJL9Yp7A5ZVy3TNyxaAjD6M= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 h1:ZK5jHhnrioRkUNOc+hOgQKlUL5JeC3S6JgLxtQ+Rm0Q= @@ -79,12 +79,12 @@ github.com/aws/aws-sdk-go-v2/service/pricing v1.32.17 h1:EtZFyL/uhaXlHjIwHW0KSJv github.com/aws/aws-sdk-go-v2/service/pricing v1.32.17/go.mod h1:l7bufyRvU+8mY0Z1BNWbWvjr59dlj9YrLKmeiz5CJ30= github.com/aws/aws-sdk-go-v2/service/s3 v1.53.1 h1:6cnno47Me9bRykw9AEv9zkXE+5or7jz8TsskTTccbgc= github.com/aws/aws-sdk-go-v2/service/s3 v1.53.1/go.mod h1:qmdkIIAC+GCLASF7R2whgNrJADz0QZPX+Seiw/i4S3o= -github.com/aws/aws-sdk-go-v2/service/sso v1.25.0 h1:2U9sF8nKy7UgyEeLiZTRg6ShBS22z8UnYpV6aRFL0is= -github.com/aws/aws-sdk-go-v2/service/sso v1.25.0/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.0 h1:wjAdc85cXdQR5uLx5FwWvGIHm4OPJhTyzUHU8craXtE= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.0/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.16 h1:BHEK2Q/7CMRMCb3nySi/w8UbIcPhKvYP5s1xf8/izn0= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.16/go.mod h1:cQnB8CUnxbMU82JvlqjKR2HBOm3fe9pWorWBza6MBJ4= +github.com/aws/aws-sdk-go-v2/service/sso v1.25.1 h1:8JdC7Gr9NROg1Rusk25IcZeTO59zLxsKgE0gkh5O6h0= +github.com/aws/aws-sdk-go-v2/service/sso v1.25.1/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.1 h1:KwuLovgQPcdjNMfFt9OhUd9a2OwcOKhxfvF4glTzLuA= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.29.1/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.17 h1:PZV5W8yk4OtH1JAuhV2PXwwO9v5G5Aoj+eMCn4T+1Kc= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.17/go.mod h1:cQnB8CUnxbMU82JvlqjKR2HBOm3fe9pWorWBza6MBJ4= github.com/aws/smithy-go v1.22.3 h1:Z//5NuZCSW6R4PhQ93hShNbyBbn8BWCmCVCt+Q8Io5k= github.com/aws/smithy-go v1.22.3/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= @@ -98,8 +98,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.3.3 h1:WpU6fCY0J2vDWM3zfS3vIDi/ULq3SYphZhkAGGvmEUY= -github.com/charmbracelet/bubbletea v1.3.3/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= +github.com/charmbracelet/bubbletea v1.3.4 h1:kCg7B+jSCFPLYRA52SDZjr51kG/fMUEoPoZrkaDHyoI= +github.com/charmbracelet/bubbletea v1.3.4/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= @@ -272,8 +272,8 @@ github.com/pulumi/pulumi-aws-native/sdk v1.25.0 h1:lboDYcrKaz7ggwbUWluybdhG1zNs8 github.com/pulumi/pulumi-aws-native/sdk v1.25.0/go.mod h1:Kuy19nXfmt4X9ySnWlKJwYrTc/PedPBaNfX6SCoX8gE= github.com/pulumi/pulumi-aws/sdk/v6 v6.69.0 h1:SO9xo9PIgufYORBPx82lSQN0CLg1CMab+rR6JJnGv/c= github.com/pulumi/pulumi-aws/sdk/v6 v6.69.0/go.mod h1:OaqbSRCkPxr8XpanQ7u3Xup9MgSnyqQFDxNhV2pXWzw= -github.com/pulumi/pulumi-awsx/sdk/v2 v2.21.0 h1:El2HV0GbOFFoQot0id6ZNjpjrF+HErIdreMG9WwJ7OA= -github.com/pulumi/pulumi-awsx/sdk/v2 v2.21.0/go.mod h1:ZpStejgr+RYJZwbFV6IpOxPb/wLSd86LUTC69UNQVVI= +github.com/pulumi/pulumi-awsx/sdk/v2 v2.21.1 h1:V0NaeP3Rx5WGysvNz6x13Dnd3visEgQubP/gzQ+X86Q= +github.com/pulumi/pulumi-awsx/sdk/v2 v2.21.1/go.mod h1:j8IUGf1uw47bXxHS5H98O3NZIXvVsb7bfv/zby1cVLE= github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.88.0 h1:xIb656wq0o/gOLel90Bj/3tRxwq+U+3RaktlNnHvTG4= github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.88.0/go.mod h1:DnvaZlI1YwSZhIKfPPsXq6Koy1XoOkgGwOorcZeIj0k= github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.88.0 h1:TVO1fIAW7tu2sX7SEPfLH9e5DGH4cbbcG3qee58nEgk= @@ -300,8 +300,8 @@ github.com/pulumi/pulumi-random/sdk/v4 v4.16.7 h1:39rhOe/PTUGMYia8pR5T2wbxxMt2pw github.com/pulumi/pulumi-random/sdk/v4 v4.16.7/go.mod h1:cxxDhJzUPt/YElfvlWa15Q4NGF6XXS8kUs4OQsCxSBk= github.com/pulumi/pulumi-tls/sdk/v5 v5.0.9 h1:JH5TkGJDwlTqKdSJxd49DfrJOpVkRyGDvgKS9gwcV9U= github.com/pulumi/pulumi-tls/sdk/v5 v5.0.9/go.mod h1:3B+v+HC4bjAYf1mVxRVL/bDY20+VEMwfxRKgc3oeCrs= -github.com/pulumi/pulumi/sdk/v3 v3.152.0 h1:sPstmYhbf/ArkREjkPYRgFUf+iv1llskLY2/4aASdxc= -github.com/pulumi/pulumi/sdk/v3 v3.152.0/go.mod h1:+WC9aIDo8fMgd2g0jCHuZU2S/VYNLRAZ3QXt6YVgwaA= +github.com/pulumi/pulumi/sdk/v3 v3.154.0 h1:AK2XAIYwCVcCdvHuB87DqmnRLt7AlMRQobYb2VVycN8= +github.com/pulumi/pulumi/sdk/v3 v3.154.0/go.mod h1:+WC9aIDo8fMgd2g0jCHuZU2S/VYNLRAZ3QXt6YVgwaA= github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -377,8 +377,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs= -golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk= golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= @@ -393,13 +393,13 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA= -golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= -golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -418,16 +418,16 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= -golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= +golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= +golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= -golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -440,8 +440,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= diff --git a/oci/Containerfile b/oci/Containerfile index 0b0771358..61865fc60 100644 --- a/oci/Containerfile +++ b/oci/Containerfile @@ -7,7 +7,7 @@ WORKDIR /workspace COPY . . # renovate: datasource=github-releases depName=pulumi/pulumi -ENV PULUMI_VERSION 3.152.0 +ENV PULUMI_VERSION 3.154.0 ENV PULUMI_BASE_URL="https://github.com/pulumi/pulumi/releases/download/v${PULUMI_VERSION}/pulumi-v${PULUMI_VERSION}" ENV PULUMI_URL="${PULUMI_BASE_URL}-linux-x64.tar.gz" @@ -18,7 +18,7 @@ RUN GOARCH=${TARGETARCH} make build \ && tar -xzvf pulumicli.tar.gz # ubi 9.5-1732804088 -FROM registry.access.redhat.com/ubi9/ubi:9.5-1739751568 +FROM registry.access.redhat.com/ubi9/ubi:9.5-1741850090@sha256:8d53b60617e53e4dbd6c0d485c569801f48dbeb40b48c8424a67e33a07320968 ARG TARGETARCH LABEL org.opencontainers.image.authors="Redhat Developer" @@ -35,7 +35,7 @@ ENV AWS_SDK_LOAD_CONFIG=1 \ # renovate: datasource=github-releases depName=pulumi/pulumi-aws ARG PULUMI_AWS_VERSION=v6.69.0 # renovate: datasource=github-releases depName=pulumi/pulumi-awsx -ARG PULUMI_AWSX_VERSION=v2.21.0 +ARG PULUMI_AWSX_VERSION=v2.21.1 # renovate: datasource=github-releases depName=pulumi/pulumi-azure-native ARG PULUMI_AZURE_NATIVE_VERSION=v2.88.0 # renovate: datasource=github-releases depName=pulumi/pulumi-command diff --git a/tools/go.mod b/tools/go.mod index 1b7ec0b07..f8451efd5 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -31,8 +31,8 @@ require ( github.com/bkielbasa/cyclop v1.2.3 // indirect github.com/blizzy78/varnamelen v0.8.0 // indirect github.com/bombsimon/wsl/v4 v4.5.0 // indirect - github.com/breml/bidichk v0.3.2 // indirect - github.com/breml/errchkjson v0.4.0 // indirect + github.com/breml/bidichk v0.3.3 // indirect + github.com/breml/errchkjson v0.4.1 // indirect github.com/butuzov/ireturn v0.3.1 // indirect github.com/butuzov/mirror v1.3.0 // indirect github.com/catenacyber/perfsprint v0.8.1 // indirect @@ -40,7 +40,7 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/charithe/durationcheck v0.0.10 // indirect github.com/chavacava/garif v0.1.0 // indirect - github.com/ckaznocha/intrange v0.3.0 // indirect + github.com/ckaznocha/intrange v0.3.1 // indirect github.com/curioswitch/go-reassign v0.3.0 // indirect github.com/daixiang0/gci v0.13.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -51,7 +51,7 @@ require ( github.com/firefart/nonamedreturns v1.0.5 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect - github.com/ghostiam/protogetter v0.3.9 // indirect + github.com/ghostiam/protogetter v0.3.12 // indirect github.com/go-critic/go-critic v0.12.0 // indirect github.com/go-toolsmith/astcast v1.1.0 // indirect github.com/go-toolsmith/astcopy v1.1.0 // indirect diff --git a/tools/go.sum b/tools/go.sum index 3f1384126..582ab5add 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -94,10 +94,10 @@ github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k= github.com/bombsimon/wsl/v4 v4.5.0 h1:iZRsEvDdyhd2La0FVi5k6tYehpOR/R7qIUjmKk7N74A= github.com/bombsimon/wsl/v4 v4.5.0/go.mod h1:NOQ3aLF4nD7N5YPXMruR6ZXDOAqLoM0GEpLwTdvmOSc= -github.com/breml/bidichk v0.3.2 h1:xV4flJ9V5xWTqxL+/PMFF6dtJPvZLPsyixAoPe8BGJs= -github.com/breml/bidichk v0.3.2/go.mod h1:VzFLBxuYtT23z5+iVkamXO386OB+/sVwZOpIj6zXGos= -github.com/breml/errchkjson v0.4.0 h1:gftf6uWZMtIa/Is3XJgibewBm2ksAQSY/kABDNFTAdk= -github.com/breml/errchkjson v0.4.0/go.mod h1:AuBOSTHyLSaaAFlWsRSuRBIroCh3eh7ZHh5YeelDIk8= +github.com/breml/bidichk v0.3.3 h1:WSM67ztRusf1sMoqH6/c4OBCUlRVTKq+CbSeo0R17sE= +github.com/breml/bidichk v0.3.3/go.mod h1:ISbsut8OnjB367j5NseXEGGgO/th206dVa427kR8YTE= +github.com/breml/errchkjson v0.4.1 h1:keFSS8D7A2T0haP9kzZTi7o26r7kE3vymjZNeNDRDwg= +github.com/breml/errchkjson v0.4.1/go.mod h1:a23OvR6Qvcl7DG/Z4o0el6BRAjKnaReoPQFciAl9U3s= github.com/butuzov/ireturn v0.3.1 h1:mFgbEI6m+9W8oP/oDdfA34dLisRFCj2G6o/yiI1yZrY= github.com/butuzov/ireturn v0.3.1/go.mod h1:ZfRp+E7eJLC0NQmk1Nrm1LOrn/gQlOykv+cVPdiXH5M= github.com/butuzov/mirror v1.3.0 h1:HdWCXzmwlQHdVhwvsfBb2Au0r3HyINry3bDWLYXiKoc= @@ -118,8 +118,8 @@ github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+U github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/ckaznocha/intrange v0.3.0 h1:VqnxtK32pxgkhJgYQEeOArVidIPg+ahLP7WBOXZd5ZY= -github.com/ckaznocha/intrange v0.3.0/go.mod h1:+I/o2d2A1FBHgGELbGxzIcyd3/9l9DuwjM8FsbSS3Lo= +github.com/ckaznocha/intrange v0.3.1 h1:j1onQyXvHUsPWujDH6WIjhyH26gkRt/txNlV7LspvJs= +github.com/ckaznocha/intrange v0.3.1/go.mod h1:QVepyz1AkUoFQkpEqksSYpNpUo3c5W7nWh/s6SHIJJk= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -152,8 +152,8 @@ github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwV github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= -github.com/ghostiam/protogetter v0.3.9 h1:j+zlLLWzqLay22Cz/aYwTHKQ88GE2DQ6GkWSYFOI4lQ= -github.com/ghostiam/protogetter v0.3.9/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= +github.com/ghostiam/protogetter v0.3.12 h1:xTPjH97iKph27vXRRKV0OCke5sAMoHPbVeVstdzmCLE= +github.com/ghostiam/protogetter v0.3.12/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= github.com/go-critic/go-critic v0.12.0 h1:iLosHZuye812wnkEz1Xu3aBwn5ocCPfc9yqmFG9pa6w= github.com/go-critic/go-critic v0.12.0/go.mod h1:DpE0P6OVc6JzVYzmM5gq5jMU31zLr4am5mB/VfFK64w= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= diff --git a/tools/vendor/github.com/ckaznocha/intrange/.golangci.yml b/tools/vendor/github.com/ckaznocha/intrange/.golangci.yml index b240f85ce..74a80105c 100644 --- a/tools/vendor/github.com/ckaznocha/intrange/.golangci.yml +++ b/tools/vendor/github.com/ckaznocha/intrange/.golangci.yml @@ -15,6 +15,7 @@ linters-settings: local-prefixes: github.com/ckaznocha/intrange govet: enable: + - appends - asmdecl - assign - atomic @@ -22,10 +23,11 @@ linters-settings: - bools - buildtag - cgocall - - composite - - copylock - - copyloopvar + - composites + - copylocks - deepequalerrors + - defers + - directive - errorsas - fieldalignment - findcall @@ -37,18 +39,25 @@ linters-settings: - nilfunc - nilness - printf + - reflectvaluecompare - shadow - shift + - sigchanyzer + - slog - sortslice - stdmethods + - stdversion - stringintconv - structtag - testinggoroutine - tests + - timeformat - unmarshal - unreachable - unsafeptr - unusedresult + - unusedwrite + - waitgroup misspell: locale: US linters: diff --git a/tools/vendor/github.com/ckaznocha/intrange/go.work b/tools/vendor/github.com/ckaznocha/intrange/go.work index 3814c99f9..b7e127dcb 100644 --- a/tools/vendor/github.com/ckaznocha/intrange/go.work +++ b/tools/vendor/github.com/ckaznocha/intrange/go.work @@ -1,4 +1,6 @@ -go 1.22 +go 1.23.0 + +toolchain go1.23.4 use ( . diff --git a/tools/vendor/github.com/ckaznocha/intrange/intrange.go b/tools/vendor/github.com/ckaznocha/intrange/intrange.go index 229c847d5..79aca7973 100644 --- a/tools/vendor/github.com/ckaznocha/intrange/intrange.go +++ b/tools/vendor/github.com/ckaznocha/intrange/intrange.go @@ -265,6 +265,15 @@ func checkForStmt(pass *analysis.Pass, forStmt *ast.ForStmt) { replacement = fmt.Sprintf("range %s", rangeX) } + if isFunctionOrMethodCall(operand) { + pass.Report(analysis.Diagnostic{ + Pos: forStmt.Pos(), + Message: msg + "\nBecause the key is returned by a function or method, take care to consider side effects.", + }) + + return + } + pass.Report(analysis.Diagnostic{ Pos: forStmt.Pos(), Message: msg, @@ -315,12 +324,11 @@ func checkRangeStmt(pass *analysis.Pass, rangeStmt *ast.RangeStmt) { return } - fn, ok := x.Fun.(*ast.Ident) - if !ok { + if _, ok = x.Fun.(*ast.Ident); !ok { return } - if fn.Name != "len" || len(x.Args) != 1 { + if !isLen(x) { return } @@ -385,7 +393,7 @@ func checkRangeStmt(pass *analysis.Pass, rangeStmt *ast.RangeStmt) { func findNExpr(expr ast.Expr) ast.Expr { switch e := expr.(type) { case *ast.CallExpr: - if fun, ok := e.Fun.(*ast.Ident); ok && fun.Name == "len" && len(e.Args) == 1 { + if isLen(e) { return findNExpr(e.Args[0]) } @@ -439,6 +447,8 @@ func recursiveOperandToString( return recursiveOperandToString(e.X, false) + "[" + recursiveOperandToString(e.Index, false) + "]" case *ast.BinaryExpr: return recursiveOperandToString(e.X, false) + " " + e.Op.String() + " " + recursiveOperandToString(e.Y, false) + case *ast.StarExpr: + return "*" + recursiveOperandToString(e.X, false) default: return "" } @@ -526,19 +536,7 @@ func isNumberLit(exp ast.Expr) bool { case *ast.CallExpr: switch fun := lit.Fun.(type) { case *ast.Ident: - switch fun.Name { - case - "int", - "int8", - "int16", - "int32", - "int64", - "uint", - "uint8", - "uint16", - "uint32", - "uint64": - default: + if !isIntCast(fun) { return false } default: @@ -573,19 +571,7 @@ func compareNumberLit(exp ast.Expr, val int) bool { case *ast.CallExpr: switch fun := lit.Fun.(type) { case *ast.Ident: - switch fun.Name { - case - "int", - "int8", - "int16", - "int32", - "int64", - "uint", - "uint8", - "uint16", - "uint32", - "uint64": - default: + if !isIntCast(fun) { return false } default: @@ -623,5 +609,58 @@ func operandToString( return s } + if operandIdent, ok := operand.(*ast.Ident); ok { + if operandType := pass.TypesInfo.TypeOf(operandIdent); operandType != nil && + operandType == t { + return s + } + } + return t.String() + "(" + s + ")" } + +func isFunctionOrMethodCall(expr ast.Expr) bool { + e, ok := expr.(*ast.CallExpr) + if !ok { + return false + } + + fun, ok := e.Fun.(*ast.Ident) + if !ok { + return true + } + + if isLen(e) || isIntCast(fun) { + return false + } + + return true +} + +func isIntCast(ident *ast.Ident) bool { + switch ident.Name { + case + "int", + "int8", + "int16", + "int32", + "int64", + "uint", + "uint8", + "uint16", + "uint32", + "uint64": + return true + default: + return false + } +} + +func isLen(exp *ast.CallExpr) bool { + fun, ok := exp.Fun.(*ast.Ident) + if !ok { + return false + } + + return fun.Name == "len" && len(exp.Args) == 1 +} diff --git a/tools/vendor/github.com/ghostiam/protogetter/flake.lock b/tools/vendor/github.com/ghostiam/protogetter/flake.lock new file mode 100644 index 000000000..5ed1735b1 --- /dev/null +++ b/tools/vendor/github.com/ghostiam/protogetter/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1742069588, + "narHash": "sha256-C7jVfohcGzdZRF6DO+ybyG/sqpo1h6bZi9T56sxLy+k=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c80f6a7e10b39afcc1894e02ef785b1ad0b0d7e5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/tools/vendor/github.com/ghostiam/protogetter/flake.nix b/tools/vendor/github.com/ghostiam/protogetter/flake.nix new file mode 100644 index 000000000..b6f01c4f5 --- /dev/null +++ b/tools/vendor/github.com/ghostiam/protogetter/flake.nix @@ -0,0 +1,69 @@ +{ + description = "A flake that builds a repo"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + inputs@{ + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + buildInputs = with pkgs; [ + go + coreutils + curl + xmlstarlet + + # Protobuf + gRPC + protobuf + protoc-gen-go + protoc-gen-go-grpc + grpc + ]; + + defaultShellHook = '' + export SHELL="${pkgs.bashInteractive}/bin/bash" + + export FLAKE_ROOT=$(nix flake metadata | grep 'Resolved URL' | awk '{print $3}' | awk -F'://' '{print $2}') + export HISTFILE="$FLAKE_ROOT/.nix_bash_history" + + export GOROOT="${pkgs.go}/share/go" + ''; + in + { + # run: `nix develop` + devShells = { + default = pkgs.mkShell { + inherit buildInputs; + shellHook = defaultShellHook; + }; + + # Update IDEA paths. Use only if nix installed in whole system. + # run: `nix develop .#idea` + idea = pkgs.mkShell { + inherit buildInputs; + + shellHook = pkgs.lib.concatLines [ + defaultShellHook + '' + cd "$FLAKE_ROOT" + + echo "Replace GOPATH" + xmlstarlet ed -L -u '//project/component[@name="GOROOT"]/@url' -v 'file://${pkgs.go}/share/go' .idea/workspace.xml + + exit 0 + '' + ]; + }; + }; + } + ); +} diff --git a/tools/vendor/github.com/ghostiam/protogetter/processor.go b/tools/vendor/github.com/ghostiam/protogetter/processor.go index 44f346e85..f1c876a0a 100644 --- a/tools/vendor/github.com/ghostiam/protogetter/processor.go +++ b/tools/vendor/github.com/ghostiam/protogetter/processor.go @@ -33,12 +33,21 @@ func (c *processor) process(n ast.Node) (*Result, error) { switch x := n.(type) { case *ast.AssignStmt: // Skip any assignment to the field. - for _, s := range x.Lhs { + for i, s := range x.Lhs { c.filter.AddPos(s.Pos()) if se, ok := s.(*ast.StarExpr); ok { c.filter.AddPos(se.X.Pos()) } + + if len(x.Rhs) > i { + value := x.Rhs[i] + if se, ok := value.(*ast.SelectorExpr); ok { + if hasPointerKeyWithoutPointerGetter(c.info, s, se) { + c.filter.AddPos(se.Sel.Pos()) + } + } + } } case *ast.IncDecStmt: @@ -52,6 +61,13 @@ func (c *processor) process(n ast.Node) (*Result, error) { c.filter.AddPos(x.X.Pos()) } + case *ast.KeyValueExpr: + if se, ok := x.Value.(*ast.SelectorExpr); ok { + if hasPointerKeyWithoutPointerGetter(c.info, x.Key, se) { + c.filter.AddPos(se.Sel.Pos()) + } + } + case *ast.CallExpr: if !c.cfg.ReplaceFirstArgInAppend && len(x.Args) > 0 { if v, ok := x.Fun.(*ast.Ident); ok && v.Name == "append" { @@ -176,8 +192,11 @@ func (c *processor) processInner(expr ast.Expr) { c.processInner(x.X) c.write(".") + // Skip if the field is filtered. + isFiltered := c.filter.IsFiltered(x.Sel.Pos()) + // If getter exists, use it. - if methodIsExists(c.info, x.X, "Get"+x.Sel.Name) { + if methodIsExists(c.info, x.X, "Get"+x.Sel.Name) && !isFiltered { c.writeFrom(x.Sel.Name) c.writeTo("Get" + x.Sel.Name + "()") return @@ -218,7 +237,7 @@ func (c *processor) processInner(expr ast.Expr) { c.write("*") c.processInner(x.X) - case *ast.CompositeLit, *ast.TypeAssertExpr, *ast.ArrayType, *ast.FuncLit, *ast.SliceExpr: + case *ast.CompositeLit, *ast.TypeAssertExpr, *ast.ArrayType, *ast.FuncLit, *ast.SliceExpr, *ast.MapType: // Process the node as is. c.write(formatNode(x)) @@ -349,3 +368,17 @@ func getterResultHasPointer(info *types.Info, x ast.Expr, name string) (hasPoint return false, false } + +func hasPointerKeyWithoutPointerGetter(info *types.Info, key ast.Expr, value *ast.SelectorExpr) bool { + _, isPtr := info.TypeOf(key).(*types.Pointer) + if !isPtr { + return false + } + + getterHasPointer, ok := getterResultHasPointer(info, value.X, value.Sel.Name) + if !ok { + return false + } + + return !getterHasPointer +} diff --git a/tools/vendor/github.com/ghostiam/protogetter/protogetter.go b/tools/vendor/github.com/ghostiam/protogetter/protogetter.go index c1c42c75d..0dbcf31c9 100644 --- a/tools/vendor/github.com/ghostiam/protogetter/protogetter.go +++ b/tools/vendor/github.com/ghostiam/protogetter/protogetter.go @@ -96,6 +96,7 @@ func Run(pass *analysis.Pass, cfg *Config) error { (*ast.StarExpr)(nil), (*ast.IncDecStmt)(nil), (*ast.UnaryExpr)(nil), + (*ast.KeyValueExpr)(nil), } // Skip filtered files. diff --git a/tools/vendor/modules.txt b/tools/vendor/modules.txt index 820cdbe0d..1c0db20fd 100644 --- a/tools/vendor/modules.txt +++ b/tools/vendor/modules.txt @@ -81,11 +81,11 @@ github.com/blizzy78/varnamelen # github.com/bombsimon/wsl/v4 v4.5.0 ## explicit; go 1.22 github.com/bombsimon/wsl/v4 -# github.com/breml/bidichk v0.3.2 -## explicit; go 1.22.0 +# github.com/breml/bidichk v0.3.3 +## explicit; go 1.23.0 github.com/breml/bidichk/pkg/bidichk -# github.com/breml/errchkjson v0.4.0 -## explicit; go 1.22.0 +# github.com/breml/errchkjson v0.4.1 +## explicit; go 1.23.0 github.com/breml/errchkjson # github.com/butuzov/ireturn v0.3.1 ## explicit; go 1.18 @@ -119,8 +119,8 @@ github.com/charithe/durationcheck # github.com/chavacava/garif v0.1.0 ## explicit; go 1.16 github.com/chavacava/garif -# github.com/ckaznocha/intrange v0.3.0 -## explicit; go 1.22 +# github.com/ckaznocha/intrange v0.3.1 +## explicit; go 1.23.0 github.com/ckaznocha/intrange # github.com/curioswitch/go-reassign v0.3.0 ## explicit; go 1.21 @@ -161,7 +161,7 @@ github.com/fsnotify/fsnotify # github.com/fzipp/gocyclo v0.6.0 ## explicit; go 1.18 github.com/fzipp/gocyclo -# github.com/ghostiam/protogetter v0.3.9 +# github.com/ghostiam/protogetter v0.3.12 ## explicit; go 1.22.0 github.com/ghostiam/protogetter # github.com/go-critic/go-critic v0.12.0 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/CHANGELOG.md index cf422304e..bd9667d99 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/CHANGELOG.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/CHANGELOG.md @@ -1,5 +1,12 @@ # Release History +## 1.17.1 (2025-03-20) + +### Other Changes + +* Upgraded to Go 1.23 +* Upgraded dependencies + ## 1.17.0 (2025-01-07) ### Features Added diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/shared/constants.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/shared/constants.go index 44ab00d40..c8929e596 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/shared/constants.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/shared/constants.go @@ -40,5 +40,5 @@ const ( Module = "azcore" // Version is the semantic version (see http://semver.org) of this module. - Version = "v1.17.0" + Version = "v1.17.1" ) diff --git a/vendor/github.com/aws/aws-sdk-go-v2/config/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/config/CHANGELOG.md index 97f59c071..9bcc21600 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/config/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/config/CHANGELOG.md @@ -1,3 +1,7 @@ +# v1.29.9 (2025-03-04.2) + +* **Dependency Update**: Updated to the latest SDK module versions + # v1.29.8 (2025-02-27) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/config/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/config/go_module_metadata.go index da7e89e28..51b0c57ce 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/config/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/config/go_module_metadata.go @@ -3,4 +3,4 @@ package config // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.29.8" +const goModuleVersion = "1.29.9" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/credentials/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/credentials/CHANGELOG.md index 8357cce2d..c5fe7ddca 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/credentials/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/credentials/CHANGELOG.md @@ -1,3 +1,7 @@ +# v1.17.62 (2025-03-04.2) + +* **Dependency Update**: Updated to the latest SDK module versions + # v1.17.61 (2025-02-27) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/credentials/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/credentials/go_module_metadata.go index 393107898..628b3d582 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/credentials/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/credentials/go_module_metadata.go @@ -3,4 +3,4 @@ package credentials // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.17.61" +const goModuleVersion = "1.17.62" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/CHANGELOG.md index b3d70bd79..957c0c940 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/CHANGELOG.md @@ -1,3 +1,7 @@ +# v1.25.1 (2025-03-04.2) + +* **Bug Fix**: Add assurance test for operation order. + # v1.25.0 (2025-02-27) * **Feature**: Track credential providers via User-Agent Feature ids diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/generated.json b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/generated.json index abbb7ea18..1a88fe4df 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/generated.json +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/generated.json @@ -25,6 +25,7 @@ "protocol_test.go", "serializers.go", "snapshot_test.go", + "sra_operation_order_test.go", "types/errors.go", "types/types.go", "validators.go" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/go_module_metadata.go index 429aa0cdb..b4e199605 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/go_module_metadata.go @@ -3,4 +3,4 @@ package sso // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.25.0" +const goModuleVersion = "1.25.1" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/CHANGELOG.md index c040c3ed9..7f2d6f3ac 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/CHANGELOG.md @@ -1,3 +1,7 @@ +# v1.29.1 (2025-03-04.2) + +* **Bug Fix**: Add assurance test for operation order. + # v1.29.0 (2025-02-27) * **Feature**: Track credential providers via User-Agent Feature ids diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/generated.json b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/generated.json index 23d72cf0f..35f180975 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/generated.json +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/generated.json @@ -25,6 +25,7 @@ "protocol_test.go", "serializers.go", "snapshot_test.go", + "sra_operation_order_test.go", "types/errors.go", "types/types.go", "validators.go" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/go_module_metadata.go index 5467b2f28..1fad8e390 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/go_module_metadata.go @@ -3,4 +3,4 @@ package ssooidc // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.29.0" +const goModuleVersion = "1.29.1" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/CHANGELOG.md index 557e03bd0..79ff72d75 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/CHANGELOG.md @@ -1,3 +1,7 @@ +# v1.33.17 (2025-03-04.2) + +* **Bug Fix**: Add assurance test for operation order. + # v1.33.16 (2025-02-27) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/generated.json b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/generated.json index 643c5c694..86bb3b79b 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/generated.json +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/generated.json @@ -32,6 +32,7 @@ "protocol_test.go", "serializers.go", "snapshot_test.go", + "sra_operation_order_test.go", "types/errors.go", "types/types.go", "validators.go" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/go_module_metadata.go index 32af427ca..18e1e4735 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/go_module_metadata.go @@ -3,4 +3,4 @@ package sts // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.33.16" +const goModuleVersion = "1.33.17" diff --git a/vendor/github.com/charmbracelet/bubbletea/inputreader_other.go b/vendor/github.com/charmbracelet/bubbletea/inputreader_other.go index 8e63a87dc..3426a177c 100644 --- a/vendor/github.com/charmbracelet/bubbletea/inputreader_other.go +++ b/vendor/github.com/charmbracelet/bubbletea/inputreader_other.go @@ -9,6 +9,6 @@ import ( "github.com/muesli/cancelreader" ) -func newInputReader(r io.Reader) (cancelreader.CancelReader, error) { +func newInputReader(r io.Reader, _ bool) (cancelreader.CancelReader, error) { return cancelreader.NewReader(r) } diff --git a/vendor/github.com/charmbracelet/bubbletea/inputreader_windows.go b/vendor/github.com/charmbracelet/bubbletea/inputreader_windows.go index dd5277cf0..9af89428d 100644 --- a/vendor/github.com/charmbracelet/bubbletea/inputreader_windows.go +++ b/vendor/github.com/charmbracelet/bubbletea/inputreader_windows.go @@ -25,7 +25,7 @@ type conInputReader struct { var _ cancelreader.CancelReader = &conInputReader{} -func newInputReader(r io.Reader) (cancelreader.CancelReader, error) { +func newInputReader(r io.Reader, enableMouse bool) (cancelreader.CancelReader, error) { fallback := func(io.Reader) (cancelreader.CancelReader, error) { return cancelreader.NewReader(r) } @@ -38,11 +38,21 @@ func newInputReader(r io.Reader) (cancelreader.CancelReader, error) { return fallback(r) } - originalMode, err := prepareConsole(conin, - windows.ENABLE_MOUSE_INPUT, + modes := []uint32{ windows.ENABLE_WINDOW_INPUT, windows.ENABLE_EXTENDED_FLAGS, - ) + } + + // Since we have options to enable mouse events, [WithMouseCellMotion], + // [WithMouseAllMotion], and [EnableMouseCellMotion], + // [EnableMouseAllMotion], and [DisableMouse], we need to check if the user + // has enabled mouse events and add the appropriate mode accordingly. + // Otherwise, mouse events will be enabled all the time. + if enableMouse { + modes = append(modes, windows.ENABLE_MOUSE_INPUT) + } + + originalMode, err := prepareConsole(conin, modes...) if err != nil { return nil, fmt.Errorf("failed to prepare console input: %w", err) } diff --git a/vendor/github.com/charmbracelet/bubbletea/tea.go b/vendor/github.com/charmbracelet/bubbletea/tea.go index 743a866e9..0bc915e5b 100644 --- a/vendor/github.com/charmbracelet/bubbletea/tea.go +++ b/vendor/github.com/charmbracelet/bubbletea/tea.go @@ -16,6 +16,7 @@ import ( "io" "os" "os/signal" + "runtime" "runtime/debug" "sync" "sync/atomic" @@ -183,6 +184,9 @@ type Program struct { // fps is the frames per second we should set on the renderer, if // applicable, fps int + + // mouseMode is true if the program should enable mouse mode on Windows. + mouseMode bool } // Quit is a special command that tells the Bubble Tea program to exit. @@ -413,9 +417,25 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) { // mouse mode (1006) is a no-op if the terminal doesn't support it. p.renderer.enableMouseSGRMode() + // XXX: This is used to enable mouse mode on Windows. We need + // to reinitialize the cancel reader to get the mouse events to + // work. + if runtime.GOOS == "windows" && !p.mouseMode { + p.mouseMode = true + p.initCancelReader(true) //nolint:errcheck + } + case disableMouseMsg: p.disableMouse() + // XXX: On Windows, mouse mode is enabled on the input reader + // level. We need to instruct the input reader to stop reading + // mouse events. + if runtime.GOOS == "windows" && p.mouseMode { + p.mouseMode = false + p.initCancelReader(true) //nolint:errcheck + } + case showCursorMsg: p.renderer.showCursor() @@ -579,6 +599,11 @@ func (p *Program) Run() (Model, error) { p.renderer.enableMouseAllMotion() p.renderer.enableMouseSGRMode() } + + // XXX: Should we enable mouse mode on Windows? + // This needs to happen before initializing the cancel and input reader. + p.mouseMode = p.startupOptions&withMouseCellMotion != 0 || p.startupOptions&withMouseAllMotion != 0 + if p.startupOptions&withReportFocus != 0 { p.renderer.enableReportFocus() } @@ -607,7 +632,7 @@ func (p *Program) Run() (Model, error) { // Subscribe to user input. if p.input != nil { - if err := p.initCancelReader(); err != nil { + if err := p.initCancelReader(false); err != nil { return model, err } } @@ -763,7 +788,7 @@ func (p *Program) RestoreTerminal() error { if err := p.initTerminal(); err != nil { return err } - if err := p.initCancelReader(); err != nil { + if err := p.initCancelReader(false); err != nil { return err } if p.altScreenWasActive { diff --git a/vendor/github.com/charmbracelet/bubbletea/tty.go b/vendor/github.com/charmbracelet/bubbletea/tty.go index 02507782c..9490facac 100644 --- a/vendor/github.com/charmbracelet/bubbletea/tty.go +++ b/vendor/github.com/charmbracelet/bubbletea/tty.go @@ -75,9 +75,14 @@ func (p *Program) restoreInput() error { } // initCancelReader (re)commences reading inputs. -func (p *Program) initCancelReader() error { +func (p *Program) initCancelReader(cancel bool) error { + if cancel && p.cancelReader != nil { + p.cancelReader.Cancel() + p.waitForReadLoop() + } + var err error - p.cancelReader, err = newInputReader(p.input) + p.cancelReader, err = newInputReader(p.input, p.mouseMode) if err != nil { return fmt.Errorf("error creating cancelreader: %w", err) } diff --git a/vendor/github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/internal/pulumiUtilities.go b/vendor/github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/internal/pulumiUtilities.go index 68df11139..99a591934 100644 --- a/vendor/github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/internal/pulumiUtilities.go +++ b/vendor/github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/internal/pulumiUtilities.go @@ -165,7 +165,7 @@ func callPlainInner( func PkgResourceDefaultOpts(opts []pulumi.ResourceOption) []pulumi.ResourceOption { defaults := []pulumi.ResourceOption{} - version := semver.MustParse("2.21.0") + version := semver.MustParse("2.21.1") if !version.Equals(semver.Version{}) { defaults = append(defaults, pulumi.Version(version.String())) } @@ -176,7 +176,7 @@ func PkgResourceDefaultOpts(opts []pulumi.ResourceOption) []pulumi.ResourceOptio func PkgInvokeDefaultOpts(opts []pulumi.InvokeOption) []pulumi.InvokeOption { defaults := []pulumi.InvokeOption{} - version := semver.MustParse("2.21.0") + version := semver.MustParse("2.21.1") if !version.Equals(semver.Version{}) { defaults = append(defaults, pulumi.Version(version.String())) } diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/.version b/vendor/github.com/pulumi/pulumi/sdk/v3/.version index 9c8371d40..4c6305b6e 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/.version +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/.version @@ -1 +1 @@ -3.152.0 +3.154.0 diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/optrefresh/optrefresh.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/optrefresh/optrefresh.go index e0834c318..e1113919b 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/optrefresh/optrefresh.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/optrefresh/optrefresh.go @@ -122,6 +122,13 @@ func SuppressOutputs() Option { }) } +// Display operation as a rich diff showing the overall change. +func Diff() Option { + return optionFunc(func(o *Options) { + o.Diff = true + }) +} + // ConfigFile specifies a file to use for configuration values rather than detecting the file name func ConfigFile(path string) Option { return optionFunc(func(opts *Options) { @@ -169,6 +176,8 @@ type Options struct { SuppressOutputs bool // Run using the configuration values in the specified file rather than detecting the file name ConfigFile string + // When set, display operation as a rich diff showing the overall change + Diff bool } type optionFunc func(*Options) diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/optrename/optrename.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/optrename/optrename.go new file mode 100644 index 000000000..3d8ea50bd --- /dev/null +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/optrename/optrename.go @@ -0,0 +1,66 @@ +// Copyright 2016-2025, Pulumi Corporation. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package optrename contains functional options to be used with stack rename operations +// github.com/sdk/v2/go/x/auto Stack.Rename(...optrename.Option) +package optrename + +import "io" + +// The new name of the stack. +func StackName(message string) Option { + return optionFunc(func(opts *Options) { + opts.StackName = message + }) +} + +// ErrorProgressStreams allows specifying one or more io.Writers to redirect incremental rename stderr +func ErrorProgressStreams(writers ...io.Writer) Option { + return optionFunc(func(opts *Options) { + opts.ErrorProgressStreams = writers + }) +} + +// ShowSecrets configures whether to show config secrets when they appear in the config. +func ShowSecrets(show bool) Option { + return optionFunc(func(opts *Options) { + opts.ShowSecrets = &show + }) +} + +// Option is a parameter to be applied to a Stack.Rename() operation +type Option interface { + ApplyOption(*Options) +} + +// ---------------------------------- implementation details ---------------------------------- + +// Options is an implementation detail +type Options struct { + // The new name for the stack. + StackName string + // ProgressStreams allows specifying one or more io.Writers to redirect incremental refresh stdout + ProgressStreams []io.Writer + // ErrorProgressStreams allows specifying one or more io.Writers to redirect incremental refresh stderr + ErrorProgressStreams []io.Writer + // Show config secrets when they appear. + ShowSecrets *bool +} + +type optionFunc func(*Options) + +// ApplyOption is an implementation detail +func (o optionFunc) ApplyOption(opts *Options) { + o(opts) +} diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/stack.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/stack.go index b21c4288f..a4728c146 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/stack.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/stack.go @@ -121,6 +121,7 @@ import ( "github.com/pulumi/pulumi/sdk/v3/go/auto/opthistory" "github.com/pulumi/pulumi/sdk/v3/go/auto/optpreview" "github.com/pulumi/pulumi/sdk/v3/go/auto/optrefresh" + "github.com/pulumi/pulumi/sdk/v3/go/auto/optrename" "github.com/pulumi/pulumi/sdk/v3/go/auto/optup" "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" "github.com/pulumi/pulumi/sdk/v3/go/common/constant" @@ -772,6 +773,9 @@ func refreshOptsToCmd(o *optrefresh.Options, s *Stack, isPreview bool) []string if o.ConfigFile != "" { args = append(args, "--config-file="+o.ConfigFile) } + if o.Diff { + args = append(args, "--diff") + } // Apply the remote args, if needed. args = append(args, s.remoteArgs()...) @@ -856,6 +860,60 @@ func (s *Stack) PreviewDestroy(ctx context.Context, opts ...optdestroy.Option) ( return res, nil } +// Rename renames the current stack. +func (s *Stack) Rename(ctx context.Context, opts ...optrename.Option) (RenameResult, error) { + var res RenameResult + + renameOpts := &optrename.Options{} + for _, o := range opts { + o.ApplyOption(renameOpts) + } + + args := renameOptsToCmd(renameOpts, s) + + stdout, stderr, code, err := s.runPulumiCmdSync( + ctx, + renameOpts.ProgressStreams, /* additionalOutputs */ + renameOpts.ErrorProgressStreams, /* additionalErrorOutputs */ + args..., + ) + if err != nil { + return res, newAutoError(fmt.Errorf("failed to rename stack: %w", err), stdout, stderr, code) + } + + historyOpts := []opthistory.Option{} + if showSecrets := renameOpts.ShowSecrets; showSecrets != nil { + historyOpts = append(historyOpts, opthistory.ShowSecrets(*showSecrets)) + } + // If it's a remote workspace, explicitly set ShowSecrets to false to prevent attempting to + // load the project file. + if s.isRemote() { + historyOpts = append(historyOpts, opthistory.ShowSecrets(false)) + } + history, err := s.History(ctx, 1 /*pageSize*/, 1 /*page*/, historyOpts...) + if err != nil { + return res, fmt.Errorf("failed to rename stack: %w", err) + } + + var summary UpdateSummary + if len(history) > 0 { + summary = history[0] + } + + res = RenameResult{ + Summary: summary, + StdOut: stdout, + StdErr: stderr, + } + + return res, nil +} + +func renameOptsToCmd(renameOpts *optrename.Options, s *Stack) []string { + args := slice.Prealloc[string](3) + return append(args, "stack", "rename", renameOpts.StackName) +} + // Destroy deletes all resources in a stack, leaving all history and configuration intact. func (s *Stack) Destroy(ctx context.Context, opts ...optdestroy.Option) (DestroyResult, error) { var res DestroyResult @@ -1301,6 +1359,13 @@ func (rr *RefreshResult) GetPermalink() (string, error) { return GetPermalink(rr.StdOut) } +// RenameResult is the output of a successful Stack.Rename operation +type RenameResult struct { + StdOut string + StdErr string + Summary UpdateSummary +} + // DestroyResult is the output of a successful Stack.Destroy operation type DestroyResult struct { StdOut string diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/apitype/policy.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/apitype/policy.go index 5d3f9380e..58289fbb1 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/apitype/policy.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/apitype/policy.go @@ -214,6 +214,7 @@ type PolicyGroupSummary struct { Name string `json:"name"` IsOrgDefault bool `json:"isOrgDefault"` NumStacks int `json:"numStacks"` + NumAccounts int `json:"numAccounts,omitempty"` NumEnabledPolicyPacks int `json:"numEnabledPolicyPacks"` } diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/apitype/service.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/apitype/service.go index 47f6e9520..3e31c364b 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/apitype/service.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/apitype/service.go @@ -31,8 +31,8 @@ const ( // via the PatchUpdateCheckpointDeltaRequest API to save on network bytes. DeltaCheckpointUploadsV2 APICapability = "delta-checkpoint-uploads-v2" - // Indicates that the service backend supports stack bulk encryption. - BulkEncrypt APICapability = "bulk-encrypt" + // Indicates that the service backend supports batch encryption. + BatchEncrypt APICapability = "batch-encrypt" ) type DeltaCheckpointUploadsConfigV2 struct { @@ -61,8 +61,8 @@ type Capabilities struct { // If non-nil, indicates that delta checkpoint updates are supported. DeltaCheckpointUpdates *DeltaCheckpointUploadsConfigV2 - // Indicates whether the service supports bulk encryption. - BulkEncryption bool + // Indicates whether the service supports batch encryption. + BatchEncryption bool } // Parse decodes the CapabilitiesResponse into a Capabilities struct for ease of use. @@ -84,8 +84,8 @@ func (r CapabilitiesResponse) Parse() (Capabilities, error) { } parsed.DeltaCheckpointUpdates = &upcfg } - case BulkEncrypt: - parsed.BulkEncryption = true + case BatchEncrypt: + parsed.BatchEncryption = true default: continue } diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/apitype/stacks.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/apitype/stacks.go index d0e52aa4f..8a1f3486c 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/apitype/stacks.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/apitype/stacks.go @@ -78,14 +78,14 @@ type EncryptValueResponse struct { Ciphertext []byte `json:"ciphertext"` } -// BulkEncryptRequest defines the request body for encrypting multiple values. -type BulkEncryptRequest struct { +// BatchEncryptRequest defines the request body for encrypting multiple values. +type BatchEncryptRequest struct { // The values to encrypt. Plaintexts [][]byte `json:"plaintexts"` } -// BulkEncryptResponse defines the response body for multiple encrypted values. -type BulkEncryptResponse struct { +// BatchEncryptResponse defines the response body for multiple encrypted values. +type BatchEncryptResponse struct { // The encrypted values, in order of the plaintexts from the request. Ciphertexts [][]byte `json:"ciphertexts"` } @@ -108,14 +108,14 @@ type Log3rdPartyDecryptionEvent struct { CommandName string `json:"commandName,omitempty"` } -// BulkDecryptValueRequest defines the request body for bulk decrypting secret values. -type BulkDecryptValueRequest struct { +// BatchDecryptRequest defines the request body for bulk decrypting secret values. +type BatchDecryptRequest struct { Ciphertexts [][]byte `json:"ciphertexts"` } -// BulkDecryptValueResponse defines the response body for bulk decrypted secret values. The key in +// BatchDecryptResponse defines the response body for bulk decrypted secret values. The key in // the map is the base64 encoding of the ciphertext. -type BulkDecryptValueResponse struct { +type BatchDecryptResponse struct { Plaintexts map[string][]byte `json:"plaintexts"` } diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/env/env.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/env/env.go index dcd2a7d87..500385a91 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/env/env.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/env/env.go @@ -18,7 +18,9 @@ package env -import "github.com/pulumi/pulumi/sdk/v3/go/common/util/env" +import ( + "github.com/pulumi/pulumi/sdk/v3/go/common/util/env" +) // Re-export some types and functions from the env library. @@ -100,6 +102,12 @@ var SuppressCopilotLink = env.Bool("SUPPRESS_COPILOT_LINK", var FallbackToStateSecretsManager = env.Bool("FALLBACK_TO_STATE_SECRETS_MANAGER", "Use the snapshot secrets manager as a fallback when the stack configuration is missing or incomplete.") +var Parallel = env.Int("PARALLEL", + "Allow P resource operations to run in parallel at once (1 for no parallelism)") + +var AccessToken = env.String("ACCESS_TOKEN", + "The access token used to authenticate with the Pulumi Service.") + // List of overrides for Plugin Download URLs. The expected format is `regexp=URL`, and multiple pairs can // be specified separated by commas, e.g. `regexp1=URL1,regexp2=URL2` // diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/config/crypt.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/config/crypt.go index 28af746e7..f1eb8e937 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/config/crypt.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/config/crypt.go @@ -38,9 +38,9 @@ type Encrypter interface { type Decrypter interface { DecryptValue(ctx context.Context, ciphertext string) (string, error) - // BulkDecrypt supports bulk decryption of secrets. + // BatchDecrypt supports decryption of secrets in a single batch round-trip, where supported. // Returns a list of decrypted values in the same order as the input ciphertexts. - BulkDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) + BatchDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) } // Crypter can both encrypt and decrypt values. @@ -61,8 +61,8 @@ func (nopCrypter) DecryptValue(ctx context.Context, ciphertext string) (string, return ciphertext, nil } -func (nopCrypter) BulkDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) { - return DefaultBulkDecrypt(ctx, NopDecrypter, ciphertexts) +func (nopCrypter) BatchDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) { + return DefaultBatchDecrypt(ctx, NopDecrypter, ciphertexts) } func (nopCrypter) EncryptValue(ctx context.Context, plaintext string) (string, error) { @@ -89,8 +89,8 @@ func (b blindingCrypter) EncryptValue(ctx context.Context, plaintext string) (st return "[secret]", nil } -func (b blindingCrypter) BulkDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) { - return DefaultBulkDecrypt(ctx, b, ciphertexts) +func (b blindingCrypter) BatchDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) { + return DefaultBatchDecrypt(ctx, b, ciphertexts) } // NewPanicCrypter returns a new config crypter that will panic if used. @@ -108,7 +108,7 @@ func (p panicCrypter) DecryptValue(ctx context.Context, _ string) (string, error panic("attempt to decrypt value") } -func (p panicCrypter) BulkDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) { +func (p panicCrypter) BatchDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) { panic("attempt to bulk decrypt values") } @@ -178,8 +178,8 @@ func (s symmetricCrypter) DecryptValue(ctx context.Context, value string) (strin return string(msg), err } -func (s symmetricCrypter) BulkDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) { - return DefaultBulkDecrypt(ctx, s, ciphertexts) +func (s symmetricCrypter) BatchDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) { + return DefaultBatchDecrypt(ctx, s, ciphertexts) } // encryptAES256GCGM returns the ciphertext and the generated nonce @@ -220,14 +220,14 @@ func (c prefixCrypter) EncryptValue(ctx context.Context, plaintext string) (stri return c.prefix + plaintext, nil } -func (c prefixCrypter) BulkDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) { - return DefaultBulkDecrypt(ctx, c, ciphertexts) +func (c prefixCrypter) BatchDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) { + return DefaultBatchDecrypt(ctx, c, ciphertexts) } -// DefaultBulkDecrypt decrypts a list of ciphertexts. Each ciphertext is decrypted individually. The returned +// DefaultBatchDecrypt decrypts a list of ciphertexts. Each ciphertext is decrypted individually. The returned // map maps from ciphertext to plaintext. This should only be used by implementers of Decrypter to implement -// their BulkDecrypt method in cases where they can't do more efficient than just individual decryptions. -func DefaultBulkDecrypt(ctx context.Context, +// their BatchDecrypt method in cases where they can't do more efficient than just individual decryptions. +func DefaultBatchDecrypt(ctx context.Context, decrypter Decrypter, ciphertexts []string, ) ([]string, error) { if len(ciphertexts) == 0 { @@ -262,6 +262,6 @@ func (c *base64Crypter) DecryptValue(ctx context.Context, s string) (string, err return string(b), nil } -func (c *base64Crypter) BulkDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) { - return DefaultBulkDecrypt(ctx, c, ciphertexts) +func (c *base64Crypter) BatchDecrypt(ctx context.Context, ciphertexts []string) ([]string, error) { + return DefaultBatchDecrypt(ctx, c, ciphertexts) } diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/langruntime_plugin.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/langruntime_plugin.go index 07faab96d..90072b13f 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/langruntime_plugin.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/langruntime_plugin.go @@ -296,14 +296,20 @@ func (h *langhost) GetRequiredPackages(info ProgramInfo) ([]workspace.PackageDes } } + source := info.Name + if strings.HasPrefix(info.Server, "git://") { + source = strings.TrimPrefix(info.Server, "git://") + info.Server = "" + } + + pluginSpec, err := workspace.NewPluginSpec( + source, apitype.PluginKind(info.Kind), version, info.Server, info.Checksums) + if err != nil { + return nil, err + } + results = append(results, workspace.PackageDescriptor{ - PluginSpec: workspace.PluginSpec{ - Name: info.Name, - Kind: apitype.PluginKind(info.Kind), - Version: version, - PluginDownloadURL: info.Server, - Checksums: info.Checksums, - }, + PluginSpec: pluginSpec, Parameterization: parameterization, }) } diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/plugin.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/plugin.go index db9ba6691..401d23ffa 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/plugin.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/plugin.go @@ -37,6 +37,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/connectivity" + "google.golang.org/grpc/health/grpc_health_v1" "google.golang.org/grpc/status" "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" @@ -554,14 +555,55 @@ func buildPluginArguments(opts pluginArgumentOptions) []string { return args } +func (p *plugin) healthCheck() bool { + if p.Conn == nil { + return false + } + + // Check that the plugin looks alive by calling gRPC's Health Check service. + // Most plugins don't actually implement this service, which is OK as we treat + // an unimplemented status as OK. + + ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond) + defer cancel() + + healthy := make(chan bool, 1) + go func() { + health := grpc_health_v1.NewHealthClient(p.Conn) + req := &grpc_health_v1.HealthCheckRequest{} + + resp, err := health.Check(ctx, req) + if err != nil { + // Treat this as healthy as most plugins don't implement gRPC's Health + // Check service. An unimplemented status is enough for us to know the + // plugin is alive. + if status.Code(err) == codes.Unimplemented { + healthy <- true + return + } + + logging.V(9).Infof("healthCheck(): failed with: %v", err) + healthy <- false + return + } + + healthy <- resp.Status == grpc_health_v1.HealthCheckResponse_SERVING + }() + + select { + case result := <-healthy: + return result + case <-ctx.Done(): // hit deadline + return false + } +} + func (p *plugin) Close() error { - pluginCrashed := true + // Something has gone wrong with the plugin if it is not healthy and we have not yet + // shut it down. + pluginCrashed := !p.healthCheck() if p.Conn != nil { - // Something has gone wrong with the plugin if it is not ready to handle requests and we have not yet - // shut it down. - pluginCrashed = p.Conn.GetState() != connectivity.Ready - contract.IgnoreClose(p.Conn) } diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/provider.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/provider.go index c389c4561..1fe6e8870 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/provider.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/provider.go @@ -52,10 +52,29 @@ type ProviderHandshakeRequest struct { // that the engine has been asked to attach to an existing running provider instance via a host/port number), this // field will be empty. ProgramDirectory *string + + // If true the engine will send URN, Name, Type and ID to the provider as part of the configuration. + ConfigureWithUrn bool } // The type of responses sent as part of a Handshake call. -type ProviderHandshakeResponse struct{} +type ProviderHandshakeResponse struct { + // True if and only if the provider supports secrets. If true, the caller should pass secrets as strongly typed + // values to the provider. + AcceptSecrets bool + + // True if and only if the provider supports strongly typed resources. If true, the caller should pass resources as + // strongly typed values to the provider. + AcceptResources bool + + // True if and only if the provider supports output values as inputs. If true, the engine should pass output values + // to the provider where possible. + AcceptOutputs bool + + // True if the provider accepts and respects autonaming configuration that the engine provides on behalf of the + // user. + SupportsAutonamingConfiguration bool +} type ParameterizeParameters interface { isParameterizeParameters() @@ -114,6 +133,21 @@ type DiffConfigRequest struct { type DiffConfigResponse = DiffResult type ConfigureRequest struct { + // The URN of the provider being configured. N.B. This will be null if configure_with_urn was false in + // Handshake. + URN *resource.URN + // The name of the provider being configured. This must match the name specified by the `urn` field, and + // is passed so that providers do not have to implement URN parsing in order to extract the name of the + // provider. N.B. This will be null if configure_with_urn was false in Handshake. + Name *string + // The type of the provider being configured. This must match the type specified by the `urn` field, and + // is passed so that providers do not have to implement URN parsing in order to extract the type of the + // provider. N.B. This will be null if configure_with_urn was false in Handshake. + Type *tokens.Type + // The ID of the provider being configured. N.B. This will be null if configure_with_urn was false in + // Handshake. + ID *resource.ID + // A map of input properties for the provider. Inputs resource.PropertyMap } @@ -315,9 +349,9 @@ type Provider interface { // Handshake is the first call made by the engine to a provider. It is used to pass the engine's address to the // provider so that it may establish its own connections back, and to establish protocol configuration that will be - // used to communicate between the two parties. Providers that support Handshake implicitly support the set of - // feature flags previously handled by Configure prior to Handshake's introduction, such as secrets and resource - // references. + // used to communicate between the two parties. Providers that support Handshake should return a response consistent + // with those returned in response to Configure calls where there is overlap due to the use of Configure prior to + // Handshake's introduction. Handshake(context.Context, ProviderHandshakeRequest) (*ProviderHandshakeResponse, error) // Parameterize adds a sub-package to this provider instance. diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/provider_plugin.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/provider_plugin.go index b0ed2f91d..9f65ffbbb 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/provider_plugin.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/provider_plugin.go @@ -192,6 +192,7 @@ func NewProviderFromSubdir(host Host, ctx *Context, pkg tokens.Package, subdir s // If we're attaching then we don't know the root or program directory. RootDirectory: nil, ProgramDirectory: nil, + ConfigureWithUrn: true, } return handshake(ctx, bin, prefix, conn, req) } @@ -247,6 +248,7 @@ func NewProviderFromSubdir(host Host, ctx *Context, pkg tokens.Package, subdir s EngineAddress: host.ServerAddr(), RootDirectory: &dir, ProgramDirectory: &dir, + ConfigureWithUrn: true, } return handshake(ctx, bin, prefix, conn, req) } @@ -275,10 +277,11 @@ func NewProviderFromSubdir(host Host, ctx *Context, pkg tokens.Package, subdir s if handshakeRes != nil { p.protocol = &pluginProtocol{ - acceptSecrets: true, - acceptResources: true, - supportsPreview: true, - acceptOutputs: true, + acceptSecrets: handshakeRes.AcceptSecrets, + acceptResources: handshakeRes.AcceptResources, + supportsPreview: true, + acceptOutputs: handshakeRes.AcceptOutputs, + supportsAutonamingConfiguration: handshakeRes.SupportsAutonamingConfiguration, } } @@ -301,10 +304,11 @@ func handshake( req *ProviderHandshakeRequest, ) (*ProviderHandshakeResponse, error) { client := pulumirpc.NewResourceProviderClient(conn) - _, err := client.Handshake(ctx, &pulumirpc.ProviderHandshakeRequest{ + res, err := client.Handshake(ctx, &pulumirpc.ProviderHandshakeRequest{ EngineAddress: req.EngineAddress, RootDirectory: req.RootDirectory, ProgramDirectory: req.ProgramDirectory, + ConfigureWithUrn: req.ConfigureWithUrn, }) if err != nil { status, ok := status.FromError(err) @@ -316,7 +320,12 @@ func handshake( } logging.V(7).Infof("Handshake: success [%v]", bin) - return &ProviderHandshakeResponse{}, nil + return &ProviderHandshakeResponse{ + AcceptSecrets: res.GetAcceptSecrets(), + AcceptResources: res.GetAcceptResources(), + AcceptOutputs: res.GetAcceptOutputs(), + SupportsAutonamingConfiguration: res.GetSupportsAutonamingConfiguration(), + }, nil } func providerPluginDialOptions(ctx *Context, pkg tokens.Package, path string) []grpc.DialOption { @@ -355,6 +364,7 @@ func NewProviderFromPath(host Host, ctx *Context, path string) (Provider, error) EngineAddress: host.ServerAddr(), RootDirectory: &dir, ProgramDirectory: &dir, + ConfigureWithUrn: true, } return handshake(ctx, bin, prefix, conn, req) } @@ -379,10 +389,11 @@ func NewProviderFromPath(host Host, ctx *Context, path string) (Provider, error) if handshakeRes != nil { p.protocol = &pluginProtocol{ - acceptSecrets: true, - acceptResources: true, - supportsPreview: true, - acceptOutputs: true, + acceptSecrets: handshakeRes.AcceptSecrets, + acceptResources: handshakeRes.AcceptResources, + supportsPreview: true, + acceptOutputs: handshakeRes.AcceptOutputs, + supportsAutonamingConfiguration: handshakeRes.SupportsAutonamingConfiguration, } } @@ -448,16 +459,22 @@ func isDiffCheckConfigLogicallyUnimplemented(err *rpcerror.Error, providerType t } func (p *provider) Handshake(ctx context.Context, req ProviderHandshakeRequest) (*ProviderHandshakeResponse, error) { - _, err := p.clientRaw.Handshake(ctx, &pulumirpc.ProviderHandshakeRequest{ + res, err := p.clientRaw.Handshake(ctx, &pulumirpc.ProviderHandshakeRequest{ EngineAddress: req.EngineAddress, RootDirectory: req.RootDirectory, ProgramDirectory: req.ProgramDirectory, + ConfigureWithUrn: req.ConfigureWithUrn, }) if err != nil { return nil, err } - return &ProviderHandshakeResponse{}, nil + return &ProviderHandshakeResponse{ + AcceptSecrets: res.GetAcceptSecrets(), + AcceptResources: res.GetAcceptResources(), + AcceptOutputs: res.GetAcceptOutputs(), + SupportsAutonamingConfiguration: res.GetSupportsAutonamingConfiguration(), + }, nil } func (p *provider) Parameterize(ctx context.Context, request ParameterizeRequest) (ParameterizeResponse, error) { @@ -933,7 +950,25 @@ func (p *provider) Configure(ctx context.Context, req ConfigureRequest) (Configu // Spawn the configure to happen in parallel. This ensures that we remain responsive elsewhere that might // want to make forward progress, even as the configure call is happening. go func() { + var urn, typ, id *string + if req.URN != nil { + urnVal := string(*req.URN) + urn = &urnVal + } + if req.ID != nil { + idVal := string(*req.ID) + id = &idVal + } + if req.Type != nil { + typVal := string(*req.Type) + typ = &typVal + } + resp, err := p.clientRaw.Configure(p.requestContext(), &pulumirpc.ConfigureRequest{ + Urn: urn, + Name: req.Name, + Type: typ, + Id: id, AcceptSecrets: true, AcceptResources: true, SendsOldInputs: true, diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/provider_server.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/provider_server.go index 6e607f67d..4aeed6856 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/provider_server.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin/provider_server.go @@ -135,16 +135,26 @@ func (p *providerServer) Handshake( ctx context.Context, req *pulumirpc.ProviderHandshakeRequest, ) (*pulumirpc.ProviderHandshakeResponse, error) { - _, err := p.provider.Handshake(ctx, ProviderHandshakeRequest{ + res, err := p.provider.Handshake(ctx, ProviderHandshakeRequest{ EngineAddress: req.EngineAddress, RootDirectory: req.RootDirectory, ProgramDirectory: req.ProgramDirectory, + ConfigureWithUrn: req.ConfigureWithUrn, }) if err != nil { return nil, err } - return &pulumirpc.ProviderHandshakeResponse{}, nil + return &pulumirpc.ProviderHandshakeResponse{ + // providerServer can shim support for all these features, so we always set them to true. Note that we do the same + // in Configure. + AcceptSecrets: true, + AcceptResources: true, + AcceptOutputs: true, + + // For features we don't shim, we just pass through the response from the provider as expected. + SupportsAutonamingConfiguration: res.SupportsAutonamingConfiguration, + }, nil } func (p *providerServer) Parameterize( @@ -360,14 +370,42 @@ func (p *providerServer) Configure(ctx context.Context, } } - if _, err := p.provider.Configure(ctx, ConfigureRequest{inputs}); err != nil { + var urn *resource.URN + if req.Urn != nil { + urnVal := resource.URN(*req.Urn) + urn = &urnVal + } + var id *resource.ID + if req.Id != nil { + idVal := resource.ID(*req.Id) + id = &idVal + } + var typ *tokens.Type + if req.Type != nil { + typVal := tokens.Type(*req.Type) + typ = &typVal + } + + _, err := p.provider.Configure(ctx, ConfigureRequest{ + URN: urn, + Name: req.Name, + Type: typ, + ID: id, + Inputs: inputs, + }) + if err != nil { return nil, err } p.keepSecrets = req.GetAcceptSecrets() p.keepResources = req.GetAcceptResources() return &pulumirpc.ConfigureResponse{ - AcceptSecrets: true, SupportsPreview: true, AcceptResources: true, AcceptOutputs: true, + // providerServer can shim support for all these features, so we always set them to true. Note that we do the same + // in Handshake (though Handshake implies SupportsPreview, so we don't shim that there). + AcceptSecrets: true, + SupportsPreview: true, + AcceptResources: true, + AcceptOutputs: true, }, nil } diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil/args.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil/args.go index 5ed125d80..39a0d1be0 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil/args.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil/args.go @@ -15,10 +15,10 @@ package cmdutil import ( + "errors" "fmt" "github.com/hashicorp/go-multierror" - "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" "github.com/spf13/cobra" ) @@ -27,10 +27,8 @@ func ArgsFunc(argsValidator cobra.PositionalArgs) cobra.PositionalArgs { return func(cmd *cobra.Command, args []string) error { err := argsValidator(cmd, args) if err != nil { - contract.IgnoreError(cmd.Help()) - Exit(err) + return errors.Join(cmd.Help(), err) } - return nil } } diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil/exit.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil/exit.go index 125426017..209d74f68 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil/exit.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil/exit.go @@ -17,7 +17,6 @@ package cmdutil import ( "fmt" "os" - "strings" "github.com/hashicorp/go-multierror" "github.com/pkg/errors" @@ -61,68 +60,47 @@ func DetailedError(err error) string { return msg } -// runPostCommandHooks runs any post-hooks present on the given cobra.Command. This logic is copied directly from -// cobra itself; see https://github.com/spf13/cobra/blob/4dab30cb33e6633c33c787106bafbfbfdde7842d/command.go#L768-L785 -// for the original. -func runPostCommandHooks(c *cobra.Command, args []string) error { - if c.PostRunE != nil { - if err := c.PostRunE(c, args); err != nil { - return err - } - } else if c.PostRun != nil { - c.PostRun(c, args) - } - for p := c; p != nil; p = p.Parent() { - if p.PersistentPostRunE != nil { - if err := p.PersistentPostRunE(c, args); err != nil { - return err - } - break - } else if p.PersistentPostRun != nil { - p.PersistentPostRun(c, args) - break +// RunFunc wraps an error-returning run func with standard Pulumi error handling. All +// Pulumi commands should wrap themselves in this to ensure consistent and appropriate +// error behavior. In particular, we want to avoid any calls to os.Exit in the middle of +// a callstack which might prohibit reaping of child processes, resources, etc. And we +// wish to avoid the default Cobra unhandled error behavior, because it is formatted +// incorrectly and needlessly prints usage. +// +// If run returns a BailError, we will not print an error message. +// +// Deprecated: Instead of using [RunFunc], you should call [DisplayErrorMessage] and then +// manually exit with `os.Exit(-1)` +func RunFunc(run func(cmd *cobra.Command, args []string) error) func(*cobra.Command, []string) { + return func(cmd *cobra.Command, args []string) { + err := run(cmd, args) + if err != nil { + DisplayErrorMessage(err) + os.Exit(-1) } } - return nil } -// RunFunc wraps an error-returning run func with standard Pulumi error handling. All Pulumi -// commands should wrap themselves in this or [RunResultFunc] to ensure consistent and appropriate -// error behavior. In particular, we want to avoid any calls to os.Exit in the middle of a -// callstack which might prohibit reaping of child processes, resources, etc. And we wish to avoid -// the default Cobra unhandled error behavior, because it is formatted incorrectly and needlessly -// prints usage. +// DisplayErrorMessage displays an error message to the user. // -// If run returns a BailError, we will not print an error message, but will still be a non-zero exit code. -func RunFunc(run func(cmd *cobra.Command, args []string) error) func(*cobra.Command, []string) { - return func(cmd *cobra.Command, args []string) { - if err := run(cmd, args); err != nil { - // Sadly, the fact that we hard-exit below means that it's up to us to replicate the Cobra post-run - // behavior here. - if postRunErr := runPostCommandHooks(cmd, args); postRunErr != nil { - err = result.MergeBails(err, postRunErr) - } - - // If we were asked to bail, that means we already printed out a message. We just need - // to quit at this point (with an error code so no one thinks we succeeded). Bailing - // always indicates a failure, just one we don't need to print a message for. - if result.IsBail(err) { - os.Exit(-1) - return - } - - // If there is a stack trace, and logging is enabled, append it. Otherwise, debug logging it. - var msg string - if logging.LogToStderr { - msg = DetailedError(err) - } else { - msg = errorMessage(err) - logging.V(3).Info(DetailedError(err)) - } +// DisplayErrorMessage respects [result.IsBail] and [logging.LogToStderr]. +func DisplayErrorMessage(err error) { + // If we were asked to bail, that means we already printed out a message. We just need + // to quit at this point (with an error code so no one thinks we succeeded). Bailing + // always indicates a failure, just one we don't need to print a message for. + if err == nil || result.IsBail(err) { + return + } - ExitError(msg) - } + var msg string + if logging.LogToStderr { + msg = DetailedError(err) + } else { + msg = errorMessage(err) + logging.V(3).Info(DetailedError(err)) } + + Diag().Errorf(diag.Message("", "%s"), msg) } // Exit exits with a given error. @@ -132,15 +110,8 @@ func Exit(err error) { // ExitError issues an error and exits with a standard error exit code. func ExitError(msg string) { - // Escape percent sign before passing the message as a format string (e.g., msg could contain %PATH% on Windows). - format := strings.ReplaceAll(msg, "%", "%%") - exitErrorCodef(-1, format) -} - -// exitErrorCodef formats the message with arguments, issues an error and exists with the given error exit code. -func exitErrorCodef(code int, format string, args ...interface{}) { - Diag().Errorf(diag.Message("", format), args...) - os.Exit(code) + Diag().Errorf(diag.Message("", "%s"), msg) + os.Exit(-1) } // errorMessage returns a message, possibly cleaning up the text if appropriate. diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/util/errutil/format_exiterr.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/util/errutil/format_exiterr.go new file mode 100644 index 000000000..856cd63f4 --- /dev/null +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/util/errutil/format_exiterr.go @@ -0,0 +1,34 @@ +// Copyright 2025, Pulumi Corporation. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package errutil + +import ( + "errors" + "fmt" + "os/exec" + "strings" +) + +// ErrorWithStderr returns an error that includes the stderr output if the error is an ExitError. +func ErrorWithStderr(err error, message string) error { + var exitErr *exec.ExitError + if errors.As(err, &exitErr) { + stderr := strings.TrimSpace(string(exitErr.Stderr)) + if len(stderr) > 0 { + return fmt.Errorf("%s: %w: %s", message, exitErr, exitErr.Stderr) + } + } + return fmt.Errorf("%s: %w", message, err) +} diff --git a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/workspace/plugins.go b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/workspace/plugins.go index 2cdfddb7c..6905032ef 100644 --- a/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/workspace/plugins.go +++ b/vendor/github.com/pulumi/pulumi/sdk/v3/go/common/workspace/plugins.go @@ -1035,6 +1035,17 @@ func NewPluginSpec( // Prefix the url with `git://`, so we can later recognize this as a git URL. pluginDownloadURL = "git://" + u.String() isGitPlugin = true + // If there is no version specified, we version the plugin ourselves. This way the user gets + // a consistent experience once the plugin is installed, and won't have any problems when the repo + // is updated. The version will then be added to the plugins SDK, and will be reused when the NewPluginSpec + // is used, so the user gets a consistent experience. + if versionStr == "" && version == nil { + var err error + version, err = gitutil.GetLatestTagOrHash(context.Background(), url) + if err != nil { + return PluginSpec{}, err + } + } } } @@ -2293,6 +2304,11 @@ func getPluginInfoAndPath( match = LegacySelectCompatiblePlugin(plugins, kind, name, version) } + // If the plugin is located in a subdir, we need to fix up the path to include the subdir. + if subdir != "" && match != nil { + match.Path = filepath.Join(match.Path, subdir) + } + if match != nil { matchPath := getPluginPath(match) logging.V(6).Infof("GetPluginPath(%s, %s, %v): found in cache at %s", kind, name, version, matchPath) @@ -2331,10 +2347,6 @@ func SelectPrereleasePlugin( ) *PluginInfo { for _, cur := range plugins { if cur.Kind == kind && cur.Name == name && cur.Version != nil && cur.Version.EQ(*version) { - // If the plugin is located in a subdir, we need to fix up the path to include the subdir. - if subdir != "" { - cur.Path = filepath.Join(cur.Path, subdir) - } return &cur } } @@ -2496,6 +2508,8 @@ func getCandidateExtensions() []string { return []string{""} } +var PluginNameRegexp = regexp.MustCompile(`^(?P
" lines in HTML files). That may be
+// because this is the only method of the 3 that has a *concept* of
+// "junk" =p for i =p for i
+
+
+## Goal #3: Make concurrent code easier to read
+
+Doing concurrency correctly is difficult. Doing it in a way that doesn't
+obfuscate what the code is actually doing is more difficult. The `conc` package
+attempts to make common operations easier by abstracting as much boilerplate
+complexity as possible.
+
+Want to run a set of concurrent tasks with a bounded set of goroutines? Use
+`pool.New()`. Want to process an ordered stream of results concurrently, but
+still maintain order? Try `stream.New()`. What about a concurrent map over
+a slice? Take a peek at `iter.Map()`.
+
+Browse some examples below for some comparisons with doing these by hand.
+
+# Examples
+
+Each of these examples forgoes propagating panics for simplicity. To see
+what kind of complexity that would add, check out the "Goal #2" header above.
+
+Spawn a set of goroutines and waiting for them to finish:
+
+
+
+
+stdlib
+conc
+
+
+
+```go
+type caughtPanicError struct {
+ val any
+ stack []byte
+}
+
+func (e *caughtPanicError) Error() string {
+ return fmt.Sprintf(
+ "panic: %q\n%s",
+ e.val,
+ string(e.stack)
+ )
+}
+
+func main() {
+ done := make(chan error)
+ go func() {
+ defer func() {
+ if v := recover(); v != nil {
+ done <- &caughtPanicError{
+ val: v,
+ stack: debug.Stack()
+ }
+ } else {
+ done <- nil
+ }
+ }()
+ doSomethingThatMightPanic()
+ }()
+ err := <-done
+ if err != nil {
+ panic(err)
+ }
+}
+```
+
+
+
+```go
+func main() {
+ var wg conc.WaitGroup
+ wg.Go(doSomethingThatMightPanic)
+ // panics with a nice stacktrace
+ wg.Wait()
+}
+```
+
+
+
+
+Process each element of a stream in a static pool of goroutines:
+
+
+
+
+stdlib
+conc
+
+
+
+```go
+func main() {
+ var wg sync.WaitGroup
+ for i := 0; i < 10; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ // crashes on panic!
+ doSomething()
+ }()
+ }
+ wg.Wait()
+}
+```
+
+
+
+```go
+func main() {
+ var wg conc.WaitGroup
+ for i := 0; i < 10; i++ {
+ wg.Go(doSomething)
+ }
+ wg.Wait()
+}
+```
+
+
+
+
+Process each element of a slice in a static pool of goroutines:
+
+
+
+
+stdlib
+conc
+
+
+
+```go
+func process(stream chan int) {
+ var wg sync.WaitGroup
+ for i := 0; i < 10; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for elem := range stream {
+ handle(elem)
+ }
+ }()
+ }
+ wg.Wait()
+}
+```
+
+
+
+```go
+func process(stream chan int) {
+ p := pool.New().WithMaxGoroutines(10)
+ for elem := range stream {
+ elem := elem
+ p.Go(func() {
+ handle(elem)
+ })
+ }
+ p.Wait()
+}
+```
+
+
+
+
+Concurrently map a slice:
+
+
+
+
+stdlib
+conc
+
+
+
+```go
+func process(values []int) {
+ feeder := make(chan int, 8)
+
+ var wg sync.WaitGroup
+ for i := 0; i < 10; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for elem := range feeder {
+ handle(elem)
+ }
+ }()
+ }
+
+ for _, value := range values {
+ feeder <- value
+ }
+ close(feeder)
+ wg.Wait()
+}
+```
+
+
+
+```go
+func process(values []int) {
+ iter.ForEach(values, handle)
+}
+```
+
+
+
+
+Process an ordered stream concurrently:
+
+
+
+
+
+stdlib
+conc
+
+
+
+```go
+func concMap(
+ input []int,
+ f func(int) int,
+) []int {
+ res := make([]int, len(input))
+ var idx atomic.Int64
+
+ var wg sync.WaitGroup
+ for i := 0; i < 10; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+
+ for {
+ i := int(idx.Add(1) - 1)
+ if i >= len(input) {
+ return
+ }
+
+ res[i] = f(input[i])
+ }
+ }()
+ }
+ wg.Wait()
+ return res
+}
+```
+
+
+
+```go
+func concMap(
+ input []int,
+ f func(*int) int,
+) []int {
+ return iter.Map(input, f)
+}
+```
+
+
+
+
+# Status
+
+This package is currently pre-1.0. There are likely to be minor breaking
+changes before a 1.0 release as we stabilize the APIs and tweak defaults.
+Please open an issue if you have questions, concerns, or requests that you'd
+like addressed before the 1.0 release. Currently, a 1.0 is targeted for
+March 2023.
diff --git a/tools/vendor/github.com/sourcegraph/conc/internal/multierror/multierror_go119.go b/tools/vendor/github.com/sourcegraph/conc/internal/multierror/multierror_go119.go
new file mode 100644
index 000000000..7087e32a8
--- /dev/null
+++ b/tools/vendor/github.com/sourcegraph/conc/internal/multierror/multierror_go119.go
@@ -0,0 +1,10 @@
+//go:build !go1.20
+// +build !go1.20
+
+package multierror
+
+import "go.uber.org/multierr"
+
+var (
+ Join = multierr.Combine
+)
diff --git a/tools/vendor/github.com/sourcegraph/conc/internal/multierror/multierror_go120.go b/tools/vendor/github.com/sourcegraph/conc/internal/multierror/multierror_go120.go
new file mode 100644
index 000000000..39cff829a
--- /dev/null
+++ b/tools/vendor/github.com/sourcegraph/conc/internal/multierror/multierror_go120.go
@@ -0,0 +1,10 @@
+//go:build go1.20
+// +build go1.20
+
+package multierror
+
+import "errors"
+
+var (
+ Join = errors.Join
+)
diff --git a/tools/vendor/github.com/sourcegraph/conc/iter/iter.go b/tools/vendor/github.com/sourcegraph/conc/iter/iter.go
new file mode 100644
index 000000000..124b4f940
--- /dev/null
+++ b/tools/vendor/github.com/sourcegraph/conc/iter/iter.go
@@ -0,0 +1,85 @@
+package iter
+
+import (
+ "runtime"
+ "sync/atomic"
+
+ "github.com/sourcegraph/conc"
+)
+
+// defaultMaxGoroutines returns the default maximum number of
+// goroutines to use within this package.
+func defaultMaxGoroutines() int { return runtime.GOMAXPROCS(0) }
+
+// Iterator can be used to configure the behaviour of ForEach
+// and ForEachIdx. The zero value is safe to use with reasonable
+// defaults.
+//
+// Iterator is also safe for reuse and concurrent use.
+type Iterator[T any] struct {
+ // MaxGoroutines controls the maximum number of goroutines
+ // to use on this Iterator's methods.
+ //
+ // If unset, MaxGoroutines defaults to runtime.GOMAXPROCS(0).
+ MaxGoroutines int
+}
+
+// ForEach executes f in parallel over each element in input.
+//
+// It is safe to mutate the input parameter, which makes it
+// possible to map in place.
+//
+// ForEach always uses at most runtime.GOMAXPROCS goroutines.
+// It takes roughly 2µs to start up the goroutines and adds
+// an overhead of roughly 50ns per element of input. For
+// a configurable goroutine limit, use a custom Iterator.
+func ForEach[T any](input []T, f func(*T)) { Iterator[T]{}.ForEach(input, f) }
+
+// ForEach executes f in parallel over each element in input,
+// using up to the Iterator's configured maximum number of
+// goroutines.
+//
+// It is safe to mutate the input parameter, which makes it
+// possible to map in place.
+//
+// It takes roughly 2µs to start up the goroutines and adds
+// an overhead of roughly 50ns per element of input.
+func (iter Iterator[T]) ForEach(input []T, f func(*T)) {
+ iter.ForEachIdx(input, func(_ int, t *T) {
+ f(t)
+ })
+}
+
+// ForEachIdx is the same as ForEach except it also provides the
+// index of the element to the callback.
+func ForEachIdx[T any](input []T, f func(int, *T)) { Iterator[T]{}.ForEachIdx(input, f) }
+
+// ForEachIdx is the same as ForEach except it also provides the
+// index of the element to the callback.
+func (iter Iterator[T]) ForEachIdx(input []T, f func(int, *T)) {
+ if iter.MaxGoroutines == 0 {
+ // iter is a value receiver and is hence safe to mutate
+ iter.MaxGoroutines = defaultMaxGoroutines()
+ }
+
+ numInput := len(input)
+ if iter.MaxGoroutines > numInput {
+ // No more concurrent tasks than the number of input items.
+ iter.MaxGoroutines = numInput
+ }
+
+ var idx atomic.Int64
+ // Create the task outside the loop to avoid extra closure allocations.
+ task := func() {
+ i := int(idx.Add(1) - 1)
+ for ; i < numInput; i = int(idx.Add(1) - 1) {
+ f(i, &input[i])
+ }
+ }
+
+ var wg conc.WaitGroup
+ for i := 0; i < iter.MaxGoroutines; i++ {
+ wg.Go(task)
+ }
+ wg.Wait()
+}
diff --git a/tools/vendor/github.com/sourcegraph/conc/iter/map.go b/tools/vendor/github.com/sourcegraph/conc/iter/map.go
new file mode 100644
index 000000000..efbe6bfaf
--- /dev/null
+++ b/tools/vendor/github.com/sourcegraph/conc/iter/map.go
@@ -0,0 +1,65 @@
+package iter
+
+import (
+ "sync"
+
+ "github.com/sourcegraph/conc/internal/multierror"
+)
+
+// Mapper is an Iterator with a result type R. It can be used to configure
+// the behaviour of Map and MapErr. The zero value is safe to use with
+// reasonable defaults.
+//
+// Mapper is also safe for reuse and concurrent use.
+type Mapper[T, R any] Iterator[T]
+
+// Map applies f to each element of input, returning the mapped result.
+//
+// Map always uses at most runtime.GOMAXPROCS goroutines. For a configurable
+// goroutine limit, use a custom Mapper.
+func Map[T, R any](input []T, f func(*T) R) []R {
+ return Mapper[T, R]{}.Map(input, f)
+}
+
+// Map applies f to each element of input, returning the mapped result.
+//
+// Map uses up to the configured Mapper's maximum number of goroutines.
+func (m Mapper[T, R]) Map(input []T, f func(*T) R) []R {
+ res := make([]R, len(input))
+ Iterator[T](m).ForEachIdx(input, func(i int, t *T) {
+ res[i] = f(t)
+ })
+ return res
+}
+
+// MapErr applies f to each element of the input, returning the mapped result
+// and a combined error of all returned errors.
+//
+// Map always uses at most runtime.GOMAXPROCS goroutines. For a configurable
+// goroutine limit, use a custom Mapper.
+func MapErr[T, R any](input []T, f func(*T) (R, error)) ([]R, error) {
+ return Mapper[T, R]{}.MapErr(input, f)
+}
+
+// MapErr applies f to each element of the input, returning the mapped result
+// and a combined error of all returned errors.
+//
+// Map uses up to the configured Mapper's maximum number of goroutines.
+func (m Mapper[T, R]) MapErr(input []T, f func(*T) (R, error)) ([]R, error) {
+ var (
+ res = make([]R, len(input))
+ errMux sync.Mutex
+ errs error
+ )
+ Iterator[T](m).ForEachIdx(input, func(i int, t *T) {
+ var err error
+ res[i], err = f(t)
+ if err != nil {
+ errMux.Lock()
+ // TODO: use stdlib errors once multierrors land in go 1.20
+ errs = multierror.Join(errs, err)
+ errMux.Unlock()
+ }
+ })
+ return res, errs
+}
diff --git a/tools/vendor/github.com/sourcegraph/conc/panics/panics.go b/tools/vendor/github.com/sourcegraph/conc/panics/panics.go
new file mode 100644
index 000000000..abbed7fa0
--- /dev/null
+++ b/tools/vendor/github.com/sourcegraph/conc/panics/panics.go
@@ -0,0 +1,102 @@
+package panics
+
+import (
+ "fmt"
+ "runtime"
+ "runtime/debug"
+ "sync/atomic"
+)
+
+// Catcher is used to catch panics. You can execute a function with Try,
+// which will catch any spawned panic. Try can be called any number of times,
+// from any number of goroutines. Once all calls to Try have completed, you can
+// get the value of the first panic (if any) with Recovered(), or you can just
+// propagate the panic (re-panic) with Repanic().
+type Catcher struct {
+ recovered atomic.Pointer[Recovered]
+}
+
+// Try executes f, catching any panic it might spawn. It is safe
+// to call from multiple goroutines simultaneously.
+func (p *Catcher) Try(f func()) {
+ defer p.tryRecover()
+ f()
+}
+
+func (p *Catcher) tryRecover() {
+ if val := recover(); val != nil {
+ rp := NewRecovered(1, val)
+ p.recovered.CompareAndSwap(nil, &rp)
+ }
+}
+
+// Repanic panics if any calls to Try caught a panic. It will panic with the
+// value of the first panic caught, wrapped in a panics.Recovered with caller
+// information.
+func (p *Catcher) Repanic() {
+ if val := p.Recovered(); val != nil {
+ panic(val)
+ }
+}
+
+// Recovered returns the value of the first panic caught by Try, or nil if
+// no calls to Try panicked.
+func (p *Catcher) Recovered() *Recovered {
+ return p.recovered.Load()
+}
+
+// NewRecovered creates a panics.Recovered from a panic value and a collected
+// stacktrace. The skip parameter allows the caller to skip stack frames when
+// collecting the stacktrace. Calling with a skip of 0 means include the call to
+// NewRecovered in the stacktrace.
+func NewRecovered(skip int, value any) Recovered {
+ // 64 frames should be plenty
+ var callers [64]uintptr
+ n := runtime.Callers(skip+1, callers[:])
+ return Recovered{
+ Value: value,
+ Callers: callers[:n],
+ Stack: debug.Stack(),
+ }
+}
+
+// Recovered is a panic that was caught with recover().
+type Recovered struct {
+ // The original value of the panic.
+ Value any
+ // The caller list as returned by runtime.Callers when the panic was
+ // recovered. Can be used to produce a more detailed stack information with
+ // runtime.CallersFrames.
+ Callers []uintptr
+ // The formatted stacktrace from the goroutine where the panic was recovered.
+ // Easier to use than Callers.
+ Stack []byte
+}
+
+// String renders a human-readable formatting of the panic.
+func (p *Recovered) String() string {
+ return fmt.Sprintf("panic: %v\nstacktrace:\n%s\n", p.Value, p.Stack)
+}
+
+// AsError casts the panic into an error implementation. The implementation
+// is unwrappable with the cause of the panic, if the panic was provided one.
+func (p *Recovered) AsError() error {
+ if p == nil {
+ return nil
+ }
+ return &ErrRecovered{*p}
+}
+
+// ErrRecovered wraps a panics.Recovered in an error implementation.
+type ErrRecovered struct{ Recovered }
+
+var _ error = (*ErrRecovered)(nil)
+
+func (p *ErrRecovered) Error() string { return p.String() }
+
+func (p *ErrRecovered) Unwrap() error {
+ if err, ok := p.Value.(error); ok {
+ return err
+ }
+ return nil
+}
diff --git a/tools/vendor/github.com/sourcegraph/conc/panics/try.go b/tools/vendor/github.com/sourcegraph/conc/panics/try.go
new file mode 100644
index 000000000..4ded92a1c
--- /dev/null
+++ b/tools/vendor/github.com/sourcegraph/conc/panics/try.go
@@ -0,0 +1,11 @@
+package panics
+
+// Try executes f, catching and returning any panic it might spawn.
+//
+// The recovered panic can be propagated with panic(), or handled as a normal error with
+// (*panics.Recovered).AsError().
+func Try(f func()) *Recovered {
+ var c Catcher
+ c.Try(f)
+ return c.Recovered()
+}
diff --git a/tools/vendor/github.com/sourcegraph/conc/waitgroup.go b/tools/vendor/github.com/sourcegraph/conc/waitgroup.go
new file mode 100644
index 000000000..47b1bc1a5
--- /dev/null
+++ b/tools/vendor/github.com/sourcegraph/conc/waitgroup.go
@@ -0,0 +1,52 @@
+package conc
+
+import (
+ "sync"
+
+ "github.com/sourcegraph/conc/panics"
+)
+
+// NewWaitGroup creates a new WaitGroup.
+func NewWaitGroup() *WaitGroup {
+ return &WaitGroup{}
+}
+
+// WaitGroup is the primary building block for scoped concurrency.
+// Goroutines can be spawned in the WaitGroup with the Go method,
+// and calling Wait() will ensure that each of those goroutines exits
+// before continuing. Any panics in a child goroutine will be caught
+// and propagated to the caller of Wait().
+//
+// The zero value of WaitGroup is usable, just like sync.WaitGroup.
+// Also like sync.WaitGroup, it must not be copied after first use.
+type WaitGroup struct {
+ wg sync.WaitGroup
+ pc panics.Catcher
+}
+
+// Go spawns a new goroutine in the WaitGroup.
+func (h *WaitGroup) Go(f func()) {
+ h.wg.Add(1)
+ go func() {
+ defer h.wg.Done()
+ h.pc.Try(f)
+ }()
+}
+
+// Wait will block until all goroutines spawned with Go exit and will
+// propagate any panics spawned in a child goroutine.
+func (h *WaitGroup) Wait() {
+ h.wg.Wait()
+
+ // Propagate a panic if we caught one from a child goroutine.
+ h.pc.Repanic()
+}
+
+// WaitAndRecover will block until all goroutines spawned with Go exit and
+// will return a *panics.Recovered if one of the child goroutines panics.
+func (h *WaitGroup) WaitAndRecover() *panics.Recovered {
+ h.wg.Wait()
+
+ // Return a recovered panic if we caught one from a child goroutine.
+ return h.pc.Recovered()
+}
diff --git a/tools/vendor/github.com/spf13/afero/README.md b/tools/vendor/github.com/spf13/afero/README.md
index 619af574f..86f154554 100644
--- a/tools/vendor/github.com/spf13/afero/README.md
+++ b/tools/vendor/github.com/spf13/afero/README.md
@@ -2,7 +2,11 @@
A FileSystem Abstraction System for Go
-[](https://github.com/spf13/afero/actions/workflows/test.yml) [](https://godoc.org/github.com/spf13/afero) [](https://gitter.im/spf13/afero?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+[](https://github.com/spf13/afero/actions?query=workflow%3ACI)
+[](https://gitter.im/spf13/afero?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+[](https://goreportcard.com/report/github.com/spf13/afero)
+
+[](https://pkg.go.dev/mod/github.com/spf13/afero)
# Overview
@@ -427,6 +431,39 @@ See the [Releases Page](https://github.com/spf13/afero/releases).
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
+## Releasing
+
+As of version 1.14.0, Afero moved implementations with third-party libraries to
+their own submodules.
+
+Releasing a new version now requires a few steps:
+
+```
+VERSION=X.Y.Z
+git tag -a v$VERSION -m "Release $VERSION"
+git push origin v$VERSION
+
+cd gcsfs
+go get github.com/spf13/afero@v$VERSION
+go mod tidy
+git commit -am "Update afero to v$VERSION"
+git tag -a gcsfs/v$VERSION -m "Release gcsfs $VERSION"
+git push origin gcsfs/v$VERSION
+cd ..
+
+cd sftpfs
+go get github.com/spf13/afero@v$VERSION
+go mod tidy
+git commit -am "Update afero to v$VERSION"
+git tag -a sftpfs/v$VERSION -m "Release sftpfs $VERSION"
+git push origin sftpfs/v$VERSION
+cd ..
+
+git push
+```
+
+TODO: move these instructions to a Makefile or something
+
## Contributors
Names in no particular order:
diff --git a/tools/vendor/github.com/spf13/cast/README.md b/tools/vendor/github.com/spf13/cast/README.md
index 120a57342..1be666a45 100644
--- a/tools/vendor/github.com/spf13/cast/README.md
+++ b/tools/vendor/github.com/spf13/cast/README.md
@@ -1,8 +1,9 @@
-cast
-====
-[](https://godoc.org/github.com/spf13/cast)
-[](https://github.com/spf13/cast/actions/workflows/go.yml)
-[](https://goreportcard.com/report/github.com/spf13/cast)
+# cast
+
+[](https://github.com/spf13/cast/actions/workflows/test.yaml)
+[](https://pkg.go.dev/mod/github.com/spf13/cast)
+
+[](https://goreportcard.com/report/github.com/spf13/cast)
Easy and safe casting from one type to another in Go
@@ -17,7 +18,7 @@ interface into a bool, etc. Cast does this intelligently when an obvious
conversion is possible. It doesn’t make any attempts to guess what you meant,
for example you can only convert a string to an int when it is a string
representation of an int such as “8”. Cast was developed for use in
-[Hugo](http://hugo.spf13.com), a website engine which uses YAML, TOML or JSON
+[Hugo](https://gohugo.io), a website engine which uses YAML, TOML or JSON
for meta data.
## Why use Cast?
@@ -72,4 +73,3 @@ the code for a complete set.
var eight interface{} = 8
cast.ToInt(eight) // 8
cast.ToInt(nil) // 0
-
diff --git a/tools/vendor/github.com/spf13/cast/caste.go b/tools/vendor/github.com/spf13/cast/caste.go
index 514d759bf..4181a2e75 100644
--- a/tools/vendor/github.com/spf13/cast/caste.go
+++ b/tools/vendor/github.com/spf13/cast/caste.go
@@ -18,6 +18,14 @@ import (
var errNegativeNotAllowed = errors.New("unable to cast negative value")
+type float64EProvider interface {
+ Float64() (float64, error)
+}
+
+type float64Provider interface {
+ Float64() float64
+}
+
// ToTimeE casts an interface to a time.Time type.
func ToTimeE(i interface{}) (tim time.Time, err error) {
return ToTimeInDefaultLocationE(i, time.UTC)
@@ -77,11 +85,14 @@ func ToDurationE(i interface{}) (d time.Duration, err error) {
d, err = time.ParseDuration(s + "ns")
}
return
- case json.Number:
+ case float64EProvider:
var v float64
v, err = s.Float64()
d = time.Duration(v)
return
+ case float64Provider:
+ d = time.Duration(s.Float64())
+ return
default:
err = fmt.Errorf("unable to cast %#v of type %T to Duration", i, i)
return
@@ -98,10 +109,31 @@ func ToBoolE(i interface{}) (bool, error) {
case nil:
return false, nil
case int:
- if i.(int) != 0 {
- return true, nil
- }
- return false, nil
+ return b != 0, nil
+ case int64:
+ return b != 0, nil
+ case int32:
+ return b != 0, nil
+ case int16:
+ return b != 0, nil
+ case int8:
+ return b != 0, nil
+ case uint:
+ return b != 0, nil
+ case uint64:
+ return b != 0, nil
+ case uint32:
+ return b != 0, nil
+ case uint16:
+ return b != 0, nil
+ case uint8:
+ return b != 0, nil
+ case float64:
+ return b != 0, nil
+ case float32:
+ return b != 0, nil
+ case time.Duration:
+ return b != 0, nil
case string:
return strconv.ParseBool(i.(string))
case json.Number:
@@ -153,12 +185,14 @@ func ToFloat64E(i interface{}) (float64, error) {
return v, nil
}
return 0, fmt.Errorf("unable to cast %#v of type %T to float64", i, i)
- case json.Number:
+ case float64EProvider:
v, err := s.Float64()
if err == nil {
return v, nil
}
return 0, fmt.Errorf("unable to cast %#v of type %T to float64", i, i)
+ case float64Provider:
+ return s.Float64(), nil
case bool:
if s {
return 1, nil
@@ -209,12 +243,14 @@ func ToFloat32E(i interface{}) (float32, error) {
return float32(v), nil
}
return 0, fmt.Errorf("unable to cast %#v of type %T to float32", i, i)
- case json.Number:
+ case float64EProvider:
v, err := s.Float64()
if err == nil {
return float32(v), nil
}
return 0, fmt.Errorf("unable to cast %#v of type %T to float32", i, i)
+ case float64Provider:
+ return float32(s.Float64()), nil
case bool:
if s {
return 1, nil
@@ -577,12 +613,12 @@ func ToUint64E(i interface{}) (uint64, error) {
switch s := i.(type) {
case string:
- v, err := strconv.ParseInt(trimZeroDecimal(s), 0, 0)
+ v, err := strconv.ParseUint(trimZeroDecimal(s), 0, 0)
if err == nil {
if v < 0 {
return 0, errNegativeNotAllowed
}
- return uint64(v), nil
+ return v, nil
}
return 0, fmt.Errorf("unable to cast %#v of type %T to uint64", i, i)
case json.Number:
@@ -896,8 +932,8 @@ func indirectToStringerOrError(a interface{}) interface{} {
return nil
}
- var errorType = reflect.TypeOf((*error)(nil)).Elem()
- var fmtStringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem()
+ errorType := reflect.TypeOf((*error)(nil)).Elem()
+ fmtStringerType := reflect.TypeOf((*fmt.Stringer)(nil)).Elem()
v := reflect.ValueOf(a)
for !v.Type().Implements(fmtStringerType) && !v.Type().Implements(errorType) && v.Kind() == reflect.Ptr && !v.IsNil() {
@@ -966,7 +1002,7 @@ func ToStringE(i interface{}) (string, error) {
// ToStringMapStringE casts an interface to a map[string]string type.
func ToStringMapStringE(i interface{}) (map[string]string, error) {
- var m = map[string]string{}
+ m := map[string]string{}
switch v := i.(type) {
case map[string]string:
@@ -996,7 +1032,7 @@ func ToStringMapStringE(i interface{}) (map[string]string, error) {
// ToStringMapStringSliceE casts an interface to a map[string][]string type.
func ToStringMapStringSliceE(i interface{}) (map[string][]string, error) {
- var m = map[string][]string{}
+ m := map[string][]string{}
switch v := i.(type) {
case map[string][]string:
@@ -1060,7 +1096,7 @@ func ToStringMapStringSliceE(i interface{}) (map[string][]string, error) {
// ToStringMapBoolE casts an interface to a map[string]bool type.
func ToStringMapBoolE(i interface{}) (map[string]bool, error) {
- var m = map[string]bool{}
+ m := map[string]bool{}
switch v := i.(type) {
case map[interface{}]interface{}:
@@ -1085,7 +1121,7 @@ func ToStringMapBoolE(i interface{}) (map[string]bool, error) {
// ToStringMapE casts an interface to a map[string]interface{} type.
func ToStringMapE(i interface{}) (map[string]interface{}, error) {
- var m = map[string]interface{}{}
+ m := map[string]interface{}{}
switch v := i.(type) {
case map[interface{}]interface{}:
@@ -1105,7 +1141,7 @@ func ToStringMapE(i interface{}) (map[string]interface{}, error) {
// ToStringMapIntE casts an interface to a map[string]int{} type.
func ToStringMapIntE(i interface{}) (map[string]int, error) {
- var m = map[string]int{}
+ m := map[string]int{}
if i == nil {
return m, fmt.Errorf("unable to cast %#v of type %T to map[string]int", i, i)
}
@@ -1146,7 +1182,7 @@ func ToStringMapIntE(i interface{}) (map[string]int, error) {
// ToStringMapInt64E casts an interface to a map[string]int64{} type.
func ToStringMapInt64E(i interface{}) (map[string]int64, error) {
- var m = map[string]int64{}
+ m := map[string]int64{}
if i == nil {
return m, fmt.Errorf("unable to cast %#v of type %T to map[string]int64", i, i)
}
@@ -1383,37 +1419,35 @@ func (f timeFormat) hasTimezone() bool {
return f.typ >= timeFormatNumericTimezone && f.typ <= timeFormatNumericAndNamedTimezone
}
-var (
- timeFormats = []timeFormat{
- {time.RFC3339, timeFormatNumericTimezone},
- {"2006-01-02T15:04:05", timeFormatNoTimezone}, // iso8601 without timezone
- {time.RFC1123Z, timeFormatNumericTimezone},
- {time.RFC1123, timeFormatNamedTimezone},
- {time.RFC822Z, timeFormatNumericTimezone},
- {time.RFC822, timeFormatNamedTimezone},
- {time.RFC850, timeFormatNamedTimezone},
- {"2006-01-02 15:04:05.999999999 -0700 MST", timeFormatNumericAndNamedTimezone}, // Time.String()
- {"2006-01-02T15:04:05-0700", timeFormatNumericTimezone}, // RFC3339 without timezone hh:mm colon
- {"2006-01-02 15:04:05Z0700", timeFormatNumericTimezone}, // RFC3339 without T or timezone hh:mm colon
- {"2006-01-02 15:04:05", timeFormatNoTimezone},
- {time.ANSIC, timeFormatNoTimezone},
- {time.UnixDate, timeFormatNamedTimezone},
- {time.RubyDate, timeFormatNumericTimezone},
- {"2006-01-02 15:04:05Z07:00", timeFormatNumericTimezone},
- {"2006-01-02", timeFormatNoTimezone},
- {"02 Jan 2006", timeFormatNoTimezone},
- {"2006-01-02 15:04:05 -07:00", timeFormatNumericTimezone},
- {"2006-01-02 15:04:05 -0700", timeFormatNumericTimezone},
- {time.Kitchen, timeFormatTimeOnly},
- {time.Stamp, timeFormatTimeOnly},
- {time.StampMilli, timeFormatTimeOnly},
- {time.StampMicro, timeFormatTimeOnly},
- {time.StampNano, timeFormatTimeOnly},
- }
-)
+var timeFormats = []timeFormat{
+ // Keep common formats at the top.
+ {"2006-01-02", timeFormatNoTimezone},
+ {time.RFC3339, timeFormatNumericTimezone},
+ {"2006-01-02T15:04:05", timeFormatNoTimezone}, // iso8601 without timezone
+ {time.RFC1123Z, timeFormatNumericTimezone},
+ {time.RFC1123, timeFormatNamedTimezone},
+ {time.RFC822Z, timeFormatNumericTimezone},
+ {time.RFC822, timeFormatNamedTimezone},
+ {time.RFC850, timeFormatNamedTimezone},
+ {"2006-01-02 15:04:05.999999999 -0700 MST", timeFormatNumericAndNamedTimezone}, // Time.String()
+ {"2006-01-02T15:04:05-0700", timeFormatNumericTimezone}, // RFC3339 without timezone hh:mm colon
+ {"2006-01-02 15:04:05Z0700", timeFormatNumericTimezone}, // RFC3339 without T or timezone hh:mm colon
+ {"2006-01-02 15:04:05", timeFormatNoTimezone},
+ {time.ANSIC, timeFormatNoTimezone},
+ {time.UnixDate, timeFormatNamedTimezone},
+ {time.RubyDate, timeFormatNumericTimezone},
+ {"2006-01-02 15:04:05Z07:00", timeFormatNumericTimezone},
+ {"02 Jan 2006", timeFormatNoTimezone},
+ {"2006-01-02 15:04:05 -07:00", timeFormatNumericTimezone},
+ {"2006-01-02 15:04:05 -0700", timeFormatNumericTimezone},
+ {time.Kitchen, timeFormatTimeOnly},
+ {time.Stamp, timeFormatTimeOnly},
+ {time.StampMilli, timeFormatTimeOnly},
+ {time.StampMicro, timeFormatTimeOnly},
+ {time.StampNano, timeFormatTimeOnly},
+}
func parseDateWith(s string, location *time.Location, formats []timeFormat) (d time.Time, e error) {
-
for _, format := range formats {
if d, e = time.Parse(format.format, s); e == nil {
diff --git a/tools/vendor/github.com/spf13/cobra/README.md b/tools/vendor/github.com/spf13/cobra/README.md
index 6444f4b7f..71757151c 100644
--- a/tools/vendor/github.com/spf13/cobra/README.md
+++ b/tools/vendor/github.com/spf13/cobra/README.md
@@ -1,4 +1,5 @@
-
+
+
Cobra is a library for creating powerful modern CLI applications.
@@ -105,7 +106,7 @@ go install github.com/spf13/cobra-cli@latest
For complete details on using the Cobra-CLI generator, please read [The Cobra Generator README](https://github.com/spf13/cobra-cli/blob/main/README.md)
-For complete details on using the Cobra library, please read the [The Cobra User Guide](site/content/user_guide.md).
+For complete details on using the Cobra library, please read [The Cobra User Guide](site/content/user_guide.md).
# License
diff --git a/tools/vendor/github.com/spf13/cobra/active_help.go b/tools/vendor/github.com/spf13/cobra/active_help.go
index 25c30e3cc..b3e2dadfe 100644
--- a/tools/vendor/github.com/spf13/cobra/active_help.go
+++ b/tools/vendor/github.com/spf13/cobra/active_help.go
@@ -35,7 +35,7 @@ const (
// This function can be called multiple times before and/or after completions are added to
// the array. Each time this function is called with the same array, the new
// ActiveHelp line will be shown below the previous ones when completion is triggered.
-func AppendActiveHelp(compArray []string, activeHelpStr string) []string {
+func AppendActiveHelp(compArray []Completion, activeHelpStr string) []Completion {
return append(compArray, fmt.Sprintf("%s%s", activeHelpMarker, activeHelpStr))
}
diff --git a/tools/vendor/github.com/spf13/cobra/bash_completionsV2.go b/tools/vendor/github.com/spf13/cobra/bash_completionsV2.go
index 1cce5c329..d2397aa36 100644
--- a/tools/vendor/github.com/spf13/cobra/bash_completionsV2.go
+++ b/tools/vendor/github.com/spf13/cobra/bash_completionsV2.go
@@ -146,7 +146,7 @@ __%[1]s_process_completion_results() {
if (((directive & shellCompDirectiveFilterFileExt) != 0)); then
# File extension filtering
- local fullFilter filter filteringCmd
+ local fullFilter="" filter filteringCmd
# Do not use quotes around the $completions variable or else newline
# characters will be kept.
@@ -177,20 +177,71 @@ __%[1]s_process_completion_results() {
__%[1]s_handle_special_char "$cur" =
# Print the activeHelp statements before we finish
+ __%[1]s_handle_activeHelp
+}
+
+__%[1]s_handle_activeHelp() {
+ # Print the activeHelp statements
if ((${#activeHelp[*]} != 0)); then
- printf "\n";
- printf "%%s\n" "${activeHelp[@]}"
- printf "\n"
-
- # The prompt format is only available from bash 4.4.
- # We test if it is available before using it.
- if (x=${PS1@P}) 2> /dev/null; then
- printf "%%s" "${PS1@P}${COMP_LINE[@]}"
- else
- # Can't print the prompt. Just print the
- # text the user had typed, it is workable enough.
- printf "%%s" "${COMP_LINE[@]}"
+ if [ -z $COMP_TYPE ]; then
+ # Bash v3 does not set the COMP_TYPE variable.
+ printf "\n";
+ printf "%%s\n" "${activeHelp[@]}"
+ printf "\n"
+ __%[1]s_reprint_commandLine
+ return
fi
+
+ # Only print ActiveHelp on the second TAB press
+ if [ $COMP_TYPE -eq 63 ]; then
+ printf "\n"
+ printf "%%s\n" "${activeHelp[@]}"
+
+ if ((${#COMPREPLY[*]} == 0)); then
+ # When there are no completion choices from the program, file completion
+ # may kick in if the program has not disabled it; in such a case, we want
+ # to know if any files will match what the user typed, so that we know if
+ # there will be completions presented, so that we know how to handle ActiveHelp.
+ # To find out, we actually trigger the file completion ourselves;
+ # the call to _filedir will fill COMPREPLY if files match.
+ if (((directive & shellCompDirectiveNoFileComp) == 0)); then
+ __%[1]s_debug "Listing files"
+ _filedir
+ fi
+ fi
+
+ if ((${#COMPREPLY[*]} != 0)); then
+ # If there are completion choices to be shown, print a delimiter.
+ # Re-printing the command-line will automatically be done
+ # by the shell when it prints the completion choices.
+ printf -- "--"
+ else
+ # When there are no completion choices at all, we need
+ # to re-print the command-line since the shell will
+ # not be doing it itself.
+ __%[1]s_reprint_commandLine
+ fi
+ elif [ $COMP_TYPE -eq 37 ] || [ $COMP_TYPE -eq 42 ]; then
+ # For completion type: menu-complete/menu-complete-backward and insert-completions
+ # the completions are immediately inserted into the command-line, so we first
+ # print the activeHelp message and reprint the command-line since the shell won't.
+ printf "\n"
+ printf "%%s\n" "${activeHelp[@]}"
+
+ __%[1]s_reprint_commandLine
+ fi
+ fi
+}
+
+__%[1]s_reprint_commandLine() {
+ # The prompt format is only available from bash 4.4.
+ # We test if it is available before using it.
+ if (x=${PS1@P}) 2> /dev/null; then
+ printf "%%s" "${PS1@P}${COMP_LINE[@]}"
+ else
+ # Can't print the prompt. Just print the
+ # text the user had typed, it is workable enough.
+ printf "%%s" "${COMP_LINE[@]}"
fi
}
@@ -201,6 +252,8 @@ __%[1]s_extract_activeHelp() {
local endIndex=${#activeHelpMarker}
while IFS='' read -r comp; do
+ [[ -z $comp ]] && continue
+
if [[ ${comp:0:endIndex} == $activeHelpMarker ]]; then
comp=${comp:endIndex}
__%[1]s_debug "ActiveHelp found: $comp"
@@ -223,16 +276,21 @@ __%[1]s_handle_completion_types() {
# If the user requested inserting one completion at a time, or all
# completions at once on the command-line we must remove the descriptions.
# https://github.com/spf13/cobra/issues/1508
- local tab=$'\t' comp
- while IFS='' read -r comp; do
- [[ -z $comp ]] && continue
- # Strip any description
- comp=${comp%%%%$tab*}
- # Only consider the completions that match
- if [[ $comp == "$cur"* ]]; then
- COMPREPLY+=("$comp")
- fi
- done < <(printf "%%s\n" "${completions[@]}")
+
+ # If there are no completions, we don't need to do anything
+ (( ${#completions[@]} == 0 )) && return 0
+
+ local tab=$'\t'
+
+ # Strip any description and escape the completion to handled special characters
+ IFS=$'\n' read -ra completions -d '' < <(printf "%%q\n" "${completions[@]%%%%$tab*}")
+
+ # Only consider the completions that match
+ IFS=$'\n' read -ra COMPREPLY -d '' < <(IFS=$'\n'; compgen -W "${completions[*]}" -- "${cur}")
+
+ # compgen looses the escaping so we need to escape all completions again since they will
+ # all be inserted on the command-line.
+ IFS=$'\n' read -ra COMPREPLY -d '' < <(printf "%%q\n" "${COMPREPLY[@]}")
;;
*)
@@ -243,11 +301,25 @@ __%[1]s_handle_completion_types() {
}
__%[1]s_handle_standard_completion_case() {
- local tab=$'\t' comp
+ local tab=$'\t'
+
+ # If there are no completions, we don't need to do anything
+ (( ${#completions[@]} == 0 )) && return 0
# Short circuit to optimize if we don't have descriptions
if [[ "${completions[*]}" != *$tab* ]]; then
- IFS=$'\n' read -ra COMPREPLY -d '' < <(compgen -W "${completions[*]}" -- "$cur")
+ # First, escape the completions to handle special characters
+ IFS=$'\n' read -ra completions -d '' < <(printf "%%q\n" "${completions[@]}")
+ # Only consider the completions that match what the user typed
+ IFS=$'\n' read -ra COMPREPLY -d '' < <(IFS=$'\n'; compgen -W "${completions[*]}" -- "${cur}")
+
+ # compgen looses the escaping so, if there is only a single completion, we need to
+ # escape it again because it will be inserted on the command-line. If there are multiple
+ # completions, we don't want to escape them because they will be printed in a list
+ # and we don't want to show escape characters in that list.
+ if (( ${#COMPREPLY[@]} == 1 )); then
+ COMPREPLY[0]=$(printf "%%q" "${COMPREPLY[0]}")
+ fi
return 0
fi
@@ -256,23 +328,39 @@ __%[1]s_handle_standard_completion_case() {
# Look for the longest completion so that we can format things nicely
while IFS='' read -r compline; do
[[ -z $compline ]] && continue
- # Strip any description before checking the length
- comp=${compline%%%%$tab*}
+
+ # Before checking if the completion matches what the user typed,
+ # we need to strip any description and escape the completion to handle special
+ # characters because those escape characters are part of what the user typed.
+ # Don't call "printf" in a sub-shell because it will be much slower
+ # since we are in a loop.
+ printf -v comp "%%q" "${compline%%%%$tab*}" &>/dev/null || comp=$(printf "%%q" "${compline%%%%$tab*}")
+
# Only consider the completions that match
[[ $comp == "$cur"* ]] || continue
+
+ # The completions matches. Add it to the list of full completions including
+ # its description. We don't escape the completion because it may get printed
+ # in a list if there are more than one and we don't want show escape characters
+ # in that list.
COMPREPLY+=("$compline")
+
+ # Strip any description before checking the length, and again, don't escape
+ # the completion because this length is only used when printing the completions
+ # in a list and we don't want show escape characters in that list.
+ comp=${compline%%%%$tab*}
if ((${#comp}>longest)); then
longest=${#comp}
fi
done < <(printf "%%s\n" "${completions[@]}")
- # If there is a single completion left, remove the description text
+ # If there is a single completion left, remove the description text and escape any special characters
if ((${#COMPREPLY[*]} == 1)); then
__%[1]s_debug "COMPREPLY[0]: ${COMPREPLY[0]}"
- comp="${COMPREPLY[0]%%%%$tab*}"
- __%[1]s_debug "Removed description from single completion, which is now: ${comp}"
- COMPREPLY[0]=$comp
- else # Format the descriptions
+ COMPREPLY[0]=$(printf "%%q" "${COMPREPLY[0]%%%%$tab*}")
+ __%[1]s_debug "Removed description from single completion, which is now: ${COMPREPLY[0]}"
+ else
+ # Format the descriptions
__%[1]s_format_comp_descriptions $longest
fi
}
diff --git a/tools/vendor/github.com/spf13/cobra/cobra.go b/tools/vendor/github.com/spf13/cobra/cobra.go
index e0b0947b0..d9cd2414e 100644
--- a/tools/vendor/github.com/spf13/cobra/cobra.go
+++ b/tools/vendor/github.com/spf13/cobra/cobra.go
@@ -176,12 +176,16 @@ func rpad(s string, padding int) string {
return fmt.Sprintf(formattedString, s)
}
-// tmpl executes the given template text on data, writing the result to w.
-func tmpl(w io.Writer, text string, data interface{}) error {
- t := template.New("top")
- t.Funcs(templateFuncs)
- template.Must(t.Parse(text))
- return t.Execute(w, data)
+func tmpl(text string) *tmplFunc {
+ return &tmplFunc{
+ tmpl: text,
+ fn: func(w io.Writer, data interface{}) error {
+ t := template.New("top")
+ t.Funcs(templateFuncs)
+ template.Must(t.Parse(text))
+ return t.Execute(w, data)
+ },
+ }
}
// ld compares two strings and returns the levenshtein distance between them.
diff --git a/tools/vendor/github.com/spf13/cobra/command.go b/tools/vendor/github.com/spf13/cobra/command.go
index 54748fc67..dbb2c298b 100644
--- a/tools/vendor/github.com/spf13/cobra/command.go
+++ b/tools/vendor/github.com/spf13/cobra/command.go
@@ -33,6 +33,9 @@ import (
const (
FlagSetByCobraAnnotation = "cobra_annotation_flag_set_by_cobra"
CommandDisplayNameAnnotation = "cobra_annotation_command_display_name"
+
+ helpFlagName = "help"
+ helpCommandName = "help"
)
// FParseErrWhitelist configures Flag parse errors to be ignored
@@ -80,11 +83,11 @@ type Command struct {
Example string
// ValidArgs is list of all valid non-flag arguments that are accepted in shell completions
- ValidArgs []string
+ ValidArgs []Completion
// ValidArgsFunction is an optional function that provides valid non-flag arguments for shell completion.
// It is a dynamic version of using ValidArgs.
// Only one of ValidArgs and ValidArgsFunction can be used for a command.
- ValidArgsFunction func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)
+ ValidArgsFunction CompletionFunc
// Expected arguments
Args PositionalArgs
@@ -168,12 +171,12 @@ type Command struct {
// usageFunc is usage func defined by user.
usageFunc func(*Command) error
// usageTemplate is usage template defined by user.
- usageTemplate string
+ usageTemplate *tmplFunc
// flagErrorFunc is func defined by user and it's called when the parsing of
// flags returns an error.
flagErrorFunc func(*Command, error) error
// helpTemplate is help template defined by user.
- helpTemplate string
+ helpTemplate *tmplFunc
// helpFunc is help func defined by user.
helpFunc func(*Command, []string)
// helpCommand is command with usage 'help'. If it's not defined by user,
@@ -186,7 +189,7 @@ type Command struct {
completionCommandGroupID string
// versionTemplate is the version template defined by user.
- versionTemplate string
+ versionTemplate *tmplFunc
// errPrefix is the error message prefix defined by user.
errPrefix string
@@ -281,6 +284,7 @@ func (c *Command) SetArgs(a []string) {
// SetOutput sets the destination for usage and error messages.
// If output is nil, os.Stderr is used.
+//
// Deprecated: Use SetOut and/or SetErr instead
func (c *Command) SetOutput(output io.Writer) {
c.outWriter = output
@@ -312,7 +316,11 @@ func (c *Command) SetUsageFunc(f func(*Command) error) {
// SetUsageTemplate sets usage template. Can be defined by Application.
func (c *Command) SetUsageTemplate(s string) {
- c.usageTemplate = s
+ if s == "" {
+ c.usageTemplate = nil
+ return
+ }
+ c.usageTemplate = tmpl(s)
}
// SetFlagErrorFunc sets a function to generate an error when flag parsing
@@ -348,12 +356,20 @@ func (c *Command) SetCompletionCommandGroupID(groupID string) {
// SetHelpTemplate sets help template to be used. Application can use it to set custom template.
func (c *Command) SetHelpTemplate(s string) {
- c.helpTemplate = s
+ if s == "" {
+ c.helpTemplate = nil
+ return
+ }
+ c.helpTemplate = tmpl(s)
}
// SetVersionTemplate sets version template to be used. Application can use it to set custom template.
func (c *Command) SetVersionTemplate(s string) {
- c.versionTemplate = s
+ if s == "" {
+ c.versionTemplate = nil
+ return
+ }
+ c.versionTemplate = tmpl(s)
}
// SetErrPrefix sets error message prefix to be used. Application can use it to set custom prefix.
@@ -434,7 +450,8 @@ func (c *Command) UsageFunc() (f func(*Command) error) {
}
return func(c *Command) error {
c.mergePersistentFlags()
- err := tmpl(c.OutOrStderr(), c.UsageTemplate(), c)
+ fn := c.getUsageTemplateFunc()
+ err := fn(c.OutOrStderr(), c)
if err != nil {
c.PrintErrln(err)
}
@@ -442,6 +459,19 @@ func (c *Command) UsageFunc() (f func(*Command) error) {
}
}
+// getUsageTemplateFunc returns the usage template function for the command
+// going up the command tree if necessary.
+func (c *Command) getUsageTemplateFunc() func(w io.Writer, data interface{}) error {
+ if c.usageTemplate != nil {
+ return c.usageTemplate.fn
+ }
+
+ if c.HasParent() {
+ return c.parent.getUsageTemplateFunc()
+ }
+ return defaultUsageFunc
+}
+
// Usage puts out the usage for the command.
// Used when a user provides invalid input.
// Can be defined by user by overriding UsageFunc.
@@ -460,15 +490,30 @@ func (c *Command) HelpFunc() func(*Command, []string) {
}
return func(c *Command, a []string) {
c.mergePersistentFlags()
+ fn := c.getHelpTemplateFunc()
// The help should be sent to stdout
// See https://github.com/spf13/cobra/issues/1002
- err := tmpl(c.OutOrStdout(), c.HelpTemplate(), c)
+ err := fn(c.OutOrStdout(), c)
if err != nil {
c.PrintErrln(err)
}
}
}
+// getHelpTemplateFunc returns the help template function for the command
+// going up the command tree if necessary.
+func (c *Command) getHelpTemplateFunc() func(w io.Writer, data interface{}) error {
+ if c.helpTemplate != nil {
+ return c.helpTemplate.fn
+ }
+
+ if c.HasParent() {
+ return c.parent.getHelpTemplateFunc()
+ }
+
+ return defaultHelpFunc
+}
+
// Help puts out the help for the command.
// Used when a user calls help [command].
// Can be defined by user by overriding HelpFunc.
@@ -543,71 +588,55 @@ func (c *Command) NamePadding() int {
}
// UsageTemplate returns usage template for the command.
+// This function is kept for backwards-compatibility reasons.
func (c *Command) UsageTemplate() string {
- if c.usageTemplate != "" {
- return c.usageTemplate
+ if c.usageTemplate != nil {
+ return c.usageTemplate.tmpl
}
if c.HasParent() {
return c.parent.UsageTemplate()
}
- return `Usage:{{if .Runnable}}
- {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
- {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
-
-Aliases:
- {{.NameAndAliases}}{{end}}{{if .HasExample}}
-
-Examples:
-{{.Example}}{{end}}{{if .HasAvailableSubCommands}}{{$cmds := .Commands}}{{if eq (len .Groups) 0}}
-
-Available Commands:{{range $cmds}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
- {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{else}}{{range $group := .Groups}}
-
-{{.Title}}{{range $cmds}}{{if (and (eq .GroupID $group.ID) (or .IsAvailableCommand (eq .Name "help")))}}
- {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if not .AllChildCommandsHaveGroup}}
-
-Additional Commands:{{range $cmds}}{{if (and (eq .GroupID "") (or .IsAvailableCommand (eq .Name "help")))}}
- {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
-
-Flags:
-{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
-
-Global Flags:
-{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
-
-Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
- {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
-
-Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
-`
+ return defaultUsageTemplate
}
// HelpTemplate return help template for the command.
+// This function is kept for backwards-compatibility reasons.
func (c *Command) HelpTemplate() string {
- if c.helpTemplate != "" {
- return c.helpTemplate
+ if c.helpTemplate != nil {
+ return c.helpTemplate.tmpl
}
if c.HasParent() {
return c.parent.HelpTemplate()
}
- return `{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}}
-
-{{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`
+ return defaultHelpTemplate
}
// VersionTemplate return version template for the command.
+// This function is kept for backwards-compatibility reasons.
func (c *Command) VersionTemplate() string {
- if c.versionTemplate != "" {
- return c.versionTemplate
+ if c.versionTemplate != nil {
+ return c.versionTemplate.tmpl
}
if c.HasParent() {
return c.parent.VersionTemplate()
}
- return `{{with .Name}}{{printf "%s " .}}{{end}}{{printf "version %s" .Version}}
-`
+ return defaultVersionTemplate
+}
+
+// getVersionTemplateFunc returns the version template function for the command
+// going up the command tree if necessary.
+func (c *Command) getVersionTemplateFunc() func(w io.Writer, data interface{}) error {
+ if c.versionTemplate != nil {
+ return c.versionTemplate.fn
+ }
+
+ if c.HasParent() {
+ return c.parent.getVersionTemplateFunc()
+ }
+ return defaultVersionFunc
}
// ErrPrefix return error message prefix for the command
@@ -894,7 +923,7 @@ func (c *Command) execute(a []string) (err error) {
// If help is called, regardless of other flags, return we want help.
// Also say we need help if the command isn't runnable.
- helpVal, err := c.Flags().GetBool("help")
+ helpVal, err := c.Flags().GetBool(helpFlagName)
if err != nil {
// should be impossible to get here as we always declare a help
// flag in InitDefaultHelpFlag()
@@ -914,7 +943,8 @@ func (c *Command) execute(a []string) (err error) {
return err
}
if versionVal {
- err := tmpl(c.OutOrStdout(), c.VersionTemplate(), c)
+ fn := c.getVersionTemplateFunc()
+ err := fn(c.OutOrStdout(), c)
if err != nil {
c.Println(err)
}
@@ -1068,12 +1098,6 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
// initialize help at the last point to allow for user overriding
c.InitDefaultHelpCmd()
- // initialize completion at the last point to allow for user overriding
- c.InitDefaultCompletionCmd()
-
- // Now that all commands have been created, let's make sure all groups
- // are properly created also
- c.checkCommandGroups()
args := c.args
@@ -1082,9 +1106,16 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
args = os.Args[1:]
}
- // initialize the hidden command to be used for shell completion
+ // initialize the __complete command to be used for shell completion
c.initCompleteCmd(args)
+ // initialize the default completion command
+ c.InitDefaultCompletionCmd(args...)
+
+ // Now that all commands have been created, let's make sure all groups
+ // are properly created also
+ c.checkCommandGroups()
+
var flags []string
if c.TraverseChildren {
cmd, flags, err = c.Traverse(args)
@@ -1187,16 +1218,16 @@ func (c *Command) checkCommandGroups() {
// If c already has help flag, it will do nothing.
func (c *Command) InitDefaultHelpFlag() {
c.mergePersistentFlags()
- if c.Flags().Lookup("help") == nil {
+ if c.Flags().Lookup(helpFlagName) == nil {
usage := "help for "
- name := c.displayName()
+ name := c.DisplayName()
if name == "" {
usage += "this command"
} else {
usage += name
}
- c.Flags().BoolP("help", "h", false, usage)
- _ = c.Flags().SetAnnotation("help", FlagSetByCobraAnnotation, []string{"true"})
+ c.Flags().BoolP(helpFlagName, "h", false, usage)
+ _ = c.Flags().SetAnnotation(helpFlagName, FlagSetByCobraAnnotation, []string{"true"})
}
}
@@ -1215,7 +1246,7 @@ func (c *Command) InitDefaultVersionFlag() {
if c.Name() == "" {
usage += "this command"
} else {
- usage += c.Name()
+ usage += c.DisplayName()
}
if c.Flags().ShorthandLookup("v") == nil {
c.Flags().BoolP("version", "v", false, usage)
@@ -1239,9 +1270,9 @@ func (c *Command) InitDefaultHelpCmd() {
Use: "help [command]",
Short: "Help about any command",
Long: `Help provides help for any command in the application.
-Simply type ` + c.displayName() + ` help [path to command] for full details.`,
- ValidArgsFunction: func(c *Command, args []string, toComplete string) ([]string, ShellCompDirective) {
- var completions []string
+Simply type ` + c.DisplayName() + ` help [path to command] for full details.`,
+ ValidArgsFunction: func(c *Command, args []string, toComplete string) ([]Completion, ShellCompDirective) {
+ var completions []Completion
cmd, _, e := c.Root().Find(args)
if e != nil {
return nil, ShellCompDirectiveNoFileComp
@@ -1253,7 +1284,7 @@ Simply type ` + c.displayName() + ` help [path to command] for full details.`,
for _, subCmd := range cmd.Commands() {
if subCmd.IsAvailableCommand() || subCmd == cmd.helpCommand {
if strings.HasPrefix(subCmd.Name(), toComplete) {
- completions = append(completions, fmt.Sprintf("%s\t%s", subCmd.Name(), subCmd.Short))
+ completions = append(completions, CompletionWithDesc(subCmd.Name(), subCmd.Short))
}
}
}
@@ -1430,10 +1461,12 @@ func (c *Command) CommandPath() string {
if c.HasParent() {
return c.Parent().CommandPath() + " " + c.Name()
}
- return c.displayName()
+ return c.DisplayName()
}
-func (c *Command) displayName() string {
+// DisplayName returns the name to display in help text. Returns command Name()
+// If CommandDisplayNameAnnoation is not set
+func (c *Command) DisplayName() string {
if displayName, ok := c.Annotations[CommandDisplayNameAnnotation]; ok {
return displayName
}
@@ -1443,7 +1476,7 @@ func (c *Command) displayName() string {
// UseLine puts out the full usage for a given command (including parents).
func (c *Command) UseLine() string {
var useline string
- use := strings.Replace(c.Use, c.Name(), c.displayName(), 1)
+ use := strings.Replace(c.Use, c.Name(), c.DisplayName(), 1)
if c.HasParent() {
useline = c.parent.CommandPath() + " " + use
} else {
@@ -1649,7 +1682,7 @@ func (c *Command) GlobalNormalizationFunc() func(f *flag.FlagSet, name string) f
// to this command (local and persistent declared here and by all parents).
func (c *Command) Flags() *flag.FlagSet {
if c.flags == nil {
- c.flags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
+ c.flags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
if c.flagErrorBuf == nil {
c.flagErrorBuf = new(bytes.Buffer)
}
@@ -1664,7 +1697,7 @@ func (c *Command) Flags() *flag.FlagSet {
func (c *Command) LocalNonPersistentFlags() *flag.FlagSet {
persistentFlags := c.PersistentFlags()
- out := flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
+ out := flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
c.LocalFlags().VisitAll(func(f *flag.Flag) {
if persistentFlags.Lookup(f.Name) == nil {
out.AddFlag(f)
@@ -1679,7 +1712,7 @@ func (c *Command) LocalFlags() *flag.FlagSet {
c.mergePersistentFlags()
if c.lflags == nil {
- c.lflags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
+ c.lflags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
if c.flagErrorBuf == nil {
c.flagErrorBuf = new(bytes.Buffer)
}
@@ -1707,7 +1740,7 @@ func (c *Command) InheritedFlags() *flag.FlagSet {
c.mergePersistentFlags()
if c.iflags == nil {
- c.iflags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
+ c.iflags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
if c.flagErrorBuf == nil {
c.flagErrorBuf = new(bytes.Buffer)
}
@@ -1736,7 +1769,7 @@ func (c *Command) NonInheritedFlags() *flag.FlagSet {
// PersistentFlags returns the persistent FlagSet specifically set in the current command.
func (c *Command) PersistentFlags() *flag.FlagSet {
if c.pflags == nil {
- c.pflags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
+ c.pflags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
if c.flagErrorBuf == nil {
c.flagErrorBuf = new(bytes.Buffer)
}
@@ -1749,9 +1782,9 @@ func (c *Command) PersistentFlags() *flag.FlagSet {
func (c *Command) ResetFlags() {
c.flagErrorBuf = new(bytes.Buffer)
c.flagErrorBuf.Reset()
- c.flags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
+ c.flags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
c.flags.SetOutput(c.flagErrorBuf)
- c.pflags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
+ c.pflags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
c.pflags.SetOutput(c.flagErrorBuf)
c.lflags = nil
@@ -1868,7 +1901,7 @@ func (c *Command) mergePersistentFlags() {
// If c.parentsPflags == nil, it makes new.
func (c *Command) updateParentsPflags() {
if c.parentsPflags == nil {
- c.parentsPflags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
+ c.parentsPflags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
c.parentsPflags.SetOutput(c.flagErrorBuf)
c.parentsPflags.SortFlags = false
}
@@ -1894,3 +1927,141 @@ func commandNameMatches(s string, t string) bool {
return s == t
}
+
+// tmplFunc holds a template and a function that will execute said template.
+type tmplFunc struct {
+ tmpl string
+ fn func(io.Writer, interface{}) error
+}
+
+var defaultUsageTemplate = `Usage:{{if .Runnable}}
+ {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
+ {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
+
+Aliases:
+ {{.NameAndAliases}}{{end}}{{if .HasExample}}
+
+Examples:
+{{.Example}}{{end}}{{if .HasAvailableSubCommands}}{{$cmds := .Commands}}{{if eq (len .Groups) 0}}
+
+Available Commands:{{range $cmds}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
+ {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{else}}{{range $group := .Groups}}
+
+{{.Title}}{{range $cmds}}{{if (and (eq .GroupID $group.ID) (or .IsAvailableCommand (eq .Name "help")))}}
+ {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if not .AllChildCommandsHaveGroup}}
+
+Additional Commands:{{range $cmds}}{{if (and (eq .GroupID "") (or .IsAvailableCommand (eq .Name "help")))}}
+ {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
+
+Flags:
+{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
+
+Global Flags:
+{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
+
+Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
+ {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
+
+Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
+`
+
+// defaultUsageFunc is equivalent to executing defaultUsageTemplate. The two should be changed in sync.
+func defaultUsageFunc(w io.Writer, in interface{}) error {
+ c := in.(*Command)
+ fmt.Fprint(w, "Usage:")
+ if c.Runnable() {
+ fmt.Fprintf(w, "\n %s", c.UseLine())
+ }
+ if c.HasAvailableSubCommands() {
+ fmt.Fprintf(w, "\n %s [command]", c.CommandPath())
+ }
+ if len(c.Aliases) > 0 {
+ fmt.Fprintf(w, "\n\nAliases:\n")
+ fmt.Fprintf(w, " %s", c.NameAndAliases())
+ }
+ if c.HasExample() {
+ fmt.Fprintf(w, "\n\nExamples:\n")
+ fmt.Fprintf(w, "%s", c.Example)
+ }
+ if c.HasAvailableSubCommands() {
+ cmds := c.Commands()
+ if len(c.Groups()) == 0 {
+ fmt.Fprintf(w, "\n\nAvailable Commands:")
+ for _, subcmd := range cmds {
+ if subcmd.IsAvailableCommand() || subcmd.Name() == helpCommandName {
+ fmt.Fprintf(w, "\n %s %s", rpad(subcmd.Name(), subcmd.NamePadding()), subcmd.Short)
+ }
+ }
+ } else {
+ for _, group := range c.Groups() {
+ fmt.Fprintf(w, "\n\n%s", group.Title)
+ for _, subcmd := range cmds {
+ if subcmd.GroupID == group.ID && (subcmd.IsAvailableCommand() || subcmd.Name() == helpCommandName) {
+ fmt.Fprintf(w, "\n %s %s", rpad(subcmd.Name(), subcmd.NamePadding()), subcmd.Short)
+ }
+ }
+ }
+ if !c.AllChildCommandsHaveGroup() {
+ fmt.Fprintf(w, "\n\nAdditional Commands:")
+ for _, subcmd := range cmds {
+ if subcmd.GroupID == "" && (subcmd.IsAvailableCommand() || subcmd.Name() == helpCommandName) {
+ fmt.Fprintf(w, "\n %s %s", rpad(subcmd.Name(), subcmd.NamePadding()), subcmd.Short)
+ }
+ }
+ }
+ }
+ }
+ if c.HasAvailableLocalFlags() {
+ fmt.Fprintf(w, "\n\nFlags:\n")
+ fmt.Fprint(w, trimRightSpace(c.LocalFlags().FlagUsages()))
+ }
+ if c.HasAvailableInheritedFlags() {
+ fmt.Fprintf(w, "\n\nGlobal Flags:\n")
+ fmt.Fprint(w, trimRightSpace(c.InheritedFlags().FlagUsages()))
+ }
+ if c.HasHelpSubCommands() {
+ fmt.Fprintf(w, "\n\nAdditional help topcis:")
+ for _, subcmd := range c.Commands() {
+ if subcmd.IsAdditionalHelpTopicCommand() {
+ fmt.Fprintf(w, "\n %s %s", rpad(subcmd.CommandPath(), subcmd.CommandPathPadding()), subcmd.Short)
+ }
+ }
+ }
+ if c.HasAvailableSubCommands() {
+ fmt.Fprintf(w, "\n\nUse \"%s [command] --help\" for more information about a command.", c.CommandPath())
+ }
+ fmt.Fprintln(w)
+ return nil
+}
+
+var defaultHelpTemplate = `{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}}
+
+{{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`
+
+// defaultHelpFunc is equivalent to executing defaultHelpTemplate. The two should be changed in sync.
+func defaultHelpFunc(w io.Writer, in interface{}) error {
+ c := in.(*Command)
+ usage := c.Long
+ if usage == "" {
+ usage = c.Short
+ }
+ usage = trimRightSpace(usage)
+ if usage != "" {
+ fmt.Fprintln(w, usage)
+ fmt.Fprintln(w)
+ }
+ if c.Runnable() || c.HasSubCommands() {
+ fmt.Fprint(w, c.UsageString())
+ }
+ return nil
+}
+
+var defaultVersionTemplate = `{{with .DisplayName}}{{printf "%s " .}}{{end}}{{printf "version %s" .Version}}
+`
+
+// defaultVersionFunc is equivalent to executing defaultVersionTemplate. The two should be changed in sync.
+func defaultVersionFunc(w io.Writer, in interface{}) error {
+ c := in.(*Command)
+ _, err := fmt.Fprintf(w, "%s version %s\n", c.DisplayName(), c.Version)
+ return err
+}
diff --git a/tools/vendor/github.com/spf13/cobra/completions.go b/tools/vendor/github.com/spf13/cobra/completions.go
index c0c08b057..a1752f763 100644
--- a/tools/vendor/github.com/spf13/cobra/completions.go
+++ b/tools/vendor/github.com/spf13/cobra/completions.go
@@ -35,7 +35,7 @@ const (
)
// Global map of flag completion functions. Make sure to use flagCompletionMutex before you try to read and write from it.
-var flagCompletionFunctions = map[*pflag.Flag]func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective){}
+var flagCompletionFunctions = map[*pflag.Flag]CompletionFunc{}
// lock for reading and writing from flagCompletionFunctions
var flagCompletionMutex = &sync.RWMutex{}
@@ -117,22 +117,50 @@ type CompletionOptions struct {
HiddenDefaultCmd bool
}
+// Completion is a string that can be used for completions
+//
+// two formats are supported:
+// - the completion choice
+// - the completion choice with a textual description (separated by a TAB).
+//
+// [CompletionWithDesc] can be used to create a completion string with a textual description.
+//
+// Note: Go type alias is used to provide a more descriptive name in the documentation, but any string can be used.
+type Completion = string
+
+// CompletionFunc is a function that provides completion results.
+type CompletionFunc = func(cmd *Command, args []string, toComplete string) ([]Completion, ShellCompDirective)
+
+// CompletionWithDesc returns a [Completion] with a description by using the TAB delimited format.
+func CompletionWithDesc(choice string, description string) Completion {
+ return choice + "\t" + description
+}
+
// NoFileCompletions can be used to disable file completion for commands that should
// not trigger file completions.
-func NoFileCompletions(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective) {
+//
+// This method satisfies [CompletionFunc].
+// It can be used with [Command.RegisterFlagCompletionFunc] and for [Command.ValidArgsFunction].
+func NoFileCompletions(cmd *Command, args []string, toComplete string) ([]Completion, ShellCompDirective) {
return nil, ShellCompDirectiveNoFileComp
}
// FixedCompletions can be used to create a completion function which always
// returns the same results.
-func FixedCompletions(choices []string, directive ShellCompDirective) func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective) {
- return func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective) {
+//
+// This method returns a function that satisfies [CompletionFunc]
+// It can be used with [Command.RegisterFlagCompletionFunc] and for [Command.ValidArgsFunction].
+func FixedCompletions(choices []Completion, directive ShellCompDirective) CompletionFunc {
+ return func(cmd *Command, args []string, toComplete string) ([]Completion, ShellCompDirective) {
return choices, directive
}
}
// RegisterFlagCompletionFunc should be called to register a function to provide completion for a flag.
-func (c *Command) RegisterFlagCompletionFunc(flagName string, f func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)) error {
+//
+// You can use pre-defined completion functions such as [FixedCompletions] or [NoFileCompletions],
+// or you can define your own.
+func (c *Command) RegisterFlagCompletionFunc(flagName string, f CompletionFunc) error {
flag := c.Flag(flagName)
if flag == nil {
return fmt.Errorf("RegisterFlagCompletionFunc: flag '%s' does not exist", flagName)
@@ -148,7 +176,7 @@ func (c *Command) RegisterFlagCompletionFunc(flagName string, f func(cmd *Comman
}
// GetFlagCompletionFunc returns the completion function for the given flag of the command, if available.
-func (c *Command) GetFlagCompletionFunc(flagName string) (func(*Command, []string, string) ([]string, ShellCompDirective), bool) {
+func (c *Command) GetFlagCompletionFunc(flagName string) (CompletionFunc, bool) {
flag := c.Flag(flagName)
if flag == nil {
return nil, false
@@ -270,7 +298,15 @@ func (c *Command) initCompleteCmd(args []string) {
}
}
-func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDirective, error) {
+// SliceValue is a reduced version of [pflag.SliceValue]. It is used to detect
+// flags that accept multiple values and therefore can provide completion
+// multiple times.
+type SliceValue interface {
+ // GetSlice returns the flag value list as an array of strings.
+ GetSlice() []string
+}
+
+func (c *Command) getCompletions(args []string) (*Command, []Completion, ShellCompDirective, error) {
// The last argument, which is not completely typed by the user,
// should not be part of the list of arguments
toComplete := args[len(args)-1]
@@ -298,7 +334,7 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
}
if err != nil {
// Unable to find the real command. E.g.,
+
+
+stdlib
+conc
+
+
+
+```go
+func mapStream(
+ in chan int,
+ out chan int,
+ f func(int) int,
+) {
+ tasks := make(chan func())
+ taskResults := make(chan chan int)
+
+ // Worker goroutines
+ var workerWg sync.WaitGroup
+ for i := 0; i < 10; i++ {
+ workerWg.Add(1)
+ go func() {
+ defer workerWg.Done()
+ for task := range tasks {
+ task()
+ }
+ }()
+ }
+
+ // Ordered reader goroutines
+ var readerWg sync.WaitGroup
+ readerWg.Add(1)
+ go func() {
+ defer readerWg.Done()
+ for result := range taskResults {
+ item := <-result
+ out <- item
+ }
+ }()
+
+ // Feed the workers with tasks
+ for elem := range in {
+ resultCh := make(chan int, 1)
+ taskResults <- resultCh
+ tasks <- func() {
+ resultCh <- f(elem)
+ }
+ }
+
+ // We've exhausted input.
+ // Wait for everything to finish
+ close(tasks)
+ workerWg.Wait()
+ close(taskResults)
+ readerWg.Wait()
+}
+```
+
+
+
+```go
+func mapStream(
+ in chan int,
+ out chan int,
+ f func(int) int,
+) {
+ s := stream.New().WithMaxGoroutines(10)
+ for elem := range in {
+ elem := elem
+ s.Go(func() stream.Callback {
+ res := f(elem)
+ return func() { out <- res }
+ })
+ }
+ s.Wait()
+}
+```
+
+
-Released under the [MIT License](LICENSE.txt).
+Released under the [MIT License](LICENSE).
1 In particular, keep in mind that we may be
benchmarking against slightly older versions of other packages. Versions are
diff --git a/tools/vendor/go.uber.org/zap/CHANGELOG.md b/tools/vendor/go.uber.org/zap/CHANGELOG.md
index 0db1f9f15..6d6cd5f4d 100644
--- a/tools/vendor/go.uber.org/zap/CHANGELOG.md
+++ b/tools/vendor/go.uber.org/zap/CHANGELOG.md
@@ -1,7 +1,55 @@
# Changelog
All notable changes to this project will be documented in this file.
-This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## 1.27.0 (20 Feb 2024)
+Enhancements:
+* [#1378][]: Add `WithLazy` method for `SugaredLogger`.
+* [#1399][]: zaptest: Add `NewTestingWriter` for customizing TestingWriter with more flexibility than `NewLogger`.
+* [#1406][]: Add `Log`, `Logw`, `Logln` methods for `SugaredLogger`.
+* [#1416][]: Add `WithPanicHook` option for testing panic logs.
+
+Thanks to @defval, @dimmo, @arxeiss, and @MKrupauskas for their contributions to this release.
+
+[#1378]: https://github.com/uber-go/zap/pull/1378
+[#1399]: https://github.com/uber-go/zap/pull/1399
+[#1406]: https://github.com/uber-go/zap/pull/1406
+[#1416]: https://github.com/uber-go/zap/pull/1416
+
+## 1.26.0 (14 Sep 2023)
+Enhancements:
+* [#1297][]: Add Dict as a Field.
+* [#1319][]: Add `WithLazy` method to `Logger` which lazily evaluates the structured
+context.
+* [#1350][]: String encoding is much (~50%) faster now.
+
+Thanks to @hhk7734, @jquirke, and @cdvr1993 for their contributions to this release.
+
+[#1297]: https://github.com/uber-go/zap/pull/1297
+[#1319]: https://github.com/uber-go/zap/pull/1319
+[#1350]: https://github.com/uber-go/zap/pull/1350
+
+## 1.25.0 (1 Aug 2023)
+
+This release contains several improvements including performance, API additions,
+and two new experimental packages whose APIs are unstable and may change in the
+future.
+
+Enhancements:
+* [#1246][]: Add `zap/exp/zapslog` package for integration with slog.
+* [#1273][]: Add `Name` to `Logger` which returns the Logger's name if one is set.
+* [#1281][]: Add `zap/exp/expfield` package which contains helper methods
+`Str` and `Strs` for constructing String-like zap.Fields.
+* [#1310][]: Reduce stack size on `Any`.
+
+Thanks to @knight42, @dzakaammar, @bcspragu, and @rexywork for their contributions
+to this release.
+
+[#1246]: https://github.com/uber-go/zap/pull/1246
+[#1273]: https://github.com/uber-go/zap/pull/1273
+[#1281]: https://github.com/uber-go/zap/pull/1281
+[#1310]: https://github.com/uber-go/zap/pull/1310
## 1.24.0 (30 Nov 2022)
@@ -27,7 +75,6 @@ Enhancements:
[#1147]: https://github.com/uber-go/zap/pull/1147
[#1155]: https://github.com/uber-go/zap/pull/1155
-
## 1.22.0 (8 Aug 2022)
Enhancements:
@@ -176,6 +223,16 @@ Enhancements:
Thanks to @ash2k, @FMLS, @jimmystewpot, @Oncilla, @tsoslow, @tylitianrui, @withshubh, and @wziww for their contributions to this release.
+[#865]: https://github.com/uber-go/zap/pull/865
+[#867]: https://github.com/uber-go/zap/pull/867
+[#881]: https://github.com/uber-go/zap/pull/881
+[#903]: https://github.com/uber-go/zap/pull/903
+[#912]: https://github.com/uber-go/zap/pull/912
+[#913]: https://github.com/uber-go/zap/pull/913
+[#928]: https://github.com/uber-go/zap/pull/928
+[#931]: https://github.com/uber-go/zap/pull/931
+[#936]: https://github.com/uber-go/zap/pull/936
+
## 1.16.0 (1 Sep 2020)
Bugfixes:
@@ -197,6 +254,17 @@ Enhancements:
Thanks to @SteelPhase, @tmshn, @lixingwang, @wyxloading, @moul, @segevfiner, @andy-retailnext and @jcorbin for their contributions to this release.
+[#629]: https://github.com/uber-go/zap/pull/629
+[#697]: https://github.com/uber-go/zap/pull/697
+[#828]: https://github.com/uber-go/zap/pull/828
+[#835]: https://github.com/uber-go/zap/pull/835
+[#843]: https://github.com/uber-go/zap/pull/843
+[#844]: https://github.com/uber-go/zap/pull/844
+[#852]: https://github.com/uber-go/zap/pull/852
+[#854]: https://github.com/uber-go/zap/pull/854
+[#861]: https://github.com/uber-go/zap/pull/861
+[#862]: https://github.com/uber-go/zap/pull/862
+
## 1.15.0 (23 Apr 2020)
Bugfixes:
@@ -213,6 +281,11 @@ Enhancements:
Thanks to @danielbprice for their contributions to this release.
+[#804]: https://github.com/uber-go/zap/pull/804
+[#812]: https://github.com/uber-go/zap/pull/812
+[#806]: https://github.com/uber-go/zap/pull/806
+[#813]: https://github.com/uber-go/zap/pull/813
+
## 1.14.1 (14 Mar 2020)
Bugfixes:
@@ -225,6 +298,10 @@ Bugfixes:
Thanks to @YashishDua for their contributions to this release.
+[#791]: https://github.com/uber-go/zap/pull/791
+[#795]: https://github.com/uber-go/zap/pull/795
+[#799]: https://github.com/uber-go/zap/pull/799
+
## 1.14.0 (20 Feb 2020)
Enhancements:
@@ -235,6 +312,11 @@ Enhancements:
Thanks to @caibirdme for their contributions to this release.
+[#771]: https://github.com/uber-go/zap/pull/771
+[#773]: https://github.com/uber-go/zap/pull/773
+[#775]: https://github.com/uber-go/zap/pull/775
+[#786]: https://github.com/uber-go/zap/pull/786
+
## 1.13.0 (13 Nov 2019)
Enhancements:
@@ -243,11 +325,15 @@ Enhancements:
Thanks to @jbizzle for their contributions to this release.
+[#758]: https://github.com/uber-go/zap/pull/758
+
## 1.12.0 (29 Oct 2019)
Enhancements:
* [#751][]: Migrate to Go modules.
+[#751]: https://github.com/uber-go/zap/pull/751
+
## 1.11.0 (21 Oct 2019)
Enhancements:
@@ -256,6 +342,9 @@ Enhancements:
Thanks to @juicemia, @uhthomas for their contributions to this release.
+[#725]: https://github.com/uber-go/zap/pull/725
+[#736]: https://github.com/uber-go/zap/pull/736
+
## 1.10.0 (29 Apr 2019)
Bugfixes:
@@ -273,13 +362,21 @@ Enhancements:
Thanks to @iaroslav-ciupin, @lelenanam, @joa, @NWilson for their contributions
to this release.
-## v1.9.1 (06 Aug 2018)
+[#657]: https://github.com/uber-go/zap/pull/657
+[#706]: https://github.com/uber-go/zap/pull/706
+[#610]: https://github.com/uber-go/zap/pull/610
+[#675]: https://github.com/uber-go/zap/pull/675
+[#704]: https://github.com/uber-go/zap/pull/704
+
+## 1.9.1 (06 Aug 2018)
Bugfixes:
* [#614][]: MapObjectEncoder should not ignore empty slices.
-## v1.9.0 (19 Jul 2018)
+[#614]: https://github.com/uber-go/zap/pull/614
+
+## 1.9.0 (19 Jul 2018)
Enhancements:
* [#602][]: Reduce number of allocations when logging with reflection.
@@ -288,7 +385,11 @@ Enhancements:
Thanks to @nfarah86, @AlekSi, @JeanMertz, @philippgille, @etsangsplk, and
@dimroc for their contributions to this release.
-## v1.8.0 (13 Apr 2018)
+[#602]: https://github.com/uber-go/zap/pull/602
+[#572]: https://github.com/uber-go/zap/pull/572
+[#606]: https://github.com/uber-go/zap/pull/606
+
+## 1.8.0 (13 Apr 2018)
Enhancements:
* [#508][]: Make log level configurable when redirecting the standard
@@ -301,19 +402,28 @@ Bugfixes:
Thanks to @DiSiqueira and @djui for their contributions to this release.
-## v1.7.1 (25 Sep 2017)
+[#508]: https://github.com/uber-go/zap/pull/508
+[#518]: https://github.com/uber-go/zap/pull/518
+[#577]: https://github.com/uber-go/zap/pull/577
+[#574]: https://github.com/uber-go/zap/pull/574
+
+## 1.7.1 (25 Sep 2017)
Bugfixes:
* [#504][]: Store strings when using AddByteString with the map encoder.
-## v1.7.0 (21 Sep 2017)
+[#504]: https://github.com/uber-go/zap/pull/504
+
+## 1.7.0 (21 Sep 2017)
Enhancements:
* [#487][]: Add `NewStdLogAt`, which extends `NewStdLog` by allowing the user
to specify the level of the logged messages.
-## v1.6.0 (30 Aug 2017)
+[#487]: https://github.com/uber-go/zap/pull/487
+
+## 1.6.0 (30 Aug 2017)
Enhancements:
@@ -321,7 +431,10 @@ Enhancements:
* [#490][]: Add a `ContextMap` method to observer logs for simpler
field validation in tests.
-## v1.5.0 (22 Jul 2017)
+[#490]: https://github.com/uber-go/zap/pull/490
+[#491]: https://github.com/uber-go/zap/pull/491
+
+## 1.5.0 (22 Jul 2017)
Enhancements:
@@ -334,7 +447,12 @@ Bugfixes:
Thanks to @richard-tunein and @pavius for their contributions to this release.
-## v1.4.1 (08 Jun 2017)
+[#477]: https://github.com/uber-go/zap/pull/477
+[#465]: https://github.com/uber-go/zap/pull/465
+[#460]: https://github.com/uber-go/zap/pull/460
+[#470]: https://github.com/uber-go/zap/pull/470
+
+## 1.4.1 (08 Jun 2017)
This release fixes two bugs.
@@ -343,7 +461,10 @@ Bugfixes:
* [#435][]: Support a variety of case conventions when unmarshaling levels.
* [#444][]: Fix a panic in the observer.
-## v1.4.0 (12 May 2017)
+[#435]: https://github.com/uber-go/zap/pull/435
+[#444]: https://github.com/uber-go/zap/pull/444
+
+## 1.4.0 (12 May 2017)
This release adds a few small features and is fully backward-compatible.
@@ -355,7 +476,11 @@ Enhancements:
* [#431][]: Make `zap.AtomicLevel` implement `fmt.Stringer`, which makes a
variety of operations a bit simpler.
-## v1.3.0 (25 Apr 2017)
+[#424]: https://github.com/uber-go/zap/pull/424
+[#425]: https://github.com/uber-go/zap/pull/425
+[#431]: https://github.com/uber-go/zap/pull/431
+
+## 1.3.0 (25 Apr 2017)
This release adds an enhancement to zap's testing helpers as well as the
ability to marshal an AtomicLevel. It is fully backward-compatible.
@@ -366,7 +491,10 @@ Enhancements:
particularly useful when testing the `SugaredLogger`.
* [#416][]: Make `AtomicLevel` implement `encoding.TextMarshaler`.
-## v1.2.0 (13 Apr 2017)
+[#415]: https://github.com/uber-go/zap/pull/415
+[#416]: https://github.com/uber-go/zap/pull/416
+
+## 1.2.0 (13 Apr 2017)
This release adds a gRPC compatibility wrapper. It is fully backward-compatible.
@@ -375,7 +503,9 @@ Enhancements:
* [#402][]: Add a `zapgrpc` package that wraps zap's Logger and implements
`grpclog.Logger`.
-## v1.1.0 (31 Mar 2017)
+[#402]: https://github.com/uber-go/zap/pull/402
+
+## 1.1.0 (31 Mar 2017)
This release fixes two bugs and adds some enhancements to zap's testing helpers.
It is fully backward-compatible.
@@ -392,7 +522,11 @@ Enhancements:
Thanks to @moitias for contributing to this release.
-## v1.0.0 (14 Mar 2017)
+[#385]: https://github.com/uber-go/zap/pull/385
+[#396]: https://github.com/uber-go/zap/pull/396
+[#386]: https://github.com/uber-go/zap/pull/386
+
+## 1.0.0 (14 Mar 2017)
This is zap's first stable release. All exported APIs are now final, and no
further breaking changes will be made in the 1.x release series. Anyone using a
@@ -437,7 +571,21 @@ Enhancements:
Thanks to @suyash, @htrendev, @flisky, @Ulexus, and @skipor for their
contributions to this release.
-## v1.0.0-rc.3 (7 Mar 2017)
+[#366]: https://github.com/uber-go/zap/pull/366
+[#364]: https://github.com/uber-go/zap/pull/364
+[#371]: https://github.com/uber-go/zap/pull/371
+[#362]: https://github.com/uber-go/zap/pull/362
+[#369]: https://github.com/uber-go/zap/pull/369
+[#347]: https://github.com/uber-go/zap/pull/347
+[#373]: https://github.com/uber-go/zap/pull/373
+[#348]: https://github.com/uber-go/zap/pull/348
+[#327]: https://github.com/uber-go/zap/pull/327
+[#376]: https://github.com/uber-go/zap/pull/376
+[#346]: https://github.com/uber-go/zap/pull/346
+[#365]: https://github.com/uber-go/zap/pull/365
+[#372]: https://github.com/uber-go/zap/pull/372
+
+## 1.0.0-rc.3 (7 Mar 2017)
This is the third release candidate for zap's stable release. There are no
breaking changes.
@@ -458,7 +606,12 @@ Enhancements:
Thanks to @ansel1 and @suyash for their contributions to this release.
-## v1.0.0-rc.2 (21 Feb 2017)
+[#339]: https://github.com/uber-go/zap/pull/339
+[#307]: https://github.com/uber-go/zap/pull/307
+[#353]: https://github.com/uber-go/zap/pull/353
+[#311]: https://github.com/uber-go/zap/pull/311
+
+## 1.0.0-rc.2 (21 Feb 2017)
This is the second release candidate for zap's stable release. It includes two
breaking changes.
@@ -495,7 +648,16 @@ Enhancements:
Thanks to @skipor and @chapsuk for their contributions to this release.
-## v1.0.0-rc.1 (14 Feb 2017)
+[#316]: https://github.com/uber-go/zap/pull/316
+[#309]: https://github.com/uber-go/zap/pull/309
+[#317]: https://github.com/uber-go/zap/pull/317
+[#321]: https://github.com/uber-go/zap/pull/321
+[#325]: https://github.com/uber-go/zap/pull/325
+[#333]: https://github.com/uber-go/zap/pull/333
+[#326]: https://github.com/uber-go/zap/pull/326
+[#300]: https://github.com/uber-go/zap/pull/300
+
+## 1.0.0-rc.1 (14 Feb 2017)
This is the first release candidate for zap's stable release. There are multiple
breaking changes and improvements from the pre-release version. Most notably:
@@ -515,7 +677,7 @@ breaking changes and improvements from the pre-release version. Most notably:
* Sampling is more accurate, and doesn't depend on the standard library's shared
timer heap.
-## v0.1.0-beta.1 (6 Feb 2017)
+## 0.1.0-beta.1 (6 Feb 2017)
This is a minor version, tagged to allow users to pin to the pre-1.0 APIs and
upgrade at their leisure. Since this is the first tagged release, there are no
@@ -523,95 +685,3 @@ backward compatibility concerns and all functionality is new.
Early zap adopters should pin to the 0.1.x minor version until they're ready to
upgrade to the upcoming stable release.
-
-[#316]: https://github.com/uber-go/zap/pull/316
-[#309]: https://github.com/uber-go/zap/pull/309
-[#317]: https://github.com/uber-go/zap/pull/317
-[#321]: https://github.com/uber-go/zap/pull/321
-[#325]: https://github.com/uber-go/zap/pull/325
-[#333]: https://github.com/uber-go/zap/pull/333
-[#326]: https://github.com/uber-go/zap/pull/326
-[#300]: https://github.com/uber-go/zap/pull/300
-[#339]: https://github.com/uber-go/zap/pull/339
-[#307]: https://github.com/uber-go/zap/pull/307
-[#353]: https://github.com/uber-go/zap/pull/353
-[#311]: https://github.com/uber-go/zap/pull/311
-[#366]: https://github.com/uber-go/zap/pull/366
-[#364]: https://github.com/uber-go/zap/pull/364
-[#371]: https://github.com/uber-go/zap/pull/371
-[#362]: https://github.com/uber-go/zap/pull/362
-[#369]: https://github.com/uber-go/zap/pull/369
-[#347]: https://github.com/uber-go/zap/pull/347
-[#373]: https://github.com/uber-go/zap/pull/373
-[#348]: https://github.com/uber-go/zap/pull/348
-[#327]: https://github.com/uber-go/zap/pull/327
-[#376]: https://github.com/uber-go/zap/pull/376
-[#346]: https://github.com/uber-go/zap/pull/346
-[#365]: https://github.com/uber-go/zap/pull/365
-[#372]: https://github.com/uber-go/zap/pull/372
-[#385]: https://github.com/uber-go/zap/pull/385
-[#396]: https://github.com/uber-go/zap/pull/396
-[#386]: https://github.com/uber-go/zap/pull/386
-[#402]: https://github.com/uber-go/zap/pull/402
-[#415]: https://github.com/uber-go/zap/pull/415
-[#416]: https://github.com/uber-go/zap/pull/416
-[#424]: https://github.com/uber-go/zap/pull/424
-[#425]: https://github.com/uber-go/zap/pull/425
-[#431]: https://github.com/uber-go/zap/pull/431
-[#435]: https://github.com/uber-go/zap/pull/435
-[#444]: https://github.com/uber-go/zap/pull/444
-[#477]: https://github.com/uber-go/zap/pull/477
-[#465]: https://github.com/uber-go/zap/pull/465
-[#460]: https://github.com/uber-go/zap/pull/460
-[#470]: https://github.com/uber-go/zap/pull/470
-[#487]: https://github.com/uber-go/zap/pull/487
-[#490]: https://github.com/uber-go/zap/pull/490
-[#491]: https://github.com/uber-go/zap/pull/491
-[#504]: https://github.com/uber-go/zap/pull/504
-[#508]: https://github.com/uber-go/zap/pull/508
-[#518]: https://github.com/uber-go/zap/pull/518
-[#577]: https://github.com/uber-go/zap/pull/577
-[#574]: https://github.com/uber-go/zap/pull/574
-[#602]: https://github.com/uber-go/zap/pull/602
-[#572]: https://github.com/uber-go/zap/pull/572
-[#606]: https://github.com/uber-go/zap/pull/606
-[#614]: https://github.com/uber-go/zap/pull/614
-[#657]: https://github.com/uber-go/zap/pull/657
-[#706]: https://github.com/uber-go/zap/pull/706
-[#610]: https://github.com/uber-go/zap/pull/610
-[#675]: https://github.com/uber-go/zap/pull/675
-[#704]: https://github.com/uber-go/zap/pull/704
-[#725]: https://github.com/uber-go/zap/pull/725
-[#736]: https://github.com/uber-go/zap/pull/736
-[#751]: https://github.com/uber-go/zap/pull/751
-[#758]: https://github.com/uber-go/zap/pull/758
-[#771]: https://github.com/uber-go/zap/pull/771
-[#773]: https://github.com/uber-go/zap/pull/773
-[#775]: https://github.com/uber-go/zap/pull/775
-[#786]: https://github.com/uber-go/zap/pull/786
-[#791]: https://github.com/uber-go/zap/pull/791
-[#795]: https://github.com/uber-go/zap/pull/795
-[#799]: https://github.com/uber-go/zap/pull/799
-[#804]: https://github.com/uber-go/zap/pull/804
-[#812]: https://github.com/uber-go/zap/pull/812
-[#806]: https://github.com/uber-go/zap/pull/806
-[#813]: https://github.com/uber-go/zap/pull/813
-[#629]: https://github.com/uber-go/zap/pull/629
-[#697]: https://github.com/uber-go/zap/pull/697
-[#828]: https://github.com/uber-go/zap/pull/828
-[#835]: https://github.com/uber-go/zap/pull/835
-[#843]: https://github.com/uber-go/zap/pull/843
-[#844]: https://github.com/uber-go/zap/pull/844
-[#852]: https://github.com/uber-go/zap/pull/852
-[#854]: https://github.com/uber-go/zap/pull/854
-[#861]: https://github.com/uber-go/zap/pull/861
-[#862]: https://github.com/uber-go/zap/pull/862
-[#865]: https://github.com/uber-go/zap/pull/865
-[#867]: https://github.com/uber-go/zap/pull/867
-[#881]: https://github.com/uber-go/zap/pull/881
-[#903]: https://github.com/uber-go/zap/pull/903
-[#912]: https://github.com/uber-go/zap/pull/912
-[#913]: https://github.com/uber-go/zap/pull/913
-[#928]: https://github.com/uber-go/zap/pull/928
-[#931]: https://github.com/uber-go/zap/pull/931
-[#936]: https://github.com/uber-go/zap/pull/936
diff --git a/tools/vendor/go.uber.org/zap/LICENSE.txt b/tools/vendor/go.uber.org/zap/LICENSE
similarity index 100%
rename from tools/vendor/go.uber.org/zap/LICENSE.txt
rename to tools/vendor/go.uber.org/zap/LICENSE
diff --git a/tools/vendor/go.uber.org/zap/Makefile b/tools/vendor/go.uber.org/zap/Makefile
index 9b1bc3b0e..eb1cee53b 100644
--- a/tools/vendor/go.uber.org/zap/Makefile
+++ b/tools/vendor/go.uber.org/zap/Makefile
@@ -1,50 +1,51 @@
-export GOBIN ?= $(shell pwd)/bin
+# Directory containing the Makefile.
+PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
-GOLINT = $(GOBIN)/golint
-STATICCHECK = $(GOBIN)/staticcheck
+export GOBIN ?= $(PROJECT_ROOT)/bin
+export PATH := $(GOBIN):$(PATH)
+
+GOVULNCHECK = $(GOBIN)/govulncheck
BENCH_FLAGS ?= -cpuprofile=cpu.pprof -memprofile=mem.pprof -benchmem
# Directories containing independent Go modules.
-#
-# We track coverage only for the main module.
-MODULE_DIRS = . ./benchmarks ./zapgrpc/internal/test
+MODULE_DIRS = . ./exp ./benchmarks ./zapgrpc/internal/test
-# Many Go tools take file globs or directories as arguments instead of packages.
-GO_FILES := $(shell \
- find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
- -o -name '*.go' -print | cut -b3-)
+# Directories that we want to track coverage for.
+COVER_DIRS = . ./exp
.PHONY: all
all: lint test
.PHONY: lint
-lint: $(GOLINT) $(STATICCHECK)
- @rm -rf lint.log
- @echo "Checking formatting..."
- @gofmt -d -s $(GO_FILES) 2>&1 | tee lint.log
- @echo "Checking vet..."
- @$(foreach dir,$(MODULE_DIRS),(cd $(dir) && go vet ./... 2>&1) &&) true | tee -a lint.log
- @echo "Checking lint..."
- @$(foreach dir,$(MODULE_DIRS),(cd $(dir) && $(GOLINT) ./... 2>&1) &&) true | tee -a lint.log
- @echo "Checking staticcheck..."
- @$(foreach dir,$(MODULE_DIRS),(cd $(dir) && $(STATICCHECK) ./... 2>&1) &&) true | tee -a lint.log
- @echo "Checking for unresolved FIXMEs..."
- @git grep -i fixme | grep -v -e Makefile | tee -a lint.log
- @echo "Checking for license headers..."
- @./checklicense.sh | tee -a lint.log
- @[ ! -s lint.log ]
- @echo "Checking 'go mod tidy'..."
- @make tidy
- @if ! git diff --quiet; then \
- echo "'go mod tidy' resulted in changes or working tree is dirty:"; \
- git --no-pager diff; \
- fi
-
-$(GOLINT):
- cd tools && go install golang.org/x/lint/golint
-
-$(STATICCHECK):
- cd tools && go install honnef.co/go/tools/cmd/staticcheck
+lint: golangci-lint tidy-lint license-lint
+
+.PHONY: golangci-lint
+golangci-lint:
+ @$(foreach mod,$(MODULE_DIRS), \
+ (cd $(mod) && \
+ echo "[lint] golangci-lint: $(mod)" && \
+ golangci-lint run --path-prefix $(mod)) &&) true
+
+.PHONY: tidy
+tidy:
+ @$(foreach dir,$(MODULE_DIRS), \
+ (cd $(dir) && go mod tidy) &&) true
+
+.PHONY: tidy-lint
+tidy-lint:
+ @$(foreach mod,$(MODULE_DIRS), \
+ (cd $(mod) && \
+ echo "[lint] tidy: $(mod)" && \
+ go mod tidy && \
+ git diff --exit-code -- go.mod go.sum) &&) true
+
+
+.PHONY: license-lint
+license-lint:
+ ./checklicense.sh
+
+$(GOVULNCHECK):
+ cd tools && go install golang.org/x/vuln/cmd/govulncheck
.PHONY: test
test:
@@ -52,8 +53,10 @@ test:
.PHONY: cover
cover:
- go test -race -coverprofile=cover.out -coverpkg=./... ./...
- go tool cover -html=cover.out -o cover.html
+ @$(foreach dir,$(COVER_DIRS), ( \
+ cd $(dir) && \
+ go test -race -coverprofile=cover.out -coverpkg=./... ./... \
+ && go tool cover -html=cover.out -o cover.html) &&) true
.PHONY: bench
BENCH ?= .
@@ -68,6 +71,6 @@ updatereadme:
rm -f README.md
cat .readme.tmpl | go run internal/readme/readme.go > README.md
-.PHONY: tidy
-tidy:
- @$(foreach dir,$(MODULE_DIRS),(cd $(dir) && go mod tidy) &&) true
+.PHONY: vulncheck
+vulncheck: $(GOVULNCHECK)
+ $(GOVULNCHECK) ./...
diff --git a/tools/vendor/go.uber.org/zap/README.md b/tools/vendor/go.uber.org/zap/README.md
index a553a428c..a17035cb6 100644
--- a/tools/vendor/go.uber.org/zap/README.md
+++ b/tools/vendor/go.uber.org/zap/README.md
@@ -1,7 +1,16 @@
-# :zap: zap [![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov]
+# :zap: zap
+
+
+
-Released under the [MIT License](LICENSE.txt).
+Released under the [MIT License](LICENSE).
1 In particular, keep in mind that we may be
benchmarking against slightly older versions of other packages. Versions are
@@ -131,3 +146,4 @@ pinned in the [benchmarks/go.mod][] file. [↩](#anchor-versions)
[cov]: https://codecov.io/gh/uber-go/zap
[benchmarking suite]: https://github.com/uber-go/zap/tree/master/benchmarks
[benchmarks/go.mod]: https://github.com/uber-go/zap/blob/master/benchmarks/go.mod
+
diff --git a/tools/vendor/go.uber.org/zap/array.go b/tools/vendor/go.uber.org/zap/array.go
index 5be3704a3..abfccb566 100644
--- a/tools/vendor/go.uber.org/zap/array.go
+++ b/tools/vendor/go.uber.org/zap/array.go
@@ -21,6 +21,7 @@
package zap
import (
+ "fmt"
"time"
"go.uber.org/zap/zapcore"
@@ -94,11 +95,137 @@ func Int8s(key string, nums []int8) Field {
return Array(key, int8s(nums))
}
+// Objects constructs a field with the given key, holding a list of the
+// provided objects that can be marshaled by Zap.
+//
+// Note that these objects must implement zapcore.ObjectMarshaler directly.
+// That is, if you're trying to marshal a []Request, the MarshalLogObject
+// method must be declared on the Request type, not its pointer (*Request).
+// If it's on the pointer, use ObjectValues.
+//
+// Given an object that implements MarshalLogObject on the value receiver, you
+// can log a slice of those objects with Objects like so:
+//
+// type Author struct{ ... }
+// func (a Author) MarshalLogObject(enc zapcore.ObjectEncoder) error
+//
+// var authors []Author = ...
+// logger.Info("loading article", zap.Objects("authors", authors))
+//
+// Similarly, given a type that implements MarshalLogObject on its pointer
+// receiver, you can log a slice of pointers to that object with Objects like
+// so:
+//
+// type Request struct{ ... }
+// func (r *Request) MarshalLogObject(enc zapcore.ObjectEncoder) error
+//
+// var requests []*Request = ...
+// logger.Info("sending requests", zap.Objects("requests", requests))
+//
+// If instead, you have a slice of values of such an object, use the
+// ObjectValues constructor.
+//
+// var requests []Request = ...
+// logger.Info("sending requests", zap.ObjectValues("requests", requests))
+func Objects[T zapcore.ObjectMarshaler](key string, values []T) Field {
+ return Array(key, objects[T](values))
+}
+
+type objects[T zapcore.ObjectMarshaler] []T
+
+func (os objects[T]) MarshalLogArray(arr zapcore.ArrayEncoder) error {
+ for _, o := range os {
+ if err := arr.AppendObject(o); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+// ObjectMarshalerPtr is a constraint that specifies that the given type
+// implements zapcore.ObjectMarshaler on a pointer receiver.
+type ObjectMarshalerPtr[T any] interface {
+ *T
+ zapcore.ObjectMarshaler
+}
+
+// ObjectValues constructs a field with the given key, holding a list of the
+// provided objects, where pointers to these objects can be marshaled by Zap.
+//
+// Note that pointers to these objects must implement zapcore.ObjectMarshaler.
+// That is, if you're trying to marshal a []Request, the MarshalLogObject
+// method must be declared on the *Request type, not the value (Request).
+// If it's on the value, use Objects.
+//
+// Given an object that implements MarshalLogObject on the pointer receiver,
+// you can log a slice of those objects with ObjectValues like so:
+//
+// type Request struct{ ... }
+// func (r *Request) MarshalLogObject(enc zapcore.ObjectEncoder) error
+//
+// var requests []Request = ...
+// logger.Info("sending requests", zap.ObjectValues("requests", requests))
+//
+// If instead, you have a slice of pointers of such an object, use the Objects
+// field constructor.
+//
+// var requests []*Request = ...
+// logger.Info("sending requests", zap.Objects("requests", requests))
+func ObjectValues[T any, P ObjectMarshalerPtr[T]](key string, values []T) Field {
+ return Array(key, objectValues[T, P](values))
+}
+
+type objectValues[T any, P ObjectMarshalerPtr[T]] []T
+
+func (os objectValues[T, P]) MarshalLogArray(arr zapcore.ArrayEncoder) error {
+ for i := range os {
+ // It is necessary for us to explicitly reference the "P" type.
+ // We cannot simply pass "&os[i]" to AppendObject because its type
+ // is "*T", which the type system does not consider as
+ // implementing ObjectMarshaler.
+ // Only the type "P" satisfies ObjectMarshaler, which we have
+ // to convert "*T" to explicitly.
+ var p P = &os[i]
+ if err := arr.AppendObject(p); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
// Strings constructs a field that carries a slice of strings.
func Strings(key string, ss []string) Field {
return Array(key, stringArray(ss))
}
+// Stringers constructs a field with the given key, holding a list of the
+// output provided by the value's String method
+//
+// Given an object that implements String on the value receiver, you
+// can log a slice of those objects with Objects like so:
+//
+// type Request struct{ ... }
+// func (a Request) String() string
+//
+// var requests []Request = ...
+// logger.Info("sending requests", zap.Stringers("requests", requests))
+//
+// Note that these objects must implement fmt.Stringer directly.
+// That is, if you're trying to marshal a []Request, the String method
+// must be declared on the Request type, not its pointer (*Request).
+func Stringers[T fmt.Stringer](key string, values []T) Field {
+ return Array(key, stringers[T](values))
+}
+
+type stringers[T fmt.Stringer] []T
+
+func (os stringers[T]) MarshalLogArray(arr zapcore.ArrayEncoder) error {
+ for _, o := range os {
+ arr.AppendString(o.String())
+ }
+ return nil
+}
+
// Times constructs a field that carries a slice of time.Times.
func Times(key string, ts []time.Time) Field {
return Array(key, times(ts))
diff --git a/tools/vendor/go.uber.org/zap/array_go118.go b/tools/vendor/go.uber.org/zap/array_go118.go
deleted file mode 100644
index d0d2c49d6..000000000
--- a/tools/vendor/go.uber.org/zap/array_go118.go
+++ /dev/null
@@ -1,156 +0,0 @@
-// Copyright (c) 2022 Uber Technologies, Inc.
-//
-// 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.
-
-//go:build go1.18
-// +build go1.18
-
-package zap
-
-import (
- "fmt"
-
- "go.uber.org/zap/zapcore"
-)
-
-// Objects constructs a field with the given key, holding a list of the
-// provided objects that can be marshaled by Zap.
-//
-// Note that these objects must implement zapcore.ObjectMarshaler directly.
-// That is, if you're trying to marshal a []Request, the MarshalLogObject
-// method must be declared on the Request type, not its pointer (*Request).
-// If it's on the pointer, use ObjectValues.
-//
-// Given an object that implements MarshalLogObject on the value receiver, you
-// can log a slice of those objects with Objects like so:
-//
-// type Author struct{ ... }
-// func (a Author) MarshalLogObject(enc zapcore.ObjectEncoder) error
-//
-// var authors []Author = ...
-// logger.Info("loading article", zap.Objects("authors", authors))
-//
-// Similarly, given a type that implements MarshalLogObject on its pointer
-// receiver, you can log a slice of pointers to that object with Objects like
-// so:
-//
-// type Request struct{ ... }
-// func (r *Request) MarshalLogObject(enc zapcore.ObjectEncoder) error
-//
-// var requests []*Request = ...
-// logger.Info("sending requests", zap.Objects("requests", requests))
-//
-// If instead, you have a slice of values of such an object, use the
-// ObjectValues constructor.
-//
-// var requests []Request = ...
-// logger.Info("sending requests", zap.ObjectValues("requests", requests))
-func Objects[T zapcore.ObjectMarshaler](key string, values []T) Field {
- return Array(key, objects[T](values))
-}
-
-type objects[T zapcore.ObjectMarshaler] []T
-
-func (os objects[T]) MarshalLogArray(arr zapcore.ArrayEncoder) error {
- for _, o := range os {
- if err := arr.AppendObject(o); err != nil {
- return err
- }
- }
- return nil
-}
-
-// ObjectMarshalerPtr is a constraint that specifies that the given type
-// implements zapcore.ObjectMarshaler on a pointer receiver.
-type ObjectMarshalerPtr[T any] interface {
- *T
- zapcore.ObjectMarshaler
-}
-
-// ObjectValues constructs a field with the given key, holding a list of the
-// provided objects, where pointers to these objects can be marshaled by Zap.
-//
-// Note that pointers to these objects must implement zapcore.ObjectMarshaler.
-// That is, if you're trying to marshal a []Request, the MarshalLogObject
-// method must be declared on the *Request type, not the value (Request).
-// If it's on the value, use Objects.
-//
-// Given an object that implements MarshalLogObject on the pointer receiver,
-// you can log a slice of those objects with ObjectValues like so:
-//
-// type Request struct{ ... }
-// func (r *Request) MarshalLogObject(enc zapcore.ObjectEncoder) error
-//
-// var requests []Request = ...
-// logger.Info("sending requests", zap.ObjectValues("requests", requests))
-//
-// If instead, you have a slice of pointers of such an object, use the Objects
-// field constructor.
-//
-// var requests []*Request = ...
-// logger.Info("sending requests", zap.Objects("requests", requests))
-func ObjectValues[T any, P ObjectMarshalerPtr[T]](key string, values []T) Field {
- return Array(key, objectValues[T, P](values))
-}
-
-type objectValues[T any, P ObjectMarshalerPtr[T]] []T
-
-func (os objectValues[T, P]) MarshalLogArray(arr zapcore.ArrayEncoder) error {
- for i := range os {
- // It is necessary for us to explicitly reference the "P" type.
- // We cannot simply pass "&os[i]" to AppendObject because its type
- // is "*T", which the type system does not consider as
- // implementing ObjectMarshaler.
- // Only the type "P" satisfies ObjectMarshaler, which we have
- // to convert "*T" to explicitly.
- var p P = &os[i]
- if err := arr.AppendObject(p); err != nil {
- return err
- }
- }
- return nil
-}
-
-// Stringers constructs a field with the given key, holding a list of the
-// output provided by the value's String method
-//
-// Given an object that implements String on the value receiver, you
-// can log a slice of those objects with Objects like so:
-//
-// type Request struct{ ... }
-// func (a Request) String() string
-//
-// var requests []Request = ...
-// logger.Info("sending requests", zap.Stringers("requests", requests))
-//
-// Note that these objects must implement fmt.Stringer directly.
-// That is, if you're trying to marshal a []Request, the String method
-// must be declared on the Request type, not its pointer (*Request).
-func Stringers[T fmt.Stringer](key string, values []T) Field {
- return Array(key, stringers[T](values))
-}
-
-type stringers[T fmt.Stringer] []T
-
-func (os stringers[T]) MarshalLogArray(arr zapcore.ArrayEncoder) error {
- for _, o := range os {
- arr.AppendString(o.String())
- }
- return nil
-}
diff --git a/tools/vendor/go.uber.org/zap/buffer/buffer.go b/tools/vendor/go.uber.org/zap/buffer/buffer.go
index 9e929cd98..0b8540c21 100644
--- a/tools/vendor/go.uber.org/zap/buffer/buffer.go
+++ b/tools/vendor/go.uber.org/zap/buffer/buffer.go
@@ -42,6 +42,11 @@ func (b *Buffer) AppendByte(v byte) {
b.bs = append(b.bs, v)
}
+// AppendBytes writes the given slice of bytes to the Buffer.
+func (b *Buffer) AppendBytes(v []byte) {
+ b.bs = append(b.bs, v...)
+}
+
// AppendString writes a string to the Buffer.
func (b *Buffer) AppendString(s string) {
b.bs = append(b.bs, s...)
diff --git a/tools/vendor/go.uber.org/zap/buffer/pool.go b/tools/vendor/go.uber.org/zap/buffer/pool.go
index 8fb3e202c..846323360 100644
--- a/tools/vendor/go.uber.org/zap/buffer/pool.go
+++ b/tools/vendor/go.uber.org/zap/buffer/pool.go
@@ -20,25 +20,29 @@
package buffer
-import "sync"
+import (
+ "go.uber.org/zap/internal/pool"
+)
// A Pool is a type-safe wrapper around a sync.Pool.
type Pool struct {
- p *sync.Pool
+ p *pool.Pool[*Buffer]
}
// NewPool constructs a new Pool.
func NewPool() Pool {
- return Pool{p: &sync.Pool{
- New: func() interface{} {
- return &Buffer{bs: make([]byte, 0, _size)}
- },
- }}
+ return Pool{
+ p: pool.New(func() *Buffer {
+ return &Buffer{
+ bs: make([]byte, 0, _size),
+ }
+ }),
+ }
}
// Get retrieves a Buffer from the pool, creating one if necessary.
func (p Pool) Get() *Buffer {
- buf := p.p.Get().(*Buffer)
+ buf := p.p.Get()
buf.Reset()
buf.pool = p
return buf
diff --git a/tools/vendor/go.uber.org/zap/config.go b/tools/vendor/go.uber.org/zap/config.go
index ee6096766..e76e4e64f 100644
--- a/tools/vendor/go.uber.org/zap/config.go
+++ b/tools/vendor/go.uber.org/zap/config.go
@@ -95,6 +95,32 @@ type Config struct {
// NewProductionEncoderConfig returns an opinionated EncoderConfig for
// production environments.
+//
+// Messages encoded with this configuration will be JSON-formatted
+// and will have the following keys by default:
+//
+// - "level": The logging level (e.g. "info", "error").
+// - "ts": The current time in number of seconds since the Unix epoch.
+// - "msg": The message passed to the log statement.
+// - "caller": If available, a short path to the file and line number
+// where the log statement was issued.
+// The logger configuration determines whether this field is captured.
+// - "stacktrace": If available, a stack trace from the line
+// where the log statement was issued.
+// The logger configuration determines whether this field is captured.
+//
+// By default, the following formats are used for different types:
+//
+// - Time is formatted as floating-point number of seconds since the Unix
+// epoch.
+// - Duration is formatted as floating-point number of seconds.
+//
+// You may change these by setting the appropriate fields in the returned
+// object.
+// For example, use the following to change the time encoding format:
+//
+// cfg := zap.NewProductionEncoderConfig()
+// cfg.EncodeTime = zapcore.ISO8601TimeEncoder
func NewProductionEncoderConfig() zapcore.EncoderConfig {
return zapcore.EncoderConfig{
TimeKey: "ts",
@@ -112,11 +138,22 @@ func NewProductionEncoderConfig() zapcore.EncoderConfig {
}
}
-// NewProductionConfig is a reasonable production logging configuration.
-// Logging is enabled at InfoLevel and above.
+// NewProductionConfig builds a reasonable default production logging
+// configuration.
+// Logging is enabled at InfoLevel and above, and uses a JSON encoder.
+// Logs are written to standard error.
+// Stacktraces are included on logs of ErrorLevel and above.
+// DPanicLevel logs will not panic, but will write a stacktrace.
+//
+// Sampling is enabled at 100:100 by default,
+// meaning that after the first 100 log entries
+// with the same level and message in the same second,
+// it will log every 100th entry
+// with the same level and message in the same second.
+// You may disable this behavior by setting Sampling to nil.
//
-// It uses a JSON encoder, writes to standard error, and enables sampling.
-// Stacktraces are automatically included on logs of ErrorLevel and above.
+// See [NewProductionEncoderConfig] for information
+// on the default encoder configuration.
func NewProductionConfig() Config {
return Config{
Level: NewAtomicLevelAt(InfoLevel),
@@ -134,6 +171,32 @@ func NewProductionConfig() Config {
// NewDevelopmentEncoderConfig returns an opinionated EncoderConfig for
// development environments.
+//
+// Messages encoded with this configuration will use Zap's console encoder
+// intended to print human-readable output.
+// It will print log messages with the following information:
+//
+// - The log level (e.g. "INFO", "ERROR").
+// - The time in ISO8601 format (e.g. "2017-01-01T12:00:00Z").
+// - The message passed to the log statement.
+// - If available, a short path to the file and line number
+// where the log statement was issued.
+// The logger configuration determines whether this field is captured.
+// - If available, a stacktrace from the line
+// where the log statement was issued.
+// The logger configuration determines whether this field is captured.
+//
+// By default, the following formats are used for different types:
+//
+// - Time is formatted in ISO8601 format (e.g. "2017-01-01T12:00:00Z").
+// - Duration is formatted as a string (e.g. "1.234s").
+//
+// You may change these by setting the appropriate fields in the returned
+// object.
+// For example, use the following to change the time encoding format:
+//
+// cfg := zap.NewDevelopmentEncoderConfig()
+// cfg.EncodeTime = zapcore.ISO8601TimeEncoder
func NewDevelopmentEncoderConfig() zapcore.EncoderConfig {
return zapcore.EncoderConfig{
// Keys can be anything except the empty string.
@@ -152,12 +215,15 @@ func NewDevelopmentEncoderConfig() zapcore.EncoderConfig {
}
}
-// NewDevelopmentConfig is a reasonable development logging configuration.
-// Logging is enabled at DebugLevel and above.
+// NewDevelopmentConfig builds a reasonable default development logging
+// configuration.
+// Logging is enabled at DebugLevel and above, and uses a console encoder.
+// Logs are written to standard error.
+// Stacktraces are included on logs of WarnLevel and above.
+// DPanicLevel logs will panic.
//
-// It enables development mode (which makes DPanicLevel logs panic), uses a
-// console encoder, writes to standard error, and disables sampling.
-// Stacktraces are automatically included on logs of WarnLevel and above.
+// See [NewDevelopmentEncoderConfig] for information
+// on the default encoder configuration.
func NewDevelopmentConfig() Config {
return Config{
Level: NewAtomicLevelAt(DebugLevel),
diff --git a/tools/vendor/go.uber.org/zap/error.go b/tools/vendor/go.uber.org/zap/error.go
index 65982a51e..45f7b838d 100644
--- a/tools/vendor/go.uber.org/zap/error.go
+++ b/tools/vendor/go.uber.org/zap/error.go
@@ -21,14 +21,13 @@
package zap
import (
- "sync"
-
+ "go.uber.org/zap/internal/pool"
"go.uber.org/zap/zapcore"
)
-var _errArrayElemPool = sync.Pool{New: func() interface{} {
+var _errArrayElemPool = pool.New(func() *errArrayElem {
return &errArrayElem{}
-}}
+})
// Error is shorthand for the common idiom NamedError("error", err).
func Error(err error) Field {
@@ -60,11 +59,14 @@ func (errs errArray) MarshalLogArray(arr zapcore.ArrayEncoder) error {
// potentially an "errorVerbose" attribute, we need to wrap it in a
// type that implements LogObjectMarshaler. To prevent this from
// allocating, pool the wrapper type.
- elem := _errArrayElemPool.Get().(*errArrayElem)
+ elem := _errArrayElemPool.Get()
elem.error = errs[i]
- arr.AppendObject(elem)
+ err := arr.AppendObject(elem)
elem.error = nil
_errArrayElemPool.Put(elem)
+ if err != nil {
+ return err
+ }
}
return nil
}
diff --git a/tools/vendor/go.uber.org/zap/field.go b/tools/vendor/go.uber.org/zap/field.go
index bbb745db5..6743930b8 100644
--- a/tools/vendor/go.uber.org/zap/field.go
+++ b/tools/vendor/go.uber.org/zap/field.go
@@ -25,6 +25,7 @@ import (
"math"
"time"
+ "go.uber.org/zap/internal/stacktrace"
"go.uber.org/zap/zapcore"
)
@@ -374,7 +375,7 @@ func StackSkip(key string, skip int) Field {
// from expanding the zapcore.Field union struct to include a byte slice. Since
// taking a stacktrace is already so expensive (~10us), the extra allocation
// is okay.
- return String(key, takeStacktrace(skip+1)) // skip StackSkip
+ return String(key, stacktrace.Take(skip+1)) // skip StackSkip
}
// Duration constructs a field with the given key and value. The encoder
@@ -410,6 +411,65 @@ func Inline(val zapcore.ObjectMarshaler) Field {
}
}
+// Dict constructs a field containing the provided key-value pairs.
+// It acts similar to [Object], but with the fields specified as arguments.
+func Dict(key string, val ...Field) Field {
+ return dictField(key, val)
+}
+
+// We need a function with the signature (string, T) for zap.Any.
+func dictField(key string, val []Field) Field {
+ return Object(key, dictObject(val))
+}
+
+type dictObject []Field
+
+func (d dictObject) MarshalLogObject(enc zapcore.ObjectEncoder) error {
+ for _, f := range d {
+ f.AddTo(enc)
+ }
+ return nil
+}
+
+// We discovered an issue where zap.Any can cause a performance degradation
+// when used in new goroutines.
+//
+// This happens because the compiler assigns 4.8kb (one zap.Field per arm of
+// switch statement) of stack space for zap.Any when it takes the form:
+//
+// switch v := v.(type) {
+// case string:
+// return String(key, v)
+// case int:
+// return Int(key, v)
+// // ...
+// default:
+// return Reflect(key, v)
+// }
+//
+// To avoid this, we use the type switch to assign a value to a single local variable
+// and then call a function on it.
+// The local variable is just a function reference so it doesn't allocate
+// when converted to an interface{}.
+//
+// A fair bit of experimentation went into this.
+// See also:
+//
+// - https://github.com/uber-go/zap/pull/1301
+// - https://github.com/uber-go/zap/pull/1303
+// - https://github.com/uber-go/zap/pull/1304
+// - https://github.com/uber-go/zap/pull/1305
+// - https://github.com/uber-go/zap/pull/1308
+//
+// See https://github.com/golang/go/issues/62077 for upstream issue.
+type anyFieldC[T any] func(string, T) Field
+
+func (f anyFieldC[T]) Any(key string, val any) Field {
+ v, _ := val.(T)
+ // val is guaranteed to be a T, except when it's nil.
+ return f(key, v)
+}
+
// Any takes a key and an arbitrary value and chooses the best way to represent
// them as a field, falling back to a reflection-based approach only if
// necessary.
@@ -418,132 +478,138 @@ func Inline(val zapcore.ObjectMarshaler) Field {
// them. To minimize surprises, []byte values are treated as binary blobs, byte
// values are treated as uint8, and runes are always treated as integers.
func Any(key string, value interface{}) Field {
- switch val := value.(type) {
+ var c interface{ Any(string, any) Field }
+
+ switch value.(type) {
case zapcore.ObjectMarshaler:
- return Object(key, val)
+ c = anyFieldC[zapcore.ObjectMarshaler](Object)
case zapcore.ArrayMarshaler:
- return Array(key, val)
+ c = anyFieldC[zapcore.ArrayMarshaler](Array)
+ case []Field:
+ c = anyFieldC[[]Field](dictField)
case bool:
- return Bool(key, val)
+ c = anyFieldC[bool](Bool)
case *bool:
- return Boolp(key, val)
+ c = anyFieldC[*bool](Boolp)
case []bool:
- return Bools(key, val)
+ c = anyFieldC[[]bool](Bools)
case complex128:
- return Complex128(key, val)
+ c = anyFieldC[complex128](Complex128)
case *complex128:
- return Complex128p(key, val)
+ c = anyFieldC[*complex128](Complex128p)
case []complex128:
- return Complex128s(key, val)
+ c = anyFieldC[[]complex128](Complex128s)
case complex64:
- return Complex64(key, val)
+ c = anyFieldC[complex64](Complex64)
case *complex64:
- return Complex64p(key, val)
+ c = anyFieldC[*complex64](Complex64p)
case []complex64:
- return Complex64s(key, val)
+ c = anyFieldC[[]complex64](Complex64s)
case float64:
- return Float64(key, val)
+ c = anyFieldC[float64](Float64)
case *float64:
- return Float64p(key, val)
+ c = anyFieldC[*float64](Float64p)
case []float64:
- return Float64s(key, val)
+ c = anyFieldC[[]float64](Float64s)
case float32:
- return Float32(key, val)
+ c = anyFieldC[float32](Float32)
case *float32:
- return Float32p(key, val)
+ c = anyFieldC[*float32](Float32p)
case []float32:
- return Float32s(key, val)
+ c = anyFieldC[[]float32](Float32s)
case int:
- return Int(key, val)
+ c = anyFieldC[int](Int)
case *int:
- return Intp(key, val)
+ c = anyFieldC[*int](Intp)
case []int:
- return Ints(key, val)
+ c = anyFieldC[[]int](Ints)
case int64:
- return Int64(key, val)
+ c = anyFieldC[int64](Int64)
case *int64:
- return Int64p(key, val)
+ c = anyFieldC[*int64](Int64p)
case []int64:
- return Int64s(key, val)
+ c = anyFieldC[[]int64](Int64s)
case int32:
- return Int32(key, val)
+ c = anyFieldC[int32](Int32)
case *int32:
- return Int32p(key, val)
+ c = anyFieldC[*int32](Int32p)
case []int32:
- return Int32s(key, val)
+ c = anyFieldC[[]int32](Int32s)
case int16:
- return Int16(key, val)
+ c = anyFieldC[int16](Int16)
case *int16:
- return Int16p(key, val)
+ c = anyFieldC[*int16](Int16p)
case []int16:
- return Int16s(key, val)
+ c = anyFieldC[[]int16](Int16s)
case int8:
- return Int8(key, val)
+ c = anyFieldC[int8](Int8)
case *int8:
- return Int8p(key, val)
+ c = anyFieldC[*int8](Int8p)
case []int8:
- return Int8s(key, val)
+ c = anyFieldC[[]int8](Int8s)
case string:
- return String(key, val)
+ c = anyFieldC[string](String)
case *string:
- return Stringp(key, val)
+ c = anyFieldC[*string](Stringp)
case []string:
- return Strings(key, val)
+ c = anyFieldC[[]string](Strings)
case uint:
- return Uint(key, val)
+ c = anyFieldC[uint](Uint)
case *uint:
- return Uintp(key, val)
+ c = anyFieldC[*uint](Uintp)
case []uint:
- return Uints(key, val)
+ c = anyFieldC[[]uint](Uints)
case uint64:
- return Uint64(key, val)
+ c = anyFieldC[uint64](Uint64)
case *uint64:
- return Uint64p(key, val)
+ c = anyFieldC[*uint64](Uint64p)
case []uint64:
- return Uint64s(key, val)
+ c = anyFieldC[[]uint64](Uint64s)
case uint32:
- return Uint32(key, val)
+ c = anyFieldC[uint32](Uint32)
case *uint32:
- return Uint32p(key, val)
+ c = anyFieldC[*uint32](Uint32p)
case []uint32:
- return Uint32s(key, val)
+ c = anyFieldC[[]uint32](Uint32s)
case uint16:
- return Uint16(key, val)
+ c = anyFieldC[uint16](Uint16)
case *uint16:
- return Uint16p(key, val)
+ c = anyFieldC[*uint16](Uint16p)
case []uint16:
- return Uint16s(key, val)
+ c = anyFieldC[[]uint16](Uint16s)
case uint8:
- return Uint8(key, val)
+ c = anyFieldC[uint8](Uint8)
case *uint8:
- return Uint8p(key, val)
+ c = anyFieldC[*uint8](Uint8p)
case []byte:
- return Binary(key, val)
+ c = anyFieldC[[]byte](Binary)
case uintptr:
- return Uintptr(key, val)
+ c = anyFieldC[uintptr](Uintptr)
case *uintptr:
- return Uintptrp(key, val)
+ c = anyFieldC[*uintptr](Uintptrp)
case []uintptr:
- return Uintptrs(key, val)
+ c = anyFieldC[[]uintptr](Uintptrs)
case time.Time:
- return Time(key, val)
+ c = anyFieldC[time.Time](Time)
case *time.Time:
- return Timep(key, val)
+ c = anyFieldC[*time.Time](Timep)
case []time.Time:
- return Times(key, val)
+ c = anyFieldC[[]time.Time](Times)
case time.Duration:
- return Duration(key, val)
+ c = anyFieldC[time.Duration](Duration)
case *time.Duration:
- return Durationp(key, val)
+ c = anyFieldC[*time.Duration](Durationp)
case []time.Duration:
- return Durations(key, val)
+ c = anyFieldC[[]time.Duration](Durations)
case error:
- return NamedError(key, val)
+ c = anyFieldC[error](NamedError)
case []error:
- return Errors(key, val)
+ c = anyFieldC[[]error](Errors)
case fmt.Stringer:
- return Stringer(key, val)
+ c = anyFieldC[fmt.Stringer](Stringer)
default:
- return Reflect(key, val)
+ c = anyFieldC[any](Reflect)
}
+
+ return c.Any(key, value)
}
diff --git a/tools/vendor/go.uber.org/zap/http_handler.go b/tools/vendor/go.uber.org/zap/http_handler.go
index 632b6831a..2be8f6515 100644
--- a/tools/vendor/go.uber.org/zap/http_handler.go
+++ b/tools/vendor/go.uber.org/zap/http_handler.go
@@ -69,6 +69,13 @@ import (
//
// curl -X PUT localhost:8080/log/level -H "Content-Type: application/json" -d '{"level":"debug"}'
func (lvl AtomicLevel) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ if err := lvl.serveHTTP(w, r); err != nil {
+ w.WriteHeader(http.StatusInternalServerError)
+ fmt.Fprintf(w, "internal error: %v", err)
+ }
+}
+
+func (lvl AtomicLevel) serveHTTP(w http.ResponseWriter, r *http.Request) error {
type errorResponse struct {
Error string `json:"error"`
}
@@ -80,19 +87,20 @@ func (lvl AtomicLevel) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
- enc.Encode(payload{Level: lvl.Level()})
+ return enc.Encode(payload{Level: lvl.Level()})
+
case http.MethodPut:
requestedLvl, err := decodePutRequest(r.Header.Get("Content-Type"), r)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
- enc.Encode(errorResponse{Error: err.Error()})
- return
+ return enc.Encode(errorResponse{Error: err.Error()})
}
lvl.SetLevel(requestedLvl)
- enc.Encode(payload{Level: lvl.Level()})
+ return enc.Encode(payload{Level: lvl.Level()})
+
default:
w.WriteHeader(http.StatusMethodNotAllowed)
- enc.Encode(errorResponse{
+ return enc.Encode(errorResponse{
Error: "Only GET and PUT are supported.",
})
}
@@ -129,5 +137,4 @@ func decodePutJSON(body io.Reader) (zapcore.Level, error) {
return 0, errors.New("must specify logging level")
}
return *pld.Level, nil
-
}
diff --git a/tools/vendor/go.uber.org/zap/internal/level_enabler.go b/tools/vendor/go.uber.org/zap/internal/level_enabler.go
index 5f3e3f1b9..40bfed81e 100644
--- a/tools/vendor/go.uber.org/zap/internal/level_enabler.go
+++ b/tools/vendor/go.uber.org/zap/internal/level_enabler.go
@@ -18,6 +18,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+// Package internal and its subpackages hold types and functionality
+// that are not part of Zap's public API.
package internal
import "go.uber.org/zap/zapcore"
diff --git a/tools/vendor/go.uber.org/atomic/bool_ext.go b/tools/vendor/go.uber.org/zap/internal/pool/pool.go
similarity index 56%
rename from tools/vendor/go.uber.org/atomic/bool_ext.go
rename to tools/vendor/go.uber.org/zap/internal/pool/pool.go
index c7bf7a827..60e9d2c43 100644
--- a/tools/vendor/go.uber.org/atomic/bool_ext.go
+++ b/tools/vendor/go.uber.org/zap/internal/pool/pool.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2020 Uber Technologies, Inc.
+// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -18,36 +18,41 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-package atomic
+// Package pool provides internal pool utilities.
+package pool
import (
- "strconv"
+ "sync"
)
-//go:generate bin/gen-atomicwrapper -name=Bool -type=bool -wrapped=Uint32 -pack=boolToInt -unpack=truthy -cas -swap -json -file=bool.go
-
-func truthy(n uint32) bool {
- return n == 1
+// A Pool is a generic wrapper around [sync.Pool] to provide strongly-typed
+// object pooling.
+//
+// Note that SA6002 (ref: https://staticcheck.io/docs/checks/#SA6002) will
+// not be detected, so all internal pool use must take care to only store
+// pointer types.
+type Pool[T any] struct {
+ pool sync.Pool
}
-func boolToInt(b bool) uint32 {
- if b {
- return 1
+// New returns a new [Pool] for T, and will use fn to construct new Ts when
+// the pool is empty.
+func New[T any](fn func() T) *Pool[T] {
+ return &Pool[T]{
+ pool: sync.Pool{
+ New: func() any {
+ return fn()
+ },
+ },
}
- return 0
}
-// Toggle atomically negates the Boolean and returns the previous value.
-func (b *Bool) Toggle() bool {
- for {
- old := b.Load()
- if b.CAS(old, !old) {
- return old
- }
- }
+// Get gets a T from the pool, or creates a new one if the pool is empty.
+func (p *Pool[T]) Get() T {
+ return p.pool.Get().(T)
}
-// String encodes the wrapped value as a string.
-func (b *Bool) String() string {
- return strconv.FormatBool(b.Load())
+// Put returns x into the pool.
+func (p *Pool[T]) Put(x T) {
+ p.pool.Put(x)
}
diff --git a/tools/vendor/go.uber.org/zap/stacktrace.go b/tools/vendor/go.uber.org/zap/internal/stacktrace/stack.go
similarity index 73%
rename from tools/vendor/go.uber.org/zap/stacktrace.go
rename to tools/vendor/go.uber.org/zap/internal/stacktrace/stack.go
index 817a3bde8..82af7551f 100644
--- a/tools/vendor/go.uber.org/zap/stacktrace.go
+++ b/tools/vendor/go.uber.org/zap/internal/stacktrace/stack.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2016 Uber Technologies, Inc.
+// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -18,25 +18,26 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-package zap
+// Package stacktrace provides support for gathering stack traces
+// efficiently.
+package stacktrace
import (
"runtime"
- "sync"
"go.uber.org/zap/buffer"
"go.uber.org/zap/internal/bufferpool"
+ "go.uber.org/zap/internal/pool"
)
-var _stacktracePool = sync.Pool{
- New: func() interface{} {
- return &stacktrace{
- storage: make([]uintptr, 64),
- }
- },
-}
+var _stackPool = pool.New(func() *Stack {
+ return &Stack{
+ storage: make([]uintptr, 64),
+ }
+})
-type stacktrace struct {
+// Stack is a captured stack trace.
+type Stack struct {
pcs []uintptr // program counters; always a subslice of storage
frames *runtime.Frames
@@ -50,30 +51,30 @@ type stacktrace struct {
storage []uintptr
}
-// stacktraceDepth specifies how deep of a stack trace should be captured.
-type stacktraceDepth int
+// Depth specifies how deep of a stack trace should be captured.
+type Depth int
const (
- // stacktraceFirst captures only the first frame.
- stacktraceFirst stacktraceDepth = iota
+ // First captures only the first frame.
+ First Depth = iota
- // stacktraceFull captures the entire call stack, allocating more
+ // Full captures the entire call stack, allocating more
// storage for it if needed.
- stacktraceFull
+ Full
)
-// captureStacktrace captures a stack trace of the specified depth, skipping
+// Capture captures a stack trace of the specified depth, skipping
// the provided number of frames. skip=0 identifies the caller of
-// captureStacktrace.
+// Capture.
//
// The caller must call Free on the returned stacktrace after using it.
-func captureStacktrace(skip int, depth stacktraceDepth) *stacktrace {
- stack := _stacktracePool.Get().(*stacktrace)
+func Capture(skip int, depth Depth) *Stack {
+ stack := _stackPool.Get()
switch depth {
- case stacktraceFirst:
+ case First:
stack.pcs = stack.storage[:1]
- case stacktraceFull:
+ case Full:
stack.pcs = stack.storage
}
@@ -87,7 +88,7 @@ func captureStacktrace(skip int, depth stacktraceDepth) *stacktrace {
// runtime.Callers truncates the recorded stacktrace if there is no
// room in the provided slice. For the full stack trace, keep expanding
// storage until there are fewer frames than there is room.
- if depth == stacktraceFull {
+ if depth == Full {
pcs := stack.pcs
for numFrames == len(pcs) {
pcs = make([]uintptr, len(pcs)*2)
@@ -109,50 +110,54 @@ func captureStacktrace(skip int, depth stacktraceDepth) *stacktrace {
// Free releases resources associated with this stacktrace
// and returns it back to the pool.
-func (st *stacktrace) Free() {
+func (st *Stack) Free() {
st.frames = nil
st.pcs = nil
- _stacktracePool.Put(st)
+ _stackPool.Put(st)
}
// Count reports the total number of frames in this stacktrace.
// Count DOES NOT change as Next is called.
-func (st *stacktrace) Count() int {
+func (st *Stack) Count() int {
return len(st.pcs)
}
// Next returns the next frame in the stack trace,
// and a boolean indicating whether there are more after it.
-func (st *stacktrace) Next() (_ runtime.Frame, more bool) {
+func (st *Stack) Next() (_ runtime.Frame, more bool) {
return st.frames.Next()
}
-func takeStacktrace(skip int) string {
- stack := captureStacktrace(skip+1, stacktraceFull)
+// Take returns a string representation of the current stacktrace.
+//
+// skip is the number of frames to skip before recording the stack trace.
+// skip=0 identifies the caller of Take.
+func Take(skip int) string {
+ stack := Capture(skip+1, Full)
defer stack.Free()
buffer := bufferpool.Get()
defer buffer.Free()
- stackfmt := newStackFormatter(buffer)
+ stackfmt := NewFormatter(buffer)
stackfmt.FormatStack(stack)
return buffer.String()
}
-// stackFormatter formats a stack trace into a readable string representation.
-type stackFormatter struct {
+// Formatter formats a stack trace into a readable string representation.
+type Formatter struct {
b *buffer.Buffer
nonEmpty bool // whehther we've written at least one frame already
}
-// newStackFormatter builds a new stackFormatter.
-func newStackFormatter(b *buffer.Buffer) stackFormatter {
- return stackFormatter{b: b}
+// NewFormatter builds a new Formatter.
+func NewFormatter(b *buffer.Buffer) Formatter {
+ return Formatter{b: b}
}
// FormatStack formats all remaining frames in the provided stacktrace -- minus
// the final runtime.main/runtime.goexit frame.
-func (sf *stackFormatter) FormatStack(stack *stacktrace) {
+func (sf *Formatter) FormatStack(stack *Stack) {
// Note: On the last iteration, frames.Next() returns false, with a valid
// frame, but we ignore this frame. The last frame is a runtime frame which
// adds noise, since it's only either runtime.main or runtime.goexit.
@@ -162,7 +167,7 @@ func (sf *stackFormatter) FormatStack(stack *stacktrace) {
}
// FormatFrame formats the given frame.
-func (sf *stackFormatter) FormatFrame(frame runtime.Frame) {
+func (sf *Formatter) FormatFrame(frame runtime.Frame) {
if sf.nonEmpty {
sf.b.AppendByte('\n')
}
diff --git a/tools/vendor/go.uber.org/zap/level.go b/tools/vendor/go.uber.org/zap/level.go
index db951e19a..155b208bd 100644
--- a/tools/vendor/go.uber.org/zap/level.go
+++ b/tools/vendor/go.uber.org/zap/level.go
@@ -21,7 +21,8 @@
package zap
import (
- "go.uber.org/atomic"
+ "sync/atomic"
+
"go.uber.org/zap/internal"
"go.uber.org/zap/zapcore"
)
@@ -76,9 +77,9 @@ var _ internal.LeveledEnabler = AtomicLevel{}
// NewAtomicLevel creates an AtomicLevel with InfoLevel and above logging
// enabled.
func NewAtomicLevel() AtomicLevel {
- return AtomicLevel{
- l: atomic.NewInt32(int32(InfoLevel)),
- }
+ lvl := AtomicLevel{l: new(atomic.Int32)}
+ lvl.l.Store(int32(InfoLevel))
+ return lvl
}
// NewAtomicLevelAt is a convenience function that creates an AtomicLevel
diff --git a/tools/vendor/go.uber.org/zap/logger.go b/tools/vendor/go.uber.org/zap/logger.go
index cd44030d1..c4d300323 100644
--- a/tools/vendor/go.uber.org/zap/logger.go
+++ b/tools/vendor/go.uber.org/zap/logger.go
@@ -27,6 +27,7 @@ import (
"strings"
"go.uber.org/zap/internal/bufferpool"
+ "go.uber.org/zap/internal/stacktrace"
"go.uber.org/zap/zapcore"
)
@@ -42,6 +43,7 @@ type Logger struct {
development bool
addCaller bool
+ onPanic zapcore.CheckWriteHook // default is WriteThenPanic
onFatal zapcore.CheckWriteHook // default is WriteThenFatal
name string
@@ -173,7 +175,8 @@ func (log *Logger) WithOptions(opts ...Option) *Logger {
}
// With creates a child logger and adds structured context to it. Fields added
-// to the child don't affect the parent, and vice versa.
+// to the child don't affect the parent, and vice versa. Any fields that
+// require evaluation (such as Objects) are evaluated upon invocation of With.
func (log *Logger) With(fields ...Field) *Logger {
if len(fields) == 0 {
return log
@@ -183,6 +186,28 @@ func (log *Logger) With(fields ...Field) *Logger {
return l
}
+// WithLazy creates a child logger and adds structured context to it lazily.
+//
+// The fields are evaluated only if the logger is further chained with [With]
+// or is written to with any of the log level methods.
+// Until that occurs, the logger may retain references to objects inside the fields,
+// and logging will reflect the state of an object at the time of logging,
+// not the time of WithLazy().
+//
+// WithLazy provides a worthwhile performance optimization for contextual loggers
+// when the likelihood of using the child logger is low,
+// such as error paths and rarely taken branches.
+//
+// Similar to [With], fields added to the child don't affect the parent, and vice versa.
+func (log *Logger) WithLazy(fields ...Field) *Logger {
+ if len(fields) == 0 {
+ return log
+ }
+ return log.WithOptions(WrapCore(func(core zapcore.Core) zapcore.Core {
+ return zapcore.NewLazyWith(core, fields)
+ }))
+}
+
// Level reports the minimum enabled level for this logger.
//
// For NopLoggers, this is [zapcore.InvalidLevel].
@@ -199,6 +224,8 @@ func (log *Logger) Check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
// Log logs a message at the specified level. The message includes any fields
// passed at the log site, as well as any fields accumulated on the logger.
+// Any Fields that require evaluation (such as Objects) are evaluated upon
+// invocation of Log.
func (log *Logger) Log(lvl zapcore.Level, msg string, fields ...Field) {
if ce := log.check(lvl, msg); ce != nil {
ce.Write(fields...)
@@ -281,9 +308,15 @@ func (log *Logger) Core() zapcore.Core {
return log.core
}
+// Name returns the Logger's underlying name,
+// or an empty string if the logger is unnamed.
+func (log *Logger) Name() string {
+ return log.name
+}
+
func (log *Logger) clone() *Logger {
- copy := *log
- return ©
+ clone := *log
+ return &clone
}
func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
@@ -313,27 +346,12 @@ func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
// Set up any required terminal behavior.
switch ent.Level {
case zapcore.PanicLevel:
- ce = ce.After(ent, zapcore.WriteThenPanic)
+ ce = ce.After(ent, terminalHookOverride(zapcore.WriteThenPanic, log.onPanic))
case zapcore.FatalLevel:
- onFatal := log.onFatal
- // nil or WriteThenNoop will lead to continued execution after
- // a Fatal log entry, which is unexpected. For example,
- //
- // f, err := os.Open(..)
- // if err != nil {
- // log.Fatal("cannot open", zap.Error(err))
- // }
- // fmt.Println(f.Name())
- //
- // The f.Name() will panic if we continue execution after the
- // log.Fatal.
- if onFatal == nil || onFatal == zapcore.WriteThenNoop {
- onFatal = zapcore.WriteThenFatal
- }
- ce = ce.After(ent, onFatal)
+ ce = ce.After(ent, terminalHookOverride(zapcore.WriteThenFatal, log.onFatal))
case zapcore.DPanicLevel:
if log.development {
- ce = ce.After(ent, zapcore.WriteThenPanic)
+ ce = ce.After(ent, terminalHookOverride(zapcore.WriteThenPanic, log.onPanic))
}
}
@@ -354,17 +372,17 @@ func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
// Adding the caller or stack trace requires capturing the callers of
// this function. We'll share information between these two.
- stackDepth := stacktraceFirst
+ stackDepth := stacktrace.First
if addStack {
- stackDepth = stacktraceFull
+ stackDepth = stacktrace.Full
}
- stack := captureStacktrace(log.callerSkip+callerSkipOffset, stackDepth)
+ stack := stacktrace.Capture(log.callerSkip+callerSkipOffset, stackDepth)
defer stack.Free()
if stack.Count() == 0 {
if log.addCaller {
fmt.Fprintf(log.errorOutput, "%v Logger.check error: failed to get caller\n", ent.Time.UTC())
- log.errorOutput.Sync()
+ _ = log.errorOutput.Sync()
}
return ce
}
@@ -385,7 +403,7 @@ func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
buffer := bufferpool.Get()
defer buffer.Free()
- stackfmt := newStackFormatter(buffer)
+ stackfmt := stacktrace.NewFormatter(buffer)
// We've already extracted the first frame, so format that
// separately and defer to stackfmt for the rest.
@@ -398,3 +416,20 @@ func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
return ce
}
+
+func terminalHookOverride(defaultHook, override zapcore.CheckWriteHook) zapcore.CheckWriteHook {
+ // A nil or WriteThenNoop hook will lead to continued execution after
+ // a Panic or Fatal log entry, which is unexpected. For example,
+ //
+ // f, err := os.Open(..)
+ // if err != nil {
+ // log.Fatal("cannot open", zap.Error(err))
+ // }
+ // fmt.Println(f.Name())
+ //
+ // The f.Name() will panic if we continue execution after the log.Fatal.
+ if override == nil || override == zapcore.WriteThenNoop {
+ return defaultHook
+ }
+ return override
+}
diff --git a/tools/vendor/go.uber.org/zap/options.go b/tools/vendor/go.uber.org/zap/options.go
index c4f3bca3d..43d357ac9 100644
--- a/tools/vendor/go.uber.org/zap/options.go
+++ b/tools/vendor/go.uber.org/zap/options.go
@@ -132,6 +132,21 @@ func IncreaseLevel(lvl zapcore.LevelEnabler) Option {
})
}
+// WithPanicHook sets a CheckWriteHook to run on Panic/DPanic logs.
+// Zap will call this hook after writing a log statement with a Panic/DPanic level.
+//
+// For example, the following builds a logger that will exit the current
+// goroutine after writing a Panic/DPanic log message, but it will not start a panic.
+//
+// zap.New(core, zap.WithPanicHook(zapcore.WriteThenGoexit))
+//
+// This is useful for testing Panic/DPanic log output.
+func WithPanicHook(hook zapcore.CheckWriteHook) Option {
+ return optionFunc(func(log *Logger) {
+ log.onPanic = hook
+ })
+}
+
// OnFatal sets the action to take on fatal logs.
//
// Deprecated: Use [WithFatalHook] instead.
diff --git a/tools/vendor/go.uber.org/zap/sink.go b/tools/vendor/go.uber.org/zap/sink.go
index 478c9a10f..499772a00 100644
--- a/tools/vendor/go.uber.org/zap/sink.go
+++ b/tools/vendor/go.uber.org/zap/sink.go
@@ -66,7 +66,8 @@ func newSinkRegistry() *sinkRegistry {
factories: make(map[string]func(*url.URL) (Sink, error)),
openFile: os.OpenFile,
}
- sr.RegisterSink(schemeFile, sr.newFileSinkFromURL)
+ // Infallible operation: the registry is empty, so we can't have a conflict.
+ _ = sr.RegisterSink(schemeFile, sr.newFileSinkFromURL)
return sr
}
@@ -154,7 +155,7 @@ func (sr *sinkRegistry) newFileSinkFromPath(path string) (Sink, error) {
case "stderr":
return nopCloserSink{os.Stderr}, nil
}
- return sr.openFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
+ return sr.openFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0o666)
}
func normalizeScheme(s string) (string, error) {
diff --git a/tools/vendor/go.uber.org/zap/sugar.go b/tools/vendor/go.uber.org/zap/sugar.go
index ac387b3e4..8904cd087 100644
--- a/tools/vendor/go.uber.org/zap/sugar.go
+++ b/tools/vendor/go.uber.org/zap/sugar.go
@@ -115,6 +115,21 @@ func (s *SugaredLogger) With(args ...interface{}) *SugaredLogger {
return &SugaredLogger{base: s.base.With(s.sweetenFields(args)...)}
}
+// WithLazy adds a variadic number of fields to the logging context lazily.
+// The fields are evaluated only if the logger is further chained with [With]
+// or is written to with any of the log level methods.
+// Until that occurs, the logger may retain references to objects inside the fields,
+// and logging will reflect the state of an object at the time of logging,
+// not the time of WithLazy().
+//
+// Similar to [With], fields added to the child don't affect the parent,
+// and vice versa. Also, the keys in key-value pairs should be strings. In development,
+// passing a non-string key panics, while in production it logs an error and skips the pair.
+// Passing an orphaned key has the same behavior.
+func (s *SugaredLogger) WithLazy(args ...interface{}) *SugaredLogger {
+ return &SugaredLogger{base: s.base.WithLazy(s.sweetenFields(args)...)}
+}
+
// Level reports the minimum enabled level for this logger.
//
// For NopLoggers, this is [zapcore.InvalidLevel].
@@ -122,78 +137,110 @@ func (s *SugaredLogger) Level() zapcore.Level {
return zapcore.LevelOf(s.base.core)
}
-// Debug uses fmt.Sprint to construct and log a message.
+// Log logs the provided arguments at provided level.
+// Spaces are added between arguments when neither is a string.
+func (s *SugaredLogger) Log(lvl zapcore.Level, args ...interface{}) {
+ s.log(lvl, "", args, nil)
+}
+
+// Debug logs the provided arguments at [DebugLevel].
+// Spaces are added between arguments when neither is a string.
func (s *SugaredLogger) Debug(args ...interface{}) {
s.log(DebugLevel, "", args, nil)
}
-// Info uses fmt.Sprint to construct and log a message.
+// Info logs the provided arguments at [InfoLevel].
+// Spaces are added between arguments when neither is a string.
func (s *SugaredLogger) Info(args ...interface{}) {
s.log(InfoLevel, "", args, nil)
}
-// Warn uses fmt.Sprint to construct and log a message.
+// Warn logs the provided arguments at [WarnLevel].
+// Spaces are added between arguments when neither is a string.
func (s *SugaredLogger) Warn(args ...interface{}) {
s.log(WarnLevel, "", args, nil)
}
-// Error uses fmt.Sprint to construct and log a message.
+// Error logs the provided arguments at [ErrorLevel].
+// Spaces are added between arguments when neither is a string.
func (s *SugaredLogger) Error(args ...interface{}) {
s.log(ErrorLevel, "", args, nil)
}
-// DPanic uses fmt.Sprint to construct and log a message. In development, the
-// logger then panics. (See DPanicLevel for details.)
+// DPanic logs the provided arguments at [DPanicLevel].
+// In development, the logger then panics. (See [DPanicLevel] for details.)
+// Spaces are added between arguments when neither is a string.
func (s *SugaredLogger) DPanic(args ...interface{}) {
s.log(DPanicLevel, "", args, nil)
}
-// Panic uses fmt.Sprint to construct and log a message, then panics.
+// Panic constructs a message with the provided arguments and panics.
+// Spaces are added between arguments when neither is a string.
func (s *SugaredLogger) Panic(args ...interface{}) {
s.log(PanicLevel, "", args, nil)
}
-// Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
+// Fatal constructs a message with the provided arguments and calls os.Exit.
+// Spaces are added between arguments when neither is a string.
func (s *SugaredLogger) Fatal(args ...interface{}) {
s.log(FatalLevel, "", args, nil)
}
-// Debugf uses fmt.Sprintf to log a templated message.
+// Logf formats the message according to the format specifier
+// and logs it at provided level.
+func (s *SugaredLogger) Logf(lvl zapcore.Level, template string, args ...interface{}) {
+ s.log(lvl, template, args, nil)
+}
+
+// Debugf formats the message according to the format specifier
+// and logs it at [DebugLevel].
func (s *SugaredLogger) Debugf(template string, args ...interface{}) {
s.log(DebugLevel, template, args, nil)
}
-// Infof uses fmt.Sprintf to log a templated message.
+// Infof formats the message according to the format specifier
+// and logs it at [InfoLevel].
func (s *SugaredLogger) Infof(template string, args ...interface{}) {
s.log(InfoLevel, template, args, nil)
}
-// Warnf uses fmt.Sprintf to log a templated message.
+// Warnf formats the message according to the format specifier
+// and logs it at [WarnLevel].
func (s *SugaredLogger) Warnf(template string, args ...interface{}) {
s.log(WarnLevel, template, args, nil)
}
-// Errorf uses fmt.Sprintf to log a templated message.
+// Errorf formats the message according to the format specifier
+// and logs it at [ErrorLevel].
func (s *SugaredLogger) Errorf(template string, args ...interface{}) {
s.log(ErrorLevel, template, args, nil)
}
-// DPanicf uses fmt.Sprintf to log a templated message. In development, the
-// logger then panics. (See DPanicLevel for details.)
+// DPanicf formats the message according to the format specifier
+// and logs it at [DPanicLevel].
+// In development, the logger then panics. (See [DPanicLevel] for details.)
func (s *SugaredLogger) DPanicf(template string, args ...interface{}) {
s.log(DPanicLevel, template, args, nil)
}
-// Panicf uses fmt.Sprintf to log a templated message, then panics.
+// Panicf formats the message according to the format specifier
+// and panics.
func (s *SugaredLogger) Panicf(template string, args ...interface{}) {
s.log(PanicLevel, template, args, nil)
}
-// Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.
+// Fatalf formats the message according to the format specifier
+// and calls os.Exit.
func (s *SugaredLogger) Fatalf(template string, args ...interface{}) {
s.log(FatalLevel, template, args, nil)
}
+// Logw logs a message with some additional context. The variadic key-value
+// pairs are treated as they are in With.
+func (s *SugaredLogger) Logw(lvl zapcore.Level, msg string, keysAndValues ...interface{}) {
+ s.log(lvl, msg, nil, keysAndValues)
+}
+
// Debugw logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
//
@@ -241,38 +288,51 @@ func (s *SugaredLogger) Fatalw(msg string, keysAndValues ...interface{}) {
s.log(FatalLevel, msg, nil, keysAndValues)
}
-// Debugln uses fmt.Sprintln to construct and log a message.
+// Logln logs a message at provided level.
+// Spaces are always added between arguments.
+func (s *SugaredLogger) Logln(lvl zapcore.Level, args ...interface{}) {
+ s.logln(lvl, args, nil)
+}
+
+// Debugln logs a message at [DebugLevel].
+// Spaces are always added between arguments.
func (s *SugaredLogger) Debugln(args ...interface{}) {
s.logln(DebugLevel, args, nil)
}
-// Infoln uses fmt.Sprintln to construct and log a message.
+// Infoln logs a message at [InfoLevel].
+// Spaces are always added between arguments.
func (s *SugaredLogger) Infoln(args ...interface{}) {
s.logln(InfoLevel, args, nil)
}
-// Warnln uses fmt.Sprintln to construct and log a message.
+// Warnln logs a message at [WarnLevel].
+// Spaces are always added between arguments.
func (s *SugaredLogger) Warnln(args ...interface{}) {
s.logln(WarnLevel, args, nil)
}
-// Errorln uses fmt.Sprintln to construct and log a message.
+// Errorln logs a message at [ErrorLevel].
+// Spaces are always added between arguments.
func (s *SugaredLogger) Errorln(args ...interface{}) {
s.logln(ErrorLevel, args, nil)
}
-// DPanicln uses fmt.Sprintln to construct and log a message. In development, the
-// logger then panics. (See DPanicLevel for details.)
+// DPanicln logs a message at [DPanicLevel].
+// In development, the logger then panics. (See [DPanicLevel] for details.)
+// Spaces are always added between arguments.
func (s *SugaredLogger) DPanicln(args ...interface{}) {
s.logln(DPanicLevel, args, nil)
}
-// Panicln uses fmt.Sprintln to construct and log a message, then panics.
+// Panicln logs a message at [PanicLevel] and panics.
+// Spaces are always added between arguments.
func (s *SugaredLogger) Panicln(args ...interface{}) {
s.logln(PanicLevel, args, nil)
}
-// Fatalln uses fmt.Sprintln to construct and log a message, then calls os.Exit.
+// Fatalln logs a message at [FatalLevel] and calls os.Exit.
+// Spaces are always added between arguments.
func (s *SugaredLogger) Fatalln(args ...interface{}) {
s.logln(FatalLevel, args, nil)
}
diff --git a/tools/vendor/go.uber.org/zap/writer.go b/tools/vendor/go.uber.org/zap/writer.go
index f08728e1e..06768c679 100644
--- a/tools/vendor/go.uber.org/zap/writer.go
+++ b/tools/vendor/go.uber.org/zap/writer.go
@@ -48,21 +48,21 @@ import (
// os.Stdout and os.Stderr. When specified without a scheme, relative file
// paths also work.
func Open(paths ...string) (zapcore.WriteSyncer, func(), error) {
- writers, close, err := open(paths)
+ writers, closeAll, err := open(paths)
if err != nil {
return nil, nil, err
}
writer := CombineWriteSyncers(writers...)
- return writer, close, nil
+ return writer, closeAll, nil
}
func open(paths []string) ([]zapcore.WriteSyncer, func(), error) {
writers := make([]zapcore.WriteSyncer, 0, len(paths))
closers := make([]io.Closer, 0, len(paths))
- close := func() {
+ closeAll := func() {
for _, c := range closers {
- c.Close()
+ _ = c.Close()
}
}
@@ -77,11 +77,11 @@ func open(paths []string) ([]zapcore.WriteSyncer, func(), error) {
closers = append(closers, sink)
}
if openErr != nil {
- close()
+ closeAll()
return nil, nil, openErr
}
- return writers, close, nil
+ return writers, closeAll, nil
}
// CombineWriteSyncers is a utility that combines multiple WriteSyncers into a
diff --git a/tools/vendor/go.uber.org/zap/zapcore/console_encoder.go b/tools/vendor/go.uber.org/zap/zapcore/console_encoder.go
index 1aa5dc364..cc2b4e07b 100644
--- a/tools/vendor/go.uber.org/zap/zapcore/console_encoder.go
+++ b/tools/vendor/go.uber.org/zap/zapcore/console_encoder.go
@@ -22,20 +22,20 @@ package zapcore
import (
"fmt"
- "sync"
"go.uber.org/zap/buffer"
"go.uber.org/zap/internal/bufferpool"
+ "go.uber.org/zap/internal/pool"
)
-var _sliceEncoderPool = sync.Pool{
- New: func() interface{} {
- return &sliceArrayEncoder{elems: make([]interface{}, 0, 2)}
- },
-}
+var _sliceEncoderPool = pool.New(func() *sliceArrayEncoder {
+ return &sliceArrayEncoder{
+ elems: make([]interface{}, 0, 2),
+ }
+})
func getSliceEncoder() *sliceArrayEncoder {
- return _sliceEncoderPool.Get().(*sliceArrayEncoder)
+ return _sliceEncoderPool.Get()
}
func putSliceEncoder(e *sliceArrayEncoder) {
@@ -77,7 +77,7 @@ func (c consoleEncoder) EncodeEntry(ent Entry, fields []Field) (*buffer.Buffer,
// If this ever becomes a performance bottleneck, we can implement
// ArrayEncoder for our plain-text format.
arr := getSliceEncoder()
- if c.TimeKey != "" && c.EncodeTime != nil {
+ if c.TimeKey != "" && c.EncodeTime != nil && !ent.Time.IsZero() {
c.EncodeTime(ent.Time, arr)
}
if c.LevelKey != "" && c.EncodeLevel != nil {
diff --git a/tools/vendor/go.uber.org/zap/zapcore/core.go b/tools/vendor/go.uber.org/zap/zapcore/core.go
index 9dfd64051..776e93f6f 100644
--- a/tools/vendor/go.uber.org/zap/zapcore/core.go
+++ b/tools/vendor/go.uber.org/zap/zapcore/core.go
@@ -102,9 +102,9 @@ func (c *ioCore) Write(ent Entry, fields []Field) error {
return err
}
if ent.Level > ErrorLevel {
- // Since we may be crashing the program, sync the output. Ignore Sync
- // errors, pending a clean solution to issue #370.
- c.Sync()
+ // Since we may be crashing the program, sync the output.
+ // Ignore Sync errors, pending a clean solution to issue #370.
+ _ = c.Sync()
}
return nil
}
diff --git a/tools/vendor/go.uber.org/zap/zapcore/encoder.go b/tools/vendor/go.uber.org/zap/zapcore/encoder.go
index 5769ff3e4..044625415 100644
--- a/tools/vendor/go.uber.org/zap/zapcore/encoder.go
+++ b/tools/vendor/go.uber.org/zap/zapcore/encoder.go
@@ -37,6 +37,9 @@ const DefaultLineEnding = "\n"
const OmitKey = ""
// A LevelEncoder serializes a Level to a primitive type.
+//
+// This function must make exactly one call
+// to a PrimitiveArrayEncoder's Append* method.
type LevelEncoder func(Level, PrimitiveArrayEncoder)
// LowercaseLevelEncoder serializes a Level to a lowercase string. For example,
@@ -90,6 +93,9 @@ func (e *LevelEncoder) UnmarshalText(text []byte) error {
}
// A TimeEncoder serializes a time.Time to a primitive type.
+//
+// This function must make exactly one call
+// to a PrimitiveArrayEncoder's Append* method.
type TimeEncoder func(time.Time, PrimitiveArrayEncoder)
// EpochTimeEncoder serializes a time.Time to a floating-point number of seconds
@@ -219,6 +225,9 @@ func (e *TimeEncoder) UnmarshalJSON(data []byte) error {
}
// A DurationEncoder serializes a time.Duration to a primitive type.
+//
+// This function must make exactly one call
+// to a PrimitiveArrayEncoder's Append* method.
type DurationEncoder func(time.Duration, PrimitiveArrayEncoder)
// SecondsDurationEncoder serializes a time.Duration to a floating-point number of seconds elapsed.
@@ -262,6 +271,9 @@ func (e *DurationEncoder) UnmarshalText(text []byte) error {
}
// A CallerEncoder serializes an EntryCaller to a primitive type.
+//
+// This function must make exactly one call
+// to a PrimitiveArrayEncoder's Append* method.
type CallerEncoder func(EntryCaller, PrimitiveArrayEncoder)
// FullCallerEncoder serializes a caller in /full/path/to/package/file:line
@@ -292,6 +304,9 @@ func (e *CallerEncoder) UnmarshalText(text []byte) error {
// A NameEncoder serializes a period-separated logger name to a primitive
// type.
+//
+// This function must make exactly one call
+// to a PrimitiveArrayEncoder's Append* method.
type NameEncoder func(string, PrimitiveArrayEncoder)
// FullNameEncoder serializes the logger name as-is.
diff --git a/tools/vendor/go.uber.org/zap/zapcore/entry.go b/tools/vendor/go.uber.org/zap/zapcore/entry.go
index 9d326e95e..459a5d7ce 100644
--- a/tools/vendor/go.uber.org/zap/zapcore/entry.go
+++ b/tools/vendor/go.uber.org/zap/zapcore/entry.go
@@ -24,25 +24,23 @@ import (
"fmt"
"runtime"
"strings"
- "sync"
"time"
"go.uber.org/multierr"
"go.uber.org/zap/internal/bufferpool"
"go.uber.org/zap/internal/exit"
+ "go.uber.org/zap/internal/pool"
)
-var (
- _cePool = sync.Pool{New: func() interface{} {
- // Pre-allocate some space for cores.
- return &CheckedEntry{
- cores: make([]Core, 4),
- }
- }}
-)
+var _cePool = pool.New(func() *CheckedEntry {
+ // Pre-allocate some space for cores.
+ return &CheckedEntry{
+ cores: make([]Core, 4),
+ }
+})
func getCheckedEntry() *CheckedEntry {
- ce := _cePool.Get().(*CheckedEntry)
+ ce := _cePool.Get()
ce.reset()
return ce
}
@@ -244,7 +242,7 @@ func (ce *CheckedEntry) Write(fields ...Field) {
// CheckedEntry is being used after it was returned to the pool,
// the message may be an amalgamation from multiple call sites.
fmt.Fprintf(ce.ErrorOutput, "%v Unsafe CheckedEntry re-use near Entry %+v.\n", ce.Time, ce.Entry)
- ce.ErrorOutput.Sync()
+ _ = ce.ErrorOutput.Sync() // ignore error
}
return
}
@@ -256,7 +254,7 @@ func (ce *CheckedEntry) Write(fields ...Field) {
}
if err != nil && ce.ErrorOutput != nil {
fmt.Fprintf(ce.ErrorOutput, "%v write error: %v\n", ce.Time, err)
- ce.ErrorOutput.Sync()
+ _ = ce.ErrorOutput.Sync() // ignore error
}
hook := ce.after
diff --git a/tools/vendor/go.uber.org/zap/zapcore/error.go b/tools/vendor/go.uber.org/zap/zapcore/error.go
index 06359907a..c40df1326 100644
--- a/tools/vendor/go.uber.org/zap/zapcore/error.go
+++ b/tools/vendor/go.uber.org/zap/zapcore/error.go
@@ -23,7 +23,8 @@ package zapcore
import (
"fmt"
"reflect"
- "sync"
+
+ "go.uber.org/zap/internal/pool"
)
// Encodes the given error into fields of an object. A field with the given
@@ -97,15 +98,18 @@ func (errs errArray) MarshalLogArray(arr ArrayEncoder) error {
}
el := newErrArrayElem(errs[i])
- arr.AppendObject(el)
+ err := arr.AppendObject(el)
el.Free()
+ if err != nil {
+ return err
+ }
}
return nil
}
-var _errArrayElemPool = sync.Pool{New: func() interface{} {
+var _errArrayElemPool = pool.New(func() *errArrayElem {
return &errArrayElem{}
-}}
+})
// Encodes any error into a {"error": ...} re-using the same errors logic.
//
@@ -113,7 +117,7 @@ var _errArrayElemPool = sync.Pool{New: func() interface{} {
type errArrayElem struct{ err error }
func newErrArrayElem(err error) *errArrayElem {
- e := _errArrayElemPool.Get().(*errArrayElem)
+ e := _errArrayElemPool.Get()
e.err = err
return e
}
diff --git a/tools/vendor/go.uber.org/zap/zapcore/field.go b/tools/vendor/go.uber.org/zap/zapcore/field.go
index 95bdb0a12..308c9781e 100644
--- a/tools/vendor/go.uber.org/zap/zapcore/field.go
+++ b/tools/vendor/go.uber.org/zap/zapcore/field.go
@@ -47,7 +47,7 @@ const (
ByteStringType
// Complex128Type indicates that the field carries a complex128.
Complex128Type
- // Complex64Type indicates that the field carries a complex128.
+ // Complex64Type indicates that the field carries a complex64.
Complex64Type
// DurationType indicates that the field carries a time.Duration.
DurationType
diff --git a/tools/vendor/go.uber.org/zap/zapcore/json_encoder.go b/tools/vendor/go.uber.org/zap/zapcore/json_encoder.go
index 3921c5cd3..9685169b2 100644
--- a/tools/vendor/go.uber.org/zap/zapcore/json_encoder.go
+++ b/tools/vendor/go.uber.org/zap/zapcore/json_encoder.go
@@ -23,24 +23,20 @@ package zapcore
import (
"encoding/base64"
"math"
- "sync"
"time"
"unicode/utf8"
"go.uber.org/zap/buffer"
"go.uber.org/zap/internal/bufferpool"
+ "go.uber.org/zap/internal/pool"
)
// For JSON-escaping; see jsonEncoder.safeAddString below.
const _hex = "0123456789abcdef"
-var _jsonPool = sync.Pool{New: func() interface{} {
+var _jsonPool = pool.New(func() *jsonEncoder {
return &jsonEncoder{}
-}}
-
-func getJSONEncoder() *jsonEncoder {
- return _jsonPool.Get().(*jsonEncoder)
-}
+})
func putJSONEncoder(enc *jsonEncoder) {
if enc.reflectBuf != nil {
@@ -354,7 +350,7 @@ func (enc *jsonEncoder) Clone() Encoder {
}
func (enc *jsonEncoder) clone() *jsonEncoder {
- clone := getJSONEncoder()
+ clone := _jsonPool.Get()
clone.EncoderConfig = enc.EncoderConfig
clone.spaced = enc.spaced
clone.openNamespaces = enc.openNamespaces
@@ -376,7 +372,7 @@ func (enc *jsonEncoder) EncodeEntry(ent Entry, fields []Field) (*buffer.Buffer,
final.AppendString(ent.Level.String())
}
}
- if final.TimeKey != "" {
+ if final.TimeKey != "" && !ent.Time.IsZero() {
final.AddTime(final.TimeKey, ent.Time)
}
if ent.LoggerName != "" && final.NameKey != "" {
@@ -490,73 +486,98 @@ func (enc *jsonEncoder) appendFloat(val float64, bitSize int) {
// Unlike the standard library's encoder, it doesn't attempt to protect the
// user from browser vulnerabilities or JSONP-related problems.
func (enc *jsonEncoder) safeAddString(s string) {
- for i := 0; i < len(s); {
- if enc.tryAddRuneSelf(s[i]) {
- i++
- continue
- }
- r, size := utf8.DecodeRuneInString(s[i:])
- if enc.tryAddRuneError(r, size) {
- i++
- continue
- }
- enc.buf.AppendString(s[i : i+size])
- i += size
- }
+ safeAppendStringLike(
+ (*buffer.Buffer).AppendString,
+ utf8.DecodeRuneInString,
+ enc.buf,
+ s,
+ )
}
// safeAddByteString is no-alloc equivalent of safeAddString(string(s)) for s []byte.
func (enc *jsonEncoder) safeAddByteString(s []byte) {
+ safeAppendStringLike(
+ (*buffer.Buffer).AppendBytes,
+ utf8.DecodeRune,
+ enc.buf,
+ s,
+ )
+}
+
+// safeAppendStringLike is a generic implementation of safeAddString and safeAddByteString.
+// It appends a string or byte slice to the buffer, escaping all special characters.
+func safeAppendStringLike[S []byte | string](
+ // appendTo appends this string-like object to the buffer.
+ appendTo func(*buffer.Buffer, S),
+ // decodeRune decodes the next rune from the string-like object
+ // and returns its value and width in bytes.
+ decodeRune func(S) (rune, int),
+ buf *buffer.Buffer,
+ s S,
+) {
+ // The encoding logic below works by skipping over characters
+ // that can be safely copied as-is,
+ // until a character is found that needs special handling.
+ // At that point, we copy everything we've seen so far,
+ // and then handle that special character.
+ //
+ // last is the index of the last byte that was copied to the buffer.
+ last := 0
for i := 0; i < len(s); {
- if enc.tryAddRuneSelf(s[i]) {
+ if s[i] >= utf8.RuneSelf {
+ // Character >= RuneSelf may be part of a multi-byte rune.
+ // They need to be decoded before we can decide how to handle them.
+ r, size := decodeRune(s[i:])
+ if r != utf8.RuneError || size != 1 {
+ // No special handling required.
+ // Skip over this rune and continue.
+ i += size
+ continue
+ }
+
+ // Invalid UTF-8 sequence.
+ // Replace it with the Unicode replacement character.
+ appendTo(buf, s[last:i])
+ buf.AppendString(`\ufffd`)
+
i++
- continue
- }
- r, size := utf8.DecodeRune(s[i:])
- if enc.tryAddRuneError(r, size) {
+ last = i
+ } else {
+ // Character < RuneSelf is a single-byte UTF-8 rune.
+ if s[i] >= 0x20 && s[i] != '\\' && s[i] != '"' {
+ // No escaping necessary.
+ // Skip over this character and continue.
+ i++
+ continue
+ }
+
+ // This character needs to be escaped.
+ appendTo(buf, s[last:i])
+ switch s[i] {
+ case '\\', '"':
+ buf.AppendByte('\\')
+ buf.AppendByte(s[i])
+ case '\n':
+ buf.AppendByte('\\')
+ buf.AppendByte('n')
+ case '\r':
+ buf.AppendByte('\\')
+ buf.AppendByte('r')
+ case '\t':
+ buf.AppendByte('\\')
+ buf.AppendByte('t')
+ default:
+ // Encode bytes < 0x20, except for the escape sequences above.
+ buf.AppendString(`\u00`)
+ buf.AppendByte(_hex[s[i]>>4])
+ buf.AppendByte(_hex[s[i]&0xF])
+ }
+
i++
- continue
+ last = i
}
- enc.buf.Write(s[i : i+size])
- i += size
- }
-}
-
-// tryAddRuneSelf appends b if it is valid UTF-8 character represented in a single byte.
-func (enc *jsonEncoder) tryAddRuneSelf(b byte) bool {
- if b >= utf8.RuneSelf {
- return false
- }
- if 0x20 <= b && b != '\\' && b != '"' {
- enc.buf.AppendByte(b)
- return true
- }
- switch b {
- case '\\', '"':
- enc.buf.AppendByte('\\')
- enc.buf.AppendByte(b)
- case '\n':
- enc.buf.AppendByte('\\')
- enc.buf.AppendByte('n')
- case '\r':
- enc.buf.AppendByte('\\')
- enc.buf.AppendByte('r')
- case '\t':
- enc.buf.AppendByte('\\')
- enc.buf.AppendByte('t')
- default:
- // Encode bytes < 0x20, except for the escape sequences above.
- enc.buf.AppendString(`\u00`)
- enc.buf.AppendByte(_hex[b>>4])
- enc.buf.AppendByte(_hex[b&0xF])
}
- return true
-}
-func (enc *jsonEncoder) tryAddRuneError(r rune, size int) bool {
- if r == utf8.RuneError && size == 1 {
- enc.buf.AppendString(`\ufffd`)
- return true
- }
- return false
+ // add remaining
+ appendTo(buf, s[last:])
}
diff --git a/tools/vendor/go.uber.org/atomic/error.go b/tools/vendor/go.uber.org/zap/zapcore/lazy_with.go
similarity index 60%
rename from tools/vendor/go.uber.org/atomic/error.go
rename to tools/vendor/go.uber.org/zap/zapcore/lazy_with.go
index a6166fbea..05288d6a8 100644
--- a/tools/vendor/go.uber.org/atomic/error.go
+++ b/tools/vendor/go.uber.org/zap/zapcore/lazy_with.go
@@ -1,6 +1,4 @@
-// @generated Code generated by gen-atomicwrapper.
-
-// Copyright (c) 2020 Uber Technologies, Inc.
+// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -20,32 +18,37 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-package atomic
+package zapcore
-// Error is an atomic type-safe wrapper for error values.
-type Error struct {
- _ nocmp // disallow non-atomic comparison
+import "sync"
- v Value
+type lazyWithCore struct {
+ Core
+ sync.Once
+ fields []Field
}
-var _zeroError error
-
-// NewError creates a new Error.
-func NewError(v error) *Error {
- x := &Error{}
- if v != _zeroError {
- x.Store(v)
+// NewLazyWith wraps a Core with a "lazy" Core that will only encode fields if
+// the logger is written to (or is further chained in a lon-lazy manner).
+func NewLazyWith(core Core, fields []Field) Core {
+ return &lazyWithCore{
+ Core: core,
+ fields: fields,
}
- return x
}
-// Load atomically loads the wrapped error.
-func (x *Error) Load() error {
- return unpackError(x.v.Load())
+func (d *lazyWithCore) initOnce() {
+ d.Once.Do(func() {
+ d.Core = d.Core.With(d.fields)
+ })
+}
+
+func (d *lazyWithCore) With(fields []Field) Core {
+ d.initOnce()
+ return d.Core.With(fields)
}
-// Store atomically stores the passed error.
-func (x *Error) Store(v error) {
- x.v.Store(packError(v))
+func (d *lazyWithCore) Check(e Entry, ce *CheckedEntry) *CheckedEntry {
+ d.initOnce()
+ return d.Core.Check(e, ce)
}
diff --git a/tools/vendor/go.uber.org/zap/zapcore/sampler.go b/tools/vendor/go.uber.org/zap/zapcore/sampler.go
index dc518055a..b7c093a4f 100644
--- a/tools/vendor/go.uber.org/zap/zapcore/sampler.go
+++ b/tools/vendor/go.uber.org/zap/zapcore/sampler.go
@@ -21,9 +21,8 @@
package zapcore
import (
+ "sync/atomic"
"time"
-
- "go.uber.org/atomic"
)
const (
@@ -66,16 +65,16 @@ func (c *counter) IncCheckReset(t time.Time, tick time.Duration) uint64 {
tn := t.UnixNano()
resetAfter := c.resetAt.Load()
if resetAfter > tn {
- return c.counter.Inc()
+ return c.counter.Add(1)
}
c.counter.Store(1)
newResetAfter := tn + tick.Nanoseconds()
- if !c.resetAt.CAS(resetAfter, newResetAfter) {
+ if !c.resetAt.CompareAndSwap(resetAfter, newResetAfter) {
// We raced with another goroutine trying to reset, and it also reset
// the counter to 1, so we need to reincrement the counter.
- return c.counter.Inc()
+ return c.counter.Add(1)
}
return 1
diff --git a/tools/vendor/golang.org/x/text/encoding/encoding.go b/tools/vendor/golang.org/x/text/encoding/encoding.go
new file mode 100644
index 000000000..a0bd7cd4d
--- /dev/null
+++ b/tools/vendor/golang.org/x/text/encoding/encoding.go
@@ -0,0 +1,335 @@
+// Copyright 2013 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 encoding defines an interface for character encodings, such as Shift
+// JIS and Windows 1252, that can convert to and from UTF-8.
+//
+// Encoding implementations are provided in other packages, such as
+// golang.org/x/text/encoding/charmap and
+// golang.org/x/text/encoding/japanese.
+package encoding // import "golang.org/x/text/encoding"
+
+import (
+ "errors"
+ "io"
+ "strconv"
+ "unicode/utf8"
+
+ "golang.org/x/text/encoding/internal/identifier"
+ "golang.org/x/text/transform"
+)
+
+// TODO:
+// - There seems to be some inconsistency in when decoders return errors
+// and when not. Also documentation seems to suggest they shouldn't return
+// errors at all (except for UTF-16).
+// - Encoders seem to rely on or at least benefit from the input being in NFC
+// normal form. Perhaps add an example how users could prepare their output.
+
+// Encoding is a character set encoding that can be transformed to and from
+// UTF-8.
+type Encoding interface {
+ // NewDecoder returns a Decoder.
+ NewDecoder() *Decoder
+
+ // NewEncoder returns an Encoder.
+ NewEncoder() *Encoder
+}
+
+// A Decoder converts bytes to UTF-8. It implements transform.Transformer.
+//
+// Transforming source bytes that are not of that encoding will not result in an
+// error per se. Each byte that cannot be transcoded will be represented in the
+// output by the UTF-8 encoding of '\uFFFD', the replacement rune.
+type Decoder struct {
+ transform.Transformer
+
+ // This forces external creators of Decoders to use names in struct
+ // initializers, allowing for future extendibility without having to break
+ // code.
+ _ struct{}
+}
+
+// Bytes converts the given encoded bytes to UTF-8. It returns the converted
+// bytes or nil, err if any error occurred.
+func (d *Decoder) Bytes(b []byte) ([]byte, error) {
+ b, _, err := transform.Bytes(d, b)
+ if err != nil {
+ return nil, err
+ }
+ return b, nil
+}
+
+// String converts the given encoded string to UTF-8. It returns the converted
+// string or "", err if any error occurred.
+func (d *Decoder) String(s string) (string, error) {
+ s, _, err := transform.String(d, s)
+ if err != nil {
+ return "", err
+ }
+ return s, nil
+}
+
+// Reader wraps another Reader to decode its bytes.
+//
+// The Decoder may not be used for any other operation as long as the returned
+// Reader is in use.
+func (d *Decoder) Reader(r io.Reader) io.Reader {
+ return transform.NewReader(r, d)
+}
+
+// An Encoder converts bytes from UTF-8. It implements transform.Transformer.
+//
+// Each rune that cannot be transcoded will result in an error. In this case,
+// the transform will consume all source byte up to, not including the offending
+// rune. Transforming source bytes that are not valid UTF-8 will be replaced by
+// `\uFFFD`. To return early with an error instead, use transform.Chain to
+// preprocess the data with a UTF8Validator.
+type Encoder struct {
+ transform.Transformer
+
+ // This forces external creators of Encoders to use names in struct
+ // initializers, allowing for future extendibility without having to break
+ // code.
+ _ struct{}
+}
+
+// Bytes converts bytes from UTF-8. It returns the converted bytes or nil, err if
+// any error occurred.
+func (e *Encoder) Bytes(b []byte) ([]byte, error) {
+ b, _, err := transform.Bytes(e, b)
+ if err != nil {
+ return nil, err
+ }
+ return b, nil
+}
+
+// String converts a string from UTF-8. It returns the converted string or
+// "", err if any error occurred.
+func (e *Encoder) String(s string) (string, error) {
+ s, _, err := transform.String(e, s)
+ if err != nil {
+ return "", err
+ }
+ return s, nil
+}
+
+// Writer wraps another Writer to encode its UTF-8 output.
+//
+// The Encoder may not be used for any other operation as long as the returned
+// Writer is in use.
+func (e *Encoder) Writer(w io.Writer) io.Writer {
+ return transform.NewWriter(w, e)
+}
+
+// ASCIISub is the ASCII substitute character, as recommended by
+// https://unicode.org/reports/tr36/#Text_Comparison
+const ASCIISub = '\x1a'
+
+// Nop is the nop encoding. Its transformed bytes are the same as the source
+// bytes; it does not replace invalid UTF-8 sequences.
+var Nop Encoding = nop{}
+
+type nop struct{}
+
+func (nop) NewDecoder() *Decoder {
+ return &Decoder{Transformer: transform.Nop}
+}
+func (nop) NewEncoder() *Encoder {
+ return &Encoder{Transformer: transform.Nop}
+}
+
+// Replacement is the replacement encoding. Decoding from the replacement
+// encoding yields a single '\uFFFD' replacement rune. Encoding from UTF-8 to
+// the replacement encoding yields the same as the source bytes except that
+// invalid UTF-8 is converted to '\uFFFD'.
+//
+// It is defined at http://encoding.spec.whatwg.org/#replacement
+var Replacement Encoding = replacement{}
+
+type replacement struct{}
+
+func (replacement) NewDecoder() *Decoder {
+ return &Decoder{Transformer: replacementDecoder{}}
+}
+
+func (replacement) NewEncoder() *Encoder {
+ return &Encoder{Transformer: replacementEncoder{}}
+}
+
+func (replacement) ID() (mib identifier.MIB, other string) {
+ return identifier.Replacement, ""
+}
+
+type replacementDecoder struct{ transform.NopResetter }
+
+func (replacementDecoder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
+ if len(dst) < 3 {
+ return 0, 0, transform.ErrShortDst
+ }
+ if atEOF {
+ const fffd = "\ufffd"
+ dst[0] = fffd[0]
+ dst[1] = fffd[1]
+ dst[2] = fffd[2]
+ nDst = 3
+ }
+ return nDst, len(src), nil
+}
+
+type replacementEncoder struct{ transform.NopResetter }
+
+func (replacementEncoder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
+ r, size := rune(0), 0
+
+ for ; nSrc < len(src); nSrc += size {
+ r = rune(src[nSrc])
+
+ // Decode a 1-byte rune.
+ if r < utf8.RuneSelf {
+ size = 1
+
+ } else {
+ // Decode a multi-byte rune.
+ r, size = utf8.DecodeRune(src[nSrc:])
+ if size == 1 {
+ // All valid runes of size 1 (those below utf8.RuneSelf) were
+ // handled above. We have invalid UTF-8 or we haven't seen the
+ // full character yet.
+ if !atEOF && !utf8.FullRune(src[nSrc:]) {
+ err = transform.ErrShortSrc
+ break
+ }
+ r = '\ufffd'
+ }
+ }
+
+ if nDst+utf8.RuneLen(r) > len(dst) {
+ err = transform.ErrShortDst
+ break
+ }
+ nDst += utf8.EncodeRune(dst[nDst:], r)
+ }
+ return nDst, nSrc, err
+}
+
+// HTMLEscapeUnsupported wraps encoders to replace source runes outside the
+// repertoire of the destination encoding with HTML escape sequences.
+//
+// This wrapper exists to comply to URL and HTML forms requiring a
+// non-terminating legacy encoder. The produced sequences may lead to data
+// loss as they are indistinguishable from legitimate input. To avoid this
+// issue, use UTF-8 encodings whenever possible.
+func HTMLEscapeUnsupported(e *Encoder) *Encoder {
+ return &Encoder{Transformer: &errorHandler{e, errorToHTML}}
+}
+
+// ReplaceUnsupported wraps encoders to replace source runes outside the
+// repertoire of the destination encoding with an encoding-specific
+// replacement.
+//
+// This wrapper is only provided for backwards compatibility and legacy
+// handling. Its use is strongly discouraged. Use UTF-8 whenever possible.
+func ReplaceUnsupported(e *Encoder) *Encoder {
+ return &Encoder{Transformer: &errorHandler{e, errorToReplacement}}
+}
+
+type errorHandler struct {
+ *Encoder
+ handler func(dst []byte, r rune, err repertoireError) (n int, ok bool)
+}
+
+// TODO: consider making this error public in some form.
+type repertoireError interface {
+ Replacement() byte
+}
+
+func (h errorHandler) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
+ nDst, nSrc, err = h.Transformer.Transform(dst, src, atEOF)
+ for err != nil {
+ rerr, ok := err.(repertoireError)
+ if !ok {
+ return nDst, nSrc, err
+ }
+ r, sz := utf8.DecodeRune(src[nSrc:])
+ n, ok := h.handler(dst[nDst:], r, rerr)
+ if !ok {
+ return nDst, nSrc, transform.ErrShortDst
+ }
+ err = nil
+ nDst += n
+ if nSrc += sz; nSrc < len(src) {
+ var dn, sn int
+ dn, sn, err = h.Transformer.Transform(dst[nDst:], src[nSrc:], atEOF)
+ nDst += dn
+ nSrc += sn
+ }
+ }
+ return nDst, nSrc, err
+}
+
+func errorToHTML(dst []byte, r rune, err repertoireError) (n int, ok bool) {
+ buf := [8]byte{}
+ b := strconv.AppendUint(buf[:0], uint64(r), 10)
+ if n = len(b) + len(""); n >= len(dst) {
+ return 0, false
+ }
+ dst[0] = '&'
+ dst[1] = '#'
+ dst[copy(dst[2:], b)+2] = ';'
+ return n, true
+}
+
+func errorToReplacement(dst []byte, r rune, err repertoireError) (n int, ok bool) {
+ if len(dst) == 0 {
+ return 0, false
+ }
+ dst[0] = err.Replacement()
+ return 1, true
+}
+
+// ErrInvalidUTF8 means that a transformer encountered invalid UTF-8.
+var ErrInvalidUTF8 = errors.New("encoding: invalid UTF-8")
+
+// UTF8Validator is a transformer that returns ErrInvalidUTF8 on the first
+// input byte that is not valid UTF-8.
+var UTF8Validator transform.Transformer = utf8Validator{}
+
+type utf8Validator struct{ transform.NopResetter }
+
+func (utf8Validator) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
+ n := len(src)
+ if n > len(dst) {
+ n = len(dst)
+ }
+ for i := 0; i < n; {
+ if c := src[i]; c < utf8.RuneSelf {
+ dst[i] = c
+ i++
+ continue
+ }
+ _, size := utf8.DecodeRune(src[i:])
+ if size == 1 {
+ // All valid runes of size 1 (those below utf8.RuneSelf) were
+ // handled above. We have invalid UTF-8 or we haven't seen the
+ // full character yet.
+ err = ErrInvalidUTF8
+ if !atEOF && !utf8.FullRune(src[i:]) {
+ err = transform.ErrShortSrc
+ }
+ return i, i, err
+ }
+ if i+size > len(dst) {
+ return i, i, transform.ErrShortDst
+ }
+ for ; size > 0; size-- {
+ dst[i] = src[i]
+ i++
+ }
+ }
+ if len(src) > len(dst) {
+ err = transform.ErrShortDst
+ }
+ return n, n, err
+}
diff --git a/tools/vendor/golang.org/x/text/encoding/internal/identifier/identifier.go b/tools/vendor/golang.org/x/text/encoding/internal/identifier/identifier.go
new file mode 100644
index 000000000..5c9b85c28
--- /dev/null
+++ b/tools/vendor/golang.org/x/text/encoding/internal/identifier/identifier.go
@@ -0,0 +1,81 @@
+// Copyright 2015 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:generate go run gen.go
+
+// Package identifier defines the contract between implementations of Encoding
+// and Index by defining identifiers that uniquely identify standardized coded
+// character sets (CCS) and character encoding schemes (CES), which we will
+// together refer to as encodings, for which Encoding implementations provide
+// converters to and from UTF-8. This package is typically only of concern to
+// implementers of Indexes and Encodings.
+//
+// One part of the identifier is the MIB code, which is defined by IANA and
+// uniquely identifies a CCS or CES. Each code is associated with data that
+// references authorities, official documentation as well as aliases and MIME
+// names.
+//
+// Not all CESs are covered by the IANA registry. The "other" string that is
+// returned by ID can be used to identify other character sets or versions of
+// existing ones.
+//
+// It is recommended that each package that provides a set of Encodings provide
+// the All and Common variables to reference all supported encodings and
+// commonly used subset. This allows Index implementations to include all
+// available encodings without explicitly referencing or knowing about them.
+package identifier
+
+// Note: this package is internal, but could be made public if there is a need
+// for writing third-party Indexes and Encodings.
+
+// References:
+// - http://source.icu-project.org/repos/icu/icu/trunk/source/data/mappings/convrtrs.txt
+// - http://www.iana.org/assignments/character-sets/character-sets.xhtml
+// - http://www.iana.org/assignments/ianacharset-mib/ianacharset-mib
+// - http://www.ietf.org/rfc/rfc2978.txt
+// - https://www.unicode.org/reports/tr22/
+// - http://www.w3.org/TR/encoding/
+// - https://encoding.spec.whatwg.org/
+// - https://encoding.spec.whatwg.org/encodings.json
+// - https://tools.ietf.org/html/rfc6657#section-5
+
+// Interface can be implemented by Encodings to define the CCS or CES for which
+// it implements conversions.
+type Interface interface {
+ // ID returns an encoding identifier. Exactly one of the mib and other
+ // values should be non-zero.
+ //
+ // In the usual case it is only necessary to indicate the MIB code. The
+ // other string can be used to specify encodings for which there is no MIB,
+ // such as "x-mac-dingbat".
+ //
+ // The other string may only contain the characters a-z, A-Z, 0-9, - and _.
+ ID() (mib MIB, other string)
+
+ // NOTE: the restrictions on the encoding are to allow extending the syntax
+ // with additional information such as versions, vendors and other variants.
+}
+
+// A MIB identifies an encoding. It is derived from the IANA MIB codes and adds
+// some identifiers for some encodings that are not covered by the IANA
+// standard.
+//
+// See http://www.iana.org/assignments/ianacharset-mib.
+type MIB uint16
+
+// These additional MIB types are not defined in IANA. They are added because
+// they are common and defined within the text repo.
+const (
+ // Unofficial marks the start of encodings not registered by IANA.
+ Unofficial MIB = 10000 + iota
+
+ // Replacement is the WhatWG replacement encoding.
+ Replacement
+
+ // XUserDefined is the code for x-user-defined.
+ XUserDefined
+
+ // MacintoshCyrillic is the code for x-mac-cyrillic.
+ MacintoshCyrillic
+)
diff --git a/tools/vendor/golang.org/x/text/encoding/internal/identifier/mib.go b/tools/vendor/golang.org/x/text/encoding/internal/identifier/mib.go
new file mode 100644
index 000000000..351fb86e2
--- /dev/null
+++ b/tools/vendor/golang.org/x/text/encoding/internal/identifier/mib.go
@@ -0,0 +1,1627 @@
+// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
+
+package identifier
+
+const (
+ // ASCII is the MIB identifier with IANA name US-ASCII (MIME: US-ASCII).
+ //
+ // ANSI X3.4-1986
+ // Reference: RFC2046
+ ASCII MIB = 3
+
+ // ISOLatin1 is the MIB identifier with IANA name ISO_8859-1:1987 (MIME: ISO-8859-1).
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISOLatin1 MIB = 4
+
+ // ISOLatin2 is the MIB identifier with IANA name ISO_8859-2:1987 (MIME: ISO-8859-2).
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISOLatin2 MIB = 5
+
+ // ISOLatin3 is the MIB identifier with IANA name ISO_8859-3:1988 (MIME: ISO-8859-3).
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISOLatin3 MIB = 6
+
+ // ISOLatin4 is the MIB identifier with IANA name ISO_8859-4:1988 (MIME: ISO-8859-4).
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISOLatin4 MIB = 7
+
+ // ISOLatinCyrillic is the MIB identifier with IANA name ISO_8859-5:1988 (MIME: ISO-8859-5).
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISOLatinCyrillic MIB = 8
+
+ // ISOLatinArabic is the MIB identifier with IANA name ISO_8859-6:1987 (MIME: ISO-8859-6).
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISOLatinArabic MIB = 9
+
+ // ISOLatinGreek is the MIB identifier with IANA name ISO_8859-7:1987 (MIME: ISO-8859-7).
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1947
+ // Reference: RFC1345
+ ISOLatinGreek MIB = 10
+
+ // ISOLatinHebrew is the MIB identifier with IANA name ISO_8859-8:1988 (MIME: ISO-8859-8).
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISOLatinHebrew MIB = 11
+
+ // ISOLatin5 is the MIB identifier with IANA name ISO_8859-9:1989 (MIME: ISO-8859-9).
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISOLatin5 MIB = 12
+
+ // ISOLatin6 is the MIB identifier with IANA name ISO-8859-10 (MIME: ISO-8859-10).
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISOLatin6 MIB = 13
+
+ // ISOTextComm is the MIB identifier with IANA name ISO_6937-2-add.
+ //
+ // ISO-IR: International Register of Escape Sequences and ISO 6937-2:1983
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISOTextComm MIB = 14
+
+ // HalfWidthKatakana is the MIB identifier with IANA name JIS_X0201.
+ //
+ // JIS X 0201-1976. One byte only, this is equivalent to
+ // JIS/Roman (similar to ASCII) plus eight-bit half-width
+ // Katakana
+ // Reference: RFC1345
+ HalfWidthKatakana MIB = 15
+
+ // JISEncoding is the MIB identifier with IANA name JIS_Encoding.
+ //
+ // JIS X 0202-1991. Uses ISO 2022 escape sequences to
+ // shift code sets as documented in JIS X 0202-1991.
+ JISEncoding MIB = 16
+
+ // ShiftJIS is the MIB identifier with IANA name Shift_JIS (MIME: Shift_JIS).
+ //
+ // This charset is an extension of csHalfWidthKatakana by
+ // adding graphic characters in JIS X 0208. The CCS's are
+ // JIS X0201:1997 and JIS X0208:1997. The
+ // complete definition is shown in Appendix 1 of JIS
+ // X0208:1997.
+ // This charset can be used for the top-level media type "text".
+ ShiftJIS MIB = 17
+
+ // EUCPkdFmtJapanese is the MIB identifier with IANA name Extended_UNIX_Code_Packed_Format_for_Japanese (MIME: EUC-JP).
+ //
+ // Standardized by OSF, UNIX International, and UNIX Systems
+ // Laboratories Pacific. Uses ISO 2022 rules to select
+ // code set 0: US-ASCII (a single 7-bit byte set)
+ // code set 1: JIS X0208-1990 (a double 8-bit byte set)
+ // restricted to A0-FF in both bytes
+ // code set 2: Half Width Katakana (a single 7-bit byte set)
+ // requiring SS2 as the character prefix
+ // code set 3: JIS X0212-1990 (a double 7-bit byte set)
+ // restricted to A0-FF in both bytes
+ // requiring SS3 as the character prefix
+ EUCPkdFmtJapanese MIB = 18
+
+ // EUCFixWidJapanese is the MIB identifier with IANA name Extended_UNIX_Code_Fixed_Width_for_Japanese.
+ //
+ // Used in Japan. Each character is 2 octets.
+ // code set 0: US-ASCII (a single 7-bit byte set)
+ // 1st byte = 00
+ // 2nd byte = 20-7E
+ // code set 1: JIS X0208-1990 (a double 7-bit byte set)
+ // restricted to A0-FF in both bytes
+ // code set 2: Half Width Katakana (a single 7-bit byte set)
+ // 1st byte = 00
+ // 2nd byte = A0-FF
+ // code set 3: JIS X0212-1990 (a double 7-bit byte set)
+ // restricted to A0-FF in
+ // the first byte
+ // and 21-7E in the second byte
+ EUCFixWidJapanese MIB = 19
+
+ // ISO4UnitedKingdom is the MIB identifier with IANA name BS_4730.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO4UnitedKingdom MIB = 20
+
+ // ISO11SwedishForNames is the MIB identifier with IANA name SEN_850200_C.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO11SwedishForNames MIB = 21
+
+ // ISO15Italian is the MIB identifier with IANA name IT.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO15Italian MIB = 22
+
+ // ISO17Spanish is the MIB identifier with IANA name ES.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO17Spanish MIB = 23
+
+ // ISO21German is the MIB identifier with IANA name DIN_66003.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO21German MIB = 24
+
+ // ISO60Norwegian1 is the MIB identifier with IANA name NS_4551-1.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO60Norwegian1 MIB = 25
+
+ // ISO69French is the MIB identifier with IANA name NF_Z_62-010.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO69French MIB = 26
+
+ // ISO10646UTF1 is the MIB identifier with IANA name ISO-10646-UTF-1.
+ //
+ // Universal Transfer Format (1), this is the multibyte
+ // encoding, that subsets ASCII-7. It does not have byte
+ // ordering issues.
+ ISO10646UTF1 MIB = 27
+
+ // ISO646basic1983 is the MIB identifier with IANA name ISO_646.basic:1983.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO646basic1983 MIB = 28
+
+ // INVARIANT is the MIB identifier with IANA name INVARIANT.
+ //
+ // Reference: RFC1345
+ INVARIANT MIB = 29
+
+ // ISO2IntlRefVersion is the MIB identifier with IANA name ISO_646.irv:1983.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO2IntlRefVersion MIB = 30
+
+ // NATSSEFI is the MIB identifier with IANA name NATS-SEFI.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ NATSSEFI MIB = 31
+
+ // NATSSEFIADD is the MIB identifier with IANA name NATS-SEFI-ADD.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ NATSSEFIADD MIB = 32
+
+ // NATSDANO is the MIB identifier with IANA name NATS-DANO.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ NATSDANO MIB = 33
+
+ // NATSDANOADD is the MIB identifier with IANA name NATS-DANO-ADD.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ NATSDANOADD MIB = 34
+
+ // ISO10Swedish is the MIB identifier with IANA name SEN_850200_B.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO10Swedish MIB = 35
+
+ // KSC56011987 is the MIB identifier with IANA name KS_C_5601-1987.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ KSC56011987 MIB = 36
+
+ // ISO2022KR is the MIB identifier with IANA name ISO-2022-KR (MIME: ISO-2022-KR).
+ //
+ // rfc1557 (see also KS_C_5601-1987)
+ // Reference: RFC1557
+ ISO2022KR MIB = 37
+
+ // EUCKR is the MIB identifier with IANA name EUC-KR (MIME: EUC-KR).
+ //
+ // rfc1557 (see also KS_C_5861-1992)
+ // Reference: RFC1557
+ EUCKR MIB = 38
+
+ // ISO2022JP is the MIB identifier with IANA name ISO-2022-JP (MIME: ISO-2022-JP).
+ //
+ // rfc1468 (see also rfc2237 )
+ // Reference: RFC1468
+ ISO2022JP MIB = 39
+
+ // ISO2022JP2 is the MIB identifier with IANA name ISO-2022-JP-2 (MIME: ISO-2022-JP-2).
+ //
+ // rfc1554
+ // Reference: RFC1554
+ ISO2022JP2 MIB = 40
+
+ // ISO13JISC6220jp is the MIB identifier with IANA name JIS_C6220-1969-jp.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO13JISC6220jp MIB = 41
+
+ // ISO14JISC6220ro is the MIB identifier with IANA name JIS_C6220-1969-ro.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO14JISC6220ro MIB = 42
+
+ // ISO16Portuguese is the MIB identifier with IANA name PT.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO16Portuguese MIB = 43
+
+ // ISO18Greek7Old is the MIB identifier with IANA name greek7-old.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO18Greek7Old MIB = 44
+
+ // ISO19LatinGreek is the MIB identifier with IANA name latin-greek.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO19LatinGreek MIB = 45
+
+ // ISO25French is the MIB identifier with IANA name NF_Z_62-010_(1973).
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO25French MIB = 46
+
+ // ISO27LatinGreek1 is the MIB identifier with IANA name Latin-greek-1.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO27LatinGreek1 MIB = 47
+
+ // ISO5427Cyrillic is the MIB identifier with IANA name ISO_5427.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO5427Cyrillic MIB = 48
+
+ // ISO42JISC62261978 is the MIB identifier with IANA name JIS_C6226-1978.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO42JISC62261978 MIB = 49
+
+ // ISO47BSViewdata is the MIB identifier with IANA name BS_viewdata.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO47BSViewdata MIB = 50
+
+ // ISO49INIS is the MIB identifier with IANA name INIS.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO49INIS MIB = 51
+
+ // ISO50INIS8 is the MIB identifier with IANA name INIS-8.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO50INIS8 MIB = 52
+
+ // ISO51INISCyrillic is the MIB identifier with IANA name INIS-cyrillic.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO51INISCyrillic MIB = 53
+
+ // ISO54271981 is the MIB identifier with IANA name ISO_5427:1981.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO54271981 MIB = 54
+
+ // ISO5428Greek is the MIB identifier with IANA name ISO_5428:1980.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO5428Greek MIB = 55
+
+ // ISO57GB1988 is the MIB identifier with IANA name GB_1988-80.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO57GB1988 MIB = 56
+
+ // ISO58GB231280 is the MIB identifier with IANA name GB_2312-80.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO58GB231280 MIB = 57
+
+ // ISO61Norwegian2 is the MIB identifier with IANA name NS_4551-2.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO61Norwegian2 MIB = 58
+
+ // ISO70VideotexSupp1 is the MIB identifier with IANA name videotex-suppl.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO70VideotexSupp1 MIB = 59
+
+ // ISO84Portuguese2 is the MIB identifier with IANA name PT2.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO84Portuguese2 MIB = 60
+
+ // ISO85Spanish2 is the MIB identifier with IANA name ES2.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO85Spanish2 MIB = 61
+
+ // ISO86Hungarian is the MIB identifier with IANA name MSZ_7795.3.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO86Hungarian MIB = 62
+
+ // ISO87JISX0208 is the MIB identifier with IANA name JIS_C6226-1983.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO87JISX0208 MIB = 63
+
+ // ISO88Greek7 is the MIB identifier with IANA name greek7.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO88Greek7 MIB = 64
+
+ // ISO89ASMO449 is the MIB identifier with IANA name ASMO_449.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO89ASMO449 MIB = 65
+
+ // ISO90 is the MIB identifier with IANA name iso-ir-90.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO90 MIB = 66
+
+ // ISO91JISC62291984a is the MIB identifier with IANA name JIS_C6229-1984-a.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO91JISC62291984a MIB = 67
+
+ // ISO92JISC62991984b is the MIB identifier with IANA name JIS_C6229-1984-b.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO92JISC62991984b MIB = 68
+
+ // ISO93JIS62291984badd is the MIB identifier with IANA name JIS_C6229-1984-b-add.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO93JIS62291984badd MIB = 69
+
+ // ISO94JIS62291984hand is the MIB identifier with IANA name JIS_C6229-1984-hand.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO94JIS62291984hand MIB = 70
+
+ // ISO95JIS62291984handadd is the MIB identifier with IANA name JIS_C6229-1984-hand-add.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO95JIS62291984handadd MIB = 71
+
+ // ISO96JISC62291984kana is the MIB identifier with IANA name JIS_C6229-1984-kana.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO96JISC62291984kana MIB = 72
+
+ // ISO2033 is the MIB identifier with IANA name ISO_2033-1983.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO2033 MIB = 73
+
+ // ISO99NAPLPS is the MIB identifier with IANA name ANSI_X3.110-1983.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO99NAPLPS MIB = 74
+
+ // ISO102T617bit is the MIB identifier with IANA name T.61-7bit.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO102T617bit MIB = 75
+
+ // ISO103T618bit is the MIB identifier with IANA name T.61-8bit.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO103T618bit MIB = 76
+
+ // ISO111ECMACyrillic is the MIB identifier with IANA name ECMA-cyrillic.
+ //
+ // ISO registry
+ ISO111ECMACyrillic MIB = 77
+
+ // ISO121Canadian1 is the MIB identifier with IANA name CSA_Z243.4-1985-1.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO121Canadian1 MIB = 78
+
+ // ISO122Canadian2 is the MIB identifier with IANA name CSA_Z243.4-1985-2.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO122Canadian2 MIB = 79
+
+ // ISO123CSAZ24341985gr is the MIB identifier with IANA name CSA_Z243.4-1985-gr.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO123CSAZ24341985gr MIB = 80
+
+ // ISO88596E is the MIB identifier with IANA name ISO_8859-6-E (MIME: ISO-8859-6-E).
+ //
+ // rfc1556
+ // Reference: RFC1556
+ ISO88596E MIB = 81
+
+ // ISO88596I is the MIB identifier with IANA name ISO_8859-6-I (MIME: ISO-8859-6-I).
+ //
+ // rfc1556
+ // Reference: RFC1556
+ ISO88596I MIB = 82
+
+ // ISO128T101G2 is the MIB identifier with IANA name T.101-G2.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO128T101G2 MIB = 83
+
+ // ISO88598E is the MIB identifier with IANA name ISO_8859-8-E (MIME: ISO-8859-8-E).
+ //
+ // rfc1556
+ // Reference: RFC1556
+ ISO88598E MIB = 84
+
+ // ISO88598I is the MIB identifier with IANA name ISO_8859-8-I (MIME: ISO-8859-8-I).
+ //
+ // rfc1556
+ // Reference: RFC1556
+ ISO88598I MIB = 85
+
+ // ISO139CSN369103 is the MIB identifier with IANA name CSN_369103.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO139CSN369103 MIB = 86
+
+ // ISO141JUSIB1002 is the MIB identifier with IANA name JUS_I.B1.002.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO141JUSIB1002 MIB = 87
+
+ // ISO143IECP271 is the MIB identifier with IANA name IEC_P27-1.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO143IECP271 MIB = 88
+
+ // ISO146Serbian is the MIB identifier with IANA name JUS_I.B1.003-serb.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO146Serbian MIB = 89
+
+ // ISO147Macedonian is the MIB identifier with IANA name JUS_I.B1.003-mac.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO147Macedonian MIB = 90
+
+ // ISO150GreekCCITT is the MIB identifier with IANA name greek-ccitt.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO150GreekCCITT MIB = 91
+
+ // ISO151Cuba is the MIB identifier with IANA name NC_NC00-10:81.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO151Cuba MIB = 92
+
+ // ISO6937Add is the MIB identifier with IANA name ISO_6937-2-25.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO6937Add MIB = 93
+
+ // ISO153GOST1976874 is the MIB identifier with IANA name GOST_19768-74.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO153GOST1976874 MIB = 94
+
+ // ISO8859Supp is the MIB identifier with IANA name ISO_8859-supp.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO8859Supp MIB = 95
+
+ // ISO10367Box is the MIB identifier with IANA name ISO_10367-box.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO10367Box MIB = 96
+
+ // ISO158Lap is the MIB identifier with IANA name latin-lap.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO158Lap MIB = 97
+
+ // ISO159JISX02121990 is the MIB identifier with IANA name JIS_X0212-1990.
+ //
+ // ISO-IR: International Register of Escape Sequences
+ // Note: The current registration authority is IPSJ/ITSCJ, Japan.
+ // Reference: RFC1345
+ ISO159JISX02121990 MIB = 98
+
+ // ISO646Danish is the MIB identifier with IANA name DS_2089.
+ //
+ // Danish Standard, DS 2089, February 1974
+ // Reference: RFC1345
+ ISO646Danish MIB = 99
+
+ // USDK is the MIB identifier with IANA name us-dk.
+ //
+ // Reference: RFC1345
+ USDK MIB = 100
+
+ // DKUS is the MIB identifier with IANA name dk-us.
+ //
+ // Reference: RFC1345
+ DKUS MIB = 101
+
+ // KSC5636 is the MIB identifier with IANA name KSC5636.
+ //
+ // Reference: RFC1345
+ KSC5636 MIB = 102
+
+ // Unicode11UTF7 is the MIB identifier with IANA name UNICODE-1-1-UTF-7.
+ //
+ // rfc1642
+ // Reference: RFC1642
+ Unicode11UTF7 MIB = 103
+
+ // ISO2022CN is the MIB identifier with IANA name ISO-2022-CN.
+ //
+ // rfc1922
+ // Reference: RFC1922
+ ISO2022CN MIB = 104
+
+ // ISO2022CNEXT is the MIB identifier with IANA name ISO-2022-CN-EXT.
+ //
+ // rfc1922
+ // Reference: RFC1922
+ ISO2022CNEXT MIB = 105
+
+ // UTF8 is the MIB identifier with IANA name UTF-8.
+ //
+ // rfc3629
+ // Reference: RFC3629
+ UTF8 MIB = 106
+
+ // ISO885913 is the MIB identifier with IANA name ISO-8859-13.
+ //
+ // ISO See https://www.iana.org/assignments/charset-reg/ISO-8859-13 https://www.iana.org/assignments/charset-reg/ISO-8859-13
+ ISO885913 MIB = 109
+
+ // ISO885914 is the MIB identifier with IANA name ISO-8859-14.
+ //
+ // ISO See https://www.iana.org/assignments/charset-reg/ISO-8859-14
+ ISO885914 MIB = 110
+
+ // ISO885915 is the MIB identifier with IANA name ISO-8859-15.
+ //
+ // ISO
+ // Please see: https://www.iana.org/assignments/charset-reg/ISO-8859-15
+ ISO885915 MIB = 111
+
+ // ISO885916 is the MIB identifier with IANA name ISO-8859-16.
+ //
+ // ISO
+ ISO885916 MIB = 112
+
+ // GBK is the MIB identifier with IANA name GBK.
+ //
+ // Chinese IT Standardization Technical Committee
+ // Please see: https://www.iana.org/assignments/charset-reg/GBK
+ GBK MIB = 113
+
+ // GB18030 is the MIB identifier with IANA name GB18030.
+ //
+ // Chinese IT Standardization Technical Committee
+ // Please see: https://www.iana.org/assignments/charset-reg/GB18030
+ GB18030 MIB = 114
+
+ // OSDEBCDICDF0415 is the MIB identifier with IANA name OSD_EBCDIC_DF04_15.
+ //
+ // Fujitsu-Siemens standard mainframe EBCDIC encoding
+ // Please see: https://www.iana.org/assignments/charset-reg/OSD-EBCDIC-DF04-15
+ OSDEBCDICDF0415 MIB = 115
+
+ // OSDEBCDICDF03IRV is the MIB identifier with IANA name OSD_EBCDIC_DF03_IRV.
+ //
+ // Fujitsu-Siemens standard mainframe EBCDIC encoding
+ // Please see: https://www.iana.org/assignments/charset-reg/OSD-EBCDIC-DF03-IRV
+ OSDEBCDICDF03IRV MIB = 116
+
+ // OSDEBCDICDF041 is the MIB identifier with IANA name OSD_EBCDIC_DF04_1.
+ //
+ // Fujitsu-Siemens standard mainframe EBCDIC encoding
+ // Please see: https://www.iana.org/assignments/charset-reg/OSD-EBCDIC-DF04-1
+ OSDEBCDICDF041 MIB = 117
+
+ // ISO115481 is the MIB identifier with IANA name ISO-11548-1.
+ //
+ // See https://www.iana.org/assignments/charset-reg/ISO-11548-1
+ ISO115481 MIB = 118
+
+ // KZ1048 is the MIB identifier with IANA name KZ-1048.
+ //
+ // See https://www.iana.org/assignments/charset-reg/KZ-1048
+ KZ1048 MIB = 119
+
+ // Unicode is the MIB identifier with IANA name ISO-10646-UCS-2.
+ //
+ // the 2-octet Basic Multilingual Plane, aka Unicode
+ // this needs to specify network byte order: the standard
+ // does not specify (it is a 16-bit integer space)
+ Unicode MIB = 1000
+
+ // UCS4 is the MIB identifier with IANA name ISO-10646-UCS-4.
+ //
+ // the full code space. (same comment about byte order,
+ // these are 31-bit numbers.
+ UCS4 MIB = 1001
+
+ // UnicodeASCII is the MIB identifier with IANA name ISO-10646-UCS-Basic.
+ //
+ // ASCII subset of Unicode. Basic Latin = collection 1
+ // See ISO 10646, Appendix A
+ UnicodeASCII MIB = 1002
+
+ // UnicodeLatin1 is the MIB identifier with IANA name ISO-10646-Unicode-Latin1.
+ //
+ // ISO Latin-1 subset of Unicode. Basic Latin and Latin-1
+ // Supplement = collections 1 and 2. See ISO 10646,
+ // Appendix A. See rfc1815 .
+ UnicodeLatin1 MIB = 1003
+
+ // UnicodeJapanese is the MIB identifier with IANA name ISO-10646-J-1.
+ //
+ // ISO 10646 Japanese, see rfc1815 .
+ UnicodeJapanese MIB = 1004
+
+ // UnicodeIBM1261 is the MIB identifier with IANA name ISO-Unicode-IBM-1261.
+ //
+ // IBM Latin-2, -3, -5, Extended Presentation Set, GCSGID: 1261
+ UnicodeIBM1261 MIB = 1005
+
+ // UnicodeIBM1268 is the MIB identifier with IANA name ISO-Unicode-IBM-1268.
+ //
+ // IBM Latin-4 Extended Presentation Set, GCSGID: 1268
+ UnicodeIBM1268 MIB = 1006
+
+ // UnicodeIBM1276 is the MIB identifier with IANA name ISO-Unicode-IBM-1276.
+ //
+ // IBM Cyrillic Greek Extended Presentation Set, GCSGID: 1276
+ UnicodeIBM1276 MIB = 1007
+
+ // UnicodeIBM1264 is the MIB identifier with IANA name ISO-Unicode-IBM-1264.
+ //
+ // IBM Arabic Presentation Set, GCSGID: 1264
+ UnicodeIBM1264 MIB = 1008
+
+ // UnicodeIBM1265 is the MIB identifier with IANA name ISO-Unicode-IBM-1265.
+ //
+ // IBM Hebrew Presentation Set, GCSGID: 1265
+ UnicodeIBM1265 MIB = 1009
+
+ // Unicode11 is the MIB identifier with IANA name UNICODE-1-1.
+ //
+ // rfc1641
+ // Reference: RFC1641
+ Unicode11 MIB = 1010
+
+ // SCSU is the MIB identifier with IANA name SCSU.
+ //
+ // SCSU See https://www.iana.org/assignments/charset-reg/SCSU
+ SCSU MIB = 1011
+
+ // UTF7 is the MIB identifier with IANA name UTF-7.
+ //
+ // rfc2152
+ // Reference: RFC2152
+ UTF7 MIB = 1012
+
+ // UTF16BE is the MIB identifier with IANA name UTF-16BE.
+ //
+ // rfc2781
+ // Reference: RFC2781
+ UTF16BE MIB = 1013
+
+ // UTF16LE is the MIB identifier with IANA name UTF-16LE.
+ //
+ // rfc2781
+ // Reference: RFC2781
+ UTF16LE MIB = 1014
+
+ // UTF16 is the MIB identifier with IANA name UTF-16.
+ //
+ // rfc2781
+ // Reference: RFC2781
+ UTF16 MIB = 1015
+
+ // CESU8 is the MIB identifier with IANA name CESU-8.
+ //
+ // https://www.unicode.org/reports/tr26
+ CESU8 MIB = 1016
+
+ // UTF32 is the MIB identifier with IANA name UTF-32.
+ //
+ // https://www.unicode.org/reports/tr19/
+ UTF32 MIB = 1017
+
+ // UTF32BE is the MIB identifier with IANA name UTF-32BE.
+ //
+ // https://www.unicode.org/reports/tr19/
+ UTF32BE MIB = 1018
+
+ // UTF32LE is the MIB identifier with IANA name UTF-32LE.
+ //
+ // https://www.unicode.org/reports/tr19/
+ UTF32LE MIB = 1019
+
+ // BOCU1 is the MIB identifier with IANA name BOCU-1.
+ //
+ // https://www.unicode.org/notes/tn6/
+ BOCU1 MIB = 1020
+
+ // UTF7IMAP is the MIB identifier with IANA name UTF-7-IMAP.
+ //
+ // Note: This charset is used to encode Unicode in IMAP mailbox names;
+ // see section 5.1.3 of rfc3501 . It should never be used
+ // outside this context. A name has been assigned so that charset processing
+ // implementations can refer to it in a consistent way.
+ UTF7IMAP MIB = 1021
+
+ // Windows30Latin1 is the MIB identifier with IANA name ISO-8859-1-Windows-3.0-Latin-1.
+ //
+ // Extended ISO 8859-1 Latin-1 for Windows 3.0.
+ // PCL Symbol Set id: 9U
+ Windows30Latin1 MIB = 2000
+
+ // Windows31Latin1 is the MIB identifier with IANA name ISO-8859-1-Windows-3.1-Latin-1.
+ //
+ // Extended ISO 8859-1 Latin-1 for Windows 3.1.
+ // PCL Symbol Set id: 19U
+ Windows31Latin1 MIB = 2001
+
+ // Windows31Latin2 is the MIB identifier with IANA name ISO-8859-2-Windows-Latin-2.
+ //
+ // Extended ISO 8859-2. Latin-2 for Windows 3.1.
+ // PCL Symbol Set id: 9E
+ Windows31Latin2 MIB = 2002
+
+ // Windows31Latin5 is the MIB identifier with IANA name ISO-8859-9-Windows-Latin-5.
+ //
+ // Extended ISO 8859-9. Latin-5 for Windows 3.1
+ // PCL Symbol Set id: 5T
+ Windows31Latin5 MIB = 2003
+
+ // HPRoman8 is the MIB identifier with IANA name hp-roman8.
+ //
+ // LaserJet IIP Printer User's Manual,
+ // HP part no 33471-90901, Hewlet-Packard, June 1989.
+ // Reference: RFC1345
+ HPRoman8 MIB = 2004
+
+ // AdobeStandardEncoding is the MIB identifier with IANA name Adobe-Standard-Encoding.
+ //
+ // PostScript Language Reference Manual
+ // PCL Symbol Set id: 10J
+ AdobeStandardEncoding MIB = 2005
+
+ // VenturaUS is the MIB identifier with IANA name Ventura-US.
+ //
+ // Ventura US. ASCII plus characters typically used in
+ // publishing, like pilcrow, copyright, registered, trade mark,
+ // section, dagger, and double dagger in the range A0 (hex)
+ // to FF (hex).
+ // PCL Symbol Set id: 14J
+ VenturaUS MIB = 2006
+
+ // VenturaInternational is the MIB identifier with IANA name Ventura-International.
+ //
+ // Ventura International. ASCII plus coded characters similar
+ // to Roman8.
+ // PCL Symbol Set id: 13J
+ VenturaInternational MIB = 2007
+
+ // DECMCS is the MIB identifier with IANA name DEC-MCS.
+ //
+ // VAX/VMS User's Manual,
+ // Order Number: AI-Y517A-TE, April 1986.
+ // Reference: RFC1345
+ DECMCS MIB = 2008
+
+ // PC850Multilingual is the MIB identifier with IANA name IBM850.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ PC850Multilingual MIB = 2009
+
+ // PC8DanishNorwegian is the MIB identifier with IANA name PC8-Danish-Norwegian.
+ //
+ // PC Danish Norwegian
+ // 8-bit PC set for Danish Norwegian
+ // PCL Symbol Set id: 11U
+ PC8DanishNorwegian MIB = 2012
+
+ // PC862LatinHebrew is the MIB identifier with IANA name IBM862.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ PC862LatinHebrew MIB = 2013
+
+ // PC8Turkish is the MIB identifier with IANA name PC8-Turkish.
+ //
+ // PC Latin Turkish. PCL Symbol Set id: 9T
+ PC8Turkish MIB = 2014
+
+ // IBMSymbols is the MIB identifier with IANA name IBM-Symbols.
+ //
+ // Presentation Set, CPGID: 259
+ IBMSymbols MIB = 2015
+
+ // IBMThai is the MIB identifier with IANA name IBM-Thai.
+ //
+ // Presentation Set, CPGID: 838
+ IBMThai MIB = 2016
+
+ // HPLegal is the MIB identifier with IANA name HP-Legal.
+ //
+ // PCL 5 Comparison Guide, Hewlett-Packard,
+ // HP part number 5961-0510, October 1992
+ // PCL Symbol Set id: 1U
+ HPLegal MIB = 2017
+
+ // HPPiFont is the MIB identifier with IANA name HP-Pi-font.
+ //
+ // PCL 5 Comparison Guide, Hewlett-Packard,
+ // HP part number 5961-0510, October 1992
+ // PCL Symbol Set id: 15U
+ HPPiFont MIB = 2018
+
+ // HPMath8 is the MIB identifier with IANA name HP-Math8.
+ //
+ // PCL 5 Comparison Guide, Hewlett-Packard,
+ // HP part number 5961-0510, October 1992
+ // PCL Symbol Set id: 8M
+ HPMath8 MIB = 2019
+
+ // HPPSMath is the MIB identifier with IANA name Adobe-Symbol-Encoding.
+ //
+ // PostScript Language Reference Manual
+ // PCL Symbol Set id: 5M
+ HPPSMath MIB = 2020
+
+ // HPDesktop is the MIB identifier with IANA name HP-DeskTop.
+ //
+ // PCL 5 Comparison Guide, Hewlett-Packard,
+ // HP part number 5961-0510, October 1992
+ // PCL Symbol Set id: 7J
+ HPDesktop MIB = 2021
+
+ // VenturaMath is the MIB identifier with IANA name Ventura-Math.
+ //
+ // PCL 5 Comparison Guide, Hewlett-Packard,
+ // HP part number 5961-0510, October 1992
+ // PCL Symbol Set id: 6M
+ VenturaMath MIB = 2022
+
+ // MicrosoftPublishing is the MIB identifier with IANA name Microsoft-Publishing.
+ //
+ // PCL 5 Comparison Guide, Hewlett-Packard,
+ // HP part number 5961-0510, October 1992
+ // PCL Symbol Set id: 6J
+ MicrosoftPublishing MIB = 2023
+
+ // Windows31J is the MIB identifier with IANA name Windows-31J.
+ //
+ // Windows Japanese. A further extension of Shift_JIS
+ // to include NEC special characters (Row 13), NEC
+ // selection of IBM extensions (Rows 89 to 92), and IBM
+ // extensions (Rows 115 to 119). The CCS's are
+ // JIS X0201:1997, JIS X0208:1997, and these extensions.
+ // This charset can be used for the top-level media type "text",
+ // but it is of limited or specialized use (see rfc2278 ).
+ // PCL Symbol Set id: 19K
+ Windows31J MIB = 2024
+
+ // GB2312 is the MIB identifier with IANA name GB2312 (MIME: GB2312).
+ //
+ // Chinese for People's Republic of China (PRC) mixed one byte,
+ // two byte set:
+ // 20-7E = one byte ASCII
+ // A1-FE = two byte PRC Kanji
+ // See GB 2312-80
+ // PCL Symbol Set Id: 18C
+ GB2312 MIB = 2025
+
+ // Big5 is the MIB identifier with IANA name Big5 (MIME: Big5).
+ //
+ // Chinese for Taiwan Multi-byte set.
+ // PCL Symbol Set Id: 18T
+ Big5 MIB = 2026
+
+ // Macintosh is the MIB identifier with IANA name macintosh.
+ //
+ // The Unicode Standard ver1.0, ISBN 0-201-56788-1, Oct 1991
+ // Reference: RFC1345
+ Macintosh MIB = 2027
+
+ // IBM037 is the MIB identifier with IANA name IBM037.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM037 MIB = 2028
+
+ // IBM038 is the MIB identifier with IANA name IBM038.
+ //
+ // IBM 3174 Character Set Ref, GA27-3831-02, March 1990
+ // Reference: RFC1345
+ IBM038 MIB = 2029
+
+ // IBM273 is the MIB identifier with IANA name IBM273.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM273 MIB = 2030
+
+ // IBM274 is the MIB identifier with IANA name IBM274.
+ //
+ // IBM 3174 Character Set Ref, GA27-3831-02, March 1990
+ // Reference: RFC1345
+ IBM274 MIB = 2031
+
+ // IBM275 is the MIB identifier with IANA name IBM275.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM275 MIB = 2032
+
+ // IBM277 is the MIB identifier with IANA name IBM277.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM277 MIB = 2033
+
+ // IBM278 is the MIB identifier with IANA name IBM278.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM278 MIB = 2034
+
+ // IBM280 is the MIB identifier with IANA name IBM280.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM280 MIB = 2035
+
+ // IBM281 is the MIB identifier with IANA name IBM281.
+ //
+ // IBM 3174 Character Set Ref, GA27-3831-02, March 1990
+ // Reference: RFC1345
+ IBM281 MIB = 2036
+
+ // IBM284 is the MIB identifier with IANA name IBM284.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM284 MIB = 2037
+
+ // IBM285 is the MIB identifier with IANA name IBM285.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM285 MIB = 2038
+
+ // IBM290 is the MIB identifier with IANA name IBM290.
+ //
+ // IBM 3174 Character Set Ref, GA27-3831-02, March 1990
+ // Reference: RFC1345
+ IBM290 MIB = 2039
+
+ // IBM297 is the MIB identifier with IANA name IBM297.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM297 MIB = 2040
+
+ // IBM420 is the MIB identifier with IANA name IBM420.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990,
+ // IBM NLS RM p 11-11
+ // Reference: RFC1345
+ IBM420 MIB = 2041
+
+ // IBM423 is the MIB identifier with IANA name IBM423.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM423 MIB = 2042
+
+ // IBM424 is the MIB identifier with IANA name IBM424.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM424 MIB = 2043
+
+ // PC8CodePage437 is the MIB identifier with IANA name IBM437.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ PC8CodePage437 MIB = 2011
+
+ // IBM500 is the MIB identifier with IANA name IBM500.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM500 MIB = 2044
+
+ // IBM851 is the MIB identifier with IANA name IBM851.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM851 MIB = 2045
+
+ // PCp852 is the MIB identifier with IANA name IBM852.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ PCp852 MIB = 2010
+
+ // IBM855 is the MIB identifier with IANA name IBM855.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM855 MIB = 2046
+
+ // IBM857 is the MIB identifier with IANA name IBM857.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM857 MIB = 2047
+
+ // IBM860 is the MIB identifier with IANA name IBM860.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM860 MIB = 2048
+
+ // IBM861 is the MIB identifier with IANA name IBM861.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM861 MIB = 2049
+
+ // IBM863 is the MIB identifier with IANA name IBM863.
+ //
+ // IBM Keyboard layouts and code pages, PN 07G4586 June 1991
+ // Reference: RFC1345
+ IBM863 MIB = 2050
+
+ // IBM864 is the MIB identifier with IANA name IBM864.
+ //
+ // IBM Keyboard layouts and code pages, PN 07G4586 June 1991
+ // Reference: RFC1345
+ IBM864 MIB = 2051
+
+ // IBM865 is the MIB identifier with IANA name IBM865.
+ //
+ // IBM DOS 3.3 Ref (Abridged), 94X9575 (Feb 1987)
+ // Reference: RFC1345
+ IBM865 MIB = 2052
+
+ // IBM868 is the MIB identifier with IANA name IBM868.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM868 MIB = 2053
+
+ // IBM869 is the MIB identifier with IANA name IBM869.
+ //
+ // IBM Keyboard layouts and code pages, PN 07G4586 June 1991
+ // Reference: RFC1345
+ IBM869 MIB = 2054
+
+ // IBM870 is the MIB identifier with IANA name IBM870.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM870 MIB = 2055
+
+ // IBM871 is the MIB identifier with IANA name IBM871.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM871 MIB = 2056
+
+ // IBM880 is the MIB identifier with IANA name IBM880.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM880 MIB = 2057
+
+ // IBM891 is the MIB identifier with IANA name IBM891.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM891 MIB = 2058
+
+ // IBM903 is the MIB identifier with IANA name IBM903.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM903 MIB = 2059
+
+ // IBBM904 is the MIB identifier with IANA name IBM904.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBBM904 MIB = 2060
+
+ // IBM905 is the MIB identifier with IANA name IBM905.
+ //
+ // IBM 3174 Character Set Ref, GA27-3831-02, March 1990
+ // Reference: RFC1345
+ IBM905 MIB = 2061
+
+ // IBM918 is the MIB identifier with IANA name IBM918.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM918 MIB = 2062
+
+ // IBM1026 is the MIB identifier with IANA name IBM1026.
+ //
+ // IBM NLS RM Vol2 SE09-8002-01, March 1990
+ // Reference: RFC1345
+ IBM1026 MIB = 2063
+
+ // IBMEBCDICATDE is the MIB identifier with IANA name EBCDIC-AT-DE.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ IBMEBCDICATDE MIB = 2064
+
+ // EBCDICATDEA is the MIB identifier with IANA name EBCDIC-AT-DE-A.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICATDEA MIB = 2065
+
+ // EBCDICCAFR is the MIB identifier with IANA name EBCDIC-CA-FR.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICCAFR MIB = 2066
+
+ // EBCDICDKNO is the MIB identifier with IANA name EBCDIC-DK-NO.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICDKNO MIB = 2067
+
+ // EBCDICDKNOA is the MIB identifier with IANA name EBCDIC-DK-NO-A.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICDKNOA MIB = 2068
+
+ // EBCDICFISE is the MIB identifier with IANA name EBCDIC-FI-SE.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICFISE MIB = 2069
+
+ // EBCDICFISEA is the MIB identifier with IANA name EBCDIC-FI-SE-A.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICFISEA MIB = 2070
+
+ // EBCDICFR is the MIB identifier with IANA name EBCDIC-FR.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICFR MIB = 2071
+
+ // EBCDICIT is the MIB identifier with IANA name EBCDIC-IT.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICIT MIB = 2072
+
+ // EBCDICPT is the MIB identifier with IANA name EBCDIC-PT.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICPT MIB = 2073
+
+ // EBCDICES is the MIB identifier with IANA name EBCDIC-ES.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICES MIB = 2074
+
+ // EBCDICESA is the MIB identifier with IANA name EBCDIC-ES-A.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICESA MIB = 2075
+
+ // EBCDICESS is the MIB identifier with IANA name EBCDIC-ES-S.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICESS MIB = 2076
+
+ // EBCDICUK is the MIB identifier with IANA name EBCDIC-UK.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICUK MIB = 2077
+
+ // EBCDICUS is the MIB identifier with IANA name EBCDIC-US.
+ //
+ // IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
+ // Reference: RFC1345
+ EBCDICUS MIB = 2078
+
+ // Unknown8BiT is the MIB identifier with IANA name UNKNOWN-8BIT.
+ //
+ // Reference: RFC1428
+ Unknown8BiT MIB = 2079
+
+ // Mnemonic is the MIB identifier with IANA name MNEMONIC.
+ //
+ // rfc1345 , also known as "mnemonic+ascii+38"
+ // Reference: RFC1345
+ Mnemonic MIB = 2080
+
+ // Mnem is the MIB identifier with IANA name MNEM.
+ //
+ // rfc1345 , also known as "mnemonic+ascii+8200"
+ // Reference: RFC1345
+ Mnem MIB = 2081
+
+ // VISCII is the MIB identifier with IANA name VISCII.
+ //
+ // rfc1456
+ // Reference: RFC1456
+ VISCII MIB = 2082
+
+ // VIQR is the MIB identifier with IANA name VIQR.
+ //
+ // rfc1456
+ // Reference: RFC1456
+ VIQR MIB = 2083
+
+ // KOI8R is the MIB identifier with IANA name KOI8-R (MIME: KOI8-R).
+ //
+ // rfc1489 , based on GOST-19768-74, ISO-6937/8,
+ // INIS-Cyrillic, ISO-5427.
+ // Reference: RFC1489
+ KOI8R MIB = 2084
+
+ // HZGB2312 is the MIB identifier with IANA name HZ-GB-2312.
+ //
+ // rfc1842 , rfc1843 rfc1843 rfc1842
+ HZGB2312 MIB = 2085
+
+ // IBM866 is the MIB identifier with IANA name IBM866.
+ //
+ // IBM NLDG Volume 2 (SE09-8002-03) August 1994
+ IBM866 MIB = 2086
+
+ // PC775Baltic is the MIB identifier with IANA name IBM775.
+ //
+ // HP PCL 5 Comparison Guide (P/N 5021-0329) pp B-13, 1996
+ PC775Baltic MIB = 2087
+
+ // KOI8U is the MIB identifier with IANA name KOI8-U.
+ //
+ // rfc2319
+ // Reference: RFC2319
+ KOI8U MIB = 2088
+
+ // IBM00858 is the MIB identifier with IANA name IBM00858.
+ //
+ // IBM See https://www.iana.org/assignments/charset-reg/IBM00858
+ IBM00858 MIB = 2089
+
+ // IBM00924 is the MIB identifier with IANA name IBM00924.
+ //
+ // IBM See https://www.iana.org/assignments/charset-reg/IBM00924
+ IBM00924 MIB = 2090
+
+ // IBM01140 is the MIB identifier with IANA name IBM01140.
+ //
+ // IBM See https://www.iana.org/assignments/charset-reg/IBM01140
+ IBM01140 MIB = 2091
+
+ // IBM01141 is the MIB identifier with IANA name IBM01141.
+ //
+ // IBM See https://www.iana.org/assignments/charset-reg/IBM01141
+ IBM01141 MIB = 2092
+
+ // IBM01142 is the MIB identifier with IANA name IBM01142.
+ //
+ // IBM See https://www.iana.org/assignments/charset-reg/IBM01142
+ IBM01142 MIB = 2093
+
+ // IBM01143 is the MIB identifier with IANA name IBM01143.
+ //
+ // IBM See https://www.iana.org/assignments/charset-reg/IBM01143
+ IBM01143 MIB = 2094
+
+ // IBM01144 is the MIB identifier with IANA name IBM01144.
+ //
+ // IBM See https://www.iana.org/assignments/charset-reg/IBM01144
+ IBM01144 MIB = 2095
+
+ // IBM01145 is the MIB identifier with IANA name IBM01145.
+ //
+ // IBM See https://www.iana.org/assignments/charset-reg/IBM01145
+ IBM01145 MIB = 2096
+
+ // IBM01146 is the MIB identifier with IANA name IBM01146.
+ //
+ // IBM See https://www.iana.org/assignments/charset-reg/IBM01146
+ IBM01146 MIB = 2097
+
+ // IBM01147 is the MIB identifier with IANA name IBM01147.
+ //
+ // IBM See https://www.iana.org/assignments/charset-reg/IBM01147
+ IBM01147 MIB = 2098
+
+ // IBM01148 is the MIB identifier with IANA name IBM01148.
+ //
+ // IBM See https://www.iana.org/assignments/charset-reg/IBM01148
+ IBM01148 MIB = 2099
+
+ // IBM01149 is the MIB identifier with IANA name IBM01149.
+ //
+ // IBM See https://www.iana.org/assignments/charset-reg/IBM01149
+ IBM01149 MIB = 2100
+
+ // Big5HKSCS is the MIB identifier with IANA name Big5-HKSCS.
+ //
+ // See https://www.iana.org/assignments/charset-reg/Big5-HKSCS
+ Big5HKSCS MIB = 2101
+
+ // IBM1047 is the MIB identifier with IANA name IBM1047.
+ //
+ // IBM1047 (EBCDIC Latin 1/Open Systems) https://www-1.ibm.com/servers/eserver/iseries/software/globalization/pdf/cp01047z.pdf
+ IBM1047 MIB = 2102
+
+ // PTCP154 is the MIB identifier with IANA name PTCP154.
+ //
+ // See https://www.iana.org/assignments/charset-reg/PTCP154
+ PTCP154 MIB = 2103
+
+ // Amiga1251 is the MIB identifier with IANA name Amiga-1251.
+ //
+ // See https://www.amiga.ultranet.ru/Amiga-1251.html
+ Amiga1251 MIB = 2104
+
+ // KOI7switched is the MIB identifier with IANA name KOI7-switched.
+ //
+ // See https://www.iana.org/assignments/charset-reg/KOI7-switched
+ KOI7switched MIB = 2105
+
+ // BRF is the MIB identifier with IANA name BRF.
+ //
+ // See https://www.iana.org/assignments/charset-reg/BRF
+ BRF MIB = 2106
+
+ // TSCII is the MIB identifier with IANA name TSCII.
+ //
+ // See https://www.iana.org/assignments/charset-reg/TSCII
+ TSCII MIB = 2107
+
+ // CP51932 is the MIB identifier with IANA name CP51932.
+ //
+ // See https://www.iana.org/assignments/charset-reg/CP51932
+ CP51932 MIB = 2108
+
+ // Windows874 is the MIB identifier with IANA name windows-874.
+ //
+ // See https://www.iana.org/assignments/charset-reg/windows-874
+ Windows874 MIB = 2109
+
+ // Windows1250 is the MIB identifier with IANA name windows-1250.
+ //
+ // Microsoft https://www.iana.org/assignments/charset-reg/windows-1250
+ Windows1250 MIB = 2250
+
+ // Windows1251 is the MIB identifier with IANA name windows-1251.
+ //
+ // Microsoft https://www.iana.org/assignments/charset-reg/windows-1251
+ Windows1251 MIB = 2251
+
+ // Windows1252 is the MIB identifier with IANA name windows-1252.
+ //
+ // Microsoft https://www.iana.org/assignments/charset-reg/windows-1252
+ Windows1252 MIB = 2252
+
+ // Windows1253 is the MIB identifier with IANA name windows-1253.
+ //
+ // Microsoft https://www.iana.org/assignments/charset-reg/windows-1253
+ Windows1253 MIB = 2253
+
+ // Windows1254 is the MIB identifier with IANA name windows-1254.
+ //
+ // Microsoft https://www.iana.org/assignments/charset-reg/windows-1254
+ Windows1254 MIB = 2254
+
+ // Windows1255 is the MIB identifier with IANA name windows-1255.
+ //
+ // Microsoft https://www.iana.org/assignments/charset-reg/windows-1255
+ Windows1255 MIB = 2255
+
+ // Windows1256 is the MIB identifier with IANA name windows-1256.
+ //
+ // Microsoft https://www.iana.org/assignments/charset-reg/windows-1256
+ Windows1256 MIB = 2256
+
+ // Windows1257 is the MIB identifier with IANA name windows-1257.
+ //
+ // Microsoft https://www.iana.org/assignments/charset-reg/windows-1257
+ Windows1257 MIB = 2257
+
+ // Windows1258 is the MIB identifier with IANA name windows-1258.
+ //
+ // Microsoft https://www.iana.org/assignments/charset-reg/windows-1258
+ Windows1258 MIB = 2258
+
+ // TIS620 is the MIB identifier with IANA name TIS-620.
+ //
+ // Thai Industrial Standards Institute (TISI)
+ TIS620 MIB = 2259
+
+ // CP50220 is the MIB identifier with IANA name CP50220.
+ //
+ // See https://www.iana.org/assignments/charset-reg/CP50220
+ CP50220 MIB = 2260
+)
diff --git a/tools/vendor/golang.org/x/text/encoding/internal/internal.go b/tools/vendor/golang.org/x/text/encoding/internal/internal.go
new file mode 100644
index 000000000..413e6fc6d
--- /dev/null
+++ b/tools/vendor/golang.org/x/text/encoding/internal/internal.go
@@ -0,0 +1,75 @@
+// Copyright 2015 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 internal contains code that is shared among encoding implementations.
+package internal
+
+import (
+ "golang.org/x/text/encoding"
+ "golang.org/x/text/encoding/internal/identifier"
+ "golang.org/x/text/transform"
+)
+
+// Encoding is an implementation of the Encoding interface that adds the String
+// and ID methods to an existing encoding.
+type Encoding struct {
+ encoding.Encoding
+ Name string
+ MIB identifier.MIB
+}
+
+// _ verifies that Encoding implements identifier.Interface.
+var _ identifier.Interface = (*Encoding)(nil)
+
+func (e *Encoding) String() string {
+ return e.Name
+}
+
+func (e *Encoding) ID() (mib identifier.MIB, other string) {
+ return e.MIB, ""
+}
+
+// SimpleEncoding is an Encoding that combines two Transformers.
+type SimpleEncoding struct {
+ Decoder transform.Transformer
+ Encoder transform.Transformer
+}
+
+func (e *SimpleEncoding) NewDecoder() *encoding.Decoder {
+ return &encoding.Decoder{Transformer: e.Decoder}
+}
+
+func (e *SimpleEncoding) NewEncoder() *encoding.Encoder {
+ return &encoding.Encoder{Transformer: e.Encoder}
+}
+
+// FuncEncoding is an Encoding that combines two functions returning a new
+// Transformer.
+type FuncEncoding struct {
+ Decoder func() transform.Transformer
+ Encoder func() transform.Transformer
+}
+
+func (e FuncEncoding) NewDecoder() *encoding.Decoder {
+ return &encoding.Decoder{Transformer: e.Decoder()}
+}
+
+func (e FuncEncoding) NewEncoder() *encoding.Encoder {
+ return &encoding.Encoder{Transformer: e.Encoder()}
+}
+
+// A RepertoireError indicates a rune is not in the repertoire of a destination
+// encoding. It is associated with an encoding-specific suggested replacement
+// byte.
+type RepertoireError byte
+
+// Error implements the error interface.
+func (r RepertoireError) Error() string {
+ return "encoding: rune not supported by encoding."
+}
+
+// Replacement returns the replacement string associated with this error.
+func (r RepertoireError) Replacement() byte { return byte(r) }
+
+var ErrASCIIReplacement = RepertoireError(encoding.ASCIISub)
diff --git a/tools/vendor/golang.org/x/text/encoding/unicode/override.go b/tools/vendor/golang.org/x/text/encoding/unicode/override.go
new file mode 100644
index 000000000..35d62fcc9
--- /dev/null
+++ b/tools/vendor/golang.org/x/text/encoding/unicode/override.go
@@ -0,0 +1,82 @@
+// Copyright 2015 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 unicode
+
+import (
+ "golang.org/x/text/transform"
+)
+
+// BOMOverride returns a new decoder transformer that is identical to fallback,
+// except that the presence of a Byte Order Mark at the start of the input
+// causes it to switch to the corresponding Unicode decoding. It will only
+// consider BOMs for UTF-8, UTF-16BE, and UTF-16LE.
+//
+// This differs from using ExpectBOM by allowing a BOM to switch to UTF-8, not
+// just UTF-16 variants, and allowing falling back to any encoding scheme.
+//
+// This technique is recommended by the W3C for use in HTML 5: "For
+// compatibility with deployed content, the byte order mark (also known as BOM)
+// is considered more authoritative than anything else."
+// http://www.w3.org/TR/encoding/#specification-hooks
+//
+// Using BOMOverride is mostly intended for use cases where the first characters
+// of a fallback encoding are known to not be a BOM, for example, for valid HTML
+// and most encodings.
+func BOMOverride(fallback transform.Transformer) transform.Transformer {
+ // TODO: possibly allow a variadic argument of unicode encodings to allow
+ // specifying details of which fallbacks are supported as well as
+ // specifying the details of the implementations. This would also allow for
+ // support for UTF-32, which should not be supported by default.
+ return &bomOverride{fallback: fallback}
+}
+
+type bomOverride struct {
+ fallback transform.Transformer
+ current transform.Transformer
+}
+
+func (d *bomOverride) Reset() {
+ d.current = nil
+ d.fallback.Reset()
+}
+
+var (
+ // TODO: we could use decode functions here, instead of allocating a new
+ // decoder on every NewDecoder as IgnoreBOM decoders can be stateless.
+ utf16le = UTF16(LittleEndian, IgnoreBOM)
+ utf16be = UTF16(BigEndian, IgnoreBOM)
+)
+
+const utf8BOM = "\ufeff"
+
+func (d *bomOverride) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
+ if d.current != nil {
+ return d.current.Transform(dst, src, atEOF)
+ }
+ if len(src) < 3 && !atEOF {
+ return 0, 0, transform.ErrShortSrc
+ }
+ d.current = d.fallback
+ bomSize := 0
+ if len(src) >= 2 {
+ if src[0] == 0xFF && src[1] == 0xFE {
+ d.current = utf16le.NewDecoder()
+ bomSize = 2
+ } else if src[0] == 0xFE && src[1] == 0xFF {
+ d.current = utf16be.NewDecoder()
+ bomSize = 2
+ } else if len(src) >= 3 &&
+ src[0] == utf8BOM[0] &&
+ src[1] == utf8BOM[1] &&
+ src[2] == utf8BOM[2] {
+ d.current = transform.Nop
+ bomSize = 3
+ }
+ }
+ if bomSize < len(src) {
+ nDst, nSrc, err = d.current.Transform(dst, src[bomSize:], atEOF)
+ }
+ return nDst, nSrc + bomSize, err
+}
diff --git a/tools/vendor/golang.org/x/text/encoding/unicode/unicode.go b/tools/vendor/golang.org/x/text/encoding/unicode/unicode.go
new file mode 100644
index 000000000..dd99ad14d
--- /dev/null
+++ b/tools/vendor/golang.org/x/text/encoding/unicode/unicode.go
@@ -0,0 +1,512 @@
+// Copyright 2013 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 unicode provides Unicode encodings such as UTF-16.
+package unicode // import "golang.org/x/text/encoding/unicode"
+
+import (
+ "bytes"
+ "errors"
+ "unicode/utf16"
+ "unicode/utf8"
+
+ "golang.org/x/text/encoding"
+ "golang.org/x/text/encoding/internal"
+ "golang.org/x/text/encoding/internal/identifier"
+ "golang.org/x/text/internal/utf8internal"
+ "golang.org/x/text/runes"
+ "golang.org/x/text/transform"
+)
+
+// TODO: I think the Transformers really should return errors on unmatched
+// surrogate pairs and odd numbers of bytes. This is not required by RFC 2781,
+// which leaves it open, but is suggested by WhatWG. It will allow for all error
+// modes as defined by WhatWG: fatal, HTML and Replacement. This would require
+// the introduction of some kind of error type for conveying the erroneous code
+// point.
+
+// UTF8 is the UTF-8 encoding. It neither removes nor adds byte order marks.
+var UTF8 encoding.Encoding = utf8enc
+
+// UTF8BOM is an UTF-8 encoding where the decoder strips a leading byte order
+// mark while the encoder adds one.
+//
+// Some editors add a byte order mark as a signature to UTF-8 files. Although
+// the byte order mark is not useful for detecting byte order in UTF-8, it is
+// sometimes used as a convention to mark UTF-8-encoded files. This relies on
+// the observation that the UTF-8 byte order mark is either an illegal or at
+// least very unlikely sequence in any other character encoding.
+var UTF8BOM encoding.Encoding = utf8bomEncoding{}
+
+type utf8bomEncoding struct{}
+
+func (utf8bomEncoding) String() string {
+ return "UTF-8-BOM"
+}
+
+func (utf8bomEncoding) ID() (identifier.MIB, string) {
+ return identifier.Unofficial, "x-utf8bom"
+}
+
+func (utf8bomEncoding) NewEncoder() *encoding.Encoder {
+ return &encoding.Encoder{
+ Transformer: &utf8bomEncoder{t: runes.ReplaceIllFormed()},
+ }
+}
+
+func (utf8bomEncoding) NewDecoder() *encoding.Decoder {
+ return &encoding.Decoder{Transformer: &utf8bomDecoder{}}
+}
+
+var utf8enc = &internal.Encoding{
+ &internal.SimpleEncoding{utf8Decoder{}, runes.ReplaceIllFormed()},
+ "UTF-8",
+ identifier.UTF8,
+}
+
+type utf8bomDecoder struct {
+ checked bool
+}
+
+func (t *utf8bomDecoder) Reset() {
+ t.checked = false
+}
+
+func (t *utf8bomDecoder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
+ if !t.checked {
+ if !atEOF && len(src) < len(utf8BOM) {
+ if len(src) == 0 {
+ return 0, 0, nil
+ }
+ return 0, 0, transform.ErrShortSrc
+ }
+ if bytes.HasPrefix(src, []byte(utf8BOM)) {
+ nSrc += len(utf8BOM)
+ src = src[len(utf8BOM):]
+ }
+ t.checked = true
+ }
+ nDst, n, err := utf8Decoder.Transform(utf8Decoder{}, dst[nDst:], src, atEOF)
+ nSrc += n
+ return nDst, nSrc, err
+}
+
+type utf8bomEncoder struct {
+ written bool
+ t transform.Transformer
+}
+
+func (t *utf8bomEncoder) Reset() {
+ t.written = false
+ t.t.Reset()
+}
+
+func (t *utf8bomEncoder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
+ if !t.written {
+ if len(dst) < len(utf8BOM) {
+ return nDst, 0, transform.ErrShortDst
+ }
+ nDst = copy(dst, utf8BOM)
+ t.written = true
+ }
+ n, nSrc, err := utf8Decoder.Transform(utf8Decoder{}, dst[nDst:], src, atEOF)
+ nDst += n
+ return nDst, nSrc, err
+}
+
+type utf8Decoder struct{ transform.NopResetter }
+
+func (utf8Decoder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
+ var pSrc int // point from which to start copy in src
+ var accept utf8internal.AcceptRange
+
+ // The decoder can only make the input larger, not smaller.
+ n := len(src)
+ if len(dst) < n {
+ err = transform.ErrShortDst
+ n = len(dst)
+ atEOF = false
+ }
+ for nSrc < n {
+ c := src[nSrc]
+ if c < utf8.RuneSelf {
+ nSrc++
+ continue
+ }
+ first := utf8internal.First[c]
+ size := int(first & utf8internal.SizeMask)
+ if first == utf8internal.FirstInvalid {
+ goto handleInvalid // invalid starter byte
+ }
+ accept = utf8internal.AcceptRanges[first>>utf8internal.AcceptShift]
+ if nSrc+size > n {
+ if !atEOF {
+ // We may stop earlier than necessary here if the short sequence
+ // has invalid bytes. Not checking for this simplifies the code
+ // and may avoid duplicate computations in certain conditions.
+ if err == nil {
+ err = transform.ErrShortSrc
+ }
+ break
+ }
+ // Determine the maximal subpart of an ill-formed subsequence.
+ switch {
+ case nSrc+1 >= n || src[nSrc+1] < accept.Lo || accept.Hi < src[nSrc+1]:
+ size = 1
+ case nSrc+2 >= n || src[nSrc+2] < utf8internal.LoCB || utf8internal.HiCB < src[nSrc+2]:
+ size = 2
+ default:
+ size = 3 // As we are short, the maximum is 3.
+ }
+ goto handleInvalid
+ }
+ if c = src[nSrc+1]; c < accept.Lo || accept.Hi < c {
+ size = 1
+ goto handleInvalid // invalid continuation byte
+ } else if size == 2 {
+ } else if c = src[nSrc+2]; c < utf8internal.LoCB || utf8internal.HiCB < c {
+ size = 2
+ goto handleInvalid // invalid continuation byte
+ } else if size == 3 {
+ } else if c = src[nSrc+3]; c < utf8internal.LoCB || utf8internal.HiCB < c {
+ size = 3
+ goto handleInvalid // invalid continuation byte
+ }
+ nSrc += size
+ continue
+
+ handleInvalid:
+ // Copy the scanned input so far.
+ nDst += copy(dst[nDst:], src[pSrc:nSrc])
+
+ // Append RuneError to the destination.
+ const runeError = "\ufffd"
+ if nDst+len(runeError) > len(dst) {
+ return nDst, nSrc, transform.ErrShortDst
+ }
+ nDst += copy(dst[nDst:], runeError)
+
+ // Skip the maximal subpart of an ill-formed subsequence according to
+ // the W3C standard way instead of the Go way. This Transform is
+ // probably the only place in the text repo where it is warranted.
+ nSrc += size
+ pSrc = nSrc
+
+ // Recompute the maximum source length.
+ if sz := len(dst) - nDst; sz < len(src)-nSrc {
+ err = transform.ErrShortDst
+ n = nSrc + sz
+ atEOF = false
+ }
+ }
+ return nDst + copy(dst[nDst:], src[pSrc:nSrc]), nSrc, err
+}
+
+// UTF16 returns a UTF-16 Encoding for the given default endianness and byte
+// order mark (BOM) policy.
+//
+// When decoding from UTF-16 to UTF-8, if the BOMPolicy is IgnoreBOM then
+// neither BOMs U+FEFF nor noncharacters U+FFFE in the input stream will affect
+// the endianness used for decoding, and will instead be output as their
+// standard UTF-8 encodings: "\xef\xbb\xbf" and "\xef\xbf\xbe". If the BOMPolicy
+// is UseBOM or ExpectBOM a staring BOM is not written to the UTF-8 output.
+// Instead, it overrides the default endianness e for the remainder of the
+// transformation. Any subsequent BOMs U+FEFF or noncharacters U+FFFE will not
+// affect the endianness used, and will instead be output as their standard
+// UTF-8 encodings. For UseBOM, if there is no starting BOM, it will proceed
+// with the default Endianness. For ExpectBOM, in that case, the transformation
+// will return early with an ErrMissingBOM error.
+//
+// When encoding from UTF-8 to UTF-16, a BOM will be inserted at the start of
+// the output if the BOMPolicy is UseBOM or ExpectBOM. Otherwise, a BOM will not
+// be inserted. The UTF-8 input does not need to contain a BOM.
+//
+// There is no concept of a 'native' endianness. If the UTF-16 data is produced
+// and consumed in a greater context that implies a certain endianness, use
+// IgnoreBOM. Otherwise, use ExpectBOM and always produce and consume a BOM.
+//
+// In the language of https://www.unicode.org/faq/utf_bom.html#bom10, IgnoreBOM
+// corresponds to "Where the precise type of the data stream is known... the
+// BOM should not be used" and ExpectBOM corresponds to "A particular
+// protocol... may require use of the BOM".
+func UTF16(e Endianness, b BOMPolicy) encoding.Encoding {
+ return utf16Encoding{config{e, b}, mibValue[e][b&bomMask]}
+}
+
+// mibValue maps Endianness and BOMPolicy settings to MIB constants. Note that
+// some configurations map to the same MIB identifier. RFC 2781 has requirements
+// and recommendations. Some of the "configurations" are merely recommendations,
+// so multiple configurations could match.
+var mibValue = map[Endianness][numBOMValues]identifier.MIB{
+ BigEndian: [numBOMValues]identifier.MIB{
+ IgnoreBOM: identifier.UTF16BE,
+ UseBOM: identifier.UTF16, // BigEnding default is preferred by RFC 2781.
+ // TODO: acceptBOM | strictBOM would map to UTF16BE as well.
+ },
+ LittleEndian: [numBOMValues]identifier.MIB{
+ IgnoreBOM: identifier.UTF16LE,
+ UseBOM: identifier.UTF16, // LittleEndian default is allowed and preferred on Windows.
+ // TODO: acceptBOM | strictBOM would map to UTF16LE as well.
+ },
+ // ExpectBOM is not widely used and has no valid MIB identifier.
+}
+
+// All lists a configuration for each IANA-defined UTF-16 variant.
+var All = []encoding.Encoding{
+ UTF8,
+ UTF16(BigEndian, UseBOM),
+ UTF16(BigEndian, IgnoreBOM),
+ UTF16(LittleEndian, IgnoreBOM),
+}
+
+// BOMPolicy is a UTF-16 encoding's byte order mark policy.
+type BOMPolicy uint8
+
+const (
+ writeBOM BOMPolicy = 0x01
+ acceptBOM BOMPolicy = 0x02
+ requireBOM BOMPolicy = 0x04
+ bomMask BOMPolicy = 0x07
+
+ // HACK: numBOMValues == 8 triggers a bug in the 1.4 compiler (cannot have a
+ // map of an array of length 8 of a type that is also used as a key or value
+ // in another map). See golang.org/issue/11354.
+ // TODO: consider changing this value back to 8 if the use of 1.4.* has
+ // been minimized.
+ numBOMValues = 8 + 1
+
+ // IgnoreBOM means to ignore any byte order marks.
+ IgnoreBOM BOMPolicy = 0
+ // Common and RFC 2781-compliant interpretation for UTF-16BE/LE.
+
+ // UseBOM means that the UTF-16 form may start with a byte order mark, which
+ // will be used to override the default encoding.
+ UseBOM BOMPolicy = writeBOM | acceptBOM
+ // Common and RFC 2781-compliant interpretation for UTF-16.
+
+ // ExpectBOM means that the UTF-16 form must start with a byte order mark,
+ // which will be used to override the default encoding.
+ ExpectBOM BOMPolicy = writeBOM | acceptBOM | requireBOM
+ // Used in Java as Unicode (not to be confused with Java's UTF-16) and
+ // ICU's UTF-16,version=1. Not compliant with RFC 2781.
+
+ // TODO (maybe): strictBOM: BOM must match Endianness. This would allow:
+ // - UTF-16(B|L)E,version=1: writeBOM | acceptBOM | requireBOM | strictBOM
+ // (UnicodeBig and UnicodeLittle in Java)
+ // - RFC 2781-compliant, but less common interpretation for UTF-16(B|L)E:
+ // acceptBOM | strictBOM (e.g. assigned to CheckBOM).
+ // This addition would be consistent with supporting ExpectBOM.
+)
+
+// Endianness is a UTF-16 encoding's default endianness.
+type Endianness bool
+
+const (
+ // BigEndian is UTF-16BE.
+ BigEndian Endianness = false
+ // LittleEndian is UTF-16LE.
+ LittleEndian Endianness = true
+)
+
+// ErrMissingBOM means that decoding UTF-16 input with ExpectBOM did not find a
+// starting byte order mark.
+var ErrMissingBOM = errors.New("encoding: missing byte order mark")
+
+type utf16Encoding struct {
+ config
+ mib identifier.MIB
+}
+
+type config struct {
+ endianness Endianness
+ bomPolicy BOMPolicy
+}
+
+func (u utf16Encoding) NewDecoder() *encoding.Decoder {
+ return &encoding.Decoder{Transformer: &utf16Decoder{
+ initial: u.config,
+ current: u.config,
+ }}
+}
+
+func (u utf16Encoding) NewEncoder() *encoding.Encoder {
+ return &encoding.Encoder{Transformer: &utf16Encoder{
+ endianness: u.endianness,
+ initialBOMPolicy: u.bomPolicy,
+ currentBOMPolicy: u.bomPolicy,
+ }}
+}
+
+func (u utf16Encoding) ID() (mib identifier.MIB, other string) {
+ return u.mib, ""
+}
+
+func (u utf16Encoding) String() string {
+ e, b := "B", ""
+ if u.endianness == LittleEndian {
+ e = "L"
+ }
+ switch u.bomPolicy {
+ case ExpectBOM:
+ b = "Expect"
+ case UseBOM:
+ b = "Use"
+ case IgnoreBOM:
+ b = "Ignore"
+ }
+ return "UTF-16" + e + "E (" + b + " BOM)"
+}
+
+type utf16Decoder struct {
+ initial config
+ current config
+}
+
+func (u *utf16Decoder) Reset() {
+ u.current = u.initial
+}
+
+func (u *utf16Decoder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
+ if len(src) < 2 && atEOF && u.current.bomPolicy&requireBOM != 0 {
+ return 0, 0, ErrMissingBOM
+ }
+ if len(src) == 0 {
+ return 0, 0, nil
+ }
+ if len(src) >= 2 && u.current.bomPolicy&acceptBOM != 0 {
+ switch {
+ case src[0] == 0xfe && src[1] == 0xff:
+ u.current.endianness = BigEndian
+ nSrc = 2
+ case src[0] == 0xff && src[1] == 0xfe:
+ u.current.endianness = LittleEndian
+ nSrc = 2
+ default:
+ if u.current.bomPolicy&requireBOM != 0 {
+ return 0, 0, ErrMissingBOM
+ }
+ }
+ u.current.bomPolicy = IgnoreBOM
+ }
+
+ var r rune
+ var dSize, sSize int
+ for nSrc < len(src) {
+ if nSrc+1 < len(src) {
+ x := uint16(src[nSrc+0])<<8 | uint16(src[nSrc+1])
+ if u.current.endianness == LittleEndian {
+ x = x>>8 | x<<8
+ }
+ r, sSize = rune(x), 2
+ if utf16.IsSurrogate(r) {
+ if nSrc+3 < len(src) {
+ x = uint16(src[nSrc+2])<<8 | uint16(src[nSrc+3])
+ if u.current.endianness == LittleEndian {
+ x = x>>8 | x<<8
+ }
+ // Save for next iteration if it is not a high surrogate.
+ if isHighSurrogate(rune(x)) {
+ r, sSize = utf16.DecodeRune(r, rune(x)), 4
+ }
+ } else if !atEOF {
+ err = transform.ErrShortSrc
+ break
+ }
+ }
+ if dSize = utf8.RuneLen(r); dSize < 0 {
+ r, dSize = utf8.RuneError, 3
+ }
+ } else if atEOF {
+ // Single trailing byte.
+ r, dSize, sSize = utf8.RuneError, 3, 1
+ } else {
+ err = transform.ErrShortSrc
+ break
+ }
+ if nDst+dSize > len(dst) {
+ err = transform.ErrShortDst
+ break
+ }
+ nDst += utf8.EncodeRune(dst[nDst:], r)
+ nSrc += sSize
+ }
+ return nDst, nSrc, err
+}
+
+func isHighSurrogate(r rune) bool {
+ return 0xDC00 <= r && r <= 0xDFFF
+}
+
+type utf16Encoder struct {
+ endianness Endianness
+ initialBOMPolicy BOMPolicy
+ currentBOMPolicy BOMPolicy
+}
+
+func (u *utf16Encoder) Reset() {
+ u.currentBOMPolicy = u.initialBOMPolicy
+}
+
+func (u *utf16Encoder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
+ if u.currentBOMPolicy&writeBOM != 0 {
+ if len(dst) < 2 {
+ return 0, 0, transform.ErrShortDst
+ }
+ dst[0], dst[1] = 0xfe, 0xff
+ u.currentBOMPolicy = IgnoreBOM
+ nDst = 2
+ }
+
+ r, size := rune(0), 0
+ for nSrc < len(src) {
+ r = rune(src[nSrc])
+
+ // Decode a 1-byte rune.
+ if r < utf8.RuneSelf {
+ size = 1
+
+ } else {
+ // Decode a multi-byte rune.
+ r, size = utf8.DecodeRune(src[nSrc:])
+ if size == 1 {
+ // All valid runes of size 1 (those below utf8.RuneSelf) were
+ // handled above. We have invalid UTF-8 or we haven't seen the
+ // full character yet.
+ if !atEOF && !utf8.FullRune(src[nSrc:]) {
+ err = transform.ErrShortSrc
+ break
+ }
+ }
+ }
+
+ if r <= 0xffff {
+ if nDst+2 > len(dst) {
+ err = transform.ErrShortDst
+ break
+ }
+ dst[nDst+0] = uint8(r >> 8)
+ dst[nDst+1] = uint8(r)
+ nDst += 2
+ } else {
+ if nDst+4 > len(dst) {
+ err = transform.ErrShortDst
+ break
+ }
+ r1, r2 := utf16.EncodeRune(r)
+ dst[nDst+0] = uint8(r1 >> 8)
+ dst[nDst+1] = uint8(r1)
+ dst[nDst+2] = uint8(r2 >> 8)
+ dst[nDst+3] = uint8(r2)
+ nDst += 4
+ }
+ nSrc += size
+ }
+
+ if u.endianness == LittleEndian {
+ for i := 0; i < nDst; i += 2 {
+ dst[i], dst[i+1] = dst[i+1], dst[i]
+ }
+ }
+ return nDst, nSrc, err
+}
diff --git a/tools/vendor/golang.org/x/text/internal/number/format.go b/tools/vendor/golang.org/x/text/internal/number/format.go
index cd94c5dc4..1aadcf407 100644
--- a/tools/vendor/golang.org/x/text/internal/number/format.go
+++ b/tools/vendor/golang.org/x/text/internal/number/format.go
@@ -394,9 +394,7 @@ func appendScientific(dst []byte, f *Formatter, n *Digits) (b []byte, postPre, p
exp := n.Exp - int32(n.Comma)
exponential := f.Symbol(SymExponential)
if exponential == "E" {
- dst = append(dst, "\u202f"...) // NARROW NO-BREAK SPACE
dst = append(dst, f.Symbol(SymSuperscriptingExponent)...)
- dst = append(dst, "\u202f"...) // NARROW NO-BREAK SPACE
dst = f.AppendDigit(dst, 1)
dst = f.AppendDigit(dst, 0)
switch {
diff --git a/tools/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go b/tools/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go
new file mode 100644
index 000000000..e5c53b1b3
--- /dev/null
+++ b/tools/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go
@@ -0,0 +1,87 @@
+// Copyright 2015 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 utf8internal contains low-level utf8-related constants, tables, etc.
+// that are used internally by the text package.
+package utf8internal
+
+// The default lowest and highest continuation byte.
+const (
+ LoCB = 0x80 // 1000 0000
+ HiCB = 0xBF // 1011 1111
+)
+
+// Constants related to getting information of first bytes of UTF-8 sequences.
+const (
+ // ASCII identifies a UTF-8 byte as ASCII.
+ ASCII = as
+
+ // FirstInvalid indicates a byte is invalid as a first byte of a UTF-8
+ // sequence.
+ FirstInvalid = xx
+
+ // SizeMask is a mask for the size bits. Use use x&SizeMask to get the size.
+ SizeMask = 7
+
+ // AcceptShift is the right-shift count for the first byte info byte to get
+ // the index into the AcceptRanges table. See AcceptRanges.
+ AcceptShift = 4
+
+ // The names of these constants are chosen to give nice alignment in the
+ // table below. The first nibble is an index into acceptRanges or F for
+ // special one-byte cases. The second nibble is the Rune length or the
+ // Status for the special one-byte case.
+ xx = 0xF1 // invalid: size 1
+ as = 0xF0 // ASCII: size 1
+ s1 = 0x02 // accept 0, size 2
+ s2 = 0x13 // accept 1, size 3
+ s3 = 0x03 // accept 0, size 3
+ s4 = 0x23 // accept 2, size 3
+ s5 = 0x34 // accept 3, size 4
+ s6 = 0x04 // accept 0, size 4
+ s7 = 0x44 // accept 4, size 4
+)
+
+// First is information about the first byte in a UTF-8 sequence.
+var First = [256]uint8{
+ // 1 2 3 4 5 6 7 8 9 A B C D E F
+ as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x00-0x0F
+ as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x10-0x1F
+ as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x20-0x2F
+ as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x30-0x3F
+ as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x40-0x4F
+ as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x50-0x5F
+ as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x60-0x6F
+ as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x70-0x7F
+ // 1 2 3 4 5 6 7 8 9 A B C D E F
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0x80-0x8F
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0x90-0x9F
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0xA0-0xAF
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0xB0-0xBF
+ xx, xx, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, // 0xC0-0xCF
+ s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, // 0xD0-0xDF
+ s2, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s4, s3, s3, // 0xE0-0xEF
+ s5, s6, s6, s6, s7, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0xF0-0xFF
+}
+
+// AcceptRange gives the range of valid values for the second byte in a UTF-8
+// sequence for any value for First that is not ASCII or FirstInvalid.
+type AcceptRange struct {
+ Lo uint8 // lowest value for second byte.
+ Hi uint8 // highest value for second byte.
+}
+
+// AcceptRanges is a slice of AcceptRange values. For a given byte sequence b
+//
+// AcceptRanges[First[b[0]]>>AcceptShift]
+//
+// will give the value of AcceptRange for the multi-byte UTF-8 sequence starting
+// at b[0].
+var AcceptRanges = [...]AcceptRange{
+ 0: {LoCB, HiCB},
+ 1: {0xA0, HiCB},
+ 2: {LoCB, 0x9F},
+ 3: {0x90, HiCB},
+ 4: {LoCB, 0x8F},
+}
diff --git a/tools/vendor/golang.org/x/text/language/parse.go b/tools/vendor/golang.org/x/text/language/parse.go
index 4d57222e7..053336e28 100644
--- a/tools/vendor/golang.org/x/text/language/parse.go
+++ b/tools/vendor/golang.org/x/text/language/parse.go
@@ -59,7 +59,7 @@ func (c CanonType) Parse(s string) (t Tag, err error) {
if changed {
tt.RemakeString()
}
- return makeTag(tt), err
+ return makeTag(tt), nil
}
// Compose creates a Tag from individual parts, which may be of type Tag, Base,
diff --git a/tools/vendor/google.golang.org/protobuf/encoding/protodelim/protodelim.go b/tools/vendor/google.golang.org/protobuf/encoding/protodelim/protodelim.go
new file mode 100644
index 000000000..2ef36bbcf
--- /dev/null
+++ b/tools/vendor/google.golang.org/protobuf/encoding/protodelim/protodelim.go
@@ -0,0 +1,160 @@
+// Copyright 2022 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 protodelim marshals and unmarshals varint size-delimited messages.
+package protodelim
+
+import (
+ "bufio"
+ "encoding/binary"
+ "fmt"
+ "io"
+
+ "google.golang.org/protobuf/encoding/protowire"
+ "google.golang.org/protobuf/internal/errors"
+ "google.golang.org/protobuf/proto"
+)
+
+// MarshalOptions is a configurable varint size-delimited marshaler.
+type MarshalOptions struct{ proto.MarshalOptions }
+
+// MarshalTo writes a varint size-delimited wire-format message to w.
+// If w returns an error, MarshalTo returns it unchanged.
+func (o MarshalOptions) MarshalTo(w io.Writer, m proto.Message) (int, error) {
+ msgBytes, err := o.MarshalOptions.Marshal(m)
+ if err != nil {
+ return 0, err
+ }
+
+ sizeBytes := protowire.AppendVarint(nil, uint64(len(msgBytes)))
+ sizeWritten, err := w.Write(sizeBytes)
+ if err != nil {
+ return sizeWritten, err
+ }
+ msgWritten, err := w.Write(msgBytes)
+ if err != nil {
+ return sizeWritten + msgWritten, err
+ }
+ return sizeWritten + msgWritten, nil
+}
+
+// MarshalTo writes a varint size-delimited wire-format message to w
+// with the default options.
+//
+// See the documentation for [MarshalOptions.MarshalTo].
+func MarshalTo(w io.Writer, m proto.Message) (int, error) {
+ return MarshalOptions{}.MarshalTo(w, m)
+}
+
+// UnmarshalOptions is a configurable varint size-delimited unmarshaler.
+type UnmarshalOptions struct {
+ proto.UnmarshalOptions
+
+ // MaxSize is the maximum size in wire-format bytes of a single message.
+ // Unmarshaling a message larger than MaxSize will return an error.
+ // A zero MaxSize will default to 4 MiB.
+ // Setting MaxSize to -1 disables the limit.
+ MaxSize int64
+}
+
+const defaultMaxSize = 4 << 20 // 4 MiB, corresponds to the default gRPC max request/response size
+
+// SizeTooLargeError is an error that is returned when the unmarshaler encounters a message size
+// that is larger than its configured [UnmarshalOptions.MaxSize].
+type SizeTooLargeError struct {
+ // Size is the varint size of the message encountered
+ // that was larger than the provided MaxSize.
+ Size uint64
+
+ // MaxSize is the MaxSize limit configured in UnmarshalOptions, which Size exceeded.
+ MaxSize uint64
+}
+
+func (e *SizeTooLargeError) Error() string {
+ return fmt.Sprintf("message size %d exceeded unmarshaler's maximum configured size %d", e.Size, e.MaxSize)
+}
+
+// Reader is the interface expected by [UnmarshalFrom].
+// It is implemented by *[bufio.Reader].
+type Reader interface {
+ io.Reader
+ io.ByteReader
+}
+
+// UnmarshalFrom parses and consumes a varint size-delimited wire-format message
+// from r.
+// The provided message must be mutable (e.g., a non-nil pointer to a message).
+//
+// The error is [io.EOF] error only if no bytes are read.
+// If an EOF happens after reading some but not all the bytes,
+// UnmarshalFrom returns a non-io.EOF error.
+// In particular if r returns a non-io.EOF error, UnmarshalFrom returns it unchanged,
+// and if only a size is read with no subsequent message, [io.ErrUnexpectedEOF] is returned.
+func (o UnmarshalOptions) UnmarshalFrom(r Reader, m proto.Message) error {
+ var sizeArr [binary.MaxVarintLen64]byte
+ sizeBuf := sizeArr[:0]
+ for i := range sizeArr {
+ b, err := r.ReadByte()
+ if err != nil {
+ // Immediate EOF is unexpected.
+ if err == io.EOF && i != 0 {
+ break
+ }
+ return err
+ }
+ sizeBuf = append(sizeBuf, b)
+ if b < 0x80 {
+ break
+ }
+ }
+ size, n := protowire.ConsumeVarint(sizeBuf)
+ if n < 0 {
+ return protowire.ParseError(n)
+ }
+
+ maxSize := o.MaxSize
+ if maxSize == 0 {
+ maxSize = defaultMaxSize
+ }
+ if maxSize != -1 && size > uint64(maxSize) {
+ return errors.Wrap(&SizeTooLargeError{Size: size, MaxSize: uint64(maxSize)}, "")
+ }
+
+ var b []byte
+ var err error
+ if br, ok := r.(*bufio.Reader); ok {
+ // Use the []byte from the bufio.Reader instead of having to allocate one.
+ // This reduces CPU usage and allocated bytes.
+ b, err = br.Peek(int(size))
+ if err == nil {
+ defer br.Discard(int(size))
+ } else {
+ b = nil
+ }
+ }
+ if b == nil {
+ b = make([]byte, size)
+ _, err = io.ReadFull(r, b)
+ }
+
+ if err == io.EOF {
+ return io.ErrUnexpectedEOF
+ }
+ if err != nil {
+ return err
+ }
+ if err := o.Unmarshal(b, m); err != nil {
+ return err
+ }
+ return nil
+}
+
+// UnmarshalFrom parses and consumes a varint size-delimited wire-format message
+// from r with the default options.
+// The provided message must be mutable (e.g., a non-nil pointer to a message).
+//
+// See the documentation for [UnmarshalOptions.UnmarshalFrom].
+func UnmarshalFrom(r Reader, m proto.Message) error {
+ return UnmarshalOptions{}.UnmarshalFrom(r, m)
+}
diff --git a/tools/vendor/google.golang.org/protobuf/encoding/prototext/decode.go b/tools/vendor/google.golang.org/protobuf/encoding/prototext/decode.go
index d972a3d98..b53805056 100644
--- a/tools/vendor/google.golang.org/protobuf/encoding/prototext/decode.go
+++ b/tools/vendor/google.golang.org/protobuf/encoding/prototext/decode.go
@@ -185,11 +185,6 @@ func (d decoder) unmarshalMessage(m protoreflect.Message, checkDelims bool) erro
} else if xtErr != nil && xtErr != protoregistry.NotFound {
return d.newError(tok.Pos(), "unable to resolve [%s]: %v", tok.RawString(), xtErr)
}
- if flags.ProtoLegacyWeak {
- if fd != nil && fd.IsWeak() && fd.Message().IsPlaceholder() {
- fd = nil // reset since the weak reference is not linked in
- }
- }
// Handle unknown fields.
if fd == nil {
diff --git a/tools/vendor/google.golang.org/protobuf/internal/editionssupport/editions.go b/tools/vendor/google.golang.org/protobuf/internal/editionssupport/editions.go
deleted file mode 100644
index bf1aba0e8..000000000
--- a/tools/vendor/google.golang.org/protobuf/internal/editionssupport/editions.go
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2024 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 editionssupport defines constants for editions that are supported.
-package editionssupport
-
-import "google.golang.org/protobuf/types/descriptorpb"
-
-const (
- Minimum = descriptorpb.Edition_EDITION_PROTO2
- Maximum = descriptorpb.Edition_EDITION_2023
-
- // MaximumKnown is the maximum edition that is known to Go Protobuf, but not
- // declared as supported. In other words: end users cannot use it, but
- // testprotos inside Go Protobuf can.
- MaximumKnown = descriptorpb.Edition_EDITION_2024
-)
diff --git a/tools/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go b/tools/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go
index 7e87c7604..669133d04 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go
@@ -26,7 +26,7 @@ var byteType = reflect.TypeOf(byte(0))
// The type is the underlying field type (e.g., a repeated field may be
// represented by []T, but the Go type passed in is just T).
// A list of enum value descriptors must be provided for enum fields.
-// This does not populate the Enum or Message (except for weak message).
+// This does not populate the Enum or Message.
//
// This function is a best effort attempt; parsing errors are ignored.
func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescriptors) protoreflect.FieldDescriptor {
@@ -109,9 +109,6 @@ func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescri
}
case s == "packed":
f.L1.EditionFeatures.IsPacked = true
- case strings.HasPrefix(s, "weak="):
- f.L1.IsWeak = true
- f.L1.Message = filedesc.PlaceholderMessage(protoreflect.FullName(s[len("weak="):]))
case strings.HasPrefix(s, "def="):
// The default tag is special in that everything afterwards is the
// default regardless of the presence of commas.
@@ -183,9 +180,6 @@ func Marshal(fd protoreflect.FieldDescriptor, enumName string) string {
// the exact same semantics from the previous generator.
tag = append(tag, "json="+jsonName)
}
- if fd.IsWeak() {
- tag = append(tag, "weak="+string(fd.Message().FullName()))
- }
// The previous implementation does not tag extension fields as proto3,
// even when the field is defined in a proto3 file. Match that behavior
// for consistency.
diff --git a/tools/vendor/google.golang.org/protobuf/internal/filedesc/desc.go b/tools/vendor/google.golang.org/protobuf/internal/filedesc/desc.go
index 378b826fa..688aabe43 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/filedesc/desc.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/filedesc/desc.go
@@ -19,7 +19,6 @@ import (
"google.golang.org/protobuf/internal/pragma"
"google.golang.org/protobuf/internal/strs"
"google.golang.org/protobuf/reflect/protoreflect"
- "google.golang.org/protobuf/reflect/protoregistry"
)
// Edition is an Enum for proto2.Edition
@@ -275,7 +274,6 @@ type (
Kind protoreflect.Kind
StringName stringName
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
- IsWeak bool // promoted from google.protobuf.FieldOptions
IsLazy bool // promoted from google.protobuf.FieldOptions
Default defaultValue
ContainingOneof protoreflect.OneofDescriptor // must be consistent with Message.Oneofs.Fields
@@ -369,7 +367,7 @@ func (fd *Field) IsPacked() bool {
return fd.L1.EditionFeatures.IsPacked
}
func (fd *Field) IsExtension() bool { return false }
-func (fd *Field) IsWeak() bool { return fd.L1.IsWeak }
+func (fd *Field) IsWeak() bool { return false }
func (fd *Field) IsLazy() bool { return fd.L1.IsLazy }
func (fd *Field) IsList() bool { return fd.Cardinality() == protoreflect.Repeated && !fd.IsMap() }
func (fd *Field) IsMap() bool { return fd.Message() != nil && fd.Message().IsMapEntry() }
@@ -396,11 +394,6 @@ func (fd *Field) Enum() protoreflect.EnumDescriptor {
return fd.L1.Enum
}
func (fd *Field) Message() protoreflect.MessageDescriptor {
- if fd.L1.IsWeak {
- if d, _ := protoregistry.GlobalFiles.FindDescriptorByName(fd.L1.Message.FullName()); d != nil {
- return d.(protoreflect.MessageDescriptor)
- }
- }
return fd.L1.Message
}
func (fd *Field) IsMapEntry() bool {
diff --git a/tools/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go b/tools/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
index 67a51b327..d4c94458b 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
@@ -32,11 +32,6 @@ func (file *File) resolveMessages() {
for j := range md.L2.Fields.List {
fd := &md.L2.Fields.List[j]
- // Weak fields are resolved upon actual use.
- if fd.L1.IsWeak {
- continue
- }
-
// Resolve message field dependency.
switch fd.L1.Kind {
case protoreflect.EnumKind:
@@ -150,8 +145,6 @@ func (fd *File) unmarshalFull(b []byte) {
switch num {
case genid.FileDescriptorProto_PublicDependency_field_number:
fd.L2.Imports[v].IsPublic = true
- case genid.FileDescriptorProto_WeakDependency_field_number:
- fd.L2.Imports[v].IsWeak = true
}
case protowire.BytesType:
v, m := protowire.ConsumeBytes(b)
@@ -502,8 +495,6 @@ func (fd *Field) unmarshalOptions(b []byte) {
switch num {
case genid.FieldOptions_Packed_field_number:
fd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v)
- case genid.FieldOptions_Weak_field_number:
- fd.L1.IsWeak = protowire.DecodeBool(v)
case genid.FieldOptions_Lazy_field_number:
fd.L1.IsLazy = protowire.DecodeBool(v)
case FieldOptions_EnforceUTF8:
diff --git a/tools/vendor/google.golang.org/protobuf/internal/filetype/build.go b/tools/vendor/google.golang.org/protobuf/internal/filetype/build.go
index ba83fea44..e1b4130bd 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/filetype/build.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/filetype/build.go
@@ -63,7 +63,7 @@ type Builder struct {
// message declarations in "flattened ordering".
//
// Dependencies are Go types for enums or messages referenced by
- // message fields (excluding weak fields), for parent extended messages of
+ // message fields, for parent extended messages of
// extension fields, for enums or messages referenced by extension fields,
// and for input and output messages referenced by service methods.
// Dependencies must come after declarations, but the ordering of
diff --git a/tools/vendor/google.golang.org/protobuf/internal/flags/flags.go b/tools/vendor/google.golang.org/protobuf/internal/flags/flags.go
index 5cb3ee70f..a06ccabc2 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/flags/flags.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/flags/flags.go
@@ -6,7 +6,7 @@
package flags
// ProtoLegacy specifies whether to enable support for legacy functionality
-// such as MessageSets, weak fields, and various other obscure behavior
+// such as MessageSets, and various other obscure behavior
// that is necessary to maintain backwards compatibility with proto1 or
// the pre-release variants of proto2 and proto3.
//
@@ -22,8 +22,3 @@ const ProtoLegacy = protoLegacy
// extension fields at unmarshal time, but defers creating the message
// structure until the extension is first accessed.
const LazyUnmarshalExtensions = ProtoLegacy
-
-// ProtoLegacyWeak specifies whether to enable support for weak fields.
-// This flag was split out of ProtoLegacy in preparation for removing
-// support for weak fields (independent of the other protolegacy features).
-const ProtoLegacyWeak = ProtoLegacy
diff --git a/tools/vendor/google.golang.org/protobuf/internal/genid/goname.go b/tools/vendor/google.golang.org/protobuf/internal/genid/goname.go
index 693d2e9e1..99bb95baf 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/genid/goname.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/genid/goname.go
@@ -11,15 +11,10 @@ const (
SizeCache_goname = "sizeCache"
SizeCacheA_goname = "XXX_sizecache"
- WeakFields_goname = "weakFields"
- WeakFieldsA_goname = "XXX_weak"
-
UnknownFields_goname = "unknownFields"
UnknownFieldsA_goname = "XXX_unrecognized"
ExtensionFields_goname = "extensionFields"
ExtensionFieldsA_goname = "XXX_InternalExtensions"
ExtensionFieldsB_goname = "XXX_extensions"
-
- WeakFieldPrefix_goname = "XXX_weak_"
)
diff --git a/tools/vendor/google.golang.org/protobuf/internal/impl/codec_field.go b/tools/vendor/google.golang.org/protobuf/internal/impl/codec_field.go
index 7c1f66c8c..d14d7d93c 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/impl/codec_field.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/impl/codec_field.go
@@ -5,15 +5,12 @@
package impl
import (
- "fmt"
"reflect"
- "sync"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/internal/errors"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
- "google.golang.org/protobuf/reflect/protoregistry"
"google.golang.org/protobuf/runtime/protoiface"
)
@@ -121,78 +118,6 @@ func (mi *MessageInfo) initOneofFieldCoders(od protoreflect.OneofDescriptor, si
}
}
-func makeWeakMessageFieldCoder(fd protoreflect.FieldDescriptor) pointerCoderFuncs {
- var once sync.Once
- var messageType protoreflect.MessageType
- lazyInit := func() {
- once.Do(func() {
- messageName := fd.Message().FullName()
- messageType, _ = protoregistry.GlobalTypes.FindMessageByName(messageName)
- })
- }
-
- return pointerCoderFuncs{
- size: func(p pointer, f *coderFieldInfo, opts marshalOptions) int {
- m, ok := p.WeakFields().get(f.num)
- if !ok {
- return 0
- }
- lazyInit()
- if messageType == nil {
- panic(fmt.Sprintf("weak message %v is not linked in", fd.Message().FullName()))
- }
- return sizeMessage(m, f.tagsize, opts)
- },
- marshal: func(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
- m, ok := p.WeakFields().get(f.num)
- if !ok {
- return b, nil
- }
- lazyInit()
- if messageType == nil {
- panic(fmt.Sprintf("weak message %v is not linked in", fd.Message().FullName()))
- }
- return appendMessage(b, m, f.wiretag, opts)
- },
- unmarshal: func(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (unmarshalOutput, error) {
- fs := p.WeakFields()
- m, ok := fs.get(f.num)
- if !ok {
- lazyInit()
- if messageType == nil {
- return unmarshalOutput{}, errUnknown
- }
- m = messageType.New().Interface()
- fs.set(f.num, m)
- }
- return consumeMessage(b, m, wtyp, opts)
- },
- isInit: func(p pointer, f *coderFieldInfo) error {
- m, ok := p.WeakFields().get(f.num)
- if !ok {
- return nil
- }
- return proto.CheckInitialized(m)
- },
- merge: func(dst, src pointer, f *coderFieldInfo, opts mergeOptions) {
- sm, ok := src.WeakFields().get(f.num)
- if !ok {
- return
- }
- dm, ok := dst.WeakFields().get(f.num)
- if !ok {
- lazyInit()
- if messageType == nil {
- panic(fmt.Sprintf("weak message %v is not linked in", fd.Message().FullName()))
- }
- dm = messageType.New().Interface()
- dst.WeakFields().set(f.num, dm)
- }
- opts.Merge(dm, sm)
- },
- }
-}
-
func makeMessageFieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) pointerCoderFuncs {
if mi := getMessageInfo(ft); mi != nil {
funcs := pointerCoderFuncs{
diff --git a/tools/vendor/google.golang.org/protobuf/internal/impl/codec_message.go b/tools/vendor/google.golang.org/protobuf/internal/impl/codec_message.go
index 111d95833..f78b57b04 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/impl/codec_message.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/impl/codec_message.go
@@ -119,9 +119,6 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
}
case isOneof:
fieldOffset = offsetOf(fs)
- case fd.IsWeak():
- fieldOffset = si.weakOffset
- funcs = makeWeakMessageFieldCoder(fd)
default:
fieldOffset = offsetOf(fs)
childMessage, funcs = fieldCoder(fd, ft)
diff --git a/tools/vendor/google.golang.org/protobuf/internal/impl/codec_message_opaque.go b/tools/vendor/google.golang.org/protobuf/internal/impl/codec_message_opaque.go
index f81d7d0db..41c1f74ef 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/impl/codec_message_opaque.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/impl/codec_message_opaque.go
@@ -46,9 +46,6 @@ func (mi *MessageInfo) makeOpaqueCoderMethods(t reflect.Type, si opaqueStructInf
switch {
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
fieldOffset = offsetOf(fs)
- case fd.IsWeak():
- fieldOffset = si.weakOffset
- funcs = makeWeakMessageFieldCoder(fd)
case fd.Message() != nil && !fd.IsMap():
fieldOffset = offsetOf(fs)
if fd.IsList() {
diff --git a/tools/vendor/google.golang.org/protobuf/internal/impl/lazy.go b/tools/vendor/google.golang.org/protobuf/internal/impl/lazy.go
index e8fb6c35b..c7de31e24 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/impl/lazy.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/impl/lazy.go
@@ -131,7 +131,7 @@ func (mi *MessageInfo) skipField(b []byte, f *coderFieldInfo, wtyp protowire.Typ
fmi := f.validation.mi
if fmi == nil {
fd := mi.Desc.Fields().ByNumber(f.num)
- if fd == nil || !fd.IsWeak() {
+ if fd == nil {
return out, ValidationUnknown
}
messageName := fd.Message().FullName()
diff --git a/tools/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go b/tools/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
index bf0b6049b..a51dffbe2 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
@@ -310,12 +310,9 @@ func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey,
fd.L0.Parent = md
fd.L0.Index = n
- if fd.L1.IsWeak || fd.L1.EditionFeatures.IsPacked {
+ if fd.L1.EditionFeatures.IsPacked {
fd.L1.Options = func() protoreflect.ProtoMessage {
opts := descopts.Field.ProtoReflect().New()
- if fd.L1.IsWeak {
- opts.Set(opts.Descriptor().Fields().ByName("weak"), protoreflect.ValueOfBool(true))
- }
if fd.L1.EditionFeatures.IsPacked {
opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.EditionFeatures.IsPacked))
}
diff --git a/tools/vendor/google.golang.org/protobuf/internal/impl/message.go b/tools/vendor/google.golang.org/protobuf/internal/impl/message.go
index d1f79b422..d50423dcb 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/impl/message.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/impl/message.go
@@ -14,7 +14,6 @@ import (
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/reflect/protoreflect"
- "google.golang.org/protobuf/reflect/protoregistry"
)
// MessageInfo provides protobuf related functionality for a given Go type
@@ -120,7 +119,6 @@ type (
var (
sizecacheType = reflect.TypeOf(SizeCache(0))
- weakFieldsType = reflect.TypeOf(WeakFields(nil))
unknownFieldsAType = reflect.TypeOf(unknownFieldsA(nil))
unknownFieldsBType = reflect.TypeOf(unknownFieldsB(nil))
extensionFieldsType = reflect.TypeOf(ExtensionFields(nil))
@@ -129,8 +127,6 @@ var (
type structInfo struct {
sizecacheOffset offset
sizecacheType reflect.Type
- weakOffset offset
- weakType reflect.Type
unknownOffset offset
unknownType reflect.Type
extensionOffset offset
@@ -148,7 +144,6 @@ type structInfo struct {
func (mi *MessageInfo) makeStructInfo(t reflect.Type) structInfo {
si := structInfo{
sizecacheOffset: invalidOffset,
- weakOffset: invalidOffset,
unknownOffset: invalidOffset,
extensionOffset: invalidOffset,
lazyOffset: invalidOffset,
@@ -168,11 +163,6 @@ fieldLoop:
si.sizecacheOffset = offsetOf(f)
si.sizecacheType = f.Type
}
- case genid.WeakFields_goname, genid.WeakFieldsA_goname:
- if f.Type == weakFieldsType {
- si.weakOffset = offsetOf(f)
- si.weakType = f.Type
- }
case genid.UnknownFields_goname, genid.UnknownFieldsA_goname:
if f.Type == unknownFieldsAType || f.Type == unknownFieldsBType {
si.unknownOffset = offsetOf(f)
@@ -256,9 +246,6 @@ func (mi *MessageInfo) Message(i int) protoreflect.MessageType {
mi.init()
fd := mi.Desc.Fields().Get(i)
switch {
- case fd.IsWeak():
- mt, _ := protoregistry.GlobalTypes.FindMessageByName(fd.Message().FullName())
- return mt
case fd.IsMap():
return mapEntryType{fd.Message(), mi.fieldTypes[fd.Number()]}
default:
diff --git a/tools/vendor/google.golang.org/protobuf/internal/impl/message_opaque.go b/tools/vendor/google.golang.org/protobuf/internal/impl/message_opaque.go
index d8dcd7886..dd55e8e00 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/impl/message_opaque.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/impl/message_opaque.go
@@ -56,9 +56,6 @@ func opaqueInitHook(mi *MessageInfo) bool {
usePresence, _ := usePresenceForField(si, fd)
switch {
- case fd.IsWeak():
- // Weak fields are no different for opaque.
- fi = fieldInfoForWeakMessage(fd, si.weakOffset)
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
// Oneofs are no different for opaque.
fi = fieldInfoForOneof(fd, si.oneofsByName[fd.ContainingOneof().Name()], mi.Exporter, si.oneofWrappersByNumber[fd.Number()])
@@ -620,8 +617,6 @@ func usePresenceForField(si opaqueStructInfo, fd protoreflect.FieldDescriptor) (
switch {
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
return false, false
- case fd.IsWeak():
- return false, false
case fd.IsMap():
return false, false
case fd.Kind() == protoreflect.MessageKind || fd.Kind() == protoreflect.GroupKind:
diff --git a/tools/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go b/tools/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
index 31c19b54f..0d20132fa 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
@@ -72,8 +72,6 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) {
fi = fieldInfoForMap(fd, fs, mi.Exporter)
case fd.IsList():
fi = fieldInfoForList(fd, fs, mi.Exporter)
- case fd.IsWeak():
- fi = fieldInfoForWeakMessage(fd, si.weakOffset)
case fd.Message() != nil:
fi = fieldInfoForMessage(fd, fs, mi.Exporter)
default:
@@ -219,9 +217,6 @@ func (mi *MessageInfo) makeFieldTypes(si structInfo) {
}
case fd.Message() != nil:
ft = fs.Type
- if fd.IsWeak() {
- ft = nil
- }
isMessage = true
}
if isMessage && ft != nil && ft.Kind() != reflect.Ptr {
diff --git a/tools/vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go b/tools/vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
index 3cd1fbc21..68d4ae32e 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
@@ -8,11 +8,8 @@ import (
"fmt"
"math"
"reflect"
- "sync"
- "google.golang.org/protobuf/internal/flags"
"google.golang.org/protobuf/reflect/protoreflect"
- "google.golang.org/protobuf/reflect/protoregistry"
)
type fieldInfo struct {
@@ -332,79 +329,6 @@ func fieldInfoForScalar(fd protoreflect.FieldDescriptor, fs reflect.StructField,
}
}
-func fieldInfoForWeakMessage(fd protoreflect.FieldDescriptor, weakOffset offset) fieldInfo {
- if !flags.ProtoLegacyWeak {
- panic("no support for proto1 weak fields")
- }
-
- var once sync.Once
- var messageType protoreflect.MessageType
- lazyInit := func() {
- once.Do(func() {
- messageName := fd.Message().FullName()
- messageType, _ = protoregistry.GlobalTypes.FindMessageByName(messageName)
- if messageType == nil {
- panic(fmt.Sprintf("weak message %v for field %v is not linked in", messageName, fd.FullName()))
- }
- })
- }
-
- num := fd.Number()
- return fieldInfo{
- fieldDesc: fd,
- has: func(p pointer) bool {
- if p.IsNil() {
- return false
- }
- _, ok := p.Apply(weakOffset).WeakFields().get(num)
- return ok
- },
- clear: func(p pointer) {
- p.Apply(weakOffset).WeakFields().clear(num)
- },
- get: func(p pointer) protoreflect.Value {
- lazyInit()
- if p.IsNil() {
- return protoreflect.ValueOfMessage(messageType.Zero())
- }
- m, ok := p.Apply(weakOffset).WeakFields().get(num)
- if !ok {
- return protoreflect.ValueOfMessage(messageType.Zero())
- }
- return protoreflect.ValueOfMessage(m.ProtoReflect())
- },
- set: func(p pointer, v protoreflect.Value) {
- lazyInit()
- m := v.Message()
- if m.Descriptor() != messageType.Descriptor() {
- if got, want := m.Descriptor().FullName(), messageType.Descriptor().FullName(); got != want {
- panic(fmt.Sprintf("field %v has mismatching message descriptor: got %v, want %v", fd.FullName(), got, want))
- }
- panic(fmt.Sprintf("field %v has mismatching message descriptor: %v", fd.FullName(), m.Descriptor().FullName()))
- }
- p.Apply(weakOffset).WeakFields().set(num, m.Interface())
- },
- mutable: func(p pointer) protoreflect.Value {
- lazyInit()
- fs := p.Apply(weakOffset).WeakFields()
- m, ok := fs.get(num)
- if !ok {
- m = messageType.New().Interface()
- fs.set(num, m)
- }
- return protoreflect.ValueOfMessage(m.ProtoReflect())
- },
- newMessage: func() protoreflect.Message {
- lazyInit()
- return messageType.New()
- },
- newField: func() protoreflect.Value {
- lazyInit()
- return protoreflect.ValueOfMessage(messageType.New())
- },
- }
-}
-
func fieldInfoForMessage(fd protoreflect.FieldDescriptor, fs reflect.StructField, x exporter) fieldInfo {
ft := fs.Type
conv := NewConverter(ft, fd)
diff --git a/tools/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go b/tools/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
index 6bed45e35..62f8bf663 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
@@ -111,7 +111,6 @@ func (p pointer) StringSlice() *[]string { return (*[]string)(p.p
func (p pointer) Bytes() *[]byte { return (*[]byte)(p.p) }
func (p pointer) BytesPtr() **[]byte { return (**[]byte)(p.p) }
func (p pointer) BytesSlice() *[][]byte { return (*[][]byte)(p.p) }
-func (p pointer) WeakFields() *weakFields { return (*weakFields)(p.p) }
func (p pointer) Extensions() *map[int32]ExtensionField { return (*map[int32]ExtensionField)(p.p) }
func (p pointer) LazyInfoPtr() **protolazy.XXX_lazyUnmarshalInfo {
return (**protolazy.XXX_lazyUnmarshalInfo)(p.p)
diff --git a/tools/vendor/google.golang.org/protobuf/internal/impl/validate.go b/tools/vendor/google.golang.org/protobuf/internal/impl/validate.go
index b534a3d6d..7b2995dde 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/impl/validate.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/impl/validate.go
@@ -211,9 +211,7 @@ func newValidationInfo(fd protoreflect.FieldDescriptor, ft reflect.Type) validat
switch fd.Kind() {
case protoreflect.MessageKind:
vi.typ = validationTypeMessage
- if !fd.IsWeak() {
- vi.mi = getMessageInfo(ft)
- }
+ vi.mi = getMessageInfo(ft)
case protoreflect.GroupKind:
vi.typ = validationTypeGroup
vi.mi = getMessageInfo(ft)
@@ -320,26 +318,6 @@ State:
}
if f != nil {
vi = f.validation
- if vi.typ == validationTypeMessage && vi.mi == nil {
- // Probable weak field.
- //
- // TODO: Consider storing the results of this lookup somewhere
- // rather than recomputing it on every validation.
- fd := st.mi.Desc.Fields().ByNumber(num)
- if fd == nil || !fd.IsWeak() {
- break
- }
- messageName := fd.Message().FullName()
- messageType, err := protoregistry.GlobalTypes.FindMessageByName(messageName)
- switch err {
- case nil:
- vi.mi, _ = messageType.(*MessageInfo)
- case protoregistry.NotFound:
- vi.typ = validationTypeBytes
- default:
- return out, ValidationUnknown
- }
- }
break
}
// Possible extension field.
diff --git a/tools/vendor/google.golang.org/protobuf/internal/impl/weak.go b/tools/vendor/google.golang.org/protobuf/internal/impl/weak.go
deleted file mode 100644
index eb79a7ba9..000000000
--- a/tools/vendor/google.golang.org/protobuf/internal/impl/weak.go
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright 2019 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 impl
-
-import (
- "fmt"
-
- "google.golang.org/protobuf/reflect/protoreflect"
- "google.golang.org/protobuf/reflect/protoregistry"
-)
-
-// weakFields adds methods to the exported WeakFields type for internal use.
-//
-// The exported type is an alias to an unnamed type, so methods can't be
-// defined directly on it.
-type weakFields WeakFields
-
-func (w weakFields) get(num protoreflect.FieldNumber) (protoreflect.ProtoMessage, bool) {
- m, ok := w[int32(num)]
- return m, ok
-}
-
-func (w *weakFields) set(num protoreflect.FieldNumber, m protoreflect.ProtoMessage) {
- if *w == nil {
- *w = make(weakFields)
- }
- (*w)[int32(num)] = m
-}
-
-func (w *weakFields) clear(num protoreflect.FieldNumber) {
- delete(*w, int32(num))
-}
-
-func (Export) HasWeak(w WeakFields, num protoreflect.FieldNumber) bool {
- _, ok := w[int32(num)]
- return ok
-}
-
-func (Export) ClearWeak(w *WeakFields, num protoreflect.FieldNumber) {
- delete(*w, int32(num))
-}
-
-func (Export) GetWeak(w WeakFields, num protoreflect.FieldNumber, name protoreflect.FullName) protoreflect.ProtoMessage {
- if m, ok := w[int32(num)]; ok {
- return m
- }
- mt, _ := protoregistry.GlobalTypes.FindMessageByName(name)
- if mt == nil {
- panic(fmt.Sprintf("message %v for weak field is not linked in", name))
- }
- return mt.Zero().Interface()
-}
-
-func (Export) SetWeak(w *WeakFields, num protoreflect.FieldNumber, name protoreflect.FullName, m protoreflect.ProtoMessage) {
- if m != nil {
- mt, _ := protoregistry.GlobalTypes.FindMessageByName(name)
- if mt == nil {
- panic(fmt.Sprintf("message %v for weak field is not linked in", name))
- }
- if mt != m.ProtoReflect().Type() {
- panic(fmt.Sprintf("invalid message type for weak field: got %T, want %T", m, mt.Zero().Interface()))
- }
- }
- if m == nil || !m.ProtoReflect().IsValid() {
- delete(*w, int32(num))
- return
- }
- if *w == nil {
- *w = make(weakFields)
- }
- (*w)[int32(num)] = m
-}
diff --git a/tools/vendor/google.golang.org/protobuf/internal/version/version.go b/tools/vendor/google.golang.org/protobuf/internal/version/version.go
index 4a39af0c6..01efc3303 100644
--- a/tools/vendor/google.golang.org/protobuf/internal/version/version.go
+++ b/tools/vendor/google.golang.org/protobuf/internal/version/version.go
@@ -52,7 +52,7 @@ import (
const (
Major = 1
Minor = 36
- Patch = 4
+ Patch = 5
PreRelease = ""
)
diff --git a/tools/vendor/google.golang.org/protobuf/proto/decode.go b/tools/vendor/google.golang.org/protobuf/proto/decode.go
index e28d7acb3..4cbf1aeaf 100644
--- a/tools/vendor/google.golang.org/protobuf/proto/decode.go
+++ b/tools/vendor/google.golang.org/protobuf/proto/decode.go
@@ -8,7 +8,6 @@ import (
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/internal/encoding/messageset"
"google.golang.org/protobuf/internal/errors"
- "google.golang.org/protobuf/internal/flags"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/internal/pragma"
"google.golang.org/protobuf/reflect/protoreflect"
@@ -172,10 +171,6 @@ func (o UnmarshalOptions) unmarshalMessageSlow(b []byte, m protoreflect.Message)
var err error
if fd == nil {
err = errUnknown
- } else if flags.ProtoLegacyWeak {
- if fd.IsWeak() && fd.Message().IsPlaceholder() {
- err = errUnknown // weak referent is not linked in
- }
}
// Parse the field value.
diff --git a/tools/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go b/tools/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go
deleted file mode 100644
index 69a050509..000000000
--- a/tools/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go
+++ /dev/null
@@ -1,292 +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.
-
-// Package protodesc provides functionality for converting
-// FileDescriptorProto messages to/from [protoreflect.FileDescriptor] values.
-//
-// The google.protobuf.FileDescriptorProto is a protobuf message that describes
-// the type information for a .proto file in a form that is easily serializable.
-// The [protoreflect.FileDescriptor] is a more structured representation of
-// the FileDescriptorProto message where references and remote dependencies
-// can be directly followed.
-package protodesc
-
-import (
- "strings"
-
- "google.golang.org/protobuf/internal/editionssupport"
- "google.golang.org/protobuf/internal/errors"
- "google.golang.org/protobuf/internal/filedesc"
- "google.golang.org/protobuf/internal/pragma"
- "google.golang.org/protobuf/internal/strs"
- "google.golang.org/protobuf/proto"
- "google.golang.org/protobuf/reflect/protoreflect"
- "google.golang.org/protobuf/reflect/protoregistry"
-
- "google.golang.org/protobuf/types/descriptorpb"
-)
-
-// Resolver is the resolver used by [NewFile] to resolve dependencies.
-// The enums and messages provided must belong to some parent file,
-// which is also registered.
-//
-// It is implemented by [protoregistry.Files].
-type Resolver interface {
- FindFileByPath(string) (protoreflect.FileDescriptor, error)
- FindDescriptorByName(protoreflect.FullName) (protoreflect.Descriptor, error)
-}
-
-// FileOptions configures the construction of file descriptors.
-type FileOptions struct {
- pragma.NoUnkeyedLiterals
-
- // AllowUnresolvable configures New to permissively allow unresolvable
- // file, enum, or message dependencies. Unresolved dependencies are replaced
- // by placeholder equivalents.
- //
- // The following dependencies may be left unresolved:
- // • Resolving an imported file.
- // • Resolving the type for a message field or extension field.
- // If the kind of the field is unknown, then a placeholder is used for both
- // the Enum and Message accessors on the protoreflect.FieldDescriptor.
- // • Resolving an enum value set as the default for an optional enum field.
- // If unresolvable, the protoreflect.FieldDescriptor.Default is set to the
- // first value in the associated enum (or zero if the also enum dependency
- // is also unresolvable). The protoreflect.FieldDescriptor.DefaultEnumValue
- // is populated with a placeholder.
- // • Resolving the extended message type for an extension field.
- // • Resolving the input or output message type for a service method.
- //
- // If the unresolved dependency uses a relative name,
- // then the placeholder will contain an invalid FullName with a "*." prefix,
- // indicating that the starting prefix of the full name is unknown.
- AllowUnresolvable bool
-}
-
-// NewFile creates a new [protoreflect.FileDescriptor] from the provided
-// file descriptor message. See [FileOptions.New] for more information.
-func NewFile(fd *descriptorpb.FileDescriptorProto, r Resolver) (protoreflect.FileDescriptor, error) {
- return FileOptions{}.New(fd, r)
-}
-
-// NewFiles creates a new [protoregistry.Files] from the provided
-// FileDescriptorSet message. See [FileOptions.NewFiles] for more information.
-func NewFiles(fd *descriptorpb.FileDescriptorSet) (*protoregistry.Files, error) {
- return FileOptions{}.NewFiles(fd)
-}
-
-// New creates a new [protoreflect.FileDescriptor] from the provided
-// file descriptor message. The file must represent a valid proto file according
-// to protobuf semantics. The returned descriptor is a deep copy of the input.
-//
-// Any imported files, enum types, or message types referenced in the file are
-// resolved using the provided registry. When looking up an import file path,
-// the path must be unique. The newly created file descriptor is not registered
-// back into the provided file registry.
-func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (protoreflect.FileDescriptor, error) {
- if r == nil {
- r = (*protoregistry.Files)(nil) // empty resolver
- }
-
- // Handle the file descriptor content.
- f := &filedesc.File{L2: &filedesc.FileL2{}}
- switch fd.GetSyntax() {
- case "proto2", "":
- f.L1.Syntax = protoreflect.Proto2
- f.L1.Edition = filedesc.EditionProto2
- case "proto3":
- f.L1.Syntax = protoreflect.Proto3
- f.L1.Edition = filedesc.EditionProto3
- case "editions":
- f.L1.Syntax = protoreflect.Editions
- f.L1.Edition = fromEditionProto(fd.GetEdition())
- default:
- return nil, errors.New("invalid syntax: %q", fd.GetSyntax())
- }
- f.L1.Path = fd.GetName()
- if f.L1.Path == "" {
- return nil, errors.New("file path must be populated")
- }
- if f.L1.Syntax == protoreflect.Editions && (fd.GetEdition() < editionssupport.Minimum || fd.GetEdition() > editionssupport.Maximum) {
- // Allow cmd/protoc-gen-go/testdata to use any edition for easier
- // testing of upcoming edition features.
- if !strings.HasPrefix(fd.GetName(), "cmd/protoc-gen-go/testdata/") {
- return nil, errors.New("use of edition %v not yet supported by the Go Protobuf runtime", fd.GetEdition())
- }
- }
- f.L1.Package = protoreflect.FullName(fd.GetPackage())
- if !f.L1.Package.IsValid() && f.L1.Package != "" {
- return nil, errors.New("invalid package: %q", f.L1.Package)
- }
- if opts := fd.GetOptions(); opts != nil {
- opts = proto.Clone(opts).(*descriptorpb.FileOptions)
- f.L2.Options = func() protoreflect.ProtoMessage { return opts }
- }
- initFileDescFromFeatureSet(f, fd.GetOptions().GetFeatures())
-
- f.L2.Imports = make(filedesc.FileImports, len(fd.GetDependency()))
- for _, i := range fd.GetPublicDependency() {
- if !(0 <= i && int(i) < len(f.L2.Imports)) || f.L2.Imports[i].IsPublic {
- return nil, errors.New("invalid or duplicate public import index: %d", i)
- }
- f.L2.Imports[i].IsPublic = true
- }
- for _, i := range fd.GetWeakDependency() {
- if !(0 <= i && int(i) < len(f.L2.Imports)) || f.L2.Imports[i].IsWeak {
- return nil, errors.New("invalid or duplicate weak import index: %d", i)
- }
- f.L2.Imports[i].IsWeak = true
- }
- imps := importSet{f.Path(): true}
- for i, path := range fd.GetDependency() {
- imp := &f.L2.Imports[i]
- f, err := r.FindFileByPath(path)
- if err == protoregistry.NotFound && (o.AllowUnresolvable || imp.IsWeak) {
- f = filedesc.PlaceholderFile(path)
- } else if err != nil {
- return nil, errors.New("could not resolve import %q: %v", path, err)
- }
- imp.FileDescriptor = f
-
- if imps[imp.Path()] {
- return nil, errors.New("already imported %q", path)
- }
- imps[imp.Path()] = true
- }
- for i := range fd.GetDependency() {
- imp := &f.L2.Imports[i]
- imps.importPublic(imp.Imports())
- }
-
- // Handle source locations.
- f.L2.Locations.File = f
- for _, loc := range fd.GetSourceCodeInfo().GetLocation() {
- var l protoreflect.SourceLocation
- // TODO: Validate that the path points to an actual declaration?
- l.Path = protoreflect.SourcePath(loc.GetPath())
- s := loc.GetSpan()
- switch len(s) {
- case 3:
- l.StartLine, l.StartColumn, l.EndLine, l.EndColumn = int(s[0]), int(s[1]), int(s[0]), int(s[2])
- case 4:
- l.StartLine, l.StartColumn, l.EndLine, l.EndColumn = int(s[0]), int(s[1]), int(s[2]), int(s[3])
- default:
- return nil, errors.New("invalid span: %v", s)
- }
- // TODO: Validate that the span information is sensible?
- // See https://github.com/protocolbuffers/protobuf/issues/6378.
- if false && (l.EndLine < l.StartLine || l.StartLine < 0 || l.StartColumn < 0 || l.EndColumn < 0 ||
- (l.StartLine == l.EndLine && l.EndColumn <= l.StartColumn)) {
- return nil, errors.New("invalid span: %v", s)
- }
- l.LeadingDetachedComments = loc.GetLeadingDetachedComments()
- l.LeadingComments = loc.GetLeadingComments()
- l.TrailingComments = loc.GetTrailingComments()
- f.L2.Locations.List = append(f.L2.Locations.List, l)
- }
-
- // Step 1: Allocate and derive the names for all declarations.
- // This copies all fields from the descriptor proto except:
- // google.protobuf.FieldDescriptorProto.type_name
- // google.protobuf.FieldDescriptorProto.default_value
- // google.protobuf.FieldDescriptorProto.oneof_index
- // google.protobuf.FieldDescriptorProto.extendee
- // google.protobuf.MethodDescriptorProto.input
- // google.protobuf.MethodDescriptorProto.output
- var err error
- sb := new(strs.Builder)
- r1 := make(descsByName)
- if f.L1.Enums.List, err = r1.initEnumDeclarations(fd.GetEnumType(), f, sb); err != nil {
- return nil, err
- }
- if f.L1.Messages.List, err = r1.initMessagesDeclarations(fd.GetMessageType(), f, sb); err != nil {
- return nil, err
- }
- if f.L1.Extensions.List, err = r1.initExtensionDeclarations(fd.GetExtension(), f, sb); err != nil {
- return nil, err
- }
- if f.L1.Services.List, err = r1.initServiceDeclarations(fd.GetService(), f, sb); err != nil {
- return nil, err
- }
-
- // Step 2: Resolve every dependency reference not handled by step 1.
- r2 := &resolver{local: r1, remote: r, imports: imps, allowUnresolvable: o.AllowUnresolvable}
- if err := r2.resolveMessageDependencies(f.L1.Messages.List, fd.GetMessageType()); err != nil {
- return nil, err
- }
- if err := r2.resolveExtensionDependencies(f.L1.Extensions.List, fd.GetExtension()); err != nil {
- return nil, err
- }
- if err := r2.resolveServiceDependencies(f.L1.Services.List, fd.GetService()); err != nil {
- return nil, err
- }
-
- // Step 3: Validate every enum, message, and extension declaration.
- if err := validateEnumDeclarations(f.L1.Enums.List, fd.GetEnumType()); err != nil {
- return nil, err
- }
- if err := validateMessageDeclarations(f, f.L1.Messages.List, fd.GetMessageType()); err != nil {
- return nil, err
- }
- if err := validateExtensionDeclarations(f, f.L1.Extensions.List, fd.GetExtension()); err != nil {
- return nil, err
- }
-
- return f, nil
-}
-
-type importSet map[string]bool
-
-func (is importSet) importPublic(imps protoreflect.FileImports) {
- for i := 0; i < imps.Len(); i++ {
- if imp := imps.Get(i); imp.IsPublic {
- is[imp.Path()] = true
- is.importPublic(imp.Imports())
- }
- }
-}
-
-// NewFiles creates a new [protoregistry.Files] from the provided
-// FileDescriptorSet message. The descriptor set must include only
-// valid files according to protobuf semantics. The returned descriptors
-// are a deep copy of the input.
-func (o FileOptions) NewFiles(fds *descriptorpb.FileDescriptorSet) (*protoregistry.Files, error) {
- files := make(map[string]*descriptorpb.FileDescriptorProto)
- for _, fd := range fds.File {
- if _, ok := files[fd.GetName()]; ok {
- return nil, errors.New("file appears multiple times: %q", fd.GetName())
- }
- files[fd.GetName()] = fd
- }
- r := &protoregistry.Files{}
- for _, fd := range files {
- if err := o.addFileDeps(r, fd, files); err != nil {
- return nil, err
- }
- }
- return r, nil
-}
-func (o FileOptions) addFileDeps(r *protoregistry.Files, fd *descriptorpb.FileDescriptorProto, files map[string]*descriptorpb.FileDescriptorProto) error {
- // Set the entry to nil while descending into a file's dependencies to detect cycles.
- files[fd.GetName()] = nil
- for _, dep := range fd.Dependency {
- depfd, ok := files[dep]
- if depfd == nil {
- if ok {
- return errors.New("import cycle in file: %q", dep)
- }
- continue
- }
- if err := o.addFileDeps(r, depfd, files); err != nil {
- return err
- }
- }
- // Delete the entry once dependencies are processed.
- delete(files, fd.GetName())
- f, err := o.New(fd, r)
- if err != nil {
- return err
- }
- return r.RegisterFile(f)
-}
diff --git a/tools/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go b/tools/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go
deleted file mode 100644
index ebcb4a8ab..000000000
--- a/tools/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go
+++ /dev/null
@@ -1,289 +0,0 @@
-// Copyright 2019 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 protodesc
-
-import (
- "google.golang.org/protobuf/internal/errors"
- "google.golang.org/protobuf/internal/filedesc"
- "google.golang.org/protobuf/internal/strs"
- "google.golang.org/protobuf/proto"
- "google.golang.org/protobuf/reflect/protoreflect"
-
- "google.golang.org/protobuf/types/descriptorpb"
-)
-
-type descsByName map[protoreflect.FullName]protoreflect.Descriptor
-
-func (r descsByName) initEnumDeclarations(eds []*descriptorpb.EnumDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (es []filedesc.Enum, err error) {
- es = make([]filedesc.Enum, len(eds)) // allocate up-front to ensure stable pointers
- for i, ed := range eds {
- e := &es[i]
- e.L2 = new(filedesc.EnumL2)
- if e.L0, err = r.makeBase(e, parent, ed.GetName(), i, sb); err != nil {
- return nil, err
- }
- if opts := ed.GetOptions(); opts != nil {
- opts = proto.Clone(opts).(*descriptorpb.EnumOptions)
- e.L2.Options = func() protoreflect.ProtoMessage { return opts }
- }
- e.L1.EditionFeatures = mergeEditionFeatures(parent, ed.GetOptions().GetFeatures())
- for _, s := range ed.GetReservedName() {
- e.L2.ReservedNames.List = append(e.L2.ReservedNames.List, protoreflect.Name(s))
- }
- for _, rr := range ed.GetReservedRange() {
- e.L2.ReservedRanges.List = append(e.L2.ReservedRanges.List, [2]protoreflect.EnumNumber{
- protoreflect.EnumNumber(rr.GetStart()),
- protoreflect.EnumNumber(rr.GetEnd()),
- })
- }
- if e.L2.Values.List, err = r.initEnumValuesFromDescriptorProto(ed.GetValue(), e, sb); err != nil {
- return nil, err
- }
- }
- return es, nil
-}
-
-func (r descsByName) initEnumValuesFromDescriptorProto(vds []*descriptorpb.EnumValueDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (vs []filedesc.EnumValue, err error) {
- vs = make([]filedesc.EnumValue, len(vds)) // allocate up-front to ensure stable pointers
- for i, vd := range vds {
- v := &vs[i]
- if v.L0, err = r.makeBase(v, parent, vd.GetName(), i, sb); err != nil {
- return nil, err
- }
- if opts := vd.GetOptions(); opts != nil {
- opts = proto.Clone(opts).(*descriptorpb.EnumValueOptions)
- v.L1.Options = func() protoreflect.ProtoMessage { return opts }
- }
- v.L1.Number = protoreflect.EnumNumber(vd.GetNumber())
- }
- return vs, nil
-}
-
-func (r descsByName) initMessagesDeclarations(mds []*descriptorpb.DescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (ms []filedesc.Message, err error) {
- ms = make([]filedesc.Message, len(mds)) // allocate up-front to ensure stable pointers
- for i, md := range mds {
- m := &ms[i]
- m.L2 = new(filedesc.MessageL2)
- if m.L0, err = r.makeBase(m, parent, md.GetName(), i, sb); err != nil {
- return nil, err
- }
- m.L1.EditionFeatures = mergeEditionFeatures(parent, md.GetOptions().GetFeatures())
- if opts := md.GetOptions(); opts != nil {
- opts = proto.Clone(opts).(*descriptorpb.MessageOptions)
- m.L2.Options = func() protoreflect.ProtoMessage { return opts }
- m.L1.IsMapEntry = opts.GetMapEntry()
- m.L1.IsMessageSet = opts.GetMessageSetWireFormat()
- }
- for _, s := range md.GetReservedName() {
- m.L2.ReservedNames.List = append(m.L2.ReservedNames.List, protoreflect.Name(s))
- }
- for _, rr := range md.GetReservedRange() {
- m.L2.ReservedRanges.List = append(m.L2.ReservedRanges.List, [2]protoreflect.FieldNumber{
- protoreflect.FieldNumber(rr.GetStart()),
- protoreflect.FieldNumber(rr.GetEnd()),
- })
- }
- for _, xr := range md.GetExtensionRange() {
- m.L2.ExtensionRanges.List = append(m.L2.ExtensionRanges.List, [2]protoreflect.FieldNumber{
- protoreflect.FieldNumber(xr.GetStart()),
- protoreflect.FieldNumber(xr.GetEnd()),
- })
- var optsFunc func() protoreflect.ProtoMessage
- if opts := xr.GetOptions(); opts != nil {
- opts = proto.Clone(opts).(*descriptorpb.ExtensionRangeOptions)
- optsFunc = func() protoreflect.ProtoMessage { return opts }
- }
- m.L2.ExtensionRangeOptions = append(m.L2.ExtensionRangeOptions, optsFunc)
- }
- if m.L2.Fields.List, err = r.initFieldsFromDescriptorProto(md.GetField(), m, sb); err != nil {
- return nil, err
- }
- if m.L2.Oneofs.List, err = r.initOneofsFromDescriptorProto(md.GetOneofDecl(), m, sb); err != nil {
- return nil, err
- }
- if m.L1.Enums.List, err = r.initEnumDeclarations(md.GetEnumType(), m, sb); err != nil {
- return nil, err
- }
- if m.L1.Messages.List, err = r.initMessagesDeclarations(md.GetNestedType(), m, sb); err != nil {
- return nil, err
- }
- if m.L1.Extensions.List, err = r.initExtensionDeclarations(md.GetExtension(), m, sb); err != nil {
- return nil, err
- }
- }
- return ms, nil
-}
-
-// canBePacked returns whether the field can use packed encoding:
-// https://protobuf.dev/programming-guides/encoding/#packed
-func canBePacked(fd *descriptorpb.FieldDescriptorProto) bool {
- if fd.GetLabel() != descriptorpb.FieldDescriptorProto_LABEL_REPEATED {
- return false // not a repeated field
- }
-
- switch protoreflect.Kind(fd.GetType()) {
- case protoreflect.MessageKind, protoreflect.GroupKind:
- return false // not a scalar type field
-
- case protoreflect.StringKind, protoreflect.BytesKind:
- // string and bytes can explicitly not be declared as packed,
- // see https://protobuf.dev/programming-guides/encoding/#packed
- return false
-
- default:
- return true
- }
-}
-
-func (r descsByName) initFieldsFromDescriptorProto(fds []*descriptorpb.FieldDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (fs []filedesc.Field, err error) {
- fs = make([]filedesc.Field, len(fds)) // allocate up-front to ensure stable pointers
- for i, fd := range fds {
- f := &fs[i]
- if f.L0, err = r.makeBase(f, parent, fd.GetName(), i, sb); err != nil {
- return nil, err
- }
- f.L1.EditionFeatures = mergeEditionFeatures(parent, fd.GetOptions().GetFeatures())
- f.L1.IsProto3Optional = fd.GetProto3Optional()
- if opts := fd.GetOptions(); opts != nil {
- opts = proto.Clone(opts).(*descriptorpb.FieldOptions)
- f.L1.Options = func() protoreflect.ProtoMessage { return opts }
- f.L1.IsWeak = opts.GetWeak()
- f.L1.IsLazy = opts.GetLazy()
- if opts.Packed != nil {
- f.L1.EditionFeatures.IsPacked = opts.GetPacked()
- }
- }
- f.L1.Number = protoreflect.FieldNumber(fd.GetNumber())
- f.L1.Cardinality = protoreflect.Cardinality(fd.GetLabel())
- if fd.Type != nil {
- f.L1.Kind = protoreflect.Kind(fd.GetType())
- }
- if fd.JsonName != nil {
- f.L1.StringName.InitJSON(fd.GetJsonName())
- }
-
- if f.L1.EditionFeatures.IsLegacyRequired {
- f.L1.Cardinality = protoreflect.Required
- }
-
- if f.L1.Kind == protoreflect.MessageKind && f.L1.EditionFeatures.IsDelimitedEncoded {
- f.L1.Kind = protoreflect.GroupKind
- }
- }
- return fs, nil
-}
-
-func (r descsByName) initOneofsFromDescriptorProto(ods []*descriptorpb.OneofDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (os []filedesc.Oneof, err error) {
- os = make([]filedesc.Oneof, len(ods)) // allocate up-front to ensure stable pointers
- for i, od := range ods {
- o := &os[i]
- if o.L0, err = r.makeBase(o, parent, od.GetName(), i, sb); err != nil {
- return nil, err
- }
- o.L1.EditionFeatures = mergeEditionFeatures(parent, od.GetOptions().GetFeatures())
- if opts := od.GetOptions(); opts != nil {
- opts = proto.Clone(opts).(*descriptorpb.OneofOptions)
- o.L1.Options = func() protoreflect.ProtoMessage { return opts }
- }
- }
- return os, nil
-}
-
-func (r descsByName) initExtensionDeclarations(xds []*descriptorpb.FieldDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (xs []filedesc.Extension, err error) {
- xs = make([]filedesc.Extension, len(xds)) // allocate up-front to ensure stable pointers
- for i, xd := range xds {
- x := &xs[i]
- x.L2 = new(filedesc.ExtensionL2)
- if x.L0, err = r.makeBase(x, parent, xd.GetName(), i, sb); err != nil {
- return nil, err
- }
- x.L1.EditionFeatures = mergeEditionFeatures(parent, xd.GetOptions().GetFeatures())
- if opts := xd.GetOptions(); opts != nil {
- opts = proto.Clone(opts).(*descriptorpb.FieldOptions)
- x.L2.Options = func() protoreflect.ProtoMessage { return opts }
- if opts.Packed != nil {
- x.L1.EditionFeatures.IsPacked = opts.GetPacked()
- }
- }
- x.L1.Number = protoreflect.FieldNumber(xd.GetNumber())
- x.L1.Cardinality = protoreflect.Cardinality(xd.GetLabel())
- if xd.Type != nil {
- x.L1.Kind = protoreflect.Kind(xd.GetType())
- }
- if xd.JsonName != nil {
- x.L2.StringName.InitJSON(xd.GetJsonName())
- }
- if x.L1.Kind == protoreflect.MessageKind && x.L1.EditionFeatures.IsDelimitedEncoded {
- x.L1.Kind = protoreflect.GroupKind
- }
- }
- return xs, nil
-}
-
-func (r descsByName) initServiceDeclarations(sds []*descriptorpb.ServiceDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (ss []filedesc.Service, err error) {
- ss = make([]filedesc.Service, len(sds)) // allocate up-front to ensure stable pointers
- for i, sd := range sds {
- s := &ss[i]
- s.L2 = new(filedesc.ServiceL2)
- if s.L0, err = r.makeBase(s, parent, sd.GetName(), i, sb); err != nil {
- return nil, err
- }
- if opts := sd.GetOptions(); opts != nil {
- opts = proto.Clone(opts).(*descriptorpb.ServiceOptions)
- s.L2.Options = func() protoreflect.ProtoMessage { return opts }
- }
- if s.L2.Methods.List, err = r.initMethodsFromDescriptorProto(sd.GetMethod(), s, sb); err != nil {
- return nil, err
- }
- }
- return ss, nil
-}
-
-func (r descsByName) initMethodsFromDescriptorProto(mds []*descriptorpb.MethodDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (ms []filedesc.Method, err error) {
- ms = make([]filedesc.Method, len(mds)) // allocate up-front to ensure stable pointers
- for i, md := range mds {
- m := &ms[i]
- if m.L0, err = r.makeBase(m, parent, md.GetName(), i, sb); err != nil {
- return nil, err
- }
- if opts := md.GetOptions(); opts != nil {
- opts = proto.Clone(opts).(*descriptorpb.MethodOptions)
- m.L1.Options = func() protoreflect.ProtoMessage { return opts }
- }
- m.L1.IsStreamingClient = md.GetClientStreaming()
- m.L1.IsStreamingServer = md.GetServerStreaming()
- }
- return ms, nil
-}
-
-func (r descsByName) makeBase(child, parent protoreflect.Descriptor, name string, idx int, sb *strs.Builder) (filedesc.BaseL0, error) {
- if !protoreflect.Name(name).IsValid() {
- return filedesc.BaseL0{}, errors.New("descriptor %q has an invalid nested name: %q", parent.FullName(), name)
- }
-
- // Derive the full name of the child.
- // Note that enum values are a sibling to the enum parent in the namespace.
- var fullName protoreflect.FullName
- if _, ok := parent.(protoreflect.EnumDescriptor); ok {
- fullName = sb.AppendFullName(parent.FullName().Parent(), protoreflect.Name(name))
- } else {
- fullName = sb.AppendFullName(parent.FullName(), protoreflect.Name(name))
- }
- if _, ok := r[fullName]; ok {
- return filedesc.BaseL0{}, errors.New("descriptor %q already declared", fullName)
- }
- r[fullName] = child
-
- // TODO: Verify that the full name does not already exist in the resolver?
- // This is not as critical since most usages of NewFile will register
- // the created file back into the registry, which will perform this check.
-
- return filedesc.BaseL0{
- FullName: fullName,
- ParentFile: parent.ParentFile().(*filedesc.File),
- Parent: parent,
- Index: idx,
- }, nil
-}
diff --git a/tools/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go b/tools/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go
deleted file mode 100644
index f3cebab29..000000000
--- a/tools/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go
+++ /dev/null
@@ -1,291 +0,0 @@
-// Copyright 2019 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 protodesc
-
-import (
- "google.golang.org/protobuf/internal/encoding/defval"
- "google.golang.org/protobuf/internal/errors"
- "google.golang.org/protobuf/internal/filedesc"
- "google.golang.org/protobuf/reflect/protoreflect"
- "google.golang.org/protobuf/reflect/protoregistry"
-
- "google.golang.org/protobuf/types/descriptorpb"
-)
-
-// resolver is a wrapper around a local registry of declarations within the file
-// and the remote resolver. The remote resolver is restricted to only return
-// descriptors that have been imported.
-type resolver struct {
- local descsByName
- remote Resolver
- imports importSet
-
- allowUnresolvable bool
-}
-
-func (r *resolver) resolveMessageDependencies(ms []filedesc.Message, mds []*descriptorpb.DescriptorProto) (err error) {
- for i, md := range mds {
- m := &ms[i]
- for j, fd := range md.GetField() {
- f := &m.L2.Fields.List[j]
- if f.L1.Cardinality == protoreflect.Required {
- m.L2.RequiredNumbers.List = append(m.L2.RequiredNumbers.List, f.L1.Number)
- }
- if fd.OneofIndex != nil {
- k := int(fd.GetOneofIndex())
- if !(0 <= k && k < len(md.GetOneofDecl())) {
- return errors.New("message field %q has an invalid oneof index: %d", f.FullName(), k)
- }
- o := &m.L2.Oneofs.List[k]
- f.L1.ContainingOneof = o
- o.L1.Fields.List = append(o.L1.Fields.List, f)
- }
-
- if f.L1.Kind, f.L1.Enum, f.L1.Message, err = r.findTarget(f.Kind(), f.Parent().FullName(), partialName(fd.GetTypeName()), f.IsWeak()); err != nil {
- return errors.New("message field %q cannot resolve type: %v", f.FullName(), err)
- }
- if f.L1.Kind == protoreflect.GroupKind && (f.IsMap() || f.IsMapEntry()) {
- // A map field might inherit delimited encoding from a file-wide default feature.
- // But maps never actually use delimited encoding. (At least for now...)
- f.L1.Kind = protoreflect.MessageKind
- }
- if fd.DefaultValue != nil {
- v, ev, err := unmarshalDefault(fd.GetDefaultValue(), f, r.allowUnresolvable)
- if err != nil {
- return errors.New("message field %q has invalid default: %v", f.FullName(), err)
- }
- f.L1.Default = filedesc.DefaultValue(v, ev)
- }
- }
-
- if err := r.resolveMessageDependencies(m.L1.Messages.List, md.GetNestedType()); err != nil {
- return err
- }
- if err := r.resolveExtensionDependencies(m.L1.Extensions.List, md.GetExtension()); err != nil {
- return err
- }
- }
- return nil
-}
-
-func (r *resolver) resolveExtensionDependencies(xs []filedesc.Extension, xds []*descriptorpb.FieldDescriptorProto) (err error) {
- for i, xd := range xds {
- x := &xs[i]
- if x.L1.Extendee, err = r.findMessageDescriptor(x.Parent().FullName(), partialName(xd.GetExtendee()), false); err != nil {
- return errors.New("extension field %q cannot resolve extendee: %v", x.FullName(), err)
- }
- if x.L1.Kind, x.L2.Enum, x.L2.Message, err = r.findTarget(x.Kind(), x.Parent().FullName(), partialName(xd.GetTypeName()), false); err != nil {
- return errors.New("extension field %q cannot resolve type: %v", x.FullName(), err)
- }
- if xd.DefaultValue != nil {
- v, ev, err := unmarshalDefault(xd.GetDefaultValue(), x, r.allowUnresolvable)
- if err != nil {
- return errors.New("extension field %q has invalid default: %v", x.FullName(), err)
- }
- x.L2.Default = filedesc.DefaultValue(v, ev)
- }
- }
- return nil
-}
-
-func (r *resolver) resolveServiceDependencies(ss []filedesc.Service, sds []*descriptorpb.ServiceDescriptorProto) (err error) {
- for i, sd := range sds {
- s := &ss[i]
- for j, md := range sd.GetMethod() {
- m := &s.L2.Methods.List[j]
- m.L1.Input, err = r.findMessageDescriptor(m.Parent().FullName(), partialName(md.GetInputType()), false)
- if err != nil {
- return errors.New("service method %q cannot resolve input: %v", m.FullName(), err)
- }
- m.L1.Output, err = r.findMessageDescriptor(s.FullName(), partialName(md.GetOutputType()), false)
- if err != nil {
- return errors.New("service method %q cannot resolve output: %v", m.FullName(), err)
- }
- }
- }
- return nil
-}
-
-// findTarget finds an enum or message descriptor if k is an enum, message,
-// group, or unknown. If unknown, and the name could be resolved, the kind
-// returned kind is set based on the type of the resolved descriptor.
-func (r *resolver) findTarget(k protoreflect.Kind, scope protoreflect.FullName, ref partialName, isWeak bool) (protoreflect.Kind, protoreflect.EnumDescriptor, protoreflect.MessageDescriptor, error) {
- switch k {
- case protoreflect.EnumKind:
- ed, err := r.findEnumDescriptor(scope, ref, isWeak)
- if err != nil {
- return 0, nil, nil, err
- }
- return k, ed, nil, nil
- case protoreflect.MessageKind, protoreflect.GroupKind:
- md, err := r.findMessageDescriptor(scope, ref, isWeak)
- if err != nil {
- return 0, nil, nil, err
- }
- return k, nil, md, nil
- case 0:
- // Handle unspecified kinds (possible with parsers that operate
- // on a per-file basis without knowledge of dependencies).
- d, err := r.findDescriptor(scope, ref)
- if err == protoregistry.NotFound && (r.allowUnresolvable || isWeak) {
- return k, filedesc.PlaceholderEnum(ref.FullName()), filedesc.PlaceholderMessage(ref.FullName()), nil
- } else if err == protoregistry.NotFound {
- return 0, nil, nil, errors.New("%q not found", ref.FullName())
- } else if err != nil {
- return 0, nil, nil, err
- }
- switch d := d.(type) {
- case protoreflect.EnumDescriptor:
- return protoreflect.EnumKind, d, nil, nil
- case protoreflect.MessageDescriptor:
- return protoreflect.MessageKind, nil, d, nil
- default:
- return 0, nil, nil, errors.New("unknown kind")
- }
- default:
- if ref != "" {
- return 0, nil, nil, errors.New("target name cannot be specified for %v", k)
- }
- if !k.IsValid() {
- return 0, nil, nil, errors.New("invalid kind: %d", k)
- }
- return k, nil, nil, nil
- }
-}
-
-// findDescriptor finds the descriptor by name,
-// which may be a relative name within some scope.
-//
-// Suppose the scope was "fizz.buzz" and the reference was "Foo.Bar",
-// then the following full names are searched:
-// - fizz.buzz.Foo.Bar
-// - fizz.Foo.Bar
-// - Foo.Bar
-func (r *resolver) findDescriptor(scope protoreflect.FullName, ref partialName) (protoreflect.Descriptor, error) {
- if !ref.IsValid() {
- return nil, errors.New("invalid name reference: %q", ref)
- }
- if ref.IsFull() {
- scope, ref = "", ref[1:]
- }
- var foundButNotImported protoreflect.Descriptor
- for {
- // Derive the full name to search.
- s := protoreflect.FullName(ref)
- if scope != "" {
- s = scope + "." + s
- }
-
- // Check the current file for the descriptor.
- if d, ok := r.local[s]; ok {
- return d, nil
- }
-
- // Check the remote registry for the descriptor.
- d, err := r.remote.FindDescriptorByName(s)
- if err == nil {
- // Only allow descriptors covered by one of the imports.
- if r.imports[d.ParentFile().Path()] {
- return d, nil
- }
- foundButNotImported = d
- } else if err != protoregistry.NotFound {
- return nil, errors.Wrap(err, "%q", s)
- }
-
- // Continue on at a higher level of scoping.
- if scope == "" {
- if d := foundButNotImported; d != nil {
- return nil, errors.New("resolved %q, but %q is not imported", d.FullName(), d.ParentFile().Path())
- }
- return nil, protoregistry.NotFound
- }
- scope = scope.Parent()
- }
-}
-
-func (r *resolver) findEnumDescriptor(scope protoreflect.FullName, ref partialName, isWeak bool) (protoreflect.EnumDescriptor, error) {
- d, err := r.findDescriptor(scope, ref)
- if err == protoregistry.NotFound && (r.allowUnresolvable || isWeak) {
- return filedesc.PlaceholderEnum(ref.FullName()), nil
- } else if err == protoregistry.NotFound {
- return nil, errors.New("%q not found", ref.FullName())
- } else if err != nil {
- return nil, err
- }
- ed, ok := d.(protoreflect.EnumDescriptor)
- if !ok {
- return nil, errors.New("resolved %q, but it is not an enum", d.FullName())
- }
- return ed, nil
-}
-
-func (r *resolver) findMessageDescriptor(scope protoreflect.FullName, ref partialName, isWeak bool) (protoreflect.MessageDescriptor, error) {
- d, err := r.findDescriptor(scope, ref)
- if err == protoregistry.NotFound && (r.allowUnresolvable || isWeak) {
- return filedesc.PlaceholderMessage(ref.FullName()), nil
- } else if err == protoregistry.NotFound {
- return nil, errors.New("%q not found", ref.FullName())
- } else if err != nil {
- return nil, err
- }
- md, ok := d.(protoreflect.MessageDescriptor)
- if !ok {
- return nil, errors.New("resolved %q, but it is not an message", d.FullName())
- }
- return md, nil
-}
-
-// partialName is the partial name. A leading dot means that the name is full,
-// otherwise the name is relative to some current scope.
-// See google.protobuf.FieldDescriptorProto.type_name.
-type partialName string
-
-func (s partialName) IsFull() bool {
- return len(s) > 0 && s[0] == '.'
-}
-
-func (s partialName) IsValid() bool {
- if s.IsFull() {
- return protoreflect.FullName(s[1:]).IsValid()
- }
- return protoreflect.FullName(s).IsValid()
-}
-
-const unknownPrefix = "*."
-
-// FullName converts the partial name to a full name on a best-effort basis.
-// If relative, it creates an invalid full name, using a "*." prefix
-// to indicate that the start of the full name is unknown.
-func (s partialName) FullName() protoreflect.FullName {
- if s.IsFull() {
- return protoreflect.FullName(s[1:])
- }
- return protoreflect.FullName(unknownPrefix + s)
-}
-
-func unmarshalDefault(s string, fd protoreflect.FieldDescriptor, allowUnresolvable bool) (protoreflect.Value, protoreflect.EnumValueDescriptor, error) {
- var evs protoreflect.EnumValueDescriptors
- if fd.Enum() != nil {
- evs = fd.Enum().Values()
- }
- v, ev, err := defval.Unmarshal(s, fd.Kind(), evs, defval.Descriptor)
- if err != nil && allowUnresolvable && evs != nil && protoreflect.Name(s).IsValid() {
- v = protoreflect.ValueOfEnum(0)
- if evs.Len() > 0 {
- v = protoreflect.ValueOfEnum(evs.Get(0).Number())
- }
- ev = filedesc.PlaceholderEnumValue(fd.Enum().FullName().Parent().Append(protoreflect.Name(s)))
- } else if err != nil {
- return v, ev, err
- }
- if !fd.HasPresence() {
- return v, ev, errors.New("cannot be specified with implicit field presence")
- }
- if fd.Kind() == protoreflect.MessageKind || fd.Kind() == protoreflect.GroupKind || fd.Cardinality() == protoreflect.Repeated {
- return v, ev, errors.New("cannot be specified on composite types")
- }
- return v, ev, nil
-}
diff --git a/tools/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go b/tools/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go
deleted file mode 100644
index 5eaf65217..000000000
--- a/tools/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go
+++ /dev/null
@@ -1,371 +0,0 @@
-// Copyright 2019 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 protodesc
-
-import (
- "strings"
- "unicode"
-
- "google.golang.org/protobuf/encoding/protowire"
- "google.golang.org/protobuf/internal/errors"
- "google.golang.org/protobuf/internal/filedesc"
- "google.golang.org/protobuf/internal/flags"
- "google.golang.org/protobuf/internal/genid"
- "google.golang.org/protobuf/internal/strs"
- "google.golang.org/protobuf/reflect/protoreflect"
-
- "google.golang.org/protobuf/types/descriptorpb"
-)
-
-func validateEnumDeclarations(es []filedesc.Enum, eds []*descriptorpb.EnumDescriptorProto) error {
- for i, ed := range eds {
- e := &es[i]
- if err := e.L2.ReservedNames.CheckValid(); err != nil {
- return errors.New("enum %q reserved names has %v", e.FullName(), err)
- }
- if err := e.L2.ReservedRanges.CheckValid(); err != nil {
- return errors.New("enum %q reserved ranges has %v", e.FullName(), err)
- }
- if len(ed.GetValue()) == 0 {
- return errors.New("enum %q must contain at least one value declaration", e.FullName())
- }
- allowAlias := ed.GetOptions().GetAllowAlias()
- foundAlias := false
- for i := 0; i < e.Values().Len(); i++ {
- v1 := e.Values().Get(i)
- if v2 := e.Values().ByNumber(v1.Number()); v1 != v2 {
- foundAlias = true
- if !allowAlias {
- return errors.New("enum %q has conflicting non-aliased values on number %d: %q with %q", e.FullName(), v1.Number(), v1.Name(), v2.Name())
- }
- }
- }
- if allowAlias && !foundAlias {
- return errors.New("enum %q allows aliases, but none were found", e.FullName())
- }
- if !e.IsClosed() {
- if v := e.Values().Get(0); v.Number() != 0 {
- return errors.New("enum %q using open semantics must have zero number for the first value", v.FullName())
- }
- // Verify that value names in open enums do not conflict if the
- // case-insensitive prefix is removed.
- // See protoc v3.8.0: src/google/protobuf/descriptor.cc:4991-5055
- names := map[string]protoreflect.EnumValueDescriptor{}
- prefix := strings.Replace(strings.ToLower(string(e.Name())), "_", "", -1)
- for i := 0; i < e.Values().Len(); i++ {
- v1 := e.Values().Get(i)
- s := strs.EnumValueName(strs.TrimEnumPrefix(string(v1.Name()), prefix))
- if v2, ok := names[s]; ok && v1.Number() != v2.Number() {
- return errors.New("enum %q using open semantics has conflict: %q with %q", e.FullName(), v1.Name(), v2.Name())
- }
- names[s] = v1
- }
- }
-
- for j, vd := range ed.GetValue() {
- v := &e.L2.Values.List[j]
- if vd.Number == nil {
- return errors.New("enum value %q must have a specified number", v.FullName())
- }
- if e.L2.ReservedNames.Has(v.Name()) {
- return errors.New("enum value %q must not use reserved name", v.FullName())
- }
- if e.L2.ReservedRanges.Has(v.Number()) {
- return errors.New("enum value %q must not use reserved number %d", v.FullName(), v.Number())
- }
- }
- }
- return nil
-}
-
-func validateMessageDeclarations(file *filedesc.File, ms []filedesc.Message, mds []*descriptorpb.DescriptorProto) error {
- // There are a few limited exceptions only for proto3
- isProto3 := file.L1.Edition == fromEditionProto(descriptorpb.Edition_EDITION_PROTO3)
- for i, md := range mds {
- m := &ms[i]
-
- // Handle the message descriptor itself.
- isMessageSet := md.GetOptions().GetMessageSetWireFormat()
- if err := m.L2.ReservedNames.CheckValid(); err != nil {
- return errors.New("message %q reserved names has %v", m.FullName(), err)
- }
- if err := m.L2.ReservedRanges.CheckValid(isMessageSet); err != nil {
- return errors.New("message %q reserved ranges has %v", m.FullName(), err)
- }
- if err := m.L2.ExtensionRanges.CheckValid(isMessageSet); err != nil {
- return errors.New("message %q extension ranges has %v", m.FullName(), err)
- }
- if err := (*filedesc.FieldRanges).CheckOverlap(&m.L2.ReservedRanges, &m.L2.ExtensionRanges); err != nil {
- return errors.New("message %q reserved and extension ranges has %v", m.FullName(), err)
- }
- for i := 0; i < m.Fields().Len(); i++ {
- f1 := m.Fields().Get(i)
- if f2 := m.Fields().ByNumber(f1.Number()); f1 != f2 {
- return errors.New("message %q has conflicting fields: %q with %q", m.FullName(), f1.Name(), f2.Name())
- }
- }
- if isMessageSet && !flags.ProtoLegacy {
- return errors.New("message %q is a MessageSet, which is a legacy proto1 feature that is no longer supported", m.FullName())
- }
- if isMessageSet && (isProto3 || m.Fields().Len() > 0 || m.ExtensionRanges().Len() == 0) {
- return errors.New("message %q is an invalid proto1 MessageSet", m.FullName())
- }
- if isProto3 {
- if m.ExtensionRanges().Len() > 0 {
- return errors.New("message %q using proto3 semantics cannot have extension ranges", m.FullName())
- }
- }
-
- for j, fd := range md.GetField() {
- f := &m.L2.Fields.List[j]
- if m.L2.ReservedNames.Has(f.Name()) {
- return errors.New("message field %q must not use reserved name", f.FullName())
- }
- if !f.Number().IsValid() {
- return errors.New("message field %q has an invalid number: %d", f.FullName(), f.Number())
- }
- if !f.Cardinality().IsValid() {
- return errors.New("message field %q has an invalid cardinality: %d", f.FullName(), f.Cardinality())
- }
- if m.L2.ReservedRanges.Has(f.Number()) {
- return errors.New("message field %q must not use reserved number %d", f.FullName(), f.Number())
- }
- if m.L2.ExtensionRanges.Has(f.Number()) {
- return errors.New("message field %q with number %d in extension range", f.FullName(), f.Number())
- }
- if fd.Extendee != nil {
- return errors.New("message field %q may not have extendee: %q", f.FullName(), fd.GetExtendee())
- }
- if f.L1.IsProto3Optional {
- if !isProto3 {
- return errors.New("message field %q under proto3 optional semantics must be specified in the proto3 syntax", f.FullName())
- }
- if f.Cardinality() != protoreflect.Optional {
- return errors.New("message field %q under proto3 optional semantics must have optional cardinality", f.FullName())
- }
- if f.ContainingOneof() != nil && f.ContainingOneof().Fields().Len() != 1 {
- return errors.New("message field %q under proto3 optional semantics must be within a single element oneof", f.FullName())
- }
- }
- if f.IsWeak() && !flags.ProtoLegacyWeak {
- return errors.New("message field %q is a weak field, which is a legacy proto1 feature that is no longer supported", f.FullName())
- }
- if f.IsWeak() && (!f.HasPresence() || !isOptionalMessage(f) || f.ContainingOneof() != nil) {
- return errors.New("message field %q may only be weak for an optional message", f.FullName())
- }
- if f.IsPacked() && !isPackable(f) {
- return errors.New("message field %q is not packable", f.FullName())
- }
- if err := checkValidGroup(file, f); err != nil {
- return errors.New("message field %q is an invalid group: %v", f.FullName(), err)
- }
- if err := checkValidMap(f); err != nil {
- return errors.New("message field %q is an invalid map: %v", f.FullName(), err)
- }
- if isProto3 {
- if f.Cardinality() == protoreflect.Required {
- return errors.New("message field %q using proto3 semantics cannot be required", f.FullName())
- }
- if f.Enum() != nil && !f.Enum().IsPlaceholder() && f.Enum().IsClosed() {
- return errors.New("message field %q using proto3 semantics may only depend on open enums", f.FullName())
- }
- }
- if f.Cardinality() == protoreflect.Optional && !f.HasPresence() && f.Enum() != nil && !f.Enum().IsPlaceholder() && f.Enum().IsClosed() {
- return errors.New("message field %q with implicit presence may only use open enums", f.FullName())
- }
- }
- seenSynthetic := false // synthetic oneofs for proto3 optional must come after real oneofs
- for j := range md.GetOneofDecl() {
- o := &m.L2.Oneofs.List[j]
- if o.Fields().Len() == 0 {
- return errors.New("message oneof %q must contain at least one field declaration", o.FullName())
- }
- if n := o.Fields().Len(); n-1 != (o.Fields().Get(n-1).Index() - o.Fields().Get(0).Index()) {
- return errors.New("message oneof %q must have consecutively declared fields", o.FullName())
- }
-
- if o.IsSynthetic() {
- seenSynthetic = true
- continue
- }
- if !o.IsSynthetic() && seenSynthetic {
- return errors.New("message oneof %q must be declared before synthetic oneofs", o.FullName())
- }
-
- for i := 0; i < o.Fields().Len(); i++ {
- f := o.Fields().Get(i)
- if f.Cardinality() != protoreflect.Optional {
- return errors.New("message field %q belongs in a oneof and must be optional", f.FullName())
- }
- if f.IsWeak() {
- return errors.New("message field %q belongs in a oneof and must not be a weak reference", f.FullName())
- }
- }
- }
-
- if err := validateEnumDeclarations(m.L1.Enums.List, md.GetEnumType()); err != nil {
- return err
- }
- if err := validateMessageDeclarations(file, m.L1.Messages.List, md.GetNestedType()); err != nil {
- return err
- }
- if err := validateExtensionDeclarations(file, m.L1.Extensions.List, md.GetExtension()); err != nil {
- return err
- }
- }
- return nil
-}
-
-func validateExtensionDeclarations(f *filedesc.File, xs []filedesc.Extension, xds []*descriptorpb.FieldDescriptorProto) error {
- for i, xd := range xds {
- x := &xs[i]
- // NOTE: Avoid using the IsValid method since extensions to MessageSet
- // may have a field number higher than normal. This check only verifies
- // that the number is not negative or reserved. We check again later
- // if we know that the extendee is definitely not a MessageSet.
- if n := x.Number(); n < 0 || (protowire.FirstReservedNumber <= n && n <= protowire.LastReservedNumber) {
- return errors.New("extension field %q has an invalid number: %d", x.FullName(), x.Number())
- }
- if !x.Cardinality().IsValid() || x.Cardinality() == protoreflect.Required {
- return errors.New("extension field %q has an invalid cardinality: %d", x.FullName(), x.Cardinality())
- }
- if xd.JsonName != nil {
- // A bug in older versions of protoc would always populate the
- // "json_name" option for extensions when it is meaningless.
- // When it did so, it would always use the camel-cased field name.
- if xd.GetJsonName() != strs.JSONCamelCase(string(x.Name())) {
- return errors.New("extension field %q may not have an explicitly set JSON name: %q", x.FullName(), xd.GetJsonName())
- }
- }
- if xd.OneofIndex != nil {
- return errors.New("extension field %q may not be part of a oneof", x.FullName())
- }
- if md := x.ContainingMessage(); !md.IsPlaceholder() {
- if !md.ExtensionRanges().Has(x.Number()) {
- return errors.New("extension field %q extends %q with non-extension field number: %d", x.FullName(), md.FullName(), x.Number())
- }
- isMessageSet := md.Options().(*descriptorpb.MessageOptions).GetMessageSetWireFormat()
- if isMessageSet && !isOptionalMessage(x) {
- return errors.New("extension field %q extends MessageSet and must be an optional message", x.FullName())
- }
- if !isMessageSet && !x.Number().IsValid() {
- return errors.New("extension field %q has an invalid number: %d", x.FullName(), x.Number())
- }
- }
- if xd.GetOptions().GetWeak() {
- return errors.New("extension field %q cannot be a weak reference", x.FullName())
- }
- if x.IsPacked() && !isPackable(x) {
- return errors.New("extension field %q is not packable", x.FullName())
- }
- if err := checkValidGroup(f, x); err != nil {
- return errors.New("extension field %q is an invalid group: %v", x.FullName(), err)
- }
- if md := x.Message(); md != nil && md.IsMapEntry() {
- return errors.New("extension field %q cannot be a map entry", x.FullName())
- }
- if f.L1.Edition == fromEditionProto(descriptorpb.Edition_EDITION_PROTO3) {
- switch x.ContainingMessage().FullName() {
- case (*descriptorpb.FileOptions)(nil).ProtoReflect().Descriptor().FullName():
- case (*descriptorpb.EnumOptions)(nil).ProtoReflect().Descriptor().FullName():
- case (*descriptorpb.EnumValueOptions)(nil).ProtoReflect().Descriptor().FullName():
- case (*descriptorpb.MessageOptions)(nil).ProtoReflect().Descriptor().FullName():
- case (*descriptorpb.FieldOptions)(nil).ProtoReflect().Descriptor().FullName():
- case (*descriptorpb.OneofOptions)(nil).ProtoReflect().Descriptor().FullName():
- case (*descriptorpb.ExtensionRangeOptions)(nil).ProtoReflect().Descriptor().FullName():
- case (*descriptorpb.ServiceOptions)(nil).ProtoReflect().Descriptor().FullName():
- case (*descriptorpb.MethodOptions)(nil).ProtoReflect().Descriptor().FullName():
- default:
- return errors.New("extension field %q cannot be declared in proto3 unless extended descriptor options", x.FullName())
- }
- }
- }
- return nil
-}
-
-// isOptionalMessage reports whether this is an optional message.
-// If the kind is unknown, it is assumed to be a message.
-func isOptionalMessage(fd protoreflect.FieldDescriptor) bool {
- return (fd.Kind() == 0 || fd.Kind() == protoreflect.MessageKind) && fd.Cardinality() == protoreflect.Optional
-}
-
-// isPackable checks whether the pack option can be specified.
-func isPackable(fd protoreflect.FieldDescriptor) bool {
- switch fd.Kind() {
- case protoreflect.StringKind, protoreflect.BytesKind, protoreflect.MessageKind, protoreflect.GroupKind:
- return false
- }
- return fd.IsList()
-}
-
-// checkValidGroup reports whether fd is a valid group according to the same
-// rules that protoc imposes.
-func checkValidGroup(f *filedesc.File, fd protoreflect.FieldDescriptor) error {
- md := fd.Message()
- switch {
- case fd.Kind() != protoreflect.GroupKind:
- return nil
- case f.L1.Edition == fromEditionProto(descriptorpb.Edition_EDITION_PROTO3):
- return errors.New("invalid under proto3 semantics")
- case md == nil || md.IsPlaceholder():
- return errors.New("message must be resolvable")
- }
- if f.L1.Edition < fromEditionProto(descriptorpb.Edition_EDITION_2023) {
- switch {
- case fd.FullName().Parent() != md.FullName().Parent():
- return errors.New("message and field must be declared in the same scope")
- case !unicode.IsUpper(rune(md.Name()[0])):
- return errors.New("message name must start with an uppercase")
- case fd.Name() != protoreflect.Name(strings.ToLower(string(md.Name()))):
- return errors.New("field name must be lowercased form of the message name")
- }
- }
- return nil
-}
-
-// checkValidMap checks whether the field is a valid map according to the same
-// rules that protoc imposes.
-// See protoc v3.8.0: src/google/protobuf/descriptor.cc:6045-6115
-func checkValidMap(fd protoreflect.FieldDescriptor) error {
- md := fd.Message()
- switch {
- case md == nil || !md.IsMapEntry():
- return nil
- case fd.FullName().Parent() != md.FullName().Parent():
- return errors.New("message and field must be declared in the same scope")
- case md.Name() != protoreflect.Name(strs.MapEntryName(string(fd.Name()))):
- return errors.New("incorrect implicit map entry name")
- case fd.Cardinality() != protoreflect.Repeated:
- return errors.New("field must be repeated")
- case md.Fields().Len() != 2:
- return errors.New("message must have exactly two fields")
- case md.ExtensionRanges().Len() > 0:
- return errors.New("message must not have any extension ranges")
- case md.Enums().Len()+md.Messages().Len()+md.Extensions().Len() > 0:
- return errors.New("message must not have any nested declarations")
- }
- kf := md.Fields().Get(0)
- vf := md.Fields().Get(1)
- switch {
- case kf.Name() != genid.MapEntry_Key_field_name || kf.Number() != genid.MapEntry_Key_field_number || kf.Cardinality() != protoreflect.Optional || kf.ContainingOneof() != nil || kf.HasDefault():
- return errors.New("invalid key field")
- case vf.Name() != genid.MapEntry_Value_field_name || vf.Number() != genid.MapEntry_Value_field_number || vf.Cardinality() != protoreflect.Optional || vf.ContainingOneof() != nil || vf.HasDefault():
- return errors.New("invalid value field")
- }
- switch kf.Kind() {
- case protoreflect.BoolKind: // bool
- case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: // int32
- case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: // int64
- case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: // uint32
- case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: // uint64
- case protoreflect.StringKind: // string
- default:
- return errors.New("invalid key kind: %v", kf.Kind())
- }
- if e := vf.Enum(); e != nil && e.Values().Len() > 0 && e.Values().Get(0).Number() != 0 {
- return errors.New("map enum value must have zero number for the first value")
- }
- return nil
-}
diff --git a/tools/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go b/tools/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go
deleted file mode 100644
index 697a61b29..000000000
--- a/tools/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go
+++ /dev/null
@@ -1,181 +0,0 @@
-// Copyright 2019 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 protodesc
-
-import (
- "fmt"
- "os"
- "sync"
-
- "google.golang.org/protobuf/internal/editiondefaults"
- "google.golang.org/protobuf/internal/filedesc"
- "google.golang.org/protobuf/internal/genid"
- "google.golang.org/protobuf/proto"
- "google.golang.org/protobuf/reflect/protoreflect"
- "google.golang.org/protobuf/types/descriptorpb"
- "google.golang.org/protobuf/types/gofeaturespb"
-)
-
-var defaults = &descriptorpb.FeatureSetDefaults{}
-var defaultsCacheMu sync.Mutex
-var defaultsCache = make(map[filedesc.Edition]*descriptorpb.FeatureSet)
-
-func init() {
- err := proto.Unmarshal(editiondefaults.Defaults, defaults)
- if err != nil {
- fmt.Fprintf(os.Stderr, "unmarshal editions defaults: %v\n", err)
- os.Exit(1)
- }
-}
-
-func fromEditionProto(epb descriptorpb.Edition) filedesc.Edition {
- return filedesc.Edition(epb)
-}
-
-func toEditionProto(ed filedesc.Edition) descriptorpb.Edition {
- switch ed {
- case filedesc.EditionUnknown:
- return descriptorpb.Edition_EDITION_UNKNOWN
- case filedesc.EditionProto2:
- return descriptorpb.Edition_EDITION_PROTO2
- case filedesc.EditionProto3:
- return descriptorpb.Edition_EDITION_PROTO3
- case filedesc.Edition2023:
- return descriptorpb.Edition_EDITION_2023
- case filedesc.Edition2024:
- return descriptorpb.Edition_EDITION_2024
- default:
- panic(fmt.Sprintf("unknown value for edition: %v", ed))
- }
-}
-
-func getFeatureSetFor(ed filedesc.Edition) *descriptorpb.FeatureSet {
- defaultsCacheMu.Lock()
- defer defaultsCacheMu.Unlock()
- if def, ok := defaultsCache[ed]; ok {
- return def
- }
- edpb := toEditionProto(ed)
- if defaults.GetMinimumEdition() > edpb || defaults.GetMaximumEdition() < edpb {
- // This should never happen protodesc.(FileOptions).New would fail when
- // initializing the file descriptor.
- // This most likely means the embedded defaults were not updated.
- fmt.Fprintf(os.Stderr, "internal error: unsupported edition %v (did you forget to update the embedded defaults (i.e. the bootstrap descriptor proto)?)\n", edpb)
- os.Exit(1)
- }
- fsed := defaults.GetDefaults()[0]
- // Using a linear search for now.
- // Editions are guaranteed to be sorted and thus we could use a binary search.
- // Given that there are only a handful of editions (with one more per year)
- // there is not much reason to use a binary search.
- for _, def := range defaults.GetDefaults() {
- if def.GetEdition() <= edpb {
- fsed = def
- } else {
- break
- }
- }
- fs := proto.Clone(fsed.GetFixedFeatures()).(*descriptorpb.FeatureSet)
- proto.Merge(fs, fsed.GetOverridableFeatures())
- defaultsCache[ed] = fs
- return fs
-}
-
-// mergeEditionFeatures merges the parent and child feature sets. This function
-// should be used when initializing Go descriptors from descriptor protos which
-// is why the parent is a filedesc.EditionsFeatures (Go representation) while
-// the child is a descriptorproto.FeatureSet (protoc representation).
-// Any feature set by the child overwrites what is set by the parent.
-func mergeEditionFeatures(parentDesc protoreflect.Descriptor, child *descriptorpb.FeatureSet) filedesc.EditionFeatures {
- var parentFS filedesc.EditionFeatures
- switch p := parentDesc.(type) {
- case *filedesc.File:
- parentFS = p.L1.EditionFeatures
- case *filedesc.Message:
- parentFS = p.L1.EditionFeatures
- default:
- panic(fmt.Sprintf("unknown parent type %T", parentDesc))
- }
- if child == nil {
- return parentFS
- }
- if fp := child.FieldPresence; fp != nil {
- parentFS.IsFieldPresence = *fp == descriptorpb.FeatureSet_LEGACY_REQUIRED ||
- *fp == descriptorpb.FeatureSet_EXPLICIT
- parentFS.IsLegacyRequired = *fp == descriptorpb.FeatureSet_LEGACY_REQUIRED
- }
- if et := child.EnumType; et != nil {
- parentFS.IsOpenEnum = *et == descriptorpb.FeatureSet_OPEN
- }
-
- if rfe := child.RepeatedFieldEncoding; rfe != nil {
- parentFS.IsPacked = *rfe == descriptorpb.FeatureSet_PACKED
- }
-
- if utf8val := child.Utf8Validation; utf8val != nil {
- parentFS.IsUTF8Validated = *utf8val == descriptorpb.FeatureSet_VERIFY
- }
-
- if me := child.MessageEncoding; me != nil {
- parentFS.IsDelimitedEncoded = *me == descriptorpb.FeatureSet_DELIMITED
- }
-
- if jf := child.JsonFormat; jf != nil {
- parentFS.IsJSONCompliant = *jf == descriptorpb.FeatureSet_ALLOW
- }
-
- // We must not use proto.GetExtension(child, gofeaturespb.E_Go)
- // because that only works for messages we generated, but not for
- // dynamicpb messages. See golang/protobuf#1669.
- //
- // Further, we harden this code against adversarial inputs: a
- // service which accepts descriptors from a possibly malicious
- // source shouldn't crash.
- goFeatures := child.ProtoReflect().Get(gofeaturespb.E_Go.TypeDescriptor())
- if !goFeatures.IsValid() {
- return parentFS
- }
- gf, ok := goFeatures.Interface().(protoreflect.Message)
- if !ok {
- return parentFS
- }
- // gf.Interface() could be *dynamicpb.Message or *gofeaturespb.GoFeatures.
- fields := gf.Descriptor().Fields()
-
- if fd := fields.ByNumber(genid.GoFeatures_LegacyUnmarshalJsonEnum_field_number); fd != nil &&
- !fd.IsList() &&
- fd.Kind() == protoreflect.BoolKind &&
- gf.Has(fd) {
- parentFS.GenerateLegacyUnmarshalJSON = gf.Get(fd).Bool()
- }
-
- if fd := fields.ByNumber(genid.GoFeatures_StripEnumPrefix_field_number); fd != nil &&
- !fd.IsList() &&
- fd.Kind() == protoreflect.EnumKind &&
- gf.Has(fd) {
- parentFS.StripEnumPrefix = int(gf.Get(fd).Enum())
- }
-
- if fd := fields.ByNumber(genid.GoFeatures_ApiLevel_field_number); fd != nil &&
- !fd.IsList() &&
- fd.Kind() == protoreflect.EnumKind &&
- gf.Has(fd) {
- parentFS.APILevel = int(gf.Get(fd).Enum())
- }
-
- return parentFS
-}
-
-// initFileDescFromFeatureSet initializes editions related fields in fd based
-// on fs. If fs is nil it is assumed to be an empty featureset and all fields
-// will be initialized with the appropriate default. fd.L1.Edition must be set
-// before calling this function.
-func initFileDescFromFeatureSet(fd *filedesc.File, fs *descriptorpb.FeatureSet) {
- dfs := getFeatureSetFor(fd.L1.Edition)
- // initialize the featureset with the defaults
- fd.L1.EditionFeatures = mergeEditionFeatures(fd, dfs)
- // overwrite any options explicitly specified
- fd.L1.EditionFeatures = mergeEditionFeatures(fd, fs)
-}
diff --git a/tools/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go b/tools/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go
deleted file mode 100644
index a5de8d400..000000000
--- a/tools/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go
+++ /dev/null
@@ -1,274 +0,0 @@
-// Copyright 2019 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 protodesc
-
-import (
- "fmt"
- "strings"
-
- "google.golang.org/protobuf/internal/encoding/defval"
- "google.golang.org/protobuf/internal/strs"
- "google.golang.org/protobuf/proto"
- "google.golang.org/protobuf/reflect/protoreflect"
-
- "google.golang.org/protobuf/types/descriptorpb"
-)
-
-// ToFileDescriptorProto copies a [protoreflect.FileDescriptor] into a
-// google.protobuf.FileDescriptorProto message.
-func ToFileDescriptorProto(file protoreflect.FileDescriptor) *descriptorpb.FileDescriptorProto {
- p := &descriptorpb.FileDescriptorProto{
- Name: proto.String(file.Path()),
- Options: proto.Clone(file.Options()).(*descriptorpb.FileOptions),
- }
- if file.Package() != "" {
- p.Package = proto.String(string(file.Package()))
- }
- for i, imports := 0, file.Imports(); i < imports.Len(); i++ {
- imp := imports.Get(i)
- p.Dependency = append(p.Dependency, imp.Path())
- if imp.IsPublic {
- p.PublicDependency = append(p.PublicDependency, int32(i))
- }
- if imp.IsWeak {
- p.WeakDependency = append(p.WeakDependency, int32(i))
- }
- }
- for i, locs := 0, file.SourceLocations(); i < locs.Len(); i++ {
- loc := locs.Get(i)
- l := &descriptorpb.SourceCodeInfo_Location{}
- l.Path = append(l.Path, loc.Path...)
- if loc.StartLine == loc.EndLine {
- l.Span = []int32{int32(loc.StartLine), int32(loc.StartColumn), int32(loc.EndColumn)}
- } else {
- l.Span = []int32{int32(loc.StartLine), int32(loc.StartColumn), int32(loc.EndLine), int32(loc.EndColumn)}
- }
- l.LeadingDetachedComments = append([]string(nil), loc.LeadingDetachedComments...)
- if loc.LeadingComments != "" {
- l.LeadingComments = proto.String(loc.LeadingComments)
- }
- if loc.TrailingComments != "" {
- l.TrailingComments = proto.String(loc.TrailingComments)
- }
- if p.SourceCodeInfo == nil {
- p.SourceCodeInfo = &descriptorpb.SourceCodeInfo{}
- }
- p.SourceCodeInfo.Location = append(p.SourceCodeInfo.Location, l)
-
- }
- for i, messages := 0, file.Messages(); i < messages.Len(); i++ {
- p.MessageType = append(p.MessageType, ToDescriptorProto(messages.Get(i)))
- }
- for i, enums := 0, file.Enums(); i < enums.Len(); i++ {
- p.EnumType = append(p.EnumType, ToEnumDescriptorProto(enums.Get(i)))
- }
- for i, services := 0, file.Services(); i < services.Len(); i++ {
- p.Service = append(p.Service, ToServiceDescriptorProto(services.Get(i)))
- }
- for i, exts := 0, file.Extensions(); i < exts.Len(); i++ {
- p.Extension = append(p.Extension, ToFieldDescriptorProto(exts.Get(i)))
- }
- if syntax := file.Syntax(); syntax != protoreflect.Proto2 && syntax.IsValid() {
- p.Syntax = proto.String(file.Syntax().String())
- }
- if file.Syntax() == protoreflect.Editions {
- desc := file
- if fileImportDesc, ok := file.(protoreflect.FileImport); ok {
- desc = fileImportDesc.FileDescriptor
- }
-
- if editionsInterface, ok := desc.(interface{ Edition() int32 }); ok {
- p.Edition = descriptorpb.Edition(editionsInterface.Edition()).Enum()
- }
- }
- return p
-}
-
-// ToDescriptorProto copies a [protoreflect.MessageDescriptor] into a
-// google.protobuf.DescriptorProto message.
-func ToDescriptorProto(message protoreflect.MessageDescriptor) *descriptorpb.DescriptorProto {
- p := &descriptorpb.DescriptorProto{
- Name: proto.String(string(message.Name())),
- Options: proto.Clone(message.Options()).(*descriptorpb.MessageOptions),
- }
- for i, fields := 0, message.Fields(); i < fields.Len(); i++ {
- p.Field = append(p.Field, ToFieldDescriptorProto(fields.Get(i)))
- }
- for i, exts := 0, message.Extensions(); i < exts.Len(); i++ {
- p.Extension = append(p.Extension, ToFieldDescriptorProto(exts.Get(i)))
- }
- for i, messages := 0, message.Messages(); i < messages.Len(); i++ {
- p.NestedType = append(p.NestedType, ToDescriptorProto(messages.Get(i)))
- }
- for i, enums := 0, message.Enums(); i < enums.Len(); i++ {
- p.EnumType = append(p.EnumType, ToEnumDescriptorProto(enums.Get(i)))
- }
- for i, xranges := 0, message.ExtensionRanges(); i < xranges.Len(); i++ {
- xrange := xranges.Get(i)
- p.ExtensionRange = append(p.ExtensionRange, &descriptorpb.DescriptorProto_ExtensionRange{
- Start: proto.Int32(int32(xrange[0])),
- End: proto.Int32(int32(xrange[1])),
- Options: proto.Clone(message.ExtensionRangeOptions(i)).(*descriptorpb.ExtensionRangeOptions),
- })
- }
- for i, oneofs := 0, message.Oneofs(); i < oneofs.Len(); i++ {
- p.OneofDecl = append(p.OneofDecl, ToOneofDescriptorProto(oneofs.Get(i)))
- }
- for i, ranges := 0, message.ReservedRanges(); i < ranges.Len(); i++ {
- rrange := ranges.Get(i)
- p.ReservedRange = append(p.ReservedRange, &descriptorpb.DescriptorProto_ReservedRange{
- Start: proto.Int32(int32(rrange[0])),
- End: proto.Int32(int32(rrange[1])),
- })
- }
- for i, names := 0, message.ReservedNames(); i < names.Len(); i++ {
- p.ReservedName = append(p.ReservedName, string(names.Get(i)))
- }
- return p
-}
-
-// ToFieldDescriptorProto copies a [protoreflect.FieldDescriptor] into a
-// google.protobuf.FieldDescriptorProto message.
-func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.FieldDescriptorProto {
- p := &descriptorpb.FieldDescriptorProto{
- Name: proto.String(string(field.Name())),
- Number: proto.Int32(int32(field.Number())),
- Label: descriptorpb.FieldDescriptorProto_Label(field.Cardinality()).Enum(),
- Options: proto.Clone(field.Options()).(*descriptorpb.FieldOptions),
- }
- if field.IsExtension() {
- p.Extendee = fullNameOf(field.ContainingMessage())
- }
- if field.Kind().IsValid() {
- p.Type = descriptorpb.FieldDescriptorProto_Type(field.Kind()).Enum()
- }
- if field.Enum() != nil {
- p.TypeName = fullNameOf(field.Enum())
- }
- if field.Message() != nil {
- p.TypeName = fullNameOf(field.Message())
- }
- if field.HasJSONName() {
- // A bug in older versions of protoc would always populate the
- // "json_name" option for extensions when it is meaningless.
- // When it did so, it would always use the camel-cased field name.
- if field.IsExtension() {
- p.JsonName = proto.String(strs.JSONCamelCase(string(field.Name())))
- } else {
- p.JsonName = proto.String(field.JSONName())
- }
- }
- if field.Syntax() == protoreflect.Proto3 && field.HasOptionalKeyword() {
- p.Proto3Optional = proto.Bool(true)
- }
- if field.Syntax() == protoreflect.Editions {
- // Editions have no group keyword, this type is only set so that downstream users continue
- // treating this as delimited encoding.
- if p.GetType() == descriptorpb.FieldDescriptorProto_TYPE_GROUP {
- p.Type = descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum()
- }
- // Editions have no required keyword, this label is only set so that downstream users continue
- // treating it as required.
- if p.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REQUIRED {
- p.Label = descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum()
- }
- }
- if field.HasDefault() {
- def, err := defval.Marshal(field.Default(), field.DefaultEnumValue(), field.Kind(), defval.Descriptor)
- if err != nil && field.DefaultEnumValue() != nil {
- def = string(field.DefaultEnumValue().Name()) // occurs for unresolved enum values
- } else if err != nil {
- panic(fmt.Sprintf("%v: %v", field.FullName(), err))
- }
- p.DefaultValue = proto.String(def)
- }
- if oneof := field.ContainingOneof(); oneof != nil {
- p.OneofIndex = proto.Int32(int32(oneof.Index()))
- }
- return p
-}
-
-// ToOneofDescriptorProto copies a [protoreflect.OneofDescriptor] into a
-// google.protobuf.OneofDescriptorProto message.
-func ToOneofDescriptorProto(oneof protoreflect.OneofDescriptor) *descriptorpb.OneofDescriptorProto {
- return &descriptorpb.OneofDescriptorProto{
- Name: proto.String(string(oneof.Name())),
- Options: proto.Clone(oneof.Options()).(*descriptorpb.OneofOptions),
- }
-}
-
-// ToEnumDescriptorProto copies a [protoreflect.EnumDescriptor] into a
-// google.protobuf.EnumDescriptorProto message.
-func ToEnumDescriptorProto(enum protoreflect.EnumDescriptor) *descriptorpb.EnumDescriptorProto {
- p := &descriptorpb.EnumDescriptorProto{
- Name: proto.String(string(enum.Name())),
- Options: proto.Clone(enum.Options()).(*descriptorpb.EnumOptions),
- }
- for i, values := 0, enum.Values(); i < values.Len(); i++ {
- p.Value = append(p.Value, ToEnumValueDescriptorProto(values.Get(i)))
- }
- for i, ranges := 0, enum.ReservedRanges(); i < ranges.Len(); i++ {
- rrange := ranges.Get(i)
- p.ReservedRange = append(p.ReservedRange, &descriptorpb.EnumDescriptorProto_EnumReservedRange{
- Start: proto.Int32(int32(rrange[0])),
- End: proto.Int32(int32(rrange[1])),
- })
- }
- for i, names := 0, enum.ReservedNames(); i < names.Len(); i++ {
- p.ReservedName = append(p.ReservedName, string(names.Get(i)))
- }
- return p
-}
-
-// ToEnumValueDescriptorProto copies a [protoreflect.EnumValueDescriptor] into a
-// google.protobuf.EnumValueDescriptorProto message.
-func ToEnumValueDescriptorProto(value protoreflect.EnumValueDescriptor) *descriptorpb.EnumValueDescriptorProto {
- return &descriptorpb.EnumValueDescriptorProto{
- Name: proto.String(string(value.Name())),
- Number: proto.Int32(int32(value.Number())),
- Options: proto.Clone(value.Options()).(*descriptorpb.EnumValueOptions),
- }
-}
-
-// ToServiceDescriptorProto copies a [protoreflect.ServiceDescriptor] into a
-// google.protobuf.ServiceDescriptorProto message.
-func ToServiceDescriptorProto(service protoreflect.ServiceDescriptor) *descriptorpb.ServiceDescriptorProto {
- p := &descriptorpb.ServiceDescriptorProto{
- Name: proto.String(string(service.Name())),
- Options: proto.Clone(service.Options()).(*descriptorpb.ServiceOptions),
- }
- for i, methods := 0, service.Methods(); i < methods.Len(); i++ {
- p.Method = append(p.Method, ToMethodDescriptorProto(methods.Get(i)))
- }
- return p
-}
-
-// ToMethodDescriptorProto copies a [protoreflect.MethodDescriptor] into a
-// google.protobuf.MethodDescriptorProto message.
-func ToMethodDescriptorProto(method protoreflect.MethodDescriptor) *descriptorpb.MethodDescriptorProto {
- p := &descriptorpb.MethodDescriptorProto{
- Name: proto.String(string(method.Name())),
- InputType: fullNameOf(method.Input()),
- OutputType: fullNameOf(method.Output()),
- Options: proto.Clone(method.Options()).(*descriptorpb.MethodOptions),
- }
- if method.IsStreamingClient() {
- p.ClientStreaming = proto.Bool(true)
- }
- if method.IsStreamingServer() {
- p.ServerStreaming = proto.Bool(true)
- }
- return p
-}
-
-func fullNameOf(d protoreflect.Descriptor) *string {
- if d == nil {
- return nil
- }
- if strings.HasPrefix(string(d.FullName()), unknownPrefix) {
- return proto.String(string(d.FullName()[len(unknownPrefix):]))
- }
- return proto.String("." + string(d.FullName()))
-}
diff --git a/tools/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go b/tools/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go
index cd8fadbaf..cd7fbc87a 100644
--- a/tools/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go
+++ b/tools/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go
@@ -68,7 +68,7 @@ type Descriptor interface {
// dependency is not resolved, in which case only name information is known.
//
// Placeholder types may only be returned by the following accessors
- // as a result of unresolved dependencies or weak imports:
+ // as a result of unresolved dependencies:
//
// ╔═══════════════════════════════════╤═════════════════════╗
// ║ Accessor │ Descriptor ║
@@ -168,11 +168,7 @@ type FileImport struct {
// The current file and the imported file must be within proto package.
IsPublic bool
- // IsWeak reports whether this is a weak import, which does not impose
- // a direct dependency on the target file.
- //
- // Weak imports are a legacy proto1 feature. Equivalent behavior is
- // achieved using proto2 extension fields or proto3 Any messages.
+ // Deprecated: support for weak fields has been removed.
IsWeak bool
}
@@ -325,9 +321,7 @@ type FieldDescriptor interface {
// specified in the source .proto file.
HasOptionalKeyword() bool
- // IsWeak reports whether this is a weak field, which does not impose a
- // direct dependency on the target type.
- // If true, then Message returns a placeholder type.
+ // Deprecated: support for weak fields has been removed.
IsWeak() bool
// IsPacked reports whether repeated primitive numeric kinds should be
diff --git a/tools/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go b/tools/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go
deleted file mode 100644
index a51633767..000000000
--- a/tools/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go
+++ /dev/null
@@ -1,5310 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Author: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// The messages in this file describe the definitions found in .proto files.
-// A valid .proto file can be translated directly to a FileDescriptorProto
-// without any other information (e.g. without reading its imports).
-
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// source: google/protobuf/descriptor.proto
-
-package descriptorpb
-
-import (
- protoreflect "google.golang.org/protobuf/reflect/protoreflect"
- protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
- unsafe "unsafe"
-)
-
-// The full set of known editions.
-type Edition int32
-
-const (
- // A placeholder for an unknown edition value.
- Edition_EDITION_UNKNOWN Edition = 0
- // A placeholder edition for specifying default behaviors *before* a feature
- // was first introduced. This is effectively an "infinite past".
- Edition_EDITION_LEGACY Edition = 900
- // Legacy syntax "editions". These pre-date editions, but behave much like
- // distinct editions. These can't be used to specify the edition of proto
- // files, but feature definitions must supply proto2/proto3 defaults for
- // backwards compatibility.
- Edition_EDITION_PROTO2 Edition = 998
- Edition_EDITION_PROTO3 Edition = 999
- // Editions that have been released. The specific values are arbitrary and
- // should not be depended on, but they will always be time-ordered for easy
- // comparison.
- Edition_EDITION_2023 Edition = 1000
- Edition_EDITION_2024 Edition = 1001
- // Placeholder editions for testing feature resolution. These should not be
- // used or relied on outside of tests.
- Edition_EDITION_1_TEST_ONLY Edition = 1
- Edition_EDITION_2_TEST_ONLY Edition = 2
- Edition_EDITION_99997_TEST_ONLY Edition = 99997
- Edition_EDITION_99998_TEST_ONLY Edition = 99998
- Edition_EDITION_99999_TEST_ONLY Edition = 99999
- // Placeholder for specifying unbounded edition support. This should only
- // ever be used by plugins that can expect to never require any changes to
- // support a new edition.
- Edition_EDITION_MAX Edition = 2147483647
-)
-
-// Enum value maps for Edition.
-var (
- Edition_name = map[int32]string{
- 0: "EDITION_UNKNOWN",
- 900: "EDITION_LEGACY",
- 998: "EDITION_PROTO2",
- 999: "EDITION_PROTO3",
- 1000: "EDITION_2023",
- 1001: "EDITION_2024",
- 1: "EDITION_1_TEST_ONLY",
- 2: "EDITION_2_TEST_ONLY",
- 99997: "EDITION_99997_TEST_ONLY",
- 99998: "EDITION_99998_TEST_ONLY",
- 99999: "EDITION_99999_TEST_ONLY",
- 2147483647: "EDITION_MAX",
- }
- Edition_value = map[string]int32{
- "EDITION_UNKNOWN": 0,
- "EDITION_LEGACY": 900,
- "EDITION_PROTO2": 998,
- "EDITION_PROTO3": 999,
- "EDITION_2023": 1000,
- "EDITION_2024": 1001,
- "EDITION_1_TEST_ONLY": 1,
- "EDITION_2_TEST_ONLY": 2,
- "EDITION_99997_TEST_ONLY": 99997,
- "EDITION_99998_TEST_ONLY": 99998,
- "EDITION_99999_TEST_ONLY": 99999,
- "EDITION_MAX": 2147483647,
- }
-)
-
-func (x Edition) Enum() *Edition {
- p := new(Edition)
- *p = x
- return p
-}
-
-func (x Edition) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (Edition) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[0].Descriptor()
-}
-
-func (Edition) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[0]
-}
-
-func (x Edition) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *Edition) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = Edition(num)
- return nil
-}
-
-// Deprecated: Use Edition.Descriptor instead.
-func (Edition) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{0}
-}
-
-// The verification state of the extension range.
-type ExtensionRangeOptions_VerificationState int32
-
-const (
- // All the extensions of the range must be declared.
- ExtensionRangeOptions_DECLARATION ExtensionRangeOptions_VerificationState = 0
- ExtensionRangeOptions_UNVERIFIED ExtensionRangeOptions_VerificationState = 1
-)
-
-// Enum value maps for ExtensionRangeOptions_VerificationState.
-var (
- ExtensionRangeOptions_VerificationState_name = map[int32]string{
- 0: "DECLARATION",
- 1: "UNVERIFIED",
- }
- ExtensionRangeOptions_VerificationState_value = map[string]int32{
- "DECLARATION": 0,
- "UNVERIFIED": 1,
- }
-)
-
-func (x ExtensionRangeOptions_VerificationState) Enum() *ExtensionRangeOptions_VerificationState {
- p := new(ExtensionRangeOptions_VerificationState)
- *p = x
- return p
-}
-
-func (x ExtensionRangeOptions_VerificationState) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (ExtensionRangeOptions_VerificationState) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[1].Descriptor()
-}
-
-func (ExtensionRangeOptions_VerificationState) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[1]
-}
-
-func (x ExtensionRangeOptions_VerificationState) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *ExtensionRangeOptions_VerificationState) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = ExtensionRangeOptions_VerificationState(num)
- return nil
-}
-
-// Deprecated: Use ExtensionRangeOptions_VerificationState.Descriptor instead.
-func (ExtensionRangeOptions_VerificationState) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{3, 0}
-}
-
-type FieldDescriptorProto_Type int32
-
-const (
- // 0 is reserved for errors.
- // Order is weird for historical reasons.
- FieldDescriptorProto_TYPE_DOUBLE FieldDescriptorProto_Type = 1
- FieldDescriptorProto_TYPE_FLOAT FieldDescriptorProto_Type = 2
- // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
- // negative values are likely.
- FieldDescriptorProto_TYPE_INT64 FieldDescriptorProto_Type = 3
- FieldDescriptorProto_TYPE_UINT64 FieldDescriptorProto_Type = 4
- // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
- // negative values are likely.
- FieldDescriptorProto_TYPE_INT32 FieldDescriptorProto_Type = 5
- FieldDescriptorProto_TYPE_FIXED64 FieldDescriptorProto_Type = 6
- FieldDescriptorProto_TYPE_FIXED32 FieldDescriptorProto_Type = 7
- FieldDescriptorProto_TYPE_BOOL FieldDescriptorProto_Type = 8
- FieldDescriptorProto_TYPE_STRING FieldDescriptorProto_Type = 9
- // Tag-delimited aggregate.
- // Group type is deprecated and not supported after google.protobuf. However, Proto3
- // implementations should still be able to parse the group wire format and
- // treat group fields as unknown fields. In Editions, the group wire format
- // can be enabled via the `message_encoding` feature.
- FieldDescriptorProto_TYPE_GROUP FieldDescriptorProto_Type = 10
- FieldDescriptorProto_TYPE_MESSAGE FieldDescriptorProto_Type = 11 // Length-delimited aggregate.
- // New in version 2.
- FieldDescriptorProto_TYPE_BYTES FieldDescriptorProto_Type = 12
- FieldDescriptorProto_TYPE_UINT32 FieldDescriptorProto_Type = 13
- FieldDescriptorProto_TYPE_ENUM FieldDescriptorProto_Type = 14
- FieldDescriptorProto_TYPE_SFIXED32 FieldDescriptorProto_Type = 15
- FieldDescriptorProto_TYPE_SFIXED64 FieldDescriptorProto_Type = 16
- FieldDescriptorProto_TYPE_SINT32 FieldDescriptorProto_Type = 17 // Uses ZigZag encoding.
- FieldDescriptorProto_TYPE_SINT64 FieldDescriptorProto_Type = 18 // Uses ZigZag encoding.
-)
-
-// Enum value maps for FieldDescriptorProto_Type.
-var (
- FieldDescriptorProto_Type_name = map[int32]string{
- 1: "TYPE_DOUBLE",
- 2: "TYPE_FLOAT",
- 3: "TYPE_INT64",
- 4: "TYPE_UINT64",
- 5: "TYPE_INT32",
- 6: "TYPE_FIXED64",
- 7: "TYPE_FIXED32",
- 8: "TYPE_BOOL",
- 9: "TYPE_STRING",
- 10: "TYPE_GROUP",
- 11: "TYPE_MESSAGE",
- 12: "TYPE_BYTES",
- 13: "TYPE_UINT32",
- 14: "TYPE_ENUM",
- 15: "TYPE_SFIXED32",
- 16: "TYPE_SFIXED64",
- 17: "TYPE_SINT32",
- 18: "TYPE_SINT64",
- }
- FieldDescriptorProto_Type_value = map[string]int32{
- "TYPE_DOUBLE": 1,
- "TYPE_FLOAT": 2,
- "TYPE_INT64": 3,
- "TYPE_UINT64": 4,
- "TYPE_INT32": 5,
- "TYPE_FIXED64": 6,
- "TYPE_FIXED32": 7,
- "TYPE_BOOL": 8,
- "TYPE_STRING": 9,
- "TYPE_GROUP": 10,
- "TYPE_MESSAGE": 11,
- "TYPE_BYTES": 12,
- "TYPE_UINT32": 13,
- "TYPE_ENUM": 14,
- "TYPE_SFIXED32": 15,
- "TYPE_SFIXED64": 16,
- "TYPE_SINT32": 17,
- "TYPE_SINT64": 18,
- }
-)
-
-func (x FieldDescriptorProto_Type) Enum() *FieldDescriptorProto_Type {
- p := new(FieldDescriptorProto_Type)
- *p = x
- return p
-}
-
-func (x FieldDescriptorProto_Type) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FieldDescriptorProto_Type) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[2].Descriptor()
-}
-
-func (FieldDescriptorProto_Type) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[2]
-}
-
-func (x FieldDescriptorProto_Type) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FieldDescriptorProto_Type) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FieldDescriptorProto_Type(num)
- return nil
-}
-
-// Deprecated: Use FieldDescriptorProto_Type.Descriptor instead.
-func (FieldDescriptorProto_Type) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{4, 0}
-}
-
-type FieldDescriptorProto_Label int32
-
-const (
- // 0 is reserved for errors
- FieldDescriptorProto_LABEL_OPTIONAL FieldDescriptorProto_Label = 1
- FieldDescriptorProto_LABEL_REPEATED FieldDescriptorProto_Label = 3
- // The required label is only allowed in google.protobuf. In proto3 and Editions
- // it's explicitly prohibited. In Editions, the `field_presence` feature
- // can be used to get this behavior.
- FieldDescriptorProto_LABEL_REQUIRED FieldDescriptorProto_Label = 2
-)
-
-// Enum value maps for FieldDescriptorProto_Label.
-var (
- FieldDescriptorProto_Label_name = map[int32]string{
- 1: "LABEL_OPTIONAL",
- 3: "LABEL_REPEATED",
- 2: "LABEL_REQUIRED",
- }
- FieldDescriptorProto_Label_value = map[string]int32{
- "LABEL_OPTIONAL": 1,
- "LABEL_REPEATED": 3,
- "LABEL_REQUIRED": 2,
- }
-)
-
-func (x FieldDescriptorProto_Label) Enum() *FieldDescriptorProto_Label {
- p := new(FieldDescriptorProto_Label)
- *p = x
- return p
-}
-
-func (x FieldDescriptorProto_Label) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FieldDescriptorProto_Label) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[3].Descriptor()
-}
-
-func (FieldDescriptorProto_Label) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[3]
-}
-
-func (x FieldDescriptorProto_Label) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FieldDescriptorProto_Label) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FieldDescriptorProto_Label(num)
- return nil
-}
-
-// Deprecated: Use FieldDescriptorProto_Label.Descriptor instead.
-func (FieldDescriptorProto_Label) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{4, 1}
-}
-
-// Generated classes can be optimized for speed or code size.
-type FileOptions_OptimizeMode int32
-
-const (
- FileOptions_SPEED FileOptions_OptimizeMode = 1 // Generate complete code for parsing, serialization,
- // etc.
- FileOptions_CODE_SIZE FileOptions_OptimizeMode = 2 // Use ReflectionOps to implement these methods.
- FileOptions_LITE_RUNTIME FileOptions_OptimizeMode = 3 // Generate code using MessageLite and the lite runtime.
-)
-
-// Enum value maps for FileOptions_OptimizeMode.
-var (
- FileOptions_OptimizeMode_name = map[int32]string{
- 1: "SPEED",
- 2: "CODE_SIZE",
- 3: "LITE_RUNTIME",
- }
- FileOptions_OptimizeMode_value = map[string]int32{
- "SPEED": 1,
- "CODE_SIZE": 2,
- "LITE_RUNTIME": 3,
- }
-)
-
-func (x FileOptions_OptimizeMode) Enum() *FileOptions_OptimizeMode {
- p := new(FileOptions_OptimizeMode)
- *p = x
- return p
-}
-
-func (x FileOptions_OptimizeMode) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FileOptions_OptimizeMode) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[4].Descriptor()
-}
-
-func (FileOptions_OptimizeMode) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[4]
-}
-
-func (x FileOptions_OptimizeMode) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FileOptions_OptimizeMode) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FileOptions_OptimizeMode(num)
- return nil
-}
-
-// Deprecated: Use FileOptions_OptimizeMode.Descriptor instead.
-func (FileOptions_OptimizeMode) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{10, 0}
-}
-
-type FieldOptions_CType int32
-
-const (
- // Default mode.
- FieldOptions_STRING FieldOptions_CType = 0
- // The option [ctype=CORD] may be applied to a non-repeated field of type
- // "bytes". It indicates that in C++, the data should be stored in a Cord
- // instead of a string. For very large strings, this may reduce memory
- // fragmentation. It may also allow better performance when parsing from a
- // Cord, or when parsing with aliasing enabled, as the parsed Cord may then
- // alias the original buffer.
- FieldOptions_CORD FieldOptions_CType = 1
- FieldOptions_STRING_PIECE FieldOptions_CType = 2
-)
-
-// Enum value maps for FieldOptions_CType.
-var (
- FieldOptions_CType_name = map[int32]string{
- 0: "STRING",
- 1: "CORD",
- 2: "STRING_PIECE",
- }
- FieldOptions_CType_value = map[string]int32{
- "STRING": 0,
- "CORD": 1,
- "STRING_PIECE": 2,
- }
-)
-
-func (x FieldOptions_CType) Enum() *FieldOptions_CType {
- p := new(FieldOptions_CType)
- *p = x
- return p
-}
-
-func (x FieldOptions_CType) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FieldOptions_CType) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[5].Descriptor()
-}
-
-func (FieldOptions_CType) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[5]
-}
-
-func (x FieldOptions_CType) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FieldOptions_CType) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FieldOptions_CType(num)
- return nil
-}
-
-// Deprecated: Use FieldOptions_CType.Descriptor instead.
-func (FieldOptions_CType) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{12, 0}
-}
-
-type FieldOptions_JSType int32
-
-const (
- // Use the default type.
- FieldOptions_JS_NORMAL FieldOptions_JSType = 0
- // Use JavaScript strings.
- FieldOptions_JS_STRING FieldOptions_JSType = 1
- // Use JavaScript numbers.
- FieldOptions_JS_NUMBER FieldOptions_JSType = 2
-)
-
-// Enum value maps for FieldOptions_JSType.
-var (
- FieldOptions_JSType_name = map[int32]string{
- 0: "JS_NORMAL",
- 1: "JS_STRING",
- 2: "JS_NUMBER",
- }
- FieldOptions_JSType_value = map[string]int32{
- "JS_NORMAL": 0,
- "JS_STRING": 1,
- "JS_NUMBER": 2,
- }
-)
-
-func (x FieldOptions_JSType) Enum() *FieldOptions_JSType {
- p := new(FieldOptions_JSType)
- *p = x
- return p
-}
-
-func (x FieldOptions_JSType) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FieldOptions_JSType) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[6].Descriptor()
-}
-
-func (FieldOptions_JSType) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[6]
-}
-
-func (x FieldOptions_JSType) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FieldOptions_JSType) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FieldOptions_JSType(num)
- return nil
-}
-
-// Deprecated: Use FieldOptions_JSType.Descriptor instead.
-func (FieldOptions_JSType) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{12, 1}
-}
-
-// If set to RETENTION_SOURCE, the option will be omitted from the binary.
-type FieldOptions_OptionRetention int32
-
-const (
- FieldOptions_RETENTION_UNKNOWN FieldOptions_OptionRetention = 0
- FieldOptions_RETENTION_RUNTIME FieldOptions_OptionRetention = 1
- FieldOptions_RETENTION_SOURCE FieldOptions_OptionRetention = 2
-)
-
-// Enum value maps for FieldOptions_OptionRetention.
-var (
- FieldOptions_OptionRetention_name = map[int32]string{
- 0: "RETENTION_UNKNOWN",
- 1: "RETENTION_RUNTIME",
- 2: "RETENTION_SOURCE",
- }
- FieldOptions_OptionRetention_value = map[string]int32{
- "RETENTION_UNKNOWN": 0,
- "RETENTION_RUNTIME": 1,
- "RETENTION_SOURCE": 2,
- }
-)
-
-func (x FieldOptions_OptionRetention) Enum() *FieldOptions_OptionRetention {
- p := new(FieldOptions_OptionRetention)
- *p = x
- return p
-}
-
-func (x FieldOptions_OptionRetention) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FieldOptions_OptionRetention) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[7].Descriptor()
-}
-
-func (FieldOptions_OptionRetention) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[7]
-}
-
-func (x FieldOptions_OptionRetention) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FieldOptions_OptionRetention) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FieldOptions_OptionRetention(num)
- return nil
-}
-
-// Deprecated: Use FieldOptions_OptionRetention.Descriptor instead.
-func (FieldOptions_OptionRetention) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{12, 2}
-}
-
-// This indicates the types of entities that the field may apply to when used
-// as an option. If it is unset, then the field may be freely used as an
-// option on any kind of entity.
-type FieldOptions_OptionTargetType int32
-
-const (
- FieldOptions_TARGET_TYPE_UNKNOWN FieldOptions_OptionTargetType = 0
- FieldOptions_TARGET_TYPE_FILE FieldOptions_OptionTargetType = 1
- FieldOptions_TARGET_TYPE_EXTENSION_RANGE FieldOptions_OptionTargetType = 2
- FieldOptions_TARGET_TYPE_MESSAGE FieldOptions_OptionTargetType = 3
- FieldOptions_TARGET_TYPE_FIELD FieldOptions_OptionTargetType = 4
- FieldOptions_TARGET_TYPE_ONEOF FieldOptions_OptionTargetType = 5
- FieldOptions_TARGET_TYPE_ENUM FieldOptions_OptionTargetType = 6
- FieldOptions_TARGET_TYPE_ENUM_ENTRY FieldOptions_OptionTargetType = 7
- FieldOptions_TARGET_TYPE_SERVICE FieldOptions_OptionTargetType = 8
- FieldOptions_TARGET_TYPE_METHOD FieldOptions_OptionTargetType = 9
-)
-
-// Enum value maps for FieldOptions_OptionTargetType.
-var (
- FieldOptions_OptionTargetType_name = map[int32]string{
- 0: "TARGET_TYPE_UNKNOWN",
- 1: "TARGET_TYPE_FILE",
- 2: "TARGET_TYPE_EXTENSION_RANGE",
- 3: "TARGET_TYPE_MESSAGE",
- 4: "TARGET_TYPE_FIELD",
- 5: "TARGET_TYPE_ONEOF",
- 6: "TARGET_TYPE_ENUM",
- 7: "TARGET_TYPE_ENUM_ENTRY",
- 8: "TARGET_TYPE_SERVICE",
- 9: "TARGET_TYPE_METHOD",
- }
- FieldOptions_OptionTargetType_value = map[string]int32{
- "TARGET_TYPE_UNKNOWN": 0,
- "TARGET_TYPE_FILE": 1,
- "TARGET_TYPE_EXTENSION_RANGE": 2,
- "TARGET_TYPE_MESSAGE": 3,
- "TARGET_TYPE_FIELD": 4,
- "TARGET_TYPE_ONEOF": 5,
- "TARGET_TYPE_ENUM": 6,
- "TARGET_TYPE_ENUM_ENTRY": 7,
- "TARGET_TYPE_SERVICE": 8,
- "TARGET_TYPE_METHOD": 9,
- }
-)
-
-func (x FieldOptions_OptionTargetType) Enum() *FieldOptions_OptionTargetType {
- p := new(FieldOptions_OptionTargetType)
- *p = x
- return p
-}
-
-func (x FieldOptions_OptionTargetType) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FieldOptions_OptionTargetType) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[8].Descriptor()
-}
-
-func (FieldOptions_OptionTargetType) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[8]
-}
-
-func (x FieldOptions_OptionTargetType) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FieldOptions_OptionTargetType) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FieldOptions_OptionTargetType(num)
- return nil
-}
-
-// Deprecated: Use FieldOptions_OptionTargetType.Descriptor instead.
-func (FieldOptions_OptionTargetType) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{12, 3}
-}
-
-// Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
-// or neither? HTTP based RPC implementation may choose GET verb for safe
-// methods, and PUT verb for idempotent methods instead of the default POST.
-type MethodOptions_IdempotencyLevel int32
-
-const (
- MethodOptions_IDEMPOTENCY_UNKNOWN MethodOptions_IdempotencyLevel = 0
- MethodOptions_NO_SIDE_EFFECTS MethodOptions_IdempotencyLevel = 1 // implies idempotent
- MethodOptions_IDEMPOTENT MethodOptions_IdempotencyLevel = 2 // idempotent, but may have side effects
-)
-
-// Enum value maps for MethodOptions_IdempotencyLevel.
-var (
- MethodOptions_IdempotencyLevel_name = map[int32]string{
- 0: "IDEMPOTENCY_UNKNOWN",
- 1: "NO_SIDE_EFFECTS",
- 2: "IDEMPOTENT",
- }
- MethodOptions_IdempotencyLevel_value = map[string]int32{
- "IDEMPOTENCY_UNKNOWN": 0,
- "NO_SIDE_EFFECTS": 1,
- "IDEMPOTENT": 2,
- }
-)
-
-func (x MethodOptions_IdempotencyLevel) Enum() *MethodOptions_IdempotencyLevel {
- p := new(MethodOptions_IdempotencyLevel)
- *p = x
- return p
-}
-
-func (x MethodOptions_IdempotencyLevel) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (MethodOptions_IdempotencyLevel) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[9].Descriptor()
-}
-
-func (MethodOptions_IdempotencyLevel) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[9]
-}
-
-func (x MethodOptions_IdempotencyLevel) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *MethodOptions_IdempotencyLevel) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = MethodOptions_IdempotencyLevel(num)
- return nil
-}
-
-// Deprecated: Use MethodOptions_IdempotencyLevel.Descriptor instead.
-func (MethodOptions_IdempotencyLevel) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{17, 0}
-}
-
-type FeatureSet_FieldPresence int32
-
-const (
- FeatureSet_FIELD_PRESENCE_UNKNOWN FeatureSet_FieldPresence = 0
- FeatureSet_EXPLICIT FeatureSet_FieldPresence = 1
- FeatureSet_IMPLICIT FeatureSet_FieldPresence = 2
- FeatureSet_LEGACY_REQUIRED FeatureSet_FieldPresence = 3
-)
-
-// Enum value maps for FeatureSet_FieldPresence.
-var (
- FeatureSet_FieldPresence_name = map[int32]string{
- 0: "FIELD_PRESENCE_UNKNOWN",
- 1: "EXPLICIT",
- 2: "IMPLICIT",
- 3: "LEGACY_REQUIRED",
- }
- FeatureSet_FieldPresence_value = map[string]int32{
- "FIELD_PRESENCE_UNKNOWN": 0,
- "EXPLICIT": 1,
- "IMPLICIT": 2,
- "LEGACY_REQUIRED": 3,
- }
-)
-
-func (x FeatureSet_FieldPresence) Enum() *FeatureSet_FieldPresence {
- p := new(FeatureSet_FieldPresence)
- *p = x
- return p
-}
-
-func (x FeatureSet_FieldPresence) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FeatureSet_FieldPresence) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[10].Descriptor()
-}
-
-func (FeatureSet_FieldPresence) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[10]
-}
-
-func (x FeatureSet_FieldPresence) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FeatureSet_FieldPresence) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FeatureSet_FieldPresence(num)
- return nil
-}
-
-// Deprecated: Use FeatureSet_FieldPresence.Descriptor instead.
-func (FeatureSet_FieldPresence) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{19, 0}
-}
-
-type FeatureSet_EnumType int32
-
-const (
- FeatureSet_ENUM_TYPE_UNKNOWN FeatureSet_EnumType = 0
- FeatureSet_OPEN FeatureSet_EnumType = 1
- FeatureSet_CLOSED FeatureSet_EnumType = 2
-)
-
-// Enum value maps for FeatureSet_EnumType.
-var (
- FeatureSet_EnumType_name = map[int32]string{
- 0: "ENUM_TYPE_UNKNOWN",
- 1: "OPEN",
- 2: "CLOSED",
- }
- FeatureSet_EnumType_value = map[string]int32{
- "ENUM_TYPE_UNKNOWN": 0,
- "OPEN": 1,
- "CLOSED": 2,
- }
-)
-
-func (x FeatureSet_EnumType) Enum() *FeatureSet_EnumType {
- p := new(FeatureSet_EnumType)
- *p = x
- return p
-}
-
-func (x FeatureSet_EnumType) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FeatureSet_EnumType) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[11].Descriptor()
-}
-
-func (FeatureSet_EnumType) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[11]
-}
-
-func (x FeatureSet_EnumType) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FeatureSet_EnumType) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FeatureSet_EnumType(num)
- return nil
-}
-
-// Deprecated: Use FeatureSet_EnumType.Descriptor instead.
-func (FeatureSet_EnumType) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{19, 1}
-}
-
-type FeatureSet_RepeatedFieldEncoding int32
-
-const (
- FeatureSet_REPEATED_FIELD_ENCODING_UNKNOWN FeatureSet_RepeatedFieldEncoding = 0
- FeatureSet_PACKED FeatureSet_RepeatedFieldEncoding = 1
- FeatureSet_EXPANDED FeatureSet_RepeatedFieldEncoding = 2
-)
-
-// Enum value maps for FeatureSet_RepeatedFieldEncoding.
-var (
- FeatureSet_RepeatedFieldEncoding_name = map[int32]string{
- 0: "REPEATED_FIELD_ENCODING_UNKNOWN",
- 1: "PACKED",
- 2: "EXPANDED",
- }
- FeatureSet_RepeatedFieldEncoding_value = map[string]int32{
- "REPEATED_FIELD_ENCODING_UNKNOWN": 0,
- "PACKED": 1,
- "EXPANDED": 2,
- }
-)
-
-func (x FeatureSet_RepeatedFieldEncoding) Enum() *FeatureSet_RepeatedFieldEncoding {
- p := new(FeatureSet_RepeatedFieldEncoding)
- *p = x
- return p
-}
-
-func (x FeatureSet_RepeatedFieldEncoding) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FeatureSet_RepeatedFieldEncoding) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[12].Descriptor()
-}
-
-func (FeatureSet_RepeatedFieldEncoding) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[12]
-}
-
-func (x FeatureSet_RepeatedFieldEncoding) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FeatureSet_RepeatedFieldEncoding) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FeatureSet_RepeatedFieldEncoding(num)
- return nil
-}
-
-// Deprecated: Use FeatureSet_RepeatedFieldEncoding.Descriptor instead.
-func (FeatureSet_RepeatedFieldEncoding) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{19, 2}
-}
-
-type FeatureSet_Utf8Validation int32
-
-const (
- FeatureSet_UTF8_VALIDATION_UNKNOWN FeatureSet_Utf8Validation = 0
- FeatureSet_VERIFY FeatureSet_Utf8Validation = 2
- FeatureSet_NONE FeatureSet_Utf8Validation = 3
-)
-
-// Enum value maps for FeatureSet_Utf8Validation.
-var (
- FeatureSet_Utf8Validation_name = map[int32]string{
- 0: "UTF8_VALIDATION_UNKNOWN",
- 2: "VERIFY",
- 3: "NONE",
- }
- FeatureSet_Utf8Validation_value = map[string]int32{
- "UTF8_VALIDATION_UNKNOWN": 0,
- "VERIFY": 2,
- "NONE": 3,
- }
-)
-
-func (x FeatureSet_Utf8Validation) Enum() *FeatureSet_Utf8Validation {
- p := new(FeatureSet_Utf8Validation)
- *p = x
- return p
-}
-
-func (x FeatureSet_Utf8Validation) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FeatureSet_Utf8Validation) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[13].Descriptor()
-}
-
-func (FeatureSet_Utf8Validation) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[13]
-}
-
-func (x FeatureSet_Utf8Validation) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FeatureSet_Utf8Validation) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FeatureSet_Utf8Validation(num)
- return nil
-}
-
-// Deprecated: Use FeatureSet_Utf8Validation.Descriptor instead.
-func (FeatureSet_Utf8Validation) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{19, 3}
-}
-
-type FeatureSet_MessageEncoding int32
-
-const (
- FeatureSet_MESSAGE_ENCODING_UNKNOWN FeatureSet_MessageEncoding = 0
- FeatureSet_LENGTH_PREFIXED FeatureSet_MessageEncoding = 1
- FeatureSet_DELIMITED FeatureSet_MessageEncoding = 2
-)
-
-// Enum value maps for FeatureSet_MessageEncoding.
-var (
- FeatureSet_MessageEncoding_name = map[int32]string{
- 0: "MESSAGE_ENCODING_UNKNOWN",
- 1: "LENGTH_PREFIXED",
- 2: "DELIMITED",
- }
- FeatureSet_MessageEncoding_value = map[string]int32{
- "MESSAGE_ENCODING_UNKNOWN": 0,
- "LENGTH_PREFIXED": 1,
- "DELIMITED": 2,
- }
-)
-
-func (x FeatureSet_MessageEncoding) Enum() *FeatureSet_MessageEncoding {
- p := new(FeatureSet_MessageEncoding)
- *p = x
- return p
-}
-
-func (x FeatureSet_MessageEncoding) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FeatureSet_MessageEncoding) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[14].Descriptor()
-}
-
-func (FeatureSet_MessageEncoding) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[14]
-}
-
-func (x FeatureSet_MessageEncoding) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FeatureSet_MessageEncoding) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FeatureSet_MessageEncoding(num)
- return nil
-}
-
-// Deprecated: Use FeatureSet_MessageEncoding.Descriptor instead.
-func (FeatureSet_MessageEncoding) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{19, 4}
-}
-
-type FeatureSet_JsonFormat int32
-
-const (
- FeatureSet_JSON_FORMAT_UNKNOWN FeatureSet_JsonFormat = 0
- FeatureSet_ALLOW FeatureSet_JsonFormat = 1
- FeatureSet_LEGACY_BEST_EFFORT FeatureSet_JsonFormat = 2
-)
-
-// Enum value maps for FeatureSet_JsonFormat.
-var (
- FeatureSet_JsonFormat_name = map[int32]string{
- 0: "JSON_FORMAT_UNKNOWN",
- 1: "ALLOW",
- 2: "LEGACY_BEST_EFFORT",
- }
- FeatureSet_JsonFormat_value = map[string]int32{
- "JSON_FORMAT_UNKNOWN": 0,
- "ALLOW": 1,
- "LEGACY_BEST_EFFORT": 2,
- }
-)
-
-func (x FeatureSet_JsonFormat) Enum() *FeatureSet_JsonFormat {
- p := new(FeatureSet_JsonFormat)
- *p = x
- return p
-}
-
-func (x FeatureSet_JsonFormat) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (FeatureSet_JsonFormat) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[15].Descriptor()
-}
-
-func (FeatureSet_JsonFormat) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[15]
-}
-
-func (x FeatureSet_JsonFormat) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *FeatureSet_JsonFormat) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = FeatureSet_JsonFormat(num)
- return nil
-}
-
-// Deprecated: Use FeatureSet_JsonFormat.Descriptor instead.
-func (FeatureSet_JsonFormat) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{19, 5}
-}
-
-// Represents the identified object's effect on the element in the original
-// .proto file.
-type GeneratedCodeInfo_Annotation_Semantic int32
-
-const (
- // There is no effect or the effect is indescribable.
- GeneratedCodeInfo_Annotation_NONE GeneratedCodeInfo_Annotation_Semantic = 0
- // The element is set or otherwise mutated.
- GeneratedCodeInfo_Annotation_SET GeneratedCodeInfo_Annotation_Semantic = 1
- // An alias to the element is returned.
- GeneratedCodeInfo_Annotation_ALIAS GeneratedCodeInfo_Annotation_Semantic = 2
-)
-
-// Enum value maps for GeneratedCodeInfo_Annotation_Semantic.
-var (
- GeneratedCodeInfo_Annotation_Semantic_name = map[int32]string{
- 0: "NONE",
- 1: "SET",
- 2: "ALIAS",
- }
- GeneratedCodeInfo_Annotation_Semantic_value = map[string]int32{
- "NONE": 0,
- "SET": 1,
- "ALIAS": 2,
- }
-)
-
-func (x GeneratedCodeInfo_Annotation_Semantic) Enum() *GeneratedCodeInfo_Annotation_Semantic {
- p := new(GeneratedCodeInfo_Annotation_Semantic)
- *p = x
- return p
-}
-
-func (x GeneratedCodeInfo_Annotation_Semantic) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (GeneratedCodeInfo_Annotation_Semantic) Descriptor() protoreflect.EnumDescriptor {
- return file_google_protobuf_descriptor_proto_enumTypes[16].Descriptor()
-}
-
-func (GeneratedCodeInfo_Annotation_Semantic) Type() protoreflect.EnumType {
- return &file_google_protobuf_descriptor_proto_enumTypes[16]
-}
-
-func (x GeneratedCodeInfo_Annotation_Semantic) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *GeneratedCodeInfo_Annotation_Semantic) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = GeneratedCodeInfo_Annotation_Semantic(num)
- return nil
-}
-
-// Deprecated: Use GeneratedCodeInfo_Annotation_Semantic.Descriptor instead.
-func (GeneratedCodeInfo_Annotation_Semantic) EnumDescriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{22, 0, 0}
-}
-
-// The protocol compiler can output a FileDescriptorSet containing the .proto
-// files it parses.
-type FileDescriptorSet struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- File []*FileDescriptorProto `protobuf:"bytes,1,rep,name=file" json:"file,omitempty"`
- extensionFields protoimpl.ExtensionFields
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *FileDescriptorSet) Reset() {
- *x = FileDescriptorSet{}
- mi := &file_google_protobuf_descriptor_proto_msgTypes[0]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *FileDescriptorSet) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*FileDescriptorSet) ProtoMessage() {}
-
-func (x *FileDescriptorSet) ProtoReflect() protoreflect.Message {
- mi := &file_google_protobuf_descriptor_proto_msgTypes[0]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use FileDescriptorSet.ProtoReflect.Descriptor instead.
-func (*FileDescriptorSet) Descriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{0}
-}
-
-func (x *FileDescriptorSet) GetFile() []*FileDescriptorProto {
- if x != nil {
- return x.File
- }
- return nil
-}
-
-// Describes a complete .proto file.
-type FileDescriptorProto struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` // file name, relative to root of source tree
- Package *string `protobuf:"bytes,2,opt,name=package" json:"package,omitempty"` // e.g. "foo", "foo.bar", etc.
- // Names of files imported by this file.
- Dependency []string `protobuf:"bytes,3,rep,name=dependency" json:"dependency,omitempty"`
- // Indexes of the public imported files in the dependency list above.
- PublicDependency []int32 `protobuf:"varint,10,rep,name=public_dependency,json=publicDependency" json:"public_dependency,omitempty"`
- // Indexes of the weak imported files in the dependency list.
- // For Google-internal migration only. Do not use.
- WeakDependency []int32 `protobuf:"varint,11,rep,name=weak_dependency,json=weakDependency" json:"weak_dependency,omitempty"`
- // All top-level definitions in this file.
- MessageType []*DescriptorProto `protobuf:"bytes,4,rep,name=message_type,json=messageType" json:"message_type,omitempty"`
- EnumType []*EnumDescriptorProto `protobuf:"bytes,5,rep,name=enum_type,json=enumType" json:"enum_type,omitempty"`
- Service []*ServiceDescriptorProto `protobuf:"bytes,6,rep,name=service" json:"service,omitempty"`
- Extension []*FieldDescriptorProto `protobuf:"bytes,7,rep,name=extension" json:"extension,omitempty"`
- Options *FileOptions `protobuf:"bytes,8,opt,name=options" json:"options,omitempty"`
- // This field contains optional information about the original source code.
- // You may safely remove this entire field without harming runtime
- // functionality of the descriptors -- the information is needed only by
- // development tools.
- SourceCodeInfo *SourceCodeInfo `protobuf:"bytes,9,opt,name=source_code_info,json=sourceCodeInfo" json:"source_code_info,omitempty"`
- // The syntax of the proto file.
- // The supported values are "proto2", "proto3", and "editions".
- //
- // If `edition` is present, this value must be "editions".
- Syntax *string `protobuf:"bytes,12,opt,name=syntax" json:"syntax,omitempty"`
- // The edition of the proto file.
- Edition *Edition `protobuf:"varint,14,opt,name=edition,enum=google.protobuf.Edition" json:"edition,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *FileDescriptorProto) Reset() {
- *x = FileDescriptorProto{}
- mi := &file_google_protobuf_descriptor_proto_msgTypes[1]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *FileDescriptorProto) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*FileDescriptorProto) ProtoMessage() {}
-
-func (x *FileDescriptorProto) ProtoReflect() protoreflect.Message {
- mi := &file_google_protobuf_descriptor_proto_msgTypes[1]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use FileDescriptorProto.ProtoReflect.Descriptor instead.
-func (*FileDescriptorProto) Descriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{1}
-}
-
-func (x *FileDescriptorProto) GetName() string {
- if x != nil && x.Name != nil {
- return *x.Name
- }
- return ""
-}
-
-func (x *FileDescriptorProto) GetPackage() string {
- if x != nil && x.Package != nil {
- return *x.Package
- }
- return ""
-}
-
-func (x *FileDescriptorProto) GetDependency() []string {
- if x != nil {
- return x.Dependency
- }
- return nil
-}
-
-func (x *FileDescriptorProto) GetPublicDependency() []int32 {
- if x != nil {
- return x.PublicDependency
- }
- return nil
-}
-
-func (x *FileDescriptorProto) GetWeakDependency() []int32 {
- if x != nil {
- return x.WeakDependency
- }
- return nil
-}
-
-func (x *FileDescriptorProto) GetMessageType() []*DescriptorProto {
- if x != nil {
- return x.MessageType
- }
- return nil
-}
-
-func (x *FileDescriptorProto) GetEnumType() []*EnumDescriptorProto {
- if x != nil {
- return x.EnumType
- }
- return nil
-}
-
-func (x *FileDescriptorProto) GetService() []*ServiceDescriptorProto {
- if x != nil {
- return x.Service
- }
- return nil
-}
-
-func (x *FileDescriptorProto) GetExtension() []*FieldDescriptorProto {
- if x != nil {
- return x.Extension
- }
- return nil
-}
-
-func (x *FileDescriptorProto) GetOptions() *FileOptions {
- if x != nil {
- return x.Options
- }
- return nil
-}
-
-func (x *FileDescriptorProto) GetSourceCodeInfo() *SourceCodeInfo {
- if x != nil {
- return x.SourceCodeInfo
- }
- return nil
-}
-
-func (x *FileDescriptorProto) GetSyntax() string {
- if x != nil && x.Syntax != nil {
- return *x.Syntax
- }
- return ""
-}
-
-func (x *FileDescriptorProto) GetEdition() Edition {
- if x != nil && x.Edition != nil {
- return *x.Edition
- }
- return Edition_EDITION_UNKNOWN
-}
-
-// Describes a message type.
-type DescriptorProto struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
- Field []*FieldDescriptorProto `protobuf:"bytes,2,rep,name=field" json:"field,omitempty"`
- Extension []*FieldDescriptorProto `protobuf:"bytes,6,rep,name=extension" json:"extension,omitempty"`
- NestedType []*DescriptorProto `protobuf:"bytes,3,rep,name=nested_type,json=nestedType" json:"nested_type,omitempty"`
- EnumType []*EnumDescriptorProto `protobuf:"bytes,4,rep,name=enum_type,json=enumType" json:"enum_type,omitempty"`
- ExtensionRange []*DescriptorProto_ExtensionRange `protobuf:"bytes,5,rep,name=extension_range,json=extensionRange" json:"extension_range,omitempty"`
- OneofDecl []*OneofDescriptorProto `protobuf:"bytes,8,rep,name=oneof_decl,json=oneofDecl" json:"oneof_decl,omitempty"`
- Options *MessageOptions `protobuf:"bytes,7,opt,name=options" json:"options,omitempty"`
- ReservedRange []*DescriptorProto_ReservedRange `protobuf:"bytes,9,rep,name=reserved_range,json=reservedRange" json:"reserved_range,omitempty"`
- // Reserved field names, which may not be used by fields in the same message.
- // A given name may only be reserved once.
- ReservedName []string `protobuf:"bytes,10,rep,name=reserved_name,json=reservedName" json:"reserved_name,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *DescriptorProto) Reset() {
- *x = DescriptorProto{}
- mi := &file_google_protobuf_descriptor_proto_msgTypes[2]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *DescriptorProto) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*DescriptorProto) ProtoMessage() {}
-
-func (x *DescriptorProto) ProtoReflect() protoreflect.Message {
- mi := &file_google_protobuf_descriptor_proto_msgTypes[2]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use DescriptorProto.ProtoReflect.Descriptor instead.
-func (*DescriptorProto) Descriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{2}
-}
-
-func (x *DescriptorProto) GetName() string {
- if x != nil && x.Name != nil {
- return *x.Name
- }
- return ""
-}
-
-func (x *DescriptorProto) GetField() []*FieldDescriptorProto {
- if x != nil {
- return x.Field
- }
- return nil
-}
-
-func (x *DescriptorProto) GetExtension() []*FieldDescriptorProto {
- if x != nil {
- return x.Extension
- }
- return nil
-}
-
-func (x *DescriptorProto) GetNestedType() []*DescriptorProto {
- if x != nil {
- return x.NestedType
- }
- return nil
-}
-
-func (x *DescriptorProto) GetEnumType() []*EnumDescriptorProto {
- if x != nil {
- return x.EnumType
- }
- return nil
-}
-
-func (x *DescriptorProto) GetExtensionRange() []*DescriptorProto_ExtensionRange {
- if x != nil {
- return x.ExtensionRange
- }
- return nil
-}
-
-func (x *DescriptorProto) GetOneofDecl() []*OneofDescriptorProto {
- if x != nil {
- return x.OneofDecl
- }
- return nil
-}
-
-func (x *DescriptorProto) GetOptions() *MessageOptions {
- if x != nil {
- return x.Options
- }
- return nil
-}
-
-func (x *DescriptorProto) GetReservedRange() []*DescriptorProto_ReservedRange {
- if x != nil {
- return x.ReservedRange
- }
- return nil
-}
-
-func (x *DescriptorProto) GetReservedName() []string {
- if x != nil {
- return x.ReservedName
- }
- return nil
-}
-
-type ExtensionRangeOptions struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // The parser stores options it doesn't recognize here. See above.
- UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
- // For external users: DO NOT USE. We are in the process of open sourcing
- // extension declaration and executing internal cleanups before it can be
- // used externally.
- Declaration []*ExtensionRangeOptions_Declaration `protobuf:"bytes,2,rep,name=declaration" json:"declaration,omitempty"`
- // Any features defined in the specific edition.
- Features *FeatureSet `protobuf:"bytes,50,opt,name=features" json:"features,omitempty"`
- // The verification state of the range.
- // TODO: flip the default to DECLARATION once all empty ranges
- // are marked as UNVERIFIED.
- Verification *ExtensionRangeOptions_VerificationState `protobuf:"varint,3,opt,name=verification,enum=google.protobuf.ExtensionRangeOptions_VerificationState,def=1" json:"verification,omitempty"`
- extensionFields protoimpl.ExtensionFields
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-// Default values for ExtensionRangeOptions fields.
-const (
- Default_ExtensionRangeOptions_Verification = ExtensionRangeOptions_UNVERIFIED
-)
-
-func (x *ExtensionRangeOptions) Reset() {
- *x = ExtensionRangeOptions{}
- mi := &file_google_protobuf_descriptor_proto_msgTypes[3]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *ExtensionRangeOptions) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*ExtensionRangeOptions) ProtoMessage() {}
-
-func (x *ExtensionRangeOptions) ProtoReflect() protoreflect.Message {
- mi := &file_google_protobuf_descriptor_proto_msgTypes[3]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use ExtensionRangeOptions.ProtoReflect.Descriptor instead.
-func (*ExtensionRangeOptions) Descriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{3}
-}
-
-func (x *ExtensionRangeOptions) GetUninterpretedOption() []*UninterpretedOption {
- if x != nil {
- return x.UninterpretedOption
- }
- return nil
-}
-
-func (x *ExtensionRangeOptions) GetDeclaration() []*ExtensionRangeOptions_Declaration {
- if x != nil {
- return x.Declaration
- }
- return nil
-}
-
-func (x *ExtensionRangeOptions) GetFeatures() *FeatureSet {
- if x != nil {
- return x.Features
- }
- return nil
-}
-
-func (x *ExtensionRangeOptions) GetVerification() ExtensionRangeOptions_VerificationState {
- if x != nil && x.Verification != nil {
- return *x.Verification
- }
- return Default_ExtensionRangeOptions_Verification
-}
-
-// Describes a field within a message.
-type FieldDescriptorProto struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
- Number *int32 `protobuf:"varint,3,opt,name=number" json:"number,omitempty"`
- Label *FieldDescriptorProto_Label `protobuf:"varint,4,opt,name=label,enum=google.protobuf.FieldDescriptorProto_Label" json:"label,omitempty"`
- // If type_name is set, this need not be set. If both this and type_name
- // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
- Type *FieldDescriptorProto_Type `protobuf:"varint,5,opt,name=type,enum=google.protobuf.FieldDescriptorProto_Type" json:"type,omitempty"`
- // For message and enum types, this is the name of the type. If the name
- // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
- // rules are used to find the type (i.e. first the nested types within this
- // message are searched, then within the parent, on up to the root
- // namespace).
- TypeName *string `protobuf:"bytes,6,opt,name=type_name,json=typeName" json:"type_name,omitempty"`
- // For extensions, this is the name of the type being extended. It is
- // resolved in the same manner as type_name.
- Extendee *string `protobuf:"bytes,2,opt,name=extendee" json:"extendee,omitempty"`
- // For numeric types, contains the original text representation of the value.
- // For booleans, "true" or "false".
- // For strings, contains the default text contents (not escaped in any way).
- // For bytes, contains the C escaped value. All bytes >= 128 are escaped.
- DefaultValue *string `protobuf:"bytes,7,opt,name=default_value,json=defaultValue" json:"default_value,omitempty"`
- // If set, gives the index of a oneof in the containing type's oneof_decl
- // list. This field is a member of that oneof.
- OneofIndex *int32 `protobuf:"varint,9,opt,name=oneof_index,json=oneofIndex" json:"oneof_index,omitempty"`
- // JSON name of this field. The value is set by protocol compiler. If the
- // user has set a "json_name" option on this field, that option's value
- // will be used. Otherwise, it's deduced from the field's name by converting
- // it to camelCase.
- JsonName *string `protobuf:"bytes,10,opt,name=json_name,json=jsonName" json:"json_name,omitempty"`
- Options *FieldOptions `protobuf:"bytes,8,opt,name=options" json:"options,omitempty"`
- // If true, this is a proto3 "optional". When a proto3 field is optional, it
- // tracks presence regardless of field type.
- //
- // When proto3_optional is true, this field must belong to a oneof to signal
- // to old proto3 clients that presence is tracked for this field. This oneof
- // is known as a "synthetic" oneof, and this field must be its sole member
- // (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs
- // exist in the descriptor only, and do not generate any API. Synthetic oneofs
- // must be ordered after all "real" oneofs.
- //
- // For message fields, proto3_optional doesn't create any semantic change,
- // since non-repeated message fields always track presence. However it still
- // indicates the semantic detail of whether the user wrote "optional" or not.
- // This can be useful for round-tripping the .proto file. For consistency we
- // give message fields a synthetic oneof also, even though it is not required
- // to track presence. This is especially important because the parser can't
- // tell if a field is a message or an enum, so it must always create a
- // synthetic oneof.
- //
- // Proto2 optional fields do not set this flag, because they already indicate
- // optional with `LABEL_OPTIONAL`.
- Proto3Optional *bool `protobuf:"varint,17,opt,name=proto3_optional,json=proto3Optional" json:"proto3_optional,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *FieldDescriptorProto) Reset() {
- *x = FieldDescriptorProto{}
- mi := &file_google_protobuf_descriptor_proto_msgTypes[4]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *FieldDescriptorProto) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*FieldDescriptorProto) ProtoMessage() {}
-
-func (x *FieldDescriptorProto) ProtoReflect() protoreflect.Message {
- mi := &file_google_protobuf_descriptor_proto_msgTypes[4]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use FieldDescriptorProto.ProtoReflect.Descriptor instead.
-func (*FieldDescriptorProto) Descriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{4}
-}
-
-func (x *FieldDescriptorProto) GetName() string {
- if x != nil && x.Name != nil {
- return *x.Name
- }
- return ""
-}
-
-func (x *FieldDescriptorProto) GetNumber() int32 {
- if x != nil && x.Number != nil {
- return *x.Number
- }
- return 0
-}
-
-func (x *FieldDescriptorProto) GetLabel() FieldDescriptorProto_Label {
- if x != nil && x.Label != nil {
- return *x.Label
- }
- return FieldDescriptorProto_LABEL_OPTIONAL
-}
-
-func (x *FieldDescriptorProto) GetType() FieldDescriptorProto_Type {
- if x != nil && x.Type != nil {
- return *x.Type
- }
- return FieldDescriptorProto_TYPE_DOUBLE
-}
-
-func (x *FieldDescriptorProto) GetTypeName() string {
- if x != nil && x.TypeName != nil {
- return *x.TypeName
- }
- return ""
-}
-
-func (x *FieldDescriptorProto) GetExtendee() string {
- if x != nil && x.Extendee != nil {
- return *x.Extendee
- }
- return ""
-}
-
-func (x *FieldDescriptorProto) GetDefaultValue() string {
- if x != nil && x.DefaultValue != nil {
- return *x.DefaultValue
- }
- return ""
-}
-
-func (x *FieldDescriptorProto) GetOneofIndex() int32 {
- if x != nil && x.OneofIndex != nil {
- return *x.OneofIndex
- }
- return 0
-}
-
-func (x *FieldDescriptorProto) GetJsonName() string {
- if x != nil && x.JsonName != nil {
- return *x.JsonName
- }
- return ""
-}
-
-func (x *FieldDescriptorProto) GetOptions() *FieldOptions {
- if x != nil {
- return x.Options
- }
- return nil
-}
-
-func (x *FieldDescriptorProto) GetProto3Optional() bool {
- if x != nil && x.Proto3Optional != nil {
- return *x.Proto3Optional
- }
- return false
-}
-
-// Describes a oneof.
-type OneofDescriptorProto struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
- Options *OneofOptions `protobuf:"bytes,2,opt,name=options" json:"options,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *OneofDescriptorProto) Reset() {
- *x = OneofDescriptorProto{}
- mi := &file_google_protobuf_descriptor_proto_msgTypes[5]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *OneofDescriptorProto) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*OneofDescriptorProto) ProtoMessage() {}
-
-func (x *OneofDescriptorProto) ProtoReflect() protoreflect.Message {
- mi := &file_google_protobuf_descriptor_proto_msgTypes[5]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use OneofDescriptorProto.ProtoReflect.Descriptor instead.
-func (*OneofDescriptorProto) Descriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{5}
-}
-
-func (x *OneofDescriptorProto) GetName() string {
- if x != nil && x.Name != nil {
- return *x.Name
- }
- return ""
-}
-
-func (x *OneofDescriptorProto) GetOptions() *OneofOptions {
- if x != nil {
- return x.Options
- }
- return nil
-}
-
-// Describes an enum type.
-type EnumDescriptorProto struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
- Value []*EnumValueDescriptorProto `protobuf:"bytes,2,rep,name=value" json:"value,omitempty"`
- Options *EnumOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"`
- // Range of reserved numeric values. Reserved numeric values may not be used
- // by enum values in the same enum declaration. Reserved ranges may not
- // overlap.
- ReservedRange []*EnumDescriptorProto_EnumReservedRange `protobuf:"bytes,4,rep,name=reserved_range,json=reservedRange" json:"reserved_range,omitempty"`
- // Reserved enum value names, which may not be reused. A given name may only
- // be reserved once.
- ReservedName []string `protobuf:"bytes,5,rep,name=reserved_name,json=reservedName" json:"reserved_name,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *EnumDescriptorProto) Reset() {
- *x = EnumDescriptorProto{}
- mi := &file_google_protobuf_descriptor_proto_msgTypes[6]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *EnumDescriptorProto) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*EnumDescriptorProto) ProtoMessage() {}
-
-func (x *EnumDescriptorProto) ProtoReflect() protoreflect.Message {
- mi := &file_google_protobuf_descriptor_proto_msgTypes[6]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use EnumDescriptorProto.ProtoReflect.Descriptor instead.
-func (*EnumDescriptorProto) Descriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{6}
-}
-
-func (x *EnumDescriptorProto) GetName() string {
- if x != nil && x.Name != nil {
- return *x.Name
- }
- return ""
-}
-
-func (x *EnumDescriptorProto) GetValue() []*EnumValueDescriptorProto {
- if x != nil {
- return x.Value
- }
- return nil
-}
-
-func (x *EnumDescriptorProto) GetOptions() *EnumOptions {
- if x != nil {
- return x.Options
- }
- return nil
-}
-
-func (x *EnumDescriptorProto) GetReservedRange() []*EnumDescriptorProto_EnumReservedRange {
- if x != nil {
- return x.ReservedRange
- }
- return nil
-}
-
-func (x *EnumDescriptorProto) GetReservedName() []string {
- if x != nil {
- return x.ReservedName
- }
- return nil
-}
-
-// Describes a value within an enum.
-type EnumValueDescriptorProto struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
- Number *int32 `protobuf:"varint,2,opt,name=number" json:"number,omitempty"`
- Options *EnumValueOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *EnumValueDescriptorProto) Reset() {
- *x = EnumValueDescriptorProto{}
- mi := &file_google_protobuf_descriptor_proto_msgTypes[7]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *EnumValueDescriptorProto) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*EnumValueDescriptorProto) ProtoMessage() {}
-
-func (x *EnumValueDescriptorProto) ProtoReflect() protoreflect.Message {
- mi := &file_google_protobuf_descriptor_proto_msgTypes[7]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use EnumValueDescriptorProto.ProtoReflect.Descriptor instead.
-func (*EnumValueDescriptorProto) Descriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{7}
-}
-
-func (x *EnumValueDescriptorProto) GetName() string {
- if x != nil && x.Name != nil {
- return *x.Name
- }
- return ""
-}
-
-func (x *EnumValueDescriptorProto) GetNumber() int32 {
- if x != nil && x.Number != nil {
- return *x.Number
- }
- return 0
-}
-
-func (x *EnumValueDescriptorProto) GetOptions() *EnumValueOptions {
- if x != nil {
- return x.Options
- }
- return nil
-}
-
-// Describes a service.
-type ServiceDescriptorProto struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
- Method []*MethodDescriptorProto `protobuf:"bytes,2,rep,name=method" json:"method,omitempty"`
- Options *ServiceOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *ServiceDescriptorProto) Reset() {
- *x = ServiceDescriptorProto{}
- mi := &file_google_protobuf_descriptor_proto_msgTypes[8]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *ServiceDescriptorProto) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*ServiceDescriptorProto) ProtoMessage() {}
-
-func (x *ServiceDescriptorProto) ProtoReflect() protoreflect.Message {
- mi := &file_google_protobuf_descriptor_proto_msgTypes[8]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use ServiceDescriptorProto.ProtoReflect.Descriptor instead.
-func (*ServiceDescriptorProto) Descriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{8}
-}
-
-func (x *ServiceDescriptorProto) GetName() string {
- if x != nil && x.Name != nil {
- return *x.Name
- }
- return ""
-}
-
-func (x *ServiceDescriptorProto) GetMethod() []*MethodDescriptorProto {
- if x != nil {
- return x.Method
- }
- return nil
-}
-
-func (x *ServiceDescriptorProto) GetOptions() *ServiceOptions {
- if x != nil {
- return x.Options
- }
- return nil
-}
-
-// Describes a method of a service.
-type MethodDescriptorProto struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
- // Input and output type names. These are resolved in the same way as
- // FieldDescriptorProto.type_name, but must refer to a message type.
- InputType *string `protobuf:"bytes,2,opt,name=input_type,json=inputType" json:"input_type,omitempty"`
- OutputType *string `protobuf:"bytes,3,opt,name=output_type,json=outputType" json:"output_type,omitempty"`
- Options *MethodOptions `protobuf:"bytes,4,opt,name=options" json:"options,omitempty"`
- // Identifies if client streams multiple client messages
- ClientStreaming *bool `protobuf:"varint,5,opt,name=client_streaming,json=clientStreaming,def=0" json:"client_streaming,omitempty"`
- // Identifies if server streams multiple server messages
- ServerStreaming *bool `protobuf:"varint,6,opt,name=server_streaming,json=serverStreaming,def=0" json:"server_streaming,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-// Default values for MethodDescriptorProto fields.
-const (
- Default_MethodDescriptorProto_ClientStreaming = bool(false)
- Default_MethodDescriptorProto_ServerStreaming = bool(false)
-)
-
-func (x *MethodDescriptorProto) Reset() {
- *x = MethodDescriptorProto{}
- mi := &file_google_protobuf_descriptor_proto_msgTypes[9]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *MethodDescriptorProto) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*MethodDescriptorProto) ProtoMessage() {}
-
-func (x *MethodDescriptorProto) ProtoReflect() protoreflect.Message {
- mi := &file_google_protobuf_descriptor_proto_msgTypes[9]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use MethodDescriptorProto.ProtoReflect.Descriptor instead.
-func (*MethodDescriptorProto) Descriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{9}
-}
-
-func (x *MethodDescriptorProto) GetName() string {
- if x != nil && x.Name != nil {
- return *x.Name
- }
- return ""
-}
-
-func (x *MethodDescriptorProto) GetInputType() string {
- if x != nil && x.InputType != nil {
- return *x.InputType
- }
- return ""
-}
-
-func (x *MethodDescriptorProto) GetOutputType() string {
- if x != nil && x.OutputType != nil {
- return *x.OutputType
- }
- return ""
-}
-
-func (x *MethodDescriptorProto) GetOptions() *MethodOptions {
- if x != nil {
- return x.Options
- }
- return nil
-}
-
-func (x *MethodDescriptorProto) GetClientStreaming() bool {
- if x != nil && x.ClientStreaming != nil {
- return *x.ClientStreaming
- }
- return Default_MethodDescriptorProto_ClientStreaming
-}
-
-func (x *MethodDescriptorProto) GetServerStreaming() bool {
- if x != nil && x.ServerStreaming != nil {
- return *x.ServerStreaming
- }
- return Default_MethodDescriptorProto_ServerStreaming
-}
-
-type FileOptions struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // Sets the Java package where classes generated from this .proto will be
- // placed. By default, the proto package is used, but this is often
- // inappropriate because proto packages do not normally start with backwards
- // domain names.
- JavaPackage *string `protobuf:"bytes,1,opt,name=java_package,json=javaPackage" json:"java_package,omitempty"`
- // Controls the name of the wrapper Java class generated for the .proto file.
- // That class will always contain the .proto file's getDescriptor() method as
- // well as any top-level extensions defined in the .proto file.
- // If java_multiple_files is disabled, then all the other classes from the
- // .proto file will be nested inside the single wrapper outer class.
- JavaOuterClassname *string `protobuf:"bytes,8,opt,name=java_outer_classname,json=javaOuterClassname" json:"java_outer_classname,omitempty"`
- // If enabled, then the Java code generator will generate a separate .java
- // file for each top-level message, enum, and service defined in the .proto
- // file. Thus, these types will *not* be nested inside the wrapper class
- // named by java_outer_classname. However, the wrapper class will still be
- // generated to contain the file's getDescriptor() method as well as any
- // top-level extensions defined in the file.
- JavaMultipleFiles *bool `protobuf:"varint,10,opt,name=java_multiple_files,json=javaMultipleFiles,def=0" json:"java_multiple_files,omitempty"`
- // This option does nothing.
- //
- // Deprecated: Marked as deprecated in google/protobuf/descriptor.proto.
- JavaGenerateEqualsAndHash *bool `protobuf:"varint,20,opt,name=java_generate_equals_and_hash,json=javaGenerateEqualsAndHash" json:"java_generate_equals_and_hash,omitempty"`
- // A proto2 file can set this to true to opt in to UTF-8 checking for Java,
- // which will throw an exception if invalid UTF-8 is parsed from the wire or
- // assigned to a string field.
- //
- // TODO: clarify exactly what kinds of field types this option
- // applies to, and update these docs accordingly.
- //
- // Proto3 files already perform these checks. Setting the option explicitly to
- // false has no effect: it cannot be used to opt proto3 files out of UTF-8
- // checks.
- JavaStringCheckUtf8 *bool `protobuf:"varint,27,opt,name=java_string_check_utf8,json=javaStringCheckUtf8,def=0" json:"java_string_check_utf8,omitempty"`
- OptimizeFor *FileOptions_OptimizeMode `protobuf:"varint,9,opt,name=optimize_for,json=optimizeFor,enum=google.protobuf.FileOptions_OptimizeMode,def=1" json:"optimize_for,omitempty"`
- // Sets the Go package where structs generated from this .proto will be
- // placed. If omitted, the Go package will be derived from the following:
- // - The basename of the package import path, if provided.
- // - Otherwise, the package statement in the .proto file, if present.
- // - Otherwise, the basename of the .proto file, without extension.
- GoPackage *string `protobuf:"bytes,11,opt,name=go_package,json=goPackage" json:"go_package,omitempty"`
- // Should generic services be generated in each language? "Generic" services
- // are not specific to any particular RPC system. They are generated by the
- // main code generators in each language (without additional plugins).
- // Generic services were the only kind of service generation supported by
- // early versions of google.protobuf.
- //
- // Generic services are now considered deprecated in favor of using plugins
- // that generate code specific to your particular RPC system. Therefore,
- // these default to false. Old code which depends on generic services should
- // explicitly set them to true.
- CcGenericServices *bool `protobuf:"varint,16,opt,name=cc_generic_services,json=ccGenericServices,def=0" json:"cc_generic_services,omitempty"`
- JavaGenericServices *bool `protobuf:"varint,17,opt,name=java_generic_services,json=javaGenericServices,def=0" json:"java_generic_services,omitempty"`
- PyGenericServices *bool `protobuf:"varint,18,opt,name=py_generic_services,json=pyGenericServices,def=0" json:"py_generic_services,omitempty"`
- // Is this file deprecated?
- // Depending on the target platform, this can emit Deprecated annotations
- // for everything in the file, or it will be completely ignored; in the very
- // least, this is a formalization for deprecating files.
- Deprecated *bool `protobuf:"varint,23,opt,name=deprecated,def=0" json:"deprecated,omitempty"`
- // Enables the use of arenas for the proto messages in this file. This applies
- // only to generated classes for C++.
- CcEnableArenas *bool `protobuf:"varint,31,opt,name=cc_enable_arenas,json=ccEnableArenas,def=1" json:"cc_enable_arenas,omitempty"`
- // Sets the objective c class prefix which is prepended to all objective c
- // generated classes from this .proto. There is no default.
- ObjcClassPrefix *string `protobuf:"bytes,36,opt,name=objc_class_prefix,json=objcClassPrefix" json:"objc_class_prefix,omitempty"`
- // Namespace for generated classes; defaults to the package.
- CsharpNamespace *string `protobuf:"bytes,37,opt,name=csharp_namespace,json=csharpNamespace" json:"csharp_namespace,omitempty"`
- // By default Swift generators will take the proto package and CamelCase it
- // replacing '.' with underscore and use that to prefix the types/symbols
- // defined. When this options is provided, they will use this value instead
- // to prefix the types/symbols defined.
- SwiftPrefix *string `protobuf:"bytes,39,opt,name=swift_prefix,json=swiftPrefix" json:"swift_prefix,omitempty"`
- // Sets the php class prefix which is prepended to all php generated classes
- // from this .proto. Default is empty.
- PhpClassPrefix *string `protobuf:"bytes,40,opt,name=php_class_prefix,json=phpClassPrefix" json:"php_class_prefix,omitempty"`
- // Use this option to change the namespace of php generated classes. Default
- // is empty. When this option is empty, the package name will be used for
- // determining the namespace.
- PhpNamespace *string `protobuf:"bytes,41,opt,name=php_namespace,json=phpNamespace" json:"php_namespace,omitempty"`
- // Use this option to change the namespace of php generated metadata classes.
- // Default is empty. When this option is empty, the proto file name will be
- // used for determining the namespace.
- PhpMetadataNamespace *string `protobuf:"bytes,44,opt,name=php_metadata_namespace,json=phpMetadataNamespace" json:"php_metadata_namespace,omitempty"`
- // Use this option to change the package of ruby generated classes. Default
- // is empty. When this option is not set, the package name will be used for
- // determining the ruby package.
- RubyPackage *string `protobuf:"bytes,45,opt,name=ruby_package,json=rubyPackage" json:"ruby_package,omitempty"`
- // Any features defined in the specific edition.
- Features *FeatureSet `protobuf:"bytes,50,opt,name=features" json:"features,omitempty"`
- // The parser stores options it doesn't recognize here.
- // See the documentation for the "Options" section above.
- UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
- extensionFields protoimpl.ExtensionFields
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-// Default values for FileOptions fields.
-const (
- Default_FileOptions_JavaMultipleFiles = bool(false)
- Default_FileOptions_JavaStringCheckUtf8 = bool(false)
- Default_FileOptions_OptimizeFor = FileOptions_SPEED
- Default_FileOptions_CcGenericServices = bool(false)
- Default_FileOptions_JavaGenericServices = bool(false)
- Default_FileOptions_PyGenericServices = bool(false)
- Default_FileOptions_Deprecated = bool(false)
- Default_FileOptions_CcEnableArenas = bool(true)
-)
-
-func (x *FileOptions) Reset() {
- *x = FileOptions{}
- mi := &file_google_protobuf_descriptor_proto_msgTypes[10]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *FileOptions) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*FileOptions) ProtoMessage() {}
-
-func (x *FileOptions) ProtoReflect() protoreflect.Message {
- mi := &file_google_protobuf_descriptor_proto_msgTypes[10]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use FileOptions.ProtoReflect.Descriptor instead.
-func (*FileOptions) Descriptor() ([]byte, []int) {
- return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{10}
-}
-
-func (x *FileOptions) GetJavaPackage() string {
- if x != nil && x.JavaPackage != nil {
- return *x.JavaPackage
- }
- return ""
-}
-
-func (x *FileOptions) GetJavaOuterClassname() string {
- if x != nil && x.JavaOuterClassname != nil {
- return *x.JavaOuterClassname
- }
- return ""
-}
-
-func (x *FileOptions) GetJavaMultipleFiles() bool {
- if x != nil && x.JavaMultipleFiles != nil {
- return *x.JavaMultipleFiles
- }
- return Default_FileOptions_JavaMultipleFiles
-}
-
-// Deprecated: Marked as deprecated in google/protobuf/descriptor.proto.
-func (x *FileOptions) GetJavaGenerateEqualsAndHash() bool {
- if x != nil && x.JavaGenerateEqualsAndHash != nil {
- return *x.JavaGenerateEqualsAndHash
- }
- return false
-}
-
-func (x *FileOptions) GetJavaStringCheckUtf8() bool {
- if x != nil && x.JavaStringCheckUtf8 != nil {
- return *x.JavaStringCheckUtf8
- }
- return Default_FileOptions_JavaStringCheckUtf8
-}
-
-func (x *FileOptions) GetOptimizeFor() FileOptions_OptimizeMode {
- if x != nil && x.OptimizeFor != nil {
- return *x.OptimizeFor
- }
- return Default_FileOptions_OptimizeFor
-}
-
-func (x *FileOptions) GetGoPackage() string {
- if x != nil && x.GoPackage != nil {
- return *x.GoPackage
- }
- return ""
-}
-
-func (x *FileOptions) GetCcGenericServices() bool {
- if x != nil && x.CcGenericServices != nil {
- return *x.CcGenericServices
- }
- return Default_FileOptions_CcGenericServices
-}
-
-func (x *FileOptions) GetJavaGenericServices() bool {
- if x != nil && x.JavaGenericServices != nil {
- return *x.JavaGenericServices
- }
- return Default_FileOptions_JavaGenericServices
-}
-
-func (x *FileOptions) GetPyGenericServices() bool {
- if x != nil && x.PyGenericServices != nil {
- return *x.PyGenericServices
- }
- return Default_FileOptions_PyGenericServices
-}
-
-func (x *FileOptions) GetDeprecated() bool {
- if x != nil && x.Deprecated != nil {
- return *x.Deprecated
- }
- return Default_FileOptions_Deprecated
-}
-
-func (x *FileOptions) GetCcEnableArenas() bool {
- if x != nil && x.CcEnableArenas != nil {
- return *x.CcEnableArenas
- }
- return Default_FileOptions_CcEnableArenas
-}
-
-func (x *FileOptions) GetObjcClassPrefix() string {
- if x != nil && x.ObjcClassPrefix != nil {
- return *x.ObjcClassPrefix
- }
- return ""
-}
-
-func (x *FileOptions) GetCsharpNamespace() string {
- if x != nil && x.CsharpNamespace != nil {
- return *x.CsharpNamespace
- }
- return ""
-}
-
-func (x *FileOptions) GetSwiftPrefix() string {
- if x != nil && x.SwiftPrefix != nil {
- return *x.SwiftPrefix
- }
- return ""
-}
-
-func (x *FileOptions) GetPhpClassPrefix() string {
- if x != nil && x.PhpClassPrefix != nil {
- return *x.PhpClassPrefix
- }
- return ""
-}
-
-func (x *FileOptions) GetPhpNamespace() string {
- if x != nil && x.PhpNamespace != nil {
- return *x.PhpNamespace
- }
- return ""
-}
-
-func (x *FileOptions) GetPhpMetadataNamespace() string {
- if x != nil && x.PhpMetadataNamespace != nil {
- return *x.PhpMetadataNamespace
- }
- return ""
-}
-
-func (x *FileOptions) GetRubyPackage() string {
- if x != nil && x.RubyPackage != nil {
- return *x.RubyPackage
- }
- return ""
-}
-
-func (x *FileOptions) GetFeatures() *FeatureSet {
- if x != nil {
- return x.Features
- }
- return nil
-}
-
-func (x *FileOptions) GetUninterpretedOption() []*UninterpretedOption {
- if x != nil {
- return x.UninterpretedOption
- }
- return nil
-}
-
-type MessageOptions struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // Set true to use the old proto1 MessageSet wire format for extensions.
- // This is provided for backwards-compatibility with the MessageSet wire
- // format. You should not use this for any other reason: It's less
- // efficient, has fewer features, and is more complicated.
- //
- // The message must be defined exactly as follows:
- //
- // message Foo {
- // option message_set_wire_format = true;
- // extensions 4 to max;
- // }
- //
- // Note that the message cannot have any defined fields; MessageSets only
- // have extensions.
- //
- // All extensions of your type must be singular messages; e.g. they cannot
- // be int32s, enums, or repeated messages.
- //
- // Because this is an option, the above two restrictions are not enforced by
- // the protocol compiler.
- MessageSetWireFormat *bool `protobuf:"varint,1,opt,name=message_set_wire_format,json=messageSetWireFormat,def=0" json:"message_set_wire_format,omitempty"`
- // Disables the generation of the standard "descriptor()" accessor, which can
- // conflict with a field of the same name. This is meant to make migration
- // from proto1 easier; new code should avoid fields named "descriptor".
- NoStandardDescriptorAccessor *bool `protobuf:"varint,2,opt,name=no_standard_descriptor_accessor,json=noStandardDescriptorAccessor,def=0" json:"no_standard_descriptor_accessor,omitempty"`
- // Is this message deprecated?
- // Depending on the target platform, this can emit Deprecated annotations
- // for the message, or it will be completely ignored; in the very least,
- // this is a formalization for deprecating messages.
- Deprecated *bool `protobuf:"varint,3,opt,name=deprecated,def=0" json:"deprecated,omitempty"`
- // Whether the message is an automatically generated map entry type for the
- // maps field.
- //
- // For maps fields:
- //
- // map