cmd

package
v0.18.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RenderCmd = cli.Command{
		Name:  "render",
		Usage: "Validate and render a YAML or JSON to sbatch script",
		Flags: []cli.Flag{
			&cli.PathFlag{
				Name:        "file",
				Value:       "script.yaml",
				Usage:       "File to convert.",
				Destination: &file,
				Aliases:     []string{"f"},
			},
		},
		Action: func(ctx *cli.Context) error {
			r := renderer.NewJobRenderer(
				"logger.example.com:443",
				"/usr/local/bin/grid-logger-writer",
			)
			bytes, err := os.ReadFile(file)
			if err != nil {
				logger.I.Error("failed to read file", zap.Error(err))
				return err
			}
			j := struct {
				Job model.Job
			}{}
			if err := yaml.Unmarshal(bytes, &j); err != nil {
				logger.I.Error("failed to parse file", zap.Error(err))
				return err
			}
			out, err := r.RenderJob(&j.Job)
			if err != nil {
				logger.I.Error("failed to render sbatch script from file", zap.Error(err))
				return err
			}
			fmt.Println(out)
			return nil
		},
	}
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL