Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Service to application #210
Conversation
wallyworld
added some commits
May 25, 2016
axw
reviewed
May 25, 2016
| +// UnmarshalJSON implements the json.Unmarshaler interface. | ||
| +func (bd *BundleData) UnmarshalJSON(b []byte) error { | ||
| + // We account for the fact that the YAML may contain a legacy entry | ||
| + // for "services" instead of "applications". |
axw
reviewed
May 25, 2016
| + | ||
| +// UnmarshalYAML implements the yaml.Unmarshaler interface. | ||
| +func (bd *BundleData) UnmarshalYAML(f func(interface{}) error) error { | ||
| + // We account for the fact that the YAML may contain a legacy entry |
axw
reviewed
May 25, 2016
| @@ -36,11 +36,11 @@ The OpenStack cloud deployed is completely clean; the charms don't attempt to co | ||
| Niggles | ||
| ------- | ||
| -The neutron-gateway service requires a service unit with two network interfaces to provide full functionality; this part of OpenStack provides L3 routing between tenant networks and the rest of the world. Its possible todo this when testing on OpenStack by adding a second network interface to the neutron-gateway service: | ||
| +The neutron-gateway application requires an application unit with two network interfaces to provide full functionality; this part of OpenStack provides L3 routing between tenant networks and the rest of the world. Its possible todo this when testing on OpenStack by adding a second network interface to the neutron-gateway application: |
axw
May 25, 2016
Member
not sure that we should be changing this file, since it's taken from a real bundle...
axw
reviewed
May 25, 2016
| @@ -102,66 +102,66 @@ relations: | ||
| - mysql:shared-db | ||
| - - nova-cloud-controller:amqp | ||
| - rabbitmq-server:amqp | ||
| - - - nova-cloud-controller:image-service |
axw
May 25, 2016
Member
pretty sure those interface names correspond to openstack terms, not juju services/applications. simple sed script? :)
|
LGTM with a couple of small things. Are you sure nothing is relying on the yaml.v1 API being implemented? |
rogpeppe
reviewed
May 25, 2016
| ) | ||
| +type bundleDataCompat struct { | ||
| + // LegacyServices holds application entries for older bundle files |
rogpeppe
May 25, 2016
Owner
How about just embedding BundleData into this struct?
Something like this is simpler, I think, and consolidates the legacy checking
into one place:
type noMethodsBundleData BundleData
type legacyBundleData struct {
noMethodsBundleData `bson:",inline" yaml:",inline"`
Services map[string]*ApplicationSpec `json:"services" yaml:"services" bson:"services"`
}
func (bdc *legacyBundleData) setBundleData(bd *BundleData) error {
if len(bdc.Applications) > 0 && len(bdc.Services) > 0 {
return fmt.Errorf("cannot specify both applications and services")
}
if len(bdc.Services) > 0 {
bdc.Applications = bdc.Services
}
*bd = BundleData(bdc.noMethodsBundleData)
return nil
}
func (bd *BundleData) UnmarshalJSON(b []byte) error {
var bdc legacyBundleData
if err := json.Unmarshal(b, &bdc); err != nil {
return err
}
return bdc.setBundleData(bd)
}
func (bd *BundleData) UnmarshalYAML(f func(interface{}) error) error {
var bdc legacyBundleData
if err := f(&bdc); err != nil {
return err
}
return bdc.setBundleData(bd)
}
func (bd *BundleData) SetBSON(raw bson.Raw) error {
var bdc legacyBundleData
if err := raw.Unmarshal(&bdc); err != nil {
return err
}
return bdc.setBundleData(bd)
}
rogpeppe
reviewed
May 25, 2016
| + Relations: [][]string{ | ||
| + {"wordpress:db", "mysql:db"}, | ||
| + }, | ||
| + }, | ||
| }} |
rogpeppe
May 25, 2016
Owner
Let's have a test for a bundle that specifies both service and applications, please.
(I think that should be an error).
|
I have an implementation suggestion for the unmarshaling logic above. I think I'd probably leave the yaml.v1 interface intact as axw suggests. Also, it would be good to have some round-trip marshal/unmarshal tests Otherwise LGTM, thanks! |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-charm |
wallyworld commentedMay 25, 2016
"Service" has been renamed to "Application". A few changes:
(allow older bundle files to be read)
Waiting on names.v2 to be updated. There's a bot issue to get that sorted out.