Skip to content

Commit

Permalink
Rename for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
strideynet committed Jan 14, 2025
1 parent 9e31ab4 commit 2d7dc7c
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions lib/tbot/cli/start_workload_identity_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ func (c *WorkloadIdentityAPICommand) ApplyConfig(cfg *config.BotConfig, l *slog.
case c.NameSelector != "" && c.LabelSelector != "":
return trace.BadParameter("workload-identity-name and workload-identity-labels flags are mutually exclusive")
case c.NameSelector != "":
svc.WorkloadIdentity.Name = c.NameSelector
svc.Selector.Name = c.NameSelector
case c.LabelSelector != "":
labels, err := client.ParseLabelSpec(c.LabelSelector)
if err != nil {
return trace.Wrap(err, "parsing --workload-identity-labels")
}
svc.WorkloadIdentity.Labels = map[string][]string{}
svc.Selector.Labels = map[string][]string{}
for k, v := range labels {
svc.WorkloadIdentity.Labels[k] = []string{v}
svc.Selector.Labels[k] = []string{v}
}
default:
return trace.BadParameter("workload-identity-name or workload-identity-labels must be specified")
Expand Down
4 changes: 2 additions & 2 deletions lib/tbot/cli/start_workload_identity_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestNewWorkloadIdentityAPICommand(t *testing.T) {
require.Equal(t, map[string][]string{
"*": {"*"},
"foo": {"bar"},
}, wis.WorkloadIdentity.Labels)
}, wis.Selector.Labels)
},
},
{
Expand All @@ -68,7 +68,7 @@ func TestNewWorkloadIdentityAPICommand(t *testing.T) {
wis, ok := svc.(*config.WorkloadIdentityAPIService)
require.True(t, ok)
require.Equal(t, "unix:///opt/workload.sock", wis.Listen)
require.Equal(t, "jim", wis.WorkloadIdentity.Name)
require.Equal(t, "jim", wis.Selector.Name)
},
},
})
Expand Down
2 changes: 1 addition & 1 deletion lib/tbot/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func TestBotConfig_YAML(t *testing.T) {
},
&WorkloadIdentityAPIService{
Listen: "tcp://127.0.0.1:123",
WorkloadIdentity: WorkloadIdentitySelector{
Selector: WorkloadIdentitySelector{
Name: "my-workload-identity",
},
},
Expand Down
8 changes: 4 additions & 4 deletions lib/tbot/config/service_workload_identity_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ type WorkloadIdentityAPIService struct {
Listen string `yaml:"listen"`
// Attestors is the configuration for the workload attestation process.
Attestors workloadattest.Config `yaml:"attestors"`
// WorkloadIdentity is the selector for the WorkloadIdentity resource that
// Selector is the selector for the WorkloadIdentity resource that
// will be used to issue WICs.
WorkloadIdentity WorkloadIdentitySelector `yaml:"workload_identity"`
Selector WorkloadIdentitySelector `yaml:"selector"`
}

// CheckAndSetDefaults checks the SPIFFESVIDOutput values and sets any defaults.
Expand All @@ -50,8 +50,8 @@ func (o *WorkloadIdentityAPIService) CheckAndSetDefaults() error {
if err := o.Attestors.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err, "validating attestor")
}
if err := o.WorkloadIdentity.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err, "validating workload_identity")
if err := o.Selector.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err, "validating selector")
}
return nil
}
Expand Down
16 changes: 8 additions & 8 deletions lib/tbot/config/service_workload_identity_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestWorkloadIdentityAPIService_YAML(t *testing.T) {
},
},
},
WorkloadIdentity: WorkloadIdentitySelector{
Selector: WorkloadIdentitySelector{
Name: "my-workload-identity",
},
},
Expand All @@ -51,7 +51,7 @@ func TestWorkloadIdentityAPIService_YAML(t *testing.T) {
name: "minimal",
in: WorkloadIdentityAPIService{
Listen: "tcp://0.0.0.0:4040",
WorkloadIdentity: WorkloadIdentitySelector{
Selector: WorkloadIdentitySelector{
Name: "my-workload-identity",
},
},
Expand All @@ -68,7 +68,7 @@ func TestWorkloadIdentityAPIService_CheckAndSetDefaults(t *testing.T) {
name: "valid",
in: func() *WorkloadIdentityAPIService {
return &WorkloadIdentityAPIService{
WorkloadIdentity: WorkloadIdentitySelector{
Selector: WorkloadIdentitySelector{
Name: "my-workload-identity",
},
Listen: "tcp://0.0.0.0:4040",
Expand All @@ -79,7 +79,7 @@ func TestWorkloadIdentityAPIService_CheckAndSetDefaults(t *testing.T) {
name: "valid with labels",
in: func() *WorkloadIdentityAPIService {
return &WorkloadIdentityAPIService{
WorkloadIdentity: WorkloadIdentitySelector{
Selector: WorkloadIdentitySelector{
Labels: map[string][]string{
"key": {"value"},
},
Expand All @@ -92,8 +92,8 @@ func TestWorkloadIdentityAPIService_CheckAndSetDefaults(t *testing.T) {
name: "missing selectors",
in: func() *WorkloadIdentityAPIService {
return &WorkloadIdentityAPIService{
WorkloadIdentity: WorkloadIdentitySelector{},
Listen: "tcp://0.0.0.0:4040",
Selector: WorkloadIdentitySelector{},
Listen: "tcp://0.0.0.0:4040",
}
},
wantErr: "one of ['name', 'labels'] must be set",
Expand All @@ -102,7 +102,7 @@ func TestWorkloadIdentityAPIService_CheckAndSetDefaults(t *testing.T) {
name: "too many selectors",
in: func() *WorkloadIdentityAPIService {
return &WorkloadIdentityAPIService{
WorkloadIdentity: WorkloadIdentitySelector{
Selector: WorkloadIdentitySelector{
Name: "my-workload-identity",
Labels: map[string][]string{
"key": {"value"},
Expand All @@ -117,7 +117,7 @@ func TestWorkloadIdentityAPIService_CheckAndSetDefaults(t *testing.T) {
name: "missing listen",
in: func() *WorkloadIdentityAPIService {
return &WorkloadIdentityAPIService{
WorkloadIdentity: WorkloadIdentitySelector{
Selector: WorkloadIdentitySelector{
Name: "my-workload-identity",
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ services:
attestors:
kubernetes:
enabled: false
workload_identity:
selector:
name: my-workload-identity
debug: true
auth_server: example.teleport.sh:443
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ attestors:
ca_path: /path/to/ca.pem
skip_verify: true
anonymous: true
workload_identity:
selector:
name: my-workload-identity
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ listen: tcp://0.0.0.0:4040
attestors:
kubernetes:
enabled: false
workload_identity:
selector:
name: my-workload-identity
4 changes: 2 additions & 2 deletions lib/tbot/service_workload_identity_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func (s *WorkloadIdentityAPIService) fetchX509SVIDs(
ctx,
log,
s.client,
s.cfg.WorkloadIdentity,
s.cfg.Selector,
s.botCfg.CertificateTTL,
attest,
)
Expand Down Expand Up @@ -488,7 +488,7 @@ func (s *WorkloadIdentityAPIService) FetchJWTSVID(
ctx,
log,
s.client,
s.cfg.WorkloadIdentity,
s.cfg.Selector,
req.Audience,
s.botCfg.CertificateTTL,
attr,
Expand Down
2 changes: 1 addition & 1 deletion lib/tbot/service_workload_identity_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestBotWorkloadIdentityAPI(t *testing.T) {
onboarding, _ := makeBot(t, rootClient, "api", role.GetName())
botConfig := defaultBotConfig(t, process, onboarding, config.ServiceConfigs{
&config.WorkloadIdentityAPIService{
WorkloadIdentity: config.WorkloadIdentitySelector{
Selector: config.WorkloadIdentitySelector{
Name: workloadIdentity.GetMetadata().GetName(),
},
Listen: listenAddr.String(),
Expand Down

0 comments on commit 2d7dc7c

Please sign in to comment.