-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add simple converter from new and helper functions Problem: we should be able to create a new jobspec easily, and provide helper functions to read/serialize and validate. Solution: do that. Signed-off-by: vsoch <[email protected]>
- Loading branch information
Showing
12 changed files
with
270 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
v1 "github.com/compspec/jobspec-go/pkg/jobspec/v1" | ||
) | ||
|
||
func main() { | ||
fmt.Println("This example creates a new Jobspec") | ||
|
||
var nodes int32 = 2 | ||
var tasks int32 = 12 | ||
js, err := v1.NewSimpleJobspec("myjobspec", "echo hello world", nodes, tasks) | ||
if err != nil { | ||
fmt.Printf("error creating jobspec: %s\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
// Validate the jobspec | ||
valid, err := js.Validate() | ||
if !valid || err != nil { | ||
fmt.Printf("schema is not valid:%s\n", err) | ||
os.Exit(1) | ||
} else { | ||
fmt.Println("schema is valid") | ||
} | ||
fmt.Println(js) | ||
|
||
out, err := js.JobspecToYaml() | ||
if err != nil { | ||
fmt.Printf("error marshalling jobspec: %s\n", err) | ||
os.Exit(1) | ||
} | ||
fmt.Println(string(out)) | ||
|
||
// One example of json | ||
out, err = js.JobspecToJson() | ||
if err != nil { | ||
fmt.Printf("error marshalling jobspec: %s\n", err) | ||
os.Exit(1) | ||
} | ||
fmt.Println(string(out)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.