Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 6 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
50 changes: 50 additions & 0 deletions packages/cli/internal/pkg/cli/workflow/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type runProps struct {
path string
packPath string
workflowUrl string
manifestPath string
inputsPath string
input Input
optionFileUrl string
Expand Down Expand Up @@ -118,6 +119,12 @@ type workflowOutputProps struct {
workflowRunLogOutputs map[string]interface{}
}

type manifestProps struct {
MainWorkFlowURL string `json:"mainWorkFlowURL"`
InputFileURLs []string `json:"inputFileURLs"`
EngineOptions string `json:"engineOptions"`
}

type Manager struct {
Project storage.ProjectClient
Config storage.ConfigClient
Expand Down Expand Up @@ -311,6 +318,12 @@ func (m *Manager) uploadWorkflowToS3() {
if m.err != nil {
return
}
log.Debug().Msgf("copying %s to extra directory", m.path)
err := copyFileRecursivelyToLocation("extra", m.path)
if err != nil {
m.err = err
return
}
objectKey := fmt.Sprintf("%s/%s", m.baseWorkflowKey, workflowZip)
log.Debug().Msgf("updloading '%s' to 's3://%s/%s", m.packPath, m.bucketName, objectKey)
m.err = m.S3.UploadFile(m.bucketName, objectKey, m.packPath)
Expand Down Expand Up @@ -348,6 +361,35 @@ func (m *Manager) parseInputToArguments() {
m.arguments = []string{arguments}
}

func (m *Manager) parseAndAddToManifest() {
if m.err != nil || m.inputsPath == "" {
return
}
m.manifestPath = filepath.Join("extra", "MANIFEST.json")
log.Debug().Msgf("Reading %s", m.manifestPath)
bytes, err := m.Storage.ReadAsBytes(m.manifestPath)
if err != nil {
m.err = err
return
}
var data manifestProps
if err := json.Unmarshal(bytes, &data); err != nil {
m.err = err
return
}
data.InputFileURLs = append(data.InputFileURLs, m.inputsPath)
bytes, err = json.Marshal(data)
if err != nil {
m.err = err
return
}
err = m.Storage.WriteFromBytes(m.manifestPath, bytes)
if err != nil {
m.err = err
return
}
}

func (m *Manager) uploadInputsToS3() {
if m.err != nil || m.input == nil {
return
Expand Down Expand Up @@ -534,6 +576,14 @@ func (m *Manager) cleanUpAttachments() {
log.Warn().Msgf("Failed to clean up temporary file '%s': %s", attachment, err)
}
}
log.Debug().Msgf("removing extra directory")
err := removeAll("extra")
if err != nil {
log.Warn().Msgf("Failed to remove extra directory")
m.err = err
return
}

}

func (m *Manager) runWorkflow() {
Expand Down
1 change: 1 addition & 0 deletions packages/cli/internal/pkg/cli/workflow/workflow_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func (m *Manager) RunWorkflow(contextName, workflowName, inputsFileUrl string, o
}
m.calculateFinalLocation()
m.readInput(inputsFileUrl)
m.parseAndAddToManifest()
m.uploadInputsToS3()
m.parseInputToArguments()
m.readOptionFile(optionFileUrl)
Expand Down
Loading