-
Notifications
You must be signed in to change notification settings - Fork 7
/
workflows.go
56 lines (46 loc) · 1.69 KB
/
workflows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
func migrateWorkflows(*cli.Context) error {
promptConfirm := PromptDefaultInputs()
if len(migrationReq.AppId) == 0 {
promptConfirm = true
migrationReq.AppId = TextInput("Please provide the application ID of the app containing the workflows -")
}
if len(migrationReq.WorkflowScope) == 0 {
promptConfirm = true
migrationReq.WorkflowScope = SelectInput("Scope for workflows:", scopes, Project)
}
if len(migrationReq.WorkflowIds) == 0 && !migrationReq.All {
allWorkflowConfirm := ConfirmInput("No workflows provided. This defaults to migrating all workflows within the application. Do you want to proceed?")
if !allWorkflowConfirm {
promptConfirm = true
migrationReq.WorkflowIds = TextInput("Provide the workflows that you wish to import as template as comma separated values(e.g. workflow1,workflow2)")
}
}
if migrationReq.AsPipelines {
migrationReq.PipelineScope = Project
}
promptConfirm = PromptOrgAndProject([]string{migrationReq.PipelineScope, migrationReq.WorkflowScope, migrationReq.SecretScope, migrationReq.ConnectorScope, migrationReq.TemplateScope}) || promptConfirm
logMigrationDetails()
if promptConfirm {
confirm := ConfirmInput("Do you want to proceed with workflows migration?")
if !confirm {
log.Fatal("Aborting...")
}
}
// Migrating the workflows
var workflowIds []string
if len(migrationReq.WorkflowIds) > 0 {
workflowIds = Split(migrationReq.WorkflowIds, ",")
}
log.Info("Importing the workflows....")
CreateEntities(getReqBody(Workflow, Filter{
WorkflowIds: workflowIds,
AppId: migrationReq.AppId,
}))
log.Info("Imported the workflows.")
return nil
}