Skip to content

Commit

Permalink
Update Go dependencies (vitessio#12215)
Browse files Browse the repository at this point in the history
* Update Go dependencies

This updates the Go dependencies to the latest versions before the
Vitess 16 freeze so we can start with an up to date list.

Also updates vitess-mixin since Dependabot is reporting a bunch of
things on that.

Signed-off-by: Dirkjan Bussink <[email protected]>

* Fix deprecated sets.String

This is now available using generics.

Signed-off-by: Dirkjan Bussink <[email protected]>

* run make proto

Signed-off-by: Florent Poinsard <[email protected]>

* fix e2e test expectations

Signed-off-by: Florent Poinsard <[email protected]>

---------

Signed-off-by: Dirkjan Bussink <[email protected]>
Signed-off-by: Florent Poinsard <[email protected]>
Co-authored-by: Florent Poinsard <[email protected]>
  • Loading branch information
2 people authored and timvaillancourt committed May 29, 2024
1 parent c005649 commit da47696
Show file tree
Hide file tree
Showing 22 changed files with 99 additions and 99 deletions.
10 changes: 5 additions & 5 deletions go/flagutil/sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ var _ pflag.Value = (*StringSetFlag)(nil)
// provides an implementation of pflag.Value, so it is usable in libraries like
// cobra.
type StringSetFlag struct {
set sets.String
set sets.Set[string]
}

// ToSet returns the underlying string set, or an empty set if the underlying
// set is nil.
func (set *StringSetFlag) ToSet() sets.String {
func (set *StringSetFlag) ToSet() sets.Set[string] {
if set.set == nil {
set.set = sets.NewString()
set.set = sets.New[string]()
}

return set.set
Expand All @@ -55,7 +55,7 @@ func (set *StringSetFlag) ToSet() sets.String {
// Set is part of the pflag.Value and flag.Value interfaces.
func (set *StringSetFlag) Set(s string) error {
if set.set == nil {
set.set = sets.NewString(s)
set.set = sets.New[string]()
return nil
}

Expand All @@ -69,7 +69,7 @@ func (set *StringSetFlag) String() string {
return ""
}

return strings.Join(set.set.List(), ", ")
return strings.Join(sets.List(set.set), ", ")
}

// Type is part of the pflag.Value interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var (
PRIMARY KEY (id)
) Engine=InnoDB;`
vschemaDDL = "alter vschema create vindex test_vdx using hash"
vschemaDDLError = fmt.Sprintf("Error 1105: cannot perform Update on keyspaces/%s/VSchema as the topology server connection is read-only",
vschemaDDLError = fmt.Sprintf("Error 1105 (HY000): cannot perform Update on keyspaces/%s/VSchema as the topology server connection is read-only",
keyspaceUnshardedName)
)

Expand Down
4 changes: 2 additions & 2 deletions go/vt/topo/cell_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (ts *Server) ExpandCells(ctx context.Context, cells string) ([]string, erro
var (
err error
inputCells []string
outputCells = sets.NewString() // Use a set to dedupe if the input cells list includes an alias and a cell in that alias.
outputCells = sets.New[string]() // Use a set to dedupe if the input cells list includes an alias and a cell in that alias.
)

if cells == "" {
Expand Down Expand Up @@ -238,5 +238,5 @@ func (ts *Server) ExpandCells(ctx context.Context, cells string) ([]string, erro
}
}

return outputCells.List(), nil
return sets.List(outputCells), nil
}
4 changes: 2 additions & 2 deletions go/vt/topo/topoproto/tablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func ParseTabletAlias(aliasStr string) (*topodatapb.TabletAlias, error) {
}

// ParseTabletSet returns a set of tablets based on a provided comma separated list of tablets.
func ParseTabletSet(tabletListStr string) sets.String {
set := sets.NewString()
func ParseTabletSet(tabletListStr string) sets.Set[string] {
set := sets.New[string]()
if tabletListStr == "" {
return set
}
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtadmin/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ func (api *API) GetWorkflows(ctx context.Context, req *vtadminpb.GetWorkflowsReq

workflows, err := c.GetWorkflows(ctx, req.Keyspaces, cluster.GetWorkflowsOptions{
ActiveOnly: req.ActiveOnly,
IgnoreKeyspaces: sets.NewString(req.IgnoreKeyspaces...),
IgnoreKeyspaces: sets.New[string](req.IgnoreKeyspaces...),
})
if err != nil {
rec.RecordError(err)
Expand Down
34 changes: 17 additions & 17 deletions go/vt/vtadmin/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ func (c *Cluster) findTablets(ctx context.Context, filter func(*vtadminpb.Tablet
// FindWorkflowsOptions is the set of options for FindWorkflows requests.
type FindWorkflowsOptions struct {
ActiveOnly bool
IgnoreKeyspaces sets.String
IgnoreKeyspaces sets.Set[string]
Filter func(workflow *vtadminpb.Workflow) bool
}

Expand Down Expand Up @@ -658,7 +658,7 @@ func (c *Cluster) findWorkflows(ctx context.Context, keyspaces []string, opts Fi
}

if opts.IgnoreKeyspaces == nil {
opts.IgnoreKeyspaces = sets.NewString()
opts.IgnoreKeyspaces = sets.New[string]()
}

if len(keyspaces) == 0 {
Expand All @@ -685,15 +685,15 @@ func (c *Cluster) findWorkflows(ctx context.Context, keyspaces []string, opts Fi
span.Finish()
} else if opts.IgnoreKeyspaces.Len() > 0 {
log.Warningf("Cluster.findWorkflows: IgnoreKeyspaces was set, but Keyspaces was not empty; ignoring IgnoreKeyspaces in favor of explicitly checking everything in Keyspaces: (%s)", strings.Join(keyspaces, ", "))
opts.IgnoreKeyspaces = sets.NewString()
opts.IgnoreKeyspaces = sets.New[string]()
}

// Annotate the parent span with some additional information about the call.
if span, _ := trace.FromContext(ctx); span != nil {
span.Annotate("num_keyspaces", len(keyspaces))
span.Annotate("keyspaces", strings.Join(keyspaces, ","))
span.Annotate("num_ignore_keyspaces", opts.IgnoreKeyspaces.Len())
span.Annotate("ignore_keyspaces", strings.Join(opts.IgnoreKeyspaces.List(), ","))
span.Annotate("ignore_keyspaces", strings.Join(sets.List(opts.IgnoreKeyspaces), ","))
}

clusterpb := c.ToProto()
Expand Down Expand Up @@ -799,7 +799,7 @@ func (c *Cluster) GetBackups(ctx context.Context, req *vtadminpb.GetBackupsReque
)

for ks, shardSet := range shardsByKeyspace {
for _, shard := range shardSet.List() {
for _, shard := range sets.List(shardSet) {
wg.Add(1)

go func(keyspace, shard string) {
Expand Down Expand Up @@ -856,8 +856,8 @@ func (c *Cluster) GetBackups(ctx context.Context, req *vtadminpb.GetBackupsReque
return backups, nil
}

func (c *Cluster) getShardSets(ctx context.Context, keyspaces []string, keyspaceShards []string) (map[string]sets.String, error) {
shardsByKeyspace := map[string]sets.String{}
func (c *Cluster) getShardSets(ctx context.Context, keyspaces []string, keyspaceShards []string) (map[string]sets.Set[string], error) {
shardsByKeyspace := map[string]sets.Set[string]{}

if len(keyspaces) == 0 && len(keyspaceShards) == 0 {
// Special case: if nothing was explicitly passed, get all shards in
Expand All @@ -868,7 +868,7 @@ func (c *Cluster) getShardSets(ctx context.Context, keyspaces []string, keyspace
}

for _, ks := range kss {
shardsByKeyspace[ks.Keyspace.Name] = sets.NewString()
shardsByKeyspace[ks.Keyspace.Name] = sets.New[string]()
for _, shard := range ks.Shards {
shardsByKeyspace[ks.Keyspace.Name].Insert(shard.Name)
}
Expand All @@ -884,7 +884,7 @@ func (c *Cluster) getShardSets(ctx context.Context, keyspaces []string, keyspace
}

if _, ok := shardsByKeyspace[ks]; !ok {
shardsByKeyspace[ks] = sets.NewString(shard)
shardsByKeyspace[ks] = sets.New[string](shard)
continue
}

Expand All @@ -897,7 +897,7 @@ func (c *Cluster) getShardSets(ctx context.Context, keyspaces []string, keyspace
// empty set to indicate we should take all shards in the GetKeyspace
// section below.
if _, ok := shardsByKeyspace[ks]; !ok {
shardsByKeyspace[ks] = sets.NewString()
shardsByKeyspace[ks] = sets.New[string]()
}
}

Expand All @@ -912,7 +912,7 @@ func (c *Cluster) getShardSets(ctx context.Context, keyspaces []string, keyspace
for ksName, shardSet := range shardsByKeyspace {
wg.Add(1)

go func(ksName string, shardSet sets.String) {
go func(ksName string, shardSet sets.Set[string]) {
defer wg.Done()

keyspace, err := c.GetKeyspace(ctx, ksName)
Expand All @@ -934,7 +934,7 @@ func (c *Cluster) getShardSets(ctx context.Context, keyspaces []string, keyspace
return
}

fullShardSet := sets.NewString()
fullShardSet := sets.New[string]()
for _, shard := range keyspace.Shards {
fullShardSet.Insert(shard.Name)
}
Expand All @@ -949,7 +949,7 @@ func (c *Cluster) getShardSets(ctx context.Context, keyspaces []string, keyspace

overlap := shardSet.Intersection(fullShardSet)
if overlap.Len() != shardSet.Len() {
log.Warningf("getShardSets(): keyspace %s is missing specified shards in cluster %s: %v", ksName, c.ID, shardSet.Difference(overlap).List())
log.Warningf("getShardSets(): keyspace %s is missing specified shards in cluster %s: %v", ksName, c.ID, sets.List(shardSet.Difference(overlap)))
}

m.Lock()
Expand Down Expand Up @@ -1684,7 +1684,7 @@ func (c *Cluster) GetShardReplicationPositions(ctx context.Context, req *vtadmin
)

for ks, shardSet := range shardsByKeyspace {
for _, shard := range shardSet.List() {
for _, shard := range sets.List(shardSet) {
wg.Add(1)

go func(keyspace, shard string) {
Expand Down Expand Up @@ -1890,7 +1890,7 @@ func (c *Cluster) GetWorkflow(ctx context.Context, keyspace string, name string,
// requests.
type GetWorkflowsOptions struct {
ActiveOnly bool
IgnoreKeyspaces sets.String
IgnoreKeyspaces sets.Set[string]
}

// GetWorkflows returns a list of Workflows in this cluster, across the given
Expand Down Expand Up @@ -2046,7 +2046,7 @@ func (c *Cluster) reloadKeyspaceSchemas(ctx context.Context, req *vtadminpb.Relo
return resp.Keyspaces, nil
}

keyspaceNames := sets.NewString(req.Keyspaces...)
keyspaceNames := sets.New[string](req.Keyspaces...)

for _, ks := range resp.Keyspaces {
if keyspaceNames.Has(ks.Name) {
Expand Down Expand Up @@ -2184,7 +2184,7 @@ func (c *Cluster) reloadShardSchemas(ctx context.Context, req *vtadminpb.ReloadS

// reloadTabletSchemas reloads schemas in one or more tablets in the cluster.
func (c *Cluster) reloadTabletSchemas(ctx context.Context, req *vtadminpb.ReloadSchemasRequest) ([]*vtadminpb.ReloadSchemasResponse_TabletResult, error) {
aliasSet := sets.NewString()
aliasSet := sets.New[string]()
for _, alias := range req.Tablets {
aliasSet.Insert(topoproto.TabletAliasString(alias))
}
Expand Down
22 changes: 11 additions & 11 deletions go/vt/vtadmin/cluster/cluster_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,41 +453,41 @@ func Test_getShardSets(t *testing.T) {
name string
keyspaces []string
keyspaceShards []string
result map[string]sets.String
result map[string]sets.Set[string]
shouldErr bool
}{
{
name: "all keyspaces and shards",
keyspaces: nil,
keyspaceShards: nil,
result: map[string]sets.String{
"ks1": sets.NewString("-80", "80-"),
"ks2": sets.NewString("-"),
result: map[string]sets.Set[string]{
"ks1": sets.New[string]("-80", "80-"),
"ks2": sets.New[string]("-"),
},
},
{
name: "keyspaceShards filter",
keyspaces: nil,
keyspaceShards: []string{"ks1/-80", "ks2/-"},
result: map[string]sets.String{
"ks1": sets.NewString("-80"),
"ks2": sets.NewString("-"),
result: map[string]sets.Set[string]{
"ks1": sets.New[string]("-80"),
"ks2": sets.New[string]("-"),
},
},
{
name: "keyspace and shards filters",
keyspaces: []string{"ks1"},
keyspaceShards: []string{"ks1/80-"},
result: map[string]sets.String{
"ks1": sets.NewString("80-"),
result: map[string]sets.Set[string]{
"ks1": sets.New[string]("80-"),
},
},
{
name: "skipped non-existing shards and keyspaces",
keyspaces: nil,
keyspaceShards: []string{"ks1/-" /* does not exist */, "ks1/-80", "ks1/80-", "ks3/-" /* does not exist */},
result: map[string]sets.String{
"ks1": sets.NewString("-80", "80-"),
result: map[string]sets.Set[string]{
"ks1": sets.New[string]("-80", "80-"),
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtadmin/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ func TestFindWorkflows(t *testing.T) {
},
keyspaces: []string{"ks2"},
opts: cluster.FindWorkflowsOptions{
IgnoreKeyspaces: sets.NewString("ks2"),
IgnoreKeyspaces: sets.New[string]("ks2"),
},
expected: &vtadminpb.ClusterWorkflows{
Workflows: []*vtadminpb.Workflow{
Expand Down Expand Up @@ -1047,7 +1047,7 @@ func TestFindWorkflows(t *testing.T) {
},
keyspaces: nil,
opts: cluster.FindWorkflowsOptions{
IgnoreKeyspaces: sets.NewString("ks2"),
IgnoreKeyspaces: sets.New[string]("ks2"),
},
expected: &vtadminpb.ClusterWorkflows{
Workflows: []*vtadminpb.Workflow{
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtadmin/http/shards.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func DeleteShards(ctx context.Context, r Request, api *API) *JSONResponse {
}

shardList := r.URL.Query()["keyspace_shard"]
shardList = sets.NewString(shardList...).List()
shardList = sets.List(sets.New[string](shardList...))
shards := make([]*vtctldatapb.Shard, len(shardList))
for i, kss := range shardList {
ks, shard, err := topoproto.ParseKeyspaceShard(kss)
Expand Down
18 changes: 9 additions & 9 deletions go/vt/vtadmin/rbac/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,22 @@ func (c *Config) Reify() error {
for i, rule := range c.Rules {
resourceRules := byResource[rule.Resource]

actions := sets.NewString(rule.Actions...)
actions := sets.New[string](rule.Actions...)
if actions.Has("*") && actions.Len() > 1 {
// error to have wildcard and something else
rec.RecordError(fmt.Errorf("rule %d: actions list cannot include wildcard and other actions, have %v", i, actions.List()))
rec.RecordError(fmt.Errorf("rule %d: actions list cannot include wildcard and other actions, have %v", i, sets.List(actions)))
}

subjects := sets.NewString(rule.Subjects...)
subjects := sets.New[string](rule.Subjects...)
if subjects.Has("*") && subjects.Len() > 1 {
// error to have wildcard and something else
rec.RecordError(fmt.Errorf("rule %d: subjects list cannot include wildcard and other subjects, have %v", i, subjects.List()))
rec.RecordError(fmt.Errorf("rule %d: subjects list cannot include wildcard and other subjects, have %v", i, sets.List(subjects)))
}

clusters := sets.NewString(rule.Clusters...)
clusters := sets.New[string](rule.Clusters...)
if clusters.Has("*") && clusters.Len() > 1 {
// error to have wildcard and something else
rec.RecordError(fmt.Errorf("rule %d: clusters list cannot include wildcard and other clusters, have %v", i, clusters.List()))
rec.RecordError(fmt.Errorf("rule %d: clusters list cannot include wildcard and other clusters, have %v", i, sets.List(clusters)))
}

resourceRules = append(resourceRules, &Rule{
Expand Down Expand Up @@ -188,9 +188,9 @@ func DefaultConfig() *Config {
cfg := map[string][]*Rule{
"*": {
{
clusters: sets.NewString(clusters...),
actions: sets.NewString(actions...),
subjects: sets.NewString(subjects...),
clusters: sets.New[string](clusters...),
actions: sets.New[string](actions...),
subjects: sets.New[string](subjects...),
},
},
}
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vtadmin/rbac/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (

// Rule is a single rule governing access to a particular resource.
type Rule struct {
clusters sets.String
actions sets.String
subjects sets.String
clusters sets.Set[string]
actions sets.Set[string]
subjects sets.Set[string]
}

// Allows returns true if the actor is allowed to take the specified action in
Expand Down
Loading

0 comments on commit da47696

Please sign in to comment.