diff --git a/README.md b/README.md index f1d1c4a42..891aaf67b 100644 --- a/README.md +++ b/README.md @@ -78,14 +78,14 @@ The structure of the config and the defaults are show below: ```bash { "auth": { - "api_endpoint": "http://auth.nerdalize.com", # URL of authentication server - "public_key": "-----BEGIN PUBLIC KEY-----\nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEAkYbLnam4wo+heLlTZEeh1ZWsfruz9nk\nkyvc4LwKZ8pez5KYY76H1ox+AfUlWOEq+bExypcFfEIrJkf/JXa7jpzkOWBDF9Sa\nOWbQHMK+vvUXieCJvCc9Vj084ABwLBgX\n-----END PUBLIC KEY-----", # Public key used to verify JWT signature - "client_id": "GuoeRJLYOXzVa9ydPjKi83lCctWtXpNHuiy46Yux", #OAuth client ID + "api_endpoint": "http://auth.nerdalize.com/v1/", # URL of authentication server + "public_key": "-----BEGIN PUBLIC KEY-----\nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEBthEmchVCtA3ZPXqiCXdj+7/ZFuhxRgx\ngrTxIHK+b0vEqKqA3O++ggD1GgjqtTfNLGUjLCE3KxyIN78TsK+HU4VVexTjlWXy\nWPtidD68xGD0JVPU1cSfu8iP0XzwgttG\n-----END PUBLIC KEY-----\n", # Public key used to verify JWT signature + "client_id": "Po2PHR7YOIEQojfHy3zfOMulby9QGVSvcD9bO3S3", #OAuth client ID "oauth_localserver": "localhost:9876", #address of local oauth server "oauth_success_url": "https://cloud.nerdalize.com" #redirect URL after successful login }, "enable_logging": false, # When set to true, all output will be logged to ~/.nerd/log - "nerd_api_endpoint": "https://batch.nerdalize.com" # URL of nerdalize API (NCE) + "nerd_api_endpoint": "https://batch.nerdalize.com/v1/" # URL of nerdalize API (NCE) } ``` diff --git a/VERSION b/VERSION index 5745cc7b1..7040b8117 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.16 +0.4.17 diff --git a/command/command.go b/command/command.go index 0fc8b4e7b..d3cf0b091 100644 --- a/command/command.go +++ b/command/command.go @@ -15,7 +15,9 @@ import ( ) const ( - EnvConfigJSON = "NERD_CONFIG_JSON" + //EnvConfigJSON can be used to pass the config file as a json encoded string + EnvConfigJSON = "NERD_CONFIG_JSON" + //EnvNerdProject can be used to set the nerd project EnvNerdProject = "NERD_PROJECT" ) diff --git a/command/project.go b/command/project.go index c7fd169ac..df2ab54bc 100644 --- a/command/project.go +++ b/command/project.go @@ -26,6 +26,7 @@ func ProjectFactory() (cli.Command, error) { return cmd, nil } +//HelpTemplate provides a template for the help command, which excludes the "expel" and "place" subcommands func (cmd *Project) HelpTemplate() string { return fmt.Sprintf(` {{.Help}}{{if gt (len .Subcommands) 0}} diff --git a/command/task.go b/command/task.go index 74ade1647..7c790f4b0 100644 --- a/command/task.go +++ b/command/task.go @@ -26,6 +26,7 @@ func TaskFactory() (cli.Command, error) { return cmd, nil } +//HelpTemplate provides a template for the help command, which excludes the "failure", "heartbeat", "receive", and "success" subcommands func (cmd *Task) HelpTemplate() string { return fmt.Sprintf(` {{.Help}}{{if gt (len .Subcommands) 0}} diff --git a/command/workload.go b/command/workload.go index 70610ef6f..0e5486d13 100644 --- a/command/workload.go +++ b/command/workload.go @@ -24,6 +24,7 @@ func WorkloadFactory() (cli.Command, error) { return cmd, nil } +//HelpTemplate provides a template for the help command, which excludes the "workload work" command func (cmd *Workload) HelpTemplate() string { return ` {{.Help}}{{if gt (len .Subcommands) 0}} diff --git a/command/workload_work.go b/command/workload_work.go index e4328ae36..e8917ecd8 100644 --- a/command/workload_work.go +++ b/command/workload_work.go @@ -53,21 +53,21 @@ func (cmd *WorkloadWork) DoRun(args []string) (err error) { } var entrypoint, command []string - entrJsonStr, err := base64.StdEncoding.DecodeString(cmd.opts.EntrypointJSONB64) + entrJSONString, err := base64.StdEncoding.DecodeString(cmd.opts.EntrypointJSONB64) if err != nil { HandleError(errors.Wrapf(err, "failed to base64 decode entrypoint '%v'", cmd.opts.EntrypointJSONB64)) } - commandJsonStr, err := base64.StdEncoding.DecodeString(cmd.opts.CmdJSONB64) + commandJSONString, err := base64.StdEncoding.DecodeString(cmd.opts.CmdJSONB64) if err != nil { HandleError(errors.Wrapf(err, "failed to base64 decode cmd '%v'", cmd.opts.CmdJSONB64)) } - err = json.Unmarshal(entrJsonStr, &entrypoint) + err = json.Unmarshal(entrJSONString, &entrypoint) if err != nil { - HandleError(errors.Wrapf(err, "failed to decode entrypoint '%s'", entrJsonStr)) + HandleError(errors.Wrapf(err, "failed to decode entrypoint '%s'", entrJSONString)) } - err = json.Unmarshal(commandJsonStr, &command) + err = json.Unmarshal(commandJSONString, &command) if err != nil { - HandleError(errors.Wrapf(err, "failed to decode cmd '%s'", commandJsonStr)) + HandleError(errors.Wrapf(err, "failed to decode cmd '%s'", commandJSONString)) } bclient, err := NewClient(cmd.config, cmd.session) diff --git a/nerd/client/batch/v1/payload/workload.go b/nerd/client/batch/v1/payload/workload.go index 862247b28..9e883c6b4 100644 --- a/nerd/client/batch/v1/payload/workload.go +++ b/nerd/client/batch/v1/payload/workload.go @@ -37,7 +37,7 @@ type DescribeWorkloadOutput struct { Env map[string]string `json:"env"` } -//StartWorkloadInput is input for workload creation +//CreateWorkloadInput is input for workload creation type CreateWorkloadInput struct { ProjectID string `json:"project_id" valid:"required"` Image string `json:"image" valid:"required"` @@ -47,7 +47,7 @@ type CreateWorkloadInput struct { Env map[string]string `json:"env"` } -//StartWorkloadOutput is output for workload creation +//CreateWorkloadOutput is output for workload creation type CreateWorkloadOutput struct { WorkloadSummary } diff --git a/nerd/client/batch/v1/workload.go b/nerd/client/batch/v1/workload.go index 9a2540236..96a706901 100644 --- a/nerd/client/batch/v1/workload.go +++ b/nerd/client/batch/v1/workload.go @@ -14,7 +14,7 @@ type ClientWorkloadInterface interface { DescribeWorkload(projectID, workloadID string) (output *v1payload.DescribeWorkloadOutput, err error) } -//StartWorkload will start a workload +//CreateWorkload will start a workload func (c *Client) CreateWorkload(projectID, image, inputDatasetID string, env map[string]string, instances int, useCuteur bool) (output *v1payload.CreateWorkloadOutput, err error) { output = &v1payload.CreateWorkloadOutput{} input := &v1payload.CreateWorkloadInput{ diff --git a/nerd/conf/conf.go b/nerd/conf/conf.go index 50f30dc05..d9669df31 100644 --- a/nerd/conf/conf.go +++ b/nerd/conf/conf.go @@ -34,18 +34,19 @@ type AuthConfig struct { func Defaults() *Config { return &Config{ Auth: AuthConfig{ - APIEndpoint: "http://auth.nerdalize.com", + APIEndpoint: "https://auth.nerdalize.com/v1/", OAuthLocalServer: "localhost:9876", OAuthSuccessURL: "https://cloud.nerdalize.com", - ClientID: "GuoeRJLYOXzVa9ydPjKi83lCctWtXpNHuiy46Yux", + ClientID: "Po2PHR7YOIEQojfHy3zfOMulby9QGVSvcD9bO3S3", PublicKey: `-----BEGIN PUBLIC KEY----- -MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEAkYbLnam4wo+heLlTZEeh1ZWsfruz9nk -kyvc4LwKZ8pez5KYY76H1ox+AfUlWOEq+bExypcFfEIrJkf/JXa7jpzkOWBDF9Sa -OWbQHMK+vvUXieCJvCc9Vj084ABwLBgX ------END PUBLIC KEY-----`, +MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEBthEmchVCtA3ZPXqiCXdj+7/ZFuhxRgx +grTxIHK+b0vEqKqA3O++ggD1GgjqtTfNLGUjLCE3KxyIN78TsK+HU4VVexTjlWXy +WPtidD68xGD0JVPU1cSfu8iP0XzwgttG +-----END PUBLIC KEY----- +`, }, EnableLogging: false, - NerdAPIEndpoint: "https://batch.nerdalize.com/v1", + NerdAPIEndpoint: "https://batch.nerdalize.com/v1/", } } @@ -72,6 +73,7 @@ func Read(location string) (*Config, error) { return conf, nil } +//FromJSON returns a Config object from a JSON string func FromJSON(in string) (*Config, error) { v := Defaults() return v, json.Unmarshal([]byte(in), v) diff --git a/nerd/service/working/v1/utils.go b/nerd/service/working/v1/utils.go index 206563d21..75c5b0844 100644 --- a/nerd/service/working/v1/utils.go +++ b/nerd/service/working/v1/utils.go @@ -6,6 +6,7 @@ import ( "path/filepath" ) +//RemoveContents removes all contents of a directory func RemoveContents(dir string) error { d, err := os.Open(dir) if err != nil { @@ -25,6 +26,7 @@ func RemoveContents(dir string) error { return nil } +//IsEmptyDir checks if a directory contains files func IsEmptyDir(name string) (bool, error) { f, err := os.Open(name) if err != nil { diff --git a/nerd/service/working/v1/working.go b/nerd/service/working/v1/working.go index afa8e5107..50eb69024 100644 --- a/nerd/service/working/v1/working.go +++ b/nerd/service/working/v1/working.go @@ -173,7 +173,8 @@ func (w *Worker) startRunExec(ctx context.Context, run *v1payload.Run) { w.logs.Printf("[INFO] run process exited succesfully") outputDatasetID := "" if w.uploadConf != nil { - if empty, err := IsEmptyDir(w.uploadConf.LocalDir); !empty && err == nil { + var empty bool + if empty, err = IsEmptyDir(w.uploadConf.LocalDir); !empty && err == nil { w.logs.Printf("[INFO] uploading output data") if outputDatasetID, err = v1datatransfer.Upload(ctx, *w.uploadConf); err != nil { w.logs.Printf("[ERROR] failed to upload output dataset: %+v", err)