Skip to content
Permalink
Browse files
Merge pull request #56 from svanharmelen/f-list-with-vpcid-option
Add an option to search with VPC ID
  • Loading branch information
Sander van Harmelen committed May 18, 2016
2 parents 9811b0f + 8ed328b commit 5686bcde5af20565d8c7a3f66b5441430ac54186
Showing 2 changed files with 40 additions and 0 deletions.
@@ -411,6 +411,26 @@ func WithProject(project string) OptionFunc {
}
}

// VPCIDSetter is an interface that every type that can set a vpc ID must implement
type VPCIDSetter interface {
SetVpcid(string)
}

// WithVPCID takes a vpc ID and sets the `vpcid` parameter
func WithVPCID(id string) OptionFunc {
return func(cs *CloudStackClient, p interface{}) error {
vs, ok := p.(VPCIDSetter)

if !ok || id == "" {
return nil
}

vs.SetVpcid(id)

return nil
}
}

type APIDiscoveryService struct {
cs *CloudStackClient
}
@@ -480,6 +480,26 @@ func (as *allServices) GeneralCode() ([]byte, error) {
pn(" }")
pn("}")
pn("")
pn("// VPCIDSetter is an interface that every type that can set a vpc ID must implement")
pn("type VPCIDSetter interface {")
pn(" SetVpcid(string)")
pn("}")
pn("")
pn("// WithVPCID takes a vpc ID and sets the `vpcid` parameter")
pn("func WithVPCID(id string) OptionFunc {")
pn(" return func(cs *CloudStackClient, p interface{}) error {")
pn(" vs, ok := p.(VPCIDSetter)")
pn("")
pn(" if !ok || id == \"\" {")
pn(" return nil")
pn(" }")
pn("")
pn(" vs.SetVpcid(id)")
pn("")
pn(" return nil")
pn(" }")
pn("}")
pn("")
for _, s := range as.services {
pn("type %s struct {", s.name)
pn(" cs *CloudStackClient")

0 comments on commit 5686bcd

Please sign in to comment.