Skip to content

Commit

Permalink
pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
gssbzn committed Mar 8, 2024
1 parent 910b2d4 commit 3bc8e8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions internal/cli/default_setter_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (opts *DefaultSetterOpts) projects() (ids, names []string, err error) {
}

// Orgs fetches organizations, filtering by name.
func (opts *DefaultSetterOpts) orgs(filter string) (results *[]atlasv2.AtlasOrganization, err error) {
func (opts *DefaultSetterOpts) orgs(filter string) (results []atlasv2.AtlasOrganization, err error) {
spin := newSpinner()
spin.Start()
defer spin.Stop()
Expand All @@ -134,7 +134,7 @@ func (opts *DefaultSetterOpts) orgs(filter string) (results *[]atlasv2.AtlasOrga
if orgs.GetTotalCount() > resultsLimit {
return nil, errTooManyResults
}
return orgs.Results, nil
return orgs.GetResults(), nil
}

// ProjectExists checks if the project exists and the current user has access to it.
Expand All @@ -146,7 +146,7 @@ func (opts *DefaultSetterOpts) ProjectExists(id string) bool {
}

// AskProject will try to construct a select based on fetched projects.
// If it fails or there are no projects to show we fallback to ask for project by ID.
// If it fails or there are no projects to show we fall back to ask for project by ID.
// If only one project, select it by default without prompting the user.
func (opts *DefaultSetterOpts) AskProject() error {
ids, names, err := opts.projects()
Expand Down Expand Up @@ -203,7 +203,7 @@ func (opts *DefaultSetterOpts) OrgExists(id string) bool {
}

// AskOrg will try to construct a select based on fetched organizations.
// If it fails or there are no organizations to show we fallback to ask for org by ID.
// If it fails or there are no organizations to show we fall back to ask for org by ID.
// If only one organization, select it by default without prompting the user.
func (opts *DefaultSetterOpts) AskOrg() error {
return opts.askOrgWithFilter("")
Expand Down Expand Up @@ -274,9 +274,9 @@ func (opts *DefaultSetterOpts) manualOrgID() error {
return nil
}

func (opts *DefaultSetterOpts) selectOrg(orgs *[]atlasv2.AtlasOrganization) error {
if orgs != nil && len(*orgs) == 1 {
opts.OrgID = *(*orgs)[0].Id
func (opts *DefaultSetterOpts) selectOrg(orgs []atlasv2.AtlasOrganization) error {
if len(orgs) == 1 {
opts.OrgID = orgs[0].GetId()
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/cli/default_setter_opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestDefaultOpts_Orgs(t *testing.T) {
mockStore.EXPECT().Organizations(gomock.Any()).Return(expectedOrgs, nil).Times(1)
gotOrgs, err := opts.orgs("")
require.NoError(t, err)
assert.Equal(t, expectedOrgs.Results, gotOrgs)
assert.Equal(t, expectedOrgs.GetResults(), gotOrgs)
})

t.Run("with no org", func(t *testing.T) {
Expand Down

0 comments on commit 3bc8e8f

Please sign in to comment.