// SetSourceShards is a utility function to override the SourceShards fields
// on a Shard.
487740
func (wr *Wrangler) SetSourceShards(ctx context.Context, keyspace, shard string, sources []*topodatapb.TabletAlias, tables []string) error {
	// Read the source tablets.
	sourceTablets, err := wr.ts.GetTabletMap(ctx, sources)
	if err != nil {
		return err
	}

	// Insert their KeyRange in the SourceShards array.
	// We use a linear 0-based id, that matches what worker/split_clone.go
	// inserts into _vt.vreplication.
	// We want to guarantee sourceShards[i] is using sources[i],
	// So iterating over the sourceTablets map would be a bad idea.
	sourceShards := make([]*topodatapb.Shard_SourceShard, len(sourceTablets))
	for i, alias := range sources {
		ti := sourceTablets[topoproto.TabletAliasString(alias)]
		sourceShards[i] = &topodatapb.Shard_SourceShard{
			Uid:      uint32(i),
			Keyspace: ti.Keyspace,
			Shard:    ti.Shard,
			KeyRange: ti.KeyRange,
			Tables:   tables,
		}
	}

	// Update the shard with the new source shards.
	_, err = wr.ts.UpdateShardFields(ctx, keyspace, shard, func(si *topo.ShardInfo) error {
		// If the shard already has sources, maybe it's already been restored,
		// so let's be safe and abort right here.
		if len(si.SourceShards) > 0 {
			return fmt.Errorf("shard %v/%v already has SourceShards, not overwriting them (full record: %v)", keyspace, shard, *si.Shard)
		}

		si.SourceShards = sourceShards
		return nil
	})
	return err
}
1300514
func (s *UpdateRobotApplicationInput) SetSources(v []*SourceConfig) *UpdateRobotApplicationInput {
	s.Sources = v
	return s
}
514601
func (s *CreateStreamInput) SetShardCount(v int64) *CreateStreamInput {
	s.ShardCount = &v
	return s
}
1369310
func (s *GetDiscoveredResourceCountsOutput) SetResourceCounts(v []*ResourceCount) *GetDiscoveredResourceCountsOutput {
	s.ResourceCounts = v
	return s
}
1158075
func (s *GetResourceShareInvitationsOutput) SetResourceShareInvitations(v []*ResourceShareInvitation) *GetResourceShareInvitationsOutput {
	s.ResourceShareInvitations = v
	return s
}
890732
func (s *ConfigRule) SetSource(v *Source) *ConfigRule {
	s.Source = v
	return s
}
392942
func (s *App) SetDataSources(v []*DataSource) *App {
	s.DataSources = v
	return s
}
259972
func (s *UpdateClusterInput) SetResources(v *JobResource) *UpdateClusterInput {
	s.Resources = v
	return s
}
1076080
func (s *CreateEventSubscriptionInput) SetSourceIds(v []*string) *CreateEventSubscriptionInput {
	s.SourceIds = v
	return s
}
771599
func (s *EnvironmentDescription) SetResources(v *EnvironmentResourcesDescription) *EnvironmentDescription {
	s.Resources = v
	return s
}
631063
func (p *Pipeline) SetSource(s Source) {
	p.mutex.Lock()
	defer p.mutex.Unlock()

	p.src = s
}
447937
func (s *CaptionSelectorSettings) SetAribSourceSettings(v *AribSourceSettings) *CaptionSelectorSettings {
	s.AribSourceSettings = v
	return s
}
411130
func (s *UpdatePatchBaselineInput) SetSources(v []*PatchSource) *UpdatePatchBaselineInput {
	s.Sources = v
	return s
}
1284549
func (s *UpdateInputInput) SetSources(v []*InputSourceRequest) *UpdateInputInput {
	s.Sources = v
	return s
}
672574
func (s *Toolchain) SetSource(v *ToolchainSource) *Toolchain {
	s.Source = v
	return s
}
111036
func (s *PutEventsRequestEntry) SetResources(v []*string) *PutEventsRequestEntry {
	s.Resources = v
	return s
}
1041847
func (p *propCopySource) SetSourceArchive(sourceID int64) {
	if sourceID == EmptyID {
		return
	}
	p.SourceArchive = &Archive{
		Resource: &Resource{ID: sourceID},
	}
	p.SourceDisk = nil
}