Skip to content
Permalink
Browse files
Add an option to search with VPC ID
  • Loading branch information
Sander van Harmelen committed May 18, 2016
1 parent 9811b0f commit 8ed328b8ca13b1e9ee8b9ae91abe524d1f4ec044
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 8ed328b

Please sign in to comment.