Skip to content

Conversation

@chespinoza
Copy link
Contributor

@chespinoza chespinoza commented Jul 18, 2017

Preliminar PR addresses #79 and adds:

  • Create resources and start processes(pipes) using ./device-hub-cli create -d <folder>
  • Stop processes and delete resources ./device-hub-cli delete -d <folder>

To start a process using a config file:
./device-hub-cli start -f=../../../examples/config/http_listener_process.yaml

TODO:

  • Code revision & Improvement
  • Update Docs

Copy link
Contributor

@mdevilliers mdevilliers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking pretty good - just two major comments

  1. Could we simplify the logic in the cmd files e.g.

Rework the functionality into to 4 separate bits for each command -

  • load all the configs - -f there is one, -d there is one or more, no -f or -d construct from the command line or load through stdin. Your struct cliConfStruct looks like it could be useful here
  • order them - depending on the command I think "process" either go first or last or it doesn't matter
  • validate the configs
  • send them over the wire

I think you have got all of the bits - I would just like to see them expressed in the commands

    • A bit of code duplication round loading yaml.

return f, dm.NewDecoder(f), nil
}

func yamlDecoder(filePath string, target interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate function with helpers.go - line 132.

Tags: map[string]string{},
}
tags := []string{}
return startCall(args, request, tags, cli, in, out)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not keen on this case statement - lines 52 to 58 :

  • the other two cases are for validation whilst this specializes for the end of the function e.g. does almost the same bits of code just different.

sort.Sort(cliConfSlice(dataSlice))
case "delete":
sort.Sort(sort.Reverse(cliConfSlice(dataSlice)))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100 sure that this switch on the caller is required. I understand what you are trying to do - its just leading to a bit of spaghetti code. Maybe the ordering could be expressed clearer before the roundtrip function?

}
}

type roundTripFunc func(cli proto.HubClient, in rawConf, out iocodec.Encoder) error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly a rawConf is just a yaml doecoder - is it any different to the iocodec.Decoder for "yaml"?

return nil
}

type cliConfSlice struct {
Copy link
Contributor

@mdevilliers mdevilliers Jul 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if you could restructure the code to on each command return a cliConfSlice, order as per the intention of the command, validate, send over the wire? Please see the overall review comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants