Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): fill favorite project attribute #6873

Merged
merged 1 commit into from
Feb 28, 2024
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
6 changes: 3 additions & 3 deletions cli/cdsctl/admin_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func adminMetadataProjectExportRun(c cli.Values) error {
currentDisplay.Printf("Gettings projects list...")
currentDisplay.Do(context.Background())

projects, err := client.ProjectList(false, false)
projects, err := client.ProjectList(false, false, false)
if err != nil {
return err
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func adminMetadataApplicationExportRun(c cli.Values) error {
currentDisplay.Printf("Gettings projects list...")
currentDisplay.Do(context.Background())

projects, err := client.ProjectList(false, false)
projects, err := client.ProjectList(false, false, false)
if err != nil {
return err
}
Expand Down Expand Up @@ -260,7 +260,7 @@ func adminMetadataApplicationImportRun(c cli.Values) error {
}

func adminMetadataWorkflowExportRun(c cli.Values) error {
projects, err := client.ProjectList(false, false)
projects, err := client.ProjectList(false, false, false)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cli/cdsctl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func discoverConf(ctxArg []cli.Arg) ([]string, error) {
if err != nil {
return nil, errors.Wrap(err, "cannot get name from current repository")
}
ps, err := client.ProjectList(true, true, cdsclient.Filter{Name: "repo", Value: name})
ps, err := client.ProjectList(true, true, false, cdsclient.Filter{Name: "repo", Value: name})
if err != nil {
return nil, err
}
Expand All @@ -303,7 +303,7 @@ func discoverConf(ctxArg []cli.Arg) ([]string, error) {
}

if projects == nil {
ps, err := client.ProjectList(false, false)
ps, err := client.ProjectList(false, false, false)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -337,7 +337,7 @@ func discoverConf(ctxArg []cli.Arg) ([]string, error) {
if project == nil {
// if the project found for current repo was not selected load all projects list
if repoExists && len(projects) == 1 {
ps, err := client.ProjectList(false, false)
ps, err := client.ProjectList(false, false, false)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cdsctl/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var projectListCmd = cli.Command{
}

func projectListRun(v cli.Values) (cli.ListResult, error) {
projs, err := client.ProjectList(false, false)
projs, err := client.ProjectList(false, false, true)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cdsctl/workflow_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func interactiveChooseProject(gitRepo repo.Repo, defaultValue string) (string, e
return defaultValue, nil
}

projs, err := client.ProjectList(false, false)
projs, err := client.ProjectList(false, false, false)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion engine/api/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func Test_getProjectsHandler_FilterByRepo(t *testing.T) {
BuiltinConsumerAuthenticationToken: jws,
})

projs, err := sdkclientAdmin.ProjectList(true, true, cdsclient.Filter{Name: "repo", Value: "ovh/" + repofullName})
projs, err := sdkclientAdmin.ProjectList(true, true, false, cdsclient.Filter{Name: "repo", Value: "ovh/" + repofullName})
require.NoError(t, err)
require.True(t, len(projs) == 1)
require.True(t, len(projs[0].Workflows) == 1)
Expand Down
4 changes: 2 additions & 2 deletions sdk/cdsclient/client_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func (c *client) ProjectUpdate(key string, project *sdk.Project) error {
return nil
}

func (c *client) ProjectList(withApplications, withWorkflows bool, filters ...Filter) ([]sdk.Project, error) {
func (c *client) ProjectList(withApplications, withWorkflows, withFavorites bool, filters ...Filter) ([]sdk.Project, error) {
p := []sdk.Project{}
path := fmt.Sprintf("/project?application=%v&workflow=%v", withApplications, withWorkflows)
path := fmt.Sprintf("/project?application=%v&workflow=%v&withFavorites=%v", withApplications, withWorkflows, withFavorites)

for _, f := range filters {
path += fmt.Sprintf("&%s=%s", url.QueryEscape(f.Name), url.QueryEscape(f.Value))
Expand Down
2 changes: 1 addition & 1 deletion sdk/cdsclient/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ type ProjectClient interface {
ProjectGroupDelete(projectKey, groupName string) error
ProjectGet(projectKey string, opts ...RequestModifier) (*sdk.Project, error)
ProjectUpdate(key string, project *sdk.Project) error
ProjectList(withApplications, withWorkflow bool, filters ...Filter) ([]sdk.Project, error)
ProjectList(withApplications, withWorkflow, withFavorites bool, filters ...Filter) ([]sdk.Project, error)
ProjectKeysClient
ProjectVariablesClient
ProjectIntegrationImport(projectKey string, content io.Reader, mods ...RequestModifier) (sdk.ProjectIntegration, error)
Expand Down
16 changes: 8 additions & 8 deletions sdk/cdsclient/mock_cdsclient/interface_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.