Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dryRun flag for backplane-cli #210

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Changes from all 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
17 changes: 15 additions & 2 deletions cmd/ocm-backplane/testJob/createTestJob.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ Example usage:
"Optional library file to be passed in (must live in managed-scripts/scripts directory)",
)

cmd.Flags().BoolP(
"dry-run",
"d",
false,
"Use this flag to perform a dry run, which will yield the YAML of the job without creating it.",
)

return cmd
}

Expand All @@ -81,6 +88,11 @@ func runCreateTestJob(cmd *cobra.Command, args []string) error {

// ======== Parsing Flags ========
// Params flag
dryRun, err := cmd.Flags().GetBool("dry-run")
if err != nil {
return err
}

arr, err := cmd.Flags().GetStringArray("params")
if err != nil {
return err
Expand Down Expand Up @@ -144,7 +156,7 @@ func runCreateTestJob(cmd *cobra.Command, args []string) error {
return err
}

cj, err := createTestScriptFromFiles()
cj, err := createTestScriptFromFiles(dryRun)
if err != nil {
return err
}
Expand Down Expand Up @@ -176,7 +188,7 @@ func runCreateTestJob(cmd *cobra.Command, args []string) error {
return nil
}

func createTestScriptFromFiles() (*backplaneApi.CreateTestScriptRunJSONRequestBody, error) {
func createTestScriptFromFiles(dryRun bool) (*backplaneApi.CreateTestScriptRunJSONRequestBody, error) {
// Read the yaml file from cwd
yamlFile, err := os.ReadFile("metadata.yaml")
if err != nil {
Expand Down Expand Up @@ -212,6 +224,7 @@ func createTestScriptFromFiles() (*backplaneApi.CreateTestScriptRunJSONRequestBo
return &backplaneApi.CreateTestScriptRunJSONRequestBody{
ScriptBody: scriptBodyEncoded,
ScriptMetadata: scriptMeta,
DryRun: &dryRun,
}, nil
}

Expand Down