Command pool list #14

Merged
merged 6 commits into from Jan 28, 2015

Conversation

Projects
None yet
3 participants

One test fails. Did not touch it :D

in ../cmd/juju

deploy_test.go:216:
c.Assert(err, jc.ErrorIsNil)
... value *params.Error = &params.Error{"", "cannot add service "storage-block": no storage pool specifed and no default available for storage kind "block" for "data" storage"} ("cannot add service "storage-block": no storage pool specifed and no default available for storage kind "block" for "data" storage")

api/storage/client.go
+// PoolList lists pools according to a given filter.
+// If no filter was provided, this will return a list
+// of all pools.
+func (c *Client) PoolList(types, names []string) ([]params.PoolInstance, error) {
@axw

axw Jan 28, 2015

Collaborator

I'd prefer if we stuck with the verb[-object] convention for API method names, and called this ListPools.

api/storage/client.go
+// If no filter was provided, this will return a list
+// of all pools.
+func (c *Client) PoolList(types, names []string) ([]params.PoolInstance, error) {
+ args := params.PoolListFilter{
@axw

axw Jan 28, 2015

Collaborator

Maybe call this type "StoragePoolFilter", so it can be reused for other pool-related API calls that need to do filtering.

api/storage/client.go
+ Names: names,
+ Types: types,
+ }
+ found := params.PoolListResults{}
@axw

axw Jan 28, 2015

Collaborator

"Results" is usually used for bulk method calls, i.e. where there are multiple disparate arguments and corresponding results. As such, this should just be "PoolListResult". I think it should just be "PoolsResult" though.

@anastasiamac

anastasiamac Jan 28, 2015

Agreed. And changed to Pools :D

apiserver/params/storage.go
+}
+
+// PoolListResults holds a collection of pool instances.
+type PoolListResults struct {
@axw

axw Jan 28, 2015

Collaborator

I don't think these types make sense. It's not really a bulk call, it's a single call with a single set of filter attributes. I think this ought to be:

type StoragePoolsResult struct {
    Pools []StoragePool
}
@anastasiamac

anastasiamac Jan 28, 2015

Agree. Simplified s bit of code too ...

apiserver/params/storage.go
@@ -33,3 +33,28 @@ type StorageShowResult struct {
type StorageListResult struct {
Instances []StorageInstance
}
+
+// PoolInstance holds data for a pool instance.
+type PoolInstance struct {
@axw

axw Jan 28, 2015

Collaborator

s/PoolInstance/StoragePool/

"Pool" isn't very informative without the storage context, and "instance" isn't meaningful here. Pools are always instances.

@anastasiamac

anastasiamac Jan 28, 2015

Done. Thank you for clarification.

apiserver/params/storage.go
+
+// PoolListFilter holds a filter for pool list API call.
+type PoolListFilter struct {
+ Names []string
@axw

axw Jan 28, 2015

Collaborator

Can you comment these please? What are the fields used for? Is there any relationship between Names and Types (i.e. are they pairs?)

@anastasiamac

anastasiamac Jan 28, 2015

Added the descriptions for the individual properties. These comments make it obvious that there is no explicit relationship btw Names and Types.

apiserver/params/storage.go
+type PoolInstance struct {
+ Name string
+ Type string
+ Traits map[string]interface{}
@axw

axw Jan 28, 2015

Collaborator

I'm not married to the name "config", but I think we should be consistent or we'll have a hard time talking about things as a team. Can you please call it config, and then we can talk about renaming it all to something else?

@anastasiamac

anastasiamac Jan 28, 2015

M a bit allergic to config as a var name, especially since we've got more than a few of them. However, I agree that here consistency is important - renamed :D

cmd/juju/storage/pool_list.go
+-e, --environment (= "")
+ juju environment to operate in
+-o, --output (= "")
+ specify an output
+ c,
+ []string{"--type", "a", "--type", "b", "--name", "xyz", "--name", "abc"},
+ // Default format is yaml
+ `- name: testName
@axw

axw Jan 28, 2015

Collaborator

IMO this is much easier to read in the map style. Would you please consider changing it to a map, keyed on the pool name?

cmd/juju/storage/pool_list.go
+type PoolInfo struct {
+ Name string `yaml:"name" json:"name"`
+ Type string `yaml:"type" json:"type"`
+ Traits map[string]interface{} `yaml:"characteristics,omitempty" json:"characteristics,omitempty"`
@axw

axw Jan 28, 2015

Collaborator

config, traits or characteristics? :)

@anastasiamac

anastasiamac Jan 28, 2015

stopping at config (for consistency)

cmd/juju/storage/pool_list_test.go
+ "--name", "xyz", "--name", "abc",
+ "--format", "tabular"},
+ "TYPE NAME CHARACTERISTICS\n"+
+ "a testName one=true,two=well,three=maybe\n"+
@axw

axw Jan 28, 2015

Collaborator

The k/v map looks inappropriate for tabular. Maybe it's alright. Leave it, and we'll see how it feels in practice.

@@ -23,6 +23,8 @@ options:
juju environment to operate in
-o, --output (= "")
specify an output file
+--format (= yaml)
+ specify output format (json|yaml)
@axw

axw Jan 28, 2015

Collaborator

hold on... why are we even doing this? the cmd code should list flags for us?

@anastasiamac

anastasiamac Jan 28, 2015

ATM, it wouldn't. Cmd help is buggy and needs to be addressed. I have put a card on board.
Currently, if you run juju help storage and juju help storage show, you will only get juju help storage...
I think that this wording (and other CLI commands that are structured under SuperCommands) will need to be re-worded..

wallyworld added a commit that referenced this pull request Jan 28, 2015

@wallyworld wallyworld merged commit 1c5fe9a into wallyworld:storage-feature Jan 28, 2015

@anastasiamac anastasiamac deleted the anastasiamac:command-pool-list branch May 28, 2015

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