Skip to content

Commit

Permalink
fix:[ASSMT-247]: Prevented Blank project creation (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritek01 authored Mar 13, 2024
1 parent 5cc0d26 commit 84efba7
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ func migrateSpinnakerApplication() error {
if !confirm {
log.Fatal("Aborting...")
}

// for now we are only creating project and migrating pipelines
err := createAProject("default", migrationReq.SpinnakerAppName, formatString(migrationReq.SpinnakerAppName))
if err != nil {
log.Error(err)
if len(migrationReq.ProjectIdentifier) == 0 {
migrationReq.ProjectIdentifier = TextInput("Name of the Project - ")
}

jsonBody, err := getAllPipelines(authMethod)
Expand All @@ -88,6 +85,24 @@ func migrateSpinnakerApplication() error {
if err != nil {
return err
}
//first check if there are any pipeline to be migrated or not if not then don't create the project
if len(pipelines) == 0 {
log.Info("No pipelines found to be migrated")
return nil
} else {
// Check if the project already exists for the given input project name in the given org
projects := getProjects()
id := findProjectIdByName(projects, migrationReq.ProjectIdentifier)

if len(id) > 0 {
log.Info("Project already exists with the given name")
} else {
log.Info("Creating the project....")
if err := createAProject("default", migrationReq.ProjectIdentifier, formatString(migrationReq.ProjectIdentifier)); err != nil {
log.Error(err)
}
}
}

payload := map[string][]map[string]interface{}{"pipelines": pipelines}
_, err = createSpinnakerPipelines(payload)
Expand Down

0 comments on commit 84efba7

Please sign in to comment.