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 bub gumber AST-337567 - Send MainBarnch value #642

Merged
merged 2 commits into from
Jan 15, 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
21 changes: 17 additions & 4 deletions internal/commands/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ func findProject(

for i := 0; i < len(resp.Projects); i++ {
if resp.Projects[i].Name == projectName {
return updateProject(resp.Projects[i].ID, cmd, projectsWrapper, groupsWrapper)
return updateProject(resp, cmd, projectsWrapper, groupsWrapper, projectName)
}
}
projectID, err := createProject(projectName, cmd, projectsWrapper, groupsWrapper)
Expand Down Expand Up @@ -634,19 +634,33 @@ func createProject(
}

func updateProject(
projectID string,
resp *wrappers.ProjectsCollectionResponseModel,
cmd *cobra.Command,
projectsWrapper wrappers.ProjectsWrapper,
groupsWrapper wrappers.GroupsWrapper,
projectName string,

) (string, error) {
var projectID string
var projModel = wrappers.Project{}
projectGroups, _ := cmd.Flags().GetString(commonParams.ProjectGroupList)
projectTags, _ := cmd.Flags().GetString(commonParams.ProjectTagList)
projectPrivatePackage, _ := cmd.Flags().GetString(commonParams.ProjecPrivatePackageFlag)
for i := 0; i < len(resp.Projects); i++ {
if resp.Projects[i].Name == projectName {
projectID = resp.Projects[i].ID
}
if resp.Projects[i].MainBranch != "" {
projModel.MainBranch = resp.Projects[i].MainBranch
}
if resp.Projects[i].RepoURL != "" {
projModel.RepoURL = resp.Projects[i].RepoURL
}
}
if projectGroups == "" && projectTags == "" && projectPrivatePackage == "" {
logger.PrintIfVerbose("No groups or tags to update. Skipping project update.")
return projectID, nil
}
var projModel = wrappers.Project{}
if projectPrivatePackage != "" {
projModel.PrivatePackage, _ = strconv.ParseBool(projectPrivatePackage)
}
Expand All @@ -672,7 +686,6 @@ func updateProject(
logger.PrintIfVerbose("Updating project tags")
projModel.Tags = createTagMap(projectTags)
}

err = projectsWrapper.Update(projectID, &projModel)
if err != nil {
return "", errors.Errorf("%s: %v", failedUpdatingProj, err)
Expand Down
6 changes: 6 additions & 0 deletions internal/commands/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,3 +582,9 @@ func TestAddKicsScan(t *testing.T) {
t.Errorf("Expected %+v, but got %+v", kicsMapConfig, result)
}
}
func TestCreateScanProjectTagsCheckResendToScan(t *testing.T) {
baseArgs := []string{"scan", "create", "--project-name", "sastFilterMock", "-b", "dummy_branch", "-s", dummyRepo, "--project-tags", "SEG", "--debug"}
cmd := createASTTestCommand()
err := executeTestCommand(cmd, baseArgs...)
assert.NilError(t, err)
}
Loading