Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/cmd/graph/user/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func runCmd(ctx util.CmdContext, opts *usersListOptions) error {
io.StartProgressIndicator()
defer io.StopProgressIndicator()

var scope *util.Scope
var scope *util.Path
switch {
case opts.projectName != "" && opts.organizationName != "":
scope, err = util.ParseProjectScope(ctx, fmt.Sprintf("%s/%s", opts.organizationName, opts.projectName))
Expand All @@ -97,7 +97,7 @@ func runCmd(ctx util.CmdContext, opts *usersListOptions) error {
if parseErr != nil {
return parseErr
}
scope = &util.Scope{Organization: org}
scope = &util.Path{Organization: org}
}
if err != nil {
return util.FlagErrorWrap(err)
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/pipelines/variablegroup/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func run(cmdCtx util.CmdContext, opts *options) error {
return util.FlagErrorWrap(err)
}

groupName := strings.TrimSpace(target.Target)
groupName := strings.TrimSpace(target.Targets[0])
if groupName == "" {
return util.FlagErrorf("variable group name cannot be empty")
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func run(cmdCtx util.CmdContext, opts *options) error {

var providerData any
if keyVaultRequested {
providerData, err = buildKeyVaultProviderData(cmdCtx, target.Scope, opts)
providerData, err = buildKeyVaultProviderData(cmdCtx, *target, opts)
if err != nil {
return util.FlagErrorWrap(err)
}
Expand Down Expand Up @@ -329,7 +329,7 @@ func buildKeyVaultVariables(opts *options) (*map[string]any, error) {

func buildKeyVaultProviderData(
cmdCtx util.CmdContext,
scope util.Scope,
scope util.Path,
opts *options,
) (*taskagent.AzureKeyVaultVariableGroupProviderData, error) {
if opts.keyVaultServiceEndpoint == "" {
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/pipelines/variablegroup/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func run(cmdCtx util.CmdContext, opts *options) error {
return fmt.Errorf("failed to create task agent client: %w", err)
}

group, err := shared.ResolveVariableGroup(cmdCtx, taskClient, scope.Project, scope.Target)
group, err := shared.ResolveVariableGroup(cmdCtx, taskClient, scope.Project, scope.Targets[0])
if err != nil {
return err
}
Expand All @@ -101,7 +101,7 @@ func run(cmdCtx util.CmdContext, opts *options) error {
return fmt.Errorf("resolved variable group is missing an ID")
}
groupID := *group.Id
groupName := types.GetValue(group.Name, scope.Target)
groupName := types.GetValue(group.Name, scope.Targets[0])

projectIndex := buildProjectIndex(group)
projectIDs, err := selectProjectIDs(projectIndex, scope.Project, opts.projectReferences, opts.all)
Expand All @@ -115,7 +115,7 @@ func run(cmdCtx util.CmdContext, opts *options) error {
zap.L().Debug("resolved variable group",
zap.String("organization", scope.Organization),
zap.String("project", scope.Project),
zap.String("input", scope.Target),
zap.String("input", scope.Targets[0]),
zap.Int("groupId", groupID),
zap.String("name", groupName),
)
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/pipelines/variablegroup/show/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,17 @@ func run(cmdCtx util.CmdContext, o *opts) error {
logger := zap.L().With(
zap.String("organization", scope.Organization),
zap.String("project", scope.Project),
zap.String("variableGroup", scope.Target),
zap.String("variableGroup", scope.Targets[0]),
)

logger.Debug("resolving variable group identifier")
group, err := shared.ResolveVariableGroup(cmdCtx, taskClient, scope.Project, scope.Target)
group, err := shared.ResolveVariableGroup(cmdCtx, taskClient, scope.Project, scope.Targets[0])
if err != nil {
return err
}

if group == nil || group.Id == nil {
return fmt.Errorf("variable group %q not found", scope.Target)
return fmt.Errorf("variable group %q not found", scope.Targets[0])
}

permissionsClient, err := cmdCtx.ClientFactory().PipelinePermissions(cmdCtx.Context(), scope.Organization)
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/pipelines/variablegroup/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ func run(cmdCtx util.CmdContext, o *opts) error {
}

// resolve variable group
group, err := shared.ResolveVariableGroup(cmdCtx, taskClient, scope.Project, scope.Target)
group, err := shared.ResolveVariableGroup(cmdCtx, taskClient, scope.Project, scope.Targets[0])
if err != nil {
return err
}
if group == nil || group.Id == nil {
return fmt.Errorf("variable group %q not found", scope.Target)
return fmt.Errorf("variable group %q not found", scope.Targets[0])
}

var updatedGroup *taskagent.VariableGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ func run(cmdCtx util.CmdContext, opts *opts) error {
return fmt.Errorf("failed to create task agent client: %w", err)
}

group, err := shared.ResolveVariableGroup(cmdCtx, taskClient, scope.Project, scope.Target)
group, err := shared.ResolveVariableGroup(cmdCtx, taskClient, scope.Project, scope.Targets[0])
if err != nil {
return err
}
if group == nil {
return fmt.Errorf("variable group %q not found", scope.Target)
return fmt.Errorf("variable group %q not found", scope.Targets[0])
}
if group.Type != nil && strings.EqualFold(types.GetValue(group.Type, ""), "AzureKeyVault") {
return util.FlagErrorf("cannot add variables to an Azure Key Vault-backed variable group")
Expand All @@ -88,7 +88,7 @@ func run(cmdCtx util.CmdContext, opts *opts) error {
if group.Variables != nil {
for k := range *group.Variables {
if strings.EqualFold(k, opts.name) {
return util.FlagErrorf("variable %q already exists in group %q", opts.name, types.GetValue(group.Name, scope.Target))
return util.FlagErrorf("variable %q already exists in group %q", opts.name, types.GetValue(group.Name, scope.Targets[0]))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ func run(cmdCtx util.CmdContext, opts *opts) error {
return fmt.Errorf("failed to create task agent client: %w", err)
}

group, err := shared.ResolveVariableGroup(cmdCtx, taskClient, scope.Project, scope.Target)
group, err := shared.ResolveVariableGroup(cmdCtx, taskClient, scope.Project, scope.Targets[0])
if err != nil {
return err
}
if group == nil {
return fmt.Errorf("variable group %q not found", scope.Target)
return fmt.Errorf("variable group %q not found", scope.Targets[0])
}
if group.Id == nil {
return fmt.Errorf("resolved variable group is missing an ID")
}

groupID := *group.Id
groupName := types.GetValue(group.Name, scope.Target)
groupName := types.GetValue(group.Name, scope.Targets[0])

// Find variable key case-insensitively
var foundKey string
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/pipelines/variablegroup/variable/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func run(ctx util.CmdContext, opts *opts) error {
}

// Determine if groupIdentifier is ID or Name
groupID, err := strconv.Atoi(scope.Target)
groupID, err := strconv.Atoi(scope.Targets[0])
if err == nil && groupID < 0 {
return util.FlagErrorf("Invalid group id %d", groupID)
} else if err != nil {
Expand All @@ -92,10 +92,10 @@ func run(ctx util.CmdContext, opts *opts) error {
},
})
} else {
zap.L().Debug("Fetching variable group by name", zap.String("groupName", scope.Target))
zap.L().Debug("Fetching variable group by name", zap.String("groupName", scope.Targets[0]))
g, err = client.GetVariableGroups(ctx.Context(), taskagent.GetVariableGroupsArgs{
Project: &scope.Project,
GroupName: &scope.Target,
GroupName: &scope.Targets[0],
})
}
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions internal/cmd/pipelines/variablegroup/variable/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ func run(cmdCtx util.CmdContext, cmd *cobra.Command, opts *opts) error {
return fmt.Errorf("failed to create task agent client: %w", err)
}

group, err := shared.ResolveVariableGroup(cmdCtx, taskClient, scope.Project, scope.Target)
group, err := shared.ResolveVariableGroup(cmdCtx, taskClient, scope.Project, scope.Targets[0])
if err != nil {
return err
}
if group == nil {
return util.FlagErrorf("variable group %q not found", scope.Target)
return util.FlagErrorf("variable group %q not found", scope.Targets[0])
}

// Load --from-json if provided
Expand Down Expand Up @@ -174,7 +174,7 @@ func run(cmdCtx util.CmdContext, cmd *cobra.Command, opts *opts) error {
}
}
if origKey == "" {
return util.FlagErrorf("variable %q not found in group %q", opts.name, types.GetValue(group.Name, scope.Target))
return util.FlagErrorf("variable %q not found in group %q", opts.name, types.GetValue(group.Name, scope.Targets[0]))
}

// Detect if this is an Azure Key Vault-backed group
Expand Down Expand Up @@ -229,15 +229,15 @@ func run(cmdCtx util.CmdContext, cmd *cobra.Command, opts *opts) error {
// check collision
for k := range newVars {
if strings.EqualFold(k, *fromPayload.NewName) && !strings.EqualFold(k, origKey) {
return util.FlagErrorf("variable %q already exists in group %q", *fromPayload.NewName, types.GetValue(group.Name, scope.Target))
return util.FlagErrorf("variable %q already exists in group %q", *fromPayload.NewName, types.GetValue(group.Name, scope.Targets[0]))
}
}
finalKey = *fromPayload.NewName
} else if cmd.Flags().Changed("new-name") {
// check collision
for k := range newVars {
if strings.EqualFold(k, opts.newName) && !strings.EqualFold(k, origKey) {
return util.FlagErrorf("variable %q already exists in group %q", opts.newName, types.GetValue(group.Name, scope.Target))
return util.FlagErrorf("variable %q already exists in group %q", opts.newName, types.GetValue(group.Name, scope.Targets[0]))
}
}
finalKey = opts.newName
Expand Down Expand Up @@ -321,7 +321,7 @@ func run(cmdCtx util.CmdContext, cmd *cobra.Command, opts *opts) error {
if err != nil {
return err
}
ok, err := prompter.Confirm(fmt.Sprintf("Clear value of variable '%s' in group '%s'?", opts.name, types.GetValue(group.Name, scope.Target)), false)
ok, err := prompter.Confirm(fmt.Sprintf("Clear value of variable '%s' in group '%s'?", opts.name, types.GetValue(group.Name, scope.Targets[0])), false)
ios.StartProgressIndicator()
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/security/group/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func run(ctx util.CmdContext, opts *deleteOpts) error {
return err
}

zap.L().Debug("Resolving group for deletion", zap.String("organization", target.Organization), zap.String("project", target.Project), zap.String("group", target.Target))
targetGroup, err := shared.FindGroupByName(ctx, target.Organization, target.Project, target.Target, opts.descriptor)
zap.L().Debug("Resolving group for deletion", zap.String("organization", target.Organization), zap.String("project", target.Project), zap.String("group", target.Targets[0]))
targetGroup, err := shared.FindGroupByName(ctx, target.Organization, target.Project, target.Targets[0], opts.descriptor)
if err != nil {
return err
}
Expand All @@ -78,7 +78,7 @@ func run(ctx util.CmdContext, opts *deleteOpts) error {
if err != nil {
return err
}
confirmed, err := p.Confirm(fmt.Sprintf("Delete security group %q?", target.Target), false)
confirmed, err := p.Confirm(fmt.Sprintf("Delete security group %q?", target.Targets[0]), false)
if err != nil {
return err
}
Expand All @@ -95,6 +95,6 @@ func run(ctx util.CmdContext, opts *deleteOpts) error {
return fmt.Errorf("failed to delete group: %w", err)
}

fmt.Fprintf(ios.Out, "Deleted security group %q.\n", target.Target)
fmt.Fprintf(ios.Out, "Deleted security group %q.\n", target.Targets[0])
return nil
}
10 changes: 5 additions & 5 deletions internal/cmd/security/group/membership/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ func runAdd(ctx util.CmdContext, o *opts) error {
zap.L().Debug("resolving group for membership add",
zap.String("organization", organization),
zap.String("project", project),
zap.String("group", target.Target),
zap.String("group", target.Targets[0]),
)

group, err := shared.FindGroupByName(ctx, organization, project, target.Target, "")
group, err := shared.FindGroupByName(ctx, organization, project, target.Targets[0], "")
if err != nil {
return err
}
Expand Down Expand Up @@ -156,7 +156,7 @@ func runAdd(ctx util.CmdContext, o *opts) error {
if err == nil {
results = append(results, addResult{
GroupDescriptor: types.GetValue(group.Descriptor, ""),
GroupDisplayName: types.GetValue(group.DisplayName, target.Target),
GroupDisplayName: types.GetValue(group.DisplayName, target.Targets[0]),
MemberDescriptor: memberDescriptor,
MemberDisplayName: types.GetValue(memberSubject.DisplayName, ""),
MemberSubjectKind: types.GetValue(memberSubject.SubjectKind, ""),
Expand Down Expand Up @@ -188,7 +188,7 @@ func runAdd(ctx util.CmdContext, o *opts) error {
if errors.As(err, &addErr) && addErr != nil && addErr.StatusCode != nil && *addErr.StatusCode == http.StatusConflict {
results = append(results, addResult{
GroupDescriptor: types.GetValue(group.Descriptor, ""),
GroupDisplayName: types.GetValue(group.DisplayName, target.Target),
GroupDisplayName: types.GetValue(group.DisplayName, target.Targets[0]),
MemberDescriptor: memberDescriptor,
MemberDisplayName: types.GetValue(memberSubject.DisplayName, ""),
MemberSubjectKind: types.GetValue(memberSubject.SubjectKind, ""),
Expand All @@ -204,7 +204,7 @@ func runAdd(ctx util.CmdContext, o *opts) error {

results = append(results, addResult{
GroupDescriptor: types.GetValue(group.Descriptor, ""),
GroupDisplayName: types.GetValue(group.DisplayName, target.Target),
GroupDisplayName: types.GetValue(group.DisplayName, target.Targets[0]),
MemberDescriptor: types.GetValue(membership.MemberDescriptor, memberDescriptor),
MemberDisplayName: types.GetValue(memberSubject.DisplayName, ""),
MemberSubjectKind: types.GetValue(memberSubject.SubjectKind, ""),
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/security/group/membership/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func runList(ctx util.CmdContext, o *opts) error {
}
organization := target.Organization
project := target.Project
group := target.Target
group := target.Targets[0]

graphClient, err := ctx.ClientFactory().Graph(ctx.Context(), organization)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/security/group/membership/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ func runRemove(ctx util.CmdContext, o *opts) error {
zap.L().Debug("resolving group for membership removal",
zap.String("organization", organization),
zap.String("project", project),
zap.String("group", target.Target),
zap.String("group", target.Targets[0]),
)

group, err := shared.FindGroupByName(ctx, organization, project, target.Target, "")
group, err := shared.FindGroupByName(ctx, organization, project, target.Targets[0], "")
if err != nil {
return err
}
Expand Down Expand Up @@ -206,9 +206,9 @@ func runRemove(ctx util.CmdContext, o *opts) error {
break
}
}
prompt = fmt.Sprintf("Remove %q from group %q?", name, target.Target)
prompt = fmt.Sprintf("Remove %q from group %q?", name, target.Targets[0])
} else {
prompt = fmt.Sprintf("Remove %d members from group %q?", removable, target.Target)
prompt = fmt.Sprintf("Remove %d members from group %q?", removable, target.Targets[0])
}

confirmed, err := p.Confirm(prompt, false)
Expand Down Expand Up @@ -262,7 +262,7 @@ func runRemove(ctx util.CmdContext, o *opts) error {

results = append(results, removeResult{
GroupDescriptor: types.GetValue(group.Descriptor, ""),
GroupDisplayName: types.GetValue(group.DisplayName, target.Target),
GroupDisplayName: types.GetValue(group.DisplayName, target.Targets[0]),
MemberDescriptor: c.descriptor,
MemberDisplayName: c.displayName,
MemberSubjectKind: types.GetValue(c.subject.SubjectKind, ""),
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/security/group/show/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ func runCommand(ctx util.CmdContext, o *opts) error {
return err
}

zap.L().Sugar().Debugw("Resolved target for show command", "organization", target.Organization, "project", target.Project, "group", target.Target)
zap.L().Sugar().Debugw("Resolved target for show command", "organization", target.Organization, "project", target.Project, "group", target.Targets[0])

groupDetailsResult, err := shared.FindGroupByName(ctx, target.Organization, target.Project, target.Target, "")
groupDetailsResult, err := shared.FindGroupByName(ctx, target.Organization, target.Project, target.Targets[0], "")
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/security/group/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func run(ctx util.CmdContext, o *opts) error {
return err
}

group, err := shared.FindGroupByName(ctx, target.Organization, target.Project, target.Target, o.descriptor)
group, err := shared.FindGroupByName(ctx, target.Organization, target.Project, target.Targets[0], o.descriptor)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/security/permission/namespace/show/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func runCommand(ctx util.CmdContext, o *opts) error {
return actionPrinter.Render()
}

func parseNamespaceTarget(ctx util.CmdContext, input string) (*util.Scope, string, error) {
func parseNamespaceTarget(ctx util.CmdContext, input string) (*util.Path, string, error) {
trimmed := strings.TrimSpace(input)
if trimmed == "" {
return nil, "", util.FlagErrorf("namespace identifier is required")
Expand All @@ -198,7 +198,7 @@ func parseNamespaceTarget(ctx util.CmdContext, input string) (*util.Scope, strin
if err != nil {
return nil, "", err
}
return &util.Scope{Organization: organization}, trimmed, nil
return &util.Path{Organization: organization}, trimmed, nil
}

func namespaceMatches(ns security.SecurityNamespaceDescription, identifier string) bool {
Expand Down
Loading
Loading