Skip to content

Commit

Permalink
Merge branch 'master' into feature/worker-input-ds
Browse files Browse the repository at this point in the history
  • Loading branch information
borismattijssen committed May 26, 2017
2 parents 55d68d0 + 61f9ef2 commit f655b90
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
23 changes: 20 additions & 3 deletions command/project_place.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,30 @@ import (
"github.com/pkg/errors"
)

//ProjectPlaceOpts describes command options
type ProjectPlaceOpts struct {
Token string `long:"token" default:"" default-mask:"" description:"placement that authenticates using JWT"`
Username string `long:"username" default:"" default-mask:"" description:"username for placement that authenticates using username/password"`
Password string `long:"password" default:"" default-mask:"" description:"password for placement that authenticates using username/password"`
Insecure bool `long:"insecure" default-mask:"" description:"disable checking of server certificate"`
}

//ProjectPlace command
type ProjectPlace struct {
*command
opts *ProjectPlaceOpts
}

//ProjectPlaceFactory returns a factory method for the join command
func ProjectPlaceFactory() (cli.Command, error) {
comm, err := newCommand("nerd project place <host> <token>", "place the current project on a compute cluster", "", nil)
opts := &ProjectPlaceOpts{}
comm, err := newCommand("nerd project place <host>", "place the current project on a compute cluster", "", opts)
if err != nil {
return nil, errors.Wrap(err, "failed to create command")
}
cmd := &ProjectPlace{
command: comm,
opts: opts,
}

cmd.runFunc = cmd.DoRun
Expand All @@ -29,7 +40,7 @@ func ProjectPlaceFactory() (cli.Command, error) {

//DoRun is called by run and allows an error to be returned
func (cmd *ProjectPlace) DoRun(args []string) (err error) {
if len(args) < 2 {
if len(args) < 1 {
return fmt.Errorf("not enough arguments, see --help")
}

Expand All @@ -43,7 +54,13 @@ func (cmd *ProjectPlace) DoRun(args []string) (err error) {
HandleError(err)
}

out, err := bclient.PlaceProject(ss.Project.Name, args[0], args[1], "") //@TODO allow self signed certificate
host := args[0]
token := cmd.opts.Token
username := cmd.opts.Username
password := cmd.opts.Password
insecure := cmd.opts.Insecure

out, err := bclient.PlaceProject(ss.Project.Name, host, token, "", username, password, insecure)
if err != nil {
HandleError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion command/worker_work.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/pkg/errors"
)

//UploadOpts describes command options
//WorkerWorkOpts describes command options
type WorkerWorkOpts struct {
UploadTag string `long:"upload-tag" default:"" default-mask:"" description:"when set, data in --output-dir will be uploaded with this tag after each task run"`
OutputDir string `long:"output-dir" default:"" default-mask:"" description:"when set, data in --output-dir will be uploaded with the --upload-tag tag after each task run"`
Expand Down
5 changes: 4 additions & 1 deletion nerd/client/batch/v1/payload/placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ package v1payload
type PlaceProjectInput struct {
ProjectID string `json:"project_id" valid:"required"`
Host string `json:"host" valid:"required"`
Token string `json:"token" valid:"required"`
Token string `json:"token"`
CAPem string `json:"ca_pem"`
Password string `json:"password"`
Username string `json:"username"`
Insecure bool `json:"insecure"`
}

//PlaceProjectOutput is output for queue creation
Expand Down
7 changes: 5 additions & 2 deletions nerd/client/batch/v1/placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ import (

//ClientPlacementInterface is an interface for placement of project
type ClientPlacementInterface interface {
PlaceProject(projectID, host, token, capem string) (output *v1payload.PlaceProjectOutput, err error)
PlaceProject(projectID, host, token, capem, username, password string, insecure bool) (output *v1payload.PlaceProjectOutput, err error)
ExpelProject(projectID string) (output *v1payload.ExpelProjectOutput, err error)
}

//PlaceProject will create queue
func (c *Client) PlaceProject(projectID, host, token, capem string) (output *v1payload.PlaceProjectOutput, err error) {
func (c *Client) PlaceProject(projectID, host, token, capem, username, password string, insecure bool) (output *v1payload.PlaceProjectOutput, err error) {
output = &v1payload.PlaceProjectOutput{}
input := &v1payload.PlaceProjectInput{
ProjectID: projectID,
Host: host,
Token: token,
CAPem: capem,
Username: username,
Password: password,
Insecure: insecure,
}

return output, c.doRequest(http.MethodPost, createPath(projectID, placementsEndpoint), input, output)
Expand Down

0 comments on commit f655b90

Please sign in to comment.