Skip to content

Commit

Permalink
Merge branch 'hotfix/v1.0.36-business-criticality-support'
Browse files Browse the repository at this point in the history
  • Loading branch information
canack committed Nov 6, 2024
2 parents 812cce8 + 5f5be8f commit 195ee27
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type ProjectDetail struct {
// FeatureBranchInfiniteRetention holds a value that disables the feature branch retention period.
FeatureBranchInfiniteRetention bool `json:"feature_branch_no_retention"`
DefaultBranch string `json:"default_branch"`
CriticalityLevel int `json:"criticality_level"`
}

type ProjectSource struct {
Expand Down
18 changes: 18 additions & 0 deletions cmd/createProjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func init() {
createCmd.AddCommand(createProjectCmd)

createProjectCmd.Flags().String("project-name", "", "name of the project")
createProjectCmd.Flags().Int("criticality-level", 0, "business criticality of the project, possible values are [ 4 = Major, 3 = High, 2 = Medium, 1 = Low, 0 = None, -1 = Auto ]. Default is [0]")
createProjectCmd.Flags().Bool("force-create", false, "ignore if the URL is used by another Kondukto project")
createProjectCmd.Flags().StringP("overwrite", "w", "", "rename the project name when creating a new project")
createProjectCmd.Flags().StringP("labels", "l", "", "comma separated label names")
Expand Down Expand Up @@ -192,6 +193,22 @@ func (p *Project) createProject(repo, projectName string, force bool, overwrite
qwe(ExitCodeError, err, "failed to parse the scope-included-files flag")
}

criticality, err := p.cmd.Flags().GetInt("criticality-level")
if err != nil {
qwe(ExitCodeError, err, "failed to parse the criticality flag")
}

businessCriticalityLevel, err := func() (int, error) {
if criticality < -1 || criticality > 4 {
return 0, fmt.Errorf("invalid criticality level: %d", criticality)
}

return criticality, nil
}()
if err != nil {
qwe(ExitCodeError, err, "business criticality level must be between -1, 0, 1, 2, 3 or 4")
}

projectSource := func() client.ProjectSource {
s := client.ProjectSource{Tool: tool}
u, err := url.Parse(repo)
Expand Down Expand Up @@ -235,6 +252,7 @@ func (p *Project) createProject(repo, projectName string, force bool, overwrite
FeatureBranchRetention: featureBranchRetention,
FeatureBranchInfiniteRetention: featureBranchNoRetention,
DefaultBranch: defaultBranch,
CriticalityLevel: businessCriticalityLevel,
}

project, err := p.client.CreateProject(pd)
Expand Down

0 comments on commit 195ee27

Please sign in to comment.