Skip to content

Commit

Permalink
Merge pull request #102 from nerdalize/fix/prod-pub-key
Browse files Browse the repository at this point in the history
Update production public key
  • Loading branch information
borismattijssen committed Jun 2, 2017
2 parents fdbdac9 + c5350a6 commit 41b2a54
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 23 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -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)
}
```
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.4.16
0.4.17
4 changes: 3 additions & 1 deletion command/command.go
Expand Up @@ -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"
)

Expand Down
1 change: 1 addition & 0 deletions command/project.go
Expand Up @@ -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}}
Expand Down
1 change: 1 addition & 0 deletions command/task.go
Expand Up @@ -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}}
Expand Down
1 change: 1 addition & 0 deletions command/workload.go
Expand Up @@ -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}}
Expand Down
12 changes: 6 additions & 6 deletions command/workload_work.go
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions nerd/client/batch/v1/payload/workload.go
Expand Up @@ -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"`
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion nerd/client/batch/v1/workload.go
Expand Up @@ -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{
Expand Down
16 changes: 9 additions & 7 deletions nerd/conf/conf.go
Expand Up @@ -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/",
}
}

Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions nerd/service/working/v1/utils.go
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion nerd/service/working/v1/working.go
Expand Up @@ -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)
Expand Down

0 comments on commit 41b2a54

Please sign in to comment.