Skip to content

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
marshall007 committed Jun 12, 2024
1 parent b54dcbc commit 55fbad3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 53 deletions.
47 changes: 1 addition & 46 deletions src/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,51 +51,6 @@ var runCmd = &cobra.Command{
RunE: func(_ *cobra.Command, args []string) error {
taskName := ""

err := utils.ReadYaml(config.TaskFileLocation, &tasksFile)
if err != nil {
message.Fatalf(err, "Failed to open file: %s", err.Error())
}

// ensure vars are uppercase
setRunnerVariables = helpers.TransformMapKeys(setRunnerVariables, strings.ToUpper)

// set any env vars that come from the environment (taking MARU_ over VENDOR_)
for _, variable := range tasksFile.Variables {
if _, ok := setRunnerVariables[variable.Name]; !ok {
if value := os.Getenv(fmt.Sprintf("%s_%s", strings.ToUpper(config.EnvPrefix), variable.Name)); value != "" {
setRunnerVariables[variable.Name] = value
} else if config.VendorPrefix != "" {
if value := os.Getenv(fmt.Sprintf("%s_%s", strings.ToUpper(config.VendorPrefix), variable.Name)); value != "" {
setRunnerVariables[variable.Name] = value
}
}
}
}

if listTasks || listAllTasks {
rows := [][]string{
{"Name", "Description"},
}
for _, task := range tasksFile.Tasks {
rows = append(rows, []string{task.Name, task.Description})
}
// If ListAllTasks, add tasks from included files
if listAllTasks {
err = listTasksFromIncludes(&rows, tasksFile)
if err != nil {
message.Fatalf(err, "Cannot list tasks: %s", err.Error())
}
}

err := pterm.DefaultTable.WithHasHeader().WithData(rows).Render()
if err != nil {
message.Fatalf(err, "Error listing tasks: %s", err.Error())
}

return
}

taskName := "default"
if len(args) > 0 {
taskName = args[0]
}
Expand Down Expand Up @@ -129,7 +84,7 @@ var runCmd = &cobra.Command{

// err := utils.ReadYaml(config.TaskFileLocation, &tasksFile)
// if err != nil {
// message.Fatalf(err, "Cannot unmarshal %s", config.TaskFileLocation)
// message.Fatalf(err, "Failed to open file: %s", err.Error())
// }

// // ensure vars are uppercase
Expand Down
1 change: 1 addition & 0 deletions src/test/tasks/scripting/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ tasks:
inputs:
url:
required: true
description: the URL to fetch
outputs:
user-agent: ${{ steps.fetch.headers["User-Agent"] }}
url: ${{ inputs.url }}
Expand Down
28 changes: 21 additions & 7 deletions tasks.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/defenseunicorns/maru-runner/src/types/tasks-file",
"$id": "https://github.com/defenseunicorns/maru-runner/src/pkg/tasks/tasks-file",
"$ref": "#/$defs/TasksFile",
"$defs": {
"Action": {
Expand All @@ -11,11 +11,15 @@
},
"cmd": {
"type": "string",
"description": "The command to run. Must specify either cmd or wait for the action to do anything."
"description": "The command to run. Must specify cmd"
},
"script": {
"type": "string",
"description": "The script to run. Must specify cmd"
},
"wait": {
"$ref": "#/$defs/ActionWait",
"description": "Wait for a condition to be met before continuing. Must specify either cmd or wait for the action."
"description": "Wait for a condition to be met before continuing. Must specify cmd"
},
"env": {
"items": {
Expand Down Expand Up @@ -310,10 +314,6 @@
"type": "string",
"description": "The script to run. Must specify cmd"
},
"wait": {
"$ref": "#/$defs/ActionWait",
"description": "Wait for a condition to be met before continuing. Must specify cmd"
},
"uses": {
"type": "string",
"description": "The task to run"
Expand Down Expand Up @@ -357,11 +357,25 @@
"type": "array",
"description": "Actions to take when running the task"
},
"steps": {
"items": {
"$ref": "#/$defs/Step"
},
"type": "array",
"description": "Actions to take when running the task"
},
"inputs": {
"additionalProperties": {
"$ref": "#/$defs/InputParameter"
},
"type": "object",
"description": "Input parameters for the task"
},
"outputs": {
"additionalProperties": {
"type": "string"
},
"type": "object",
"description": "Outputs from the task"
}
},
Expand Down

0 comments on commit 55fbad3

Please sign in to comment.