func (verifier *bundleDataVerifier) verifyRelation(ep0, ep1 endpoint) {
	svc0 := verifier.bd.Applications[ep0.application]
	svc1 := verifier.bd.Applications[ep1.application]
	if svc0 == nil || svc1 == nil || svc0 == svc1 {
		// An error will be produced by verifyRelations for this case.
		return
	}
	charm0 := verifier.charms[svc0.Charm]
	charm1 := verifier.charms[svc1.Charm]
	if charm0 == nil || charm1 == nil {
		// An error will be produced by verifyApplications for this case.
		return
	}
	relProv0, okProv0 := charm0.Meta().Provides[ep0.relation]
	// The juju-info relation is provided implicitly by every
	// charm - use it if required.
	if !okProv0 && ep0.relation == infoRelation.Name {
		relProv0, okProv0 = infoRelation, true
	}
	relReq0, okReq0 := charm0.Meta().Requires[ep0.relation]
	if !okProv0 && !okReq0 {
		verifier.addErrorf("charm %q used by application %q does not define relation %q", svc0.Charm, ep0.application, ep0.relation)
	}
	relProv1, okProv1 := charm1.Meta().Provides[ep1.relation]
	// The juju-info relation is provided implicitly by every
	// charm - use it if required.
	if !okProv1 && ep1.relation == infoRelation.Name {
		relProv1, okProv1 = infoRelation, true
	}
	relReq1, okReq1 := charm1.Meta().Requires[ep1.relation]
	if !okProv1 && !okReq1 {
		verifier.addErrorf("charm %q used by application %q does not define relation %q", svc1.Charm, ep1.application, ep1.relation)
	}

	var relProv, relReq Relation
	var epProv, epReq endpoint
	switch {
	case okProv0 && okReq1:
		relProv, relReq = relProv0, relReq1
		epProv, epReq = ep0, ep1
	case okReq0 && okProv1:
		relProv, relReq = relProv1, relReq0
		epProv, epReq = ep1, ep0
	case okProv0 && okProv1:
		verifier.addErrorf("relation %q to %q relates provider to provider", ep0, ep1)
		return
	case okReq0 && okReq1:
		verifier.addErrorf("relation %q to %q relates requirer to requirer", ep0, ep1)
		return
	default:
		// Errors were added above.
		return
	}
	if relProv.Interface != relReq.Interface {
		verifier.addErrorf("mismatched interface between %q and %q (%q vs %q)", epProv, epReq, relProv.Interface, relReq.Interface)
	}
}
// verifyRelation verifies a single relation.
// It checks that both endpoints of the relation are
// defined, and that the relationship is correctly
// symmetrical (provider to requirer) and shares
// the same interface.
verifyRelation verifies a single relation.
It checks that both endpoints of the relation are
defined, and that the relationship is correctly
symmetrical (provider to requirer) and shares
the same interface.
// verifyRelation verifies a single relation . // It checks that both endpoints of the relation are // defined and that the relationship is correctly // symmetrical ( provider to requirer ) and shares // the same interface .
func (verifier *bundleDataVerifier) verifyRelation(ep0, ep1 endpoint) {
	svc0 := verifier.bd.Applications[ep0.application]
	svc1 := verifier.bd.Applications[ep1.application]
	if svc0 == nil || svc1 == nil || svc0 == svc1 {
		return
	}
	charm0 := verifier.charms[svc0.Charm]
	charm1 := verifier.charms[svc1.Charm]
	if charm0 == nil || charm1 == nil {
		return
	}
	relProv0, okProv0 := charm0.Meta().Provides[ep0.relation]
	if !okProv0 && ep0.relation == infoRelation.Name {
		relProv0, okProv0 = infoRelation, true
	}
	relReq0, okReq0 := charm0.Meta().Requires[ep0.relation]
	if !okProv0 && !okReq0 {
		verifier.addErrorf("charm %q used by application %q does not define relation %q", svc0.Charm, ep0.application, ep0.relation)
	}
	relProv1, okProv1 := charm1.Meta().Provides[ep1.relation]
	if !okProv1 && ep1.relation == infoRelation.Name {
		relProv1, okProv1 = infoRelation, true
	}
	relReq1, okReq1 := charm1.Meta().Requires[ep1.relation]
	if !okProv1 && !okReq1 {
		verifier.addErrorf("charm %q used by application %q does not define relation %q", svc1.Charm, ep1.application, ep1.relation)
	}
	var relProv, relReq Relation
	var epProv, epReq endpoint
	switch {
	case okProv0 && okReq1:
		relProv, relReq = relProv0, relReq1
		epProv, epReq = ep0, ep1
	case okReq0 && okProv1:
		relProv, relReq = relProv1, relReq0
		epProv, epReq = ep1, ep0
	case okProv0 && okProv1:
		verifier.addErrorf("relation %q to %q relates provider to provider", ep0, ep1)
		return
	case okReq0 && okReq1:
		verifier.addErrorf("relation %q to %q relates requirer to requirer", ep0, ep1)
		return
	default:
		return
	}
	if relProv.Interface != relReq.Interface {
		verifier.addErrorf("mismatched interface between %q and %q (%q vs %q)", epProv, epReq, relProv.Interface, relReq.Interface)
	}
}
func ( verifier * bundleDataVerifier ) verifyRelation ( ep0 , ep1 endpoint ) { svc0 := verifier . bd . Applications [ ep0 . application ] svc1 := verifier . bd . Applications [ ep1 . application ] if svc0 == nil || svc1 == nil || svc0 == svc1 { return } charm0 := verifier . charms [ svc0 . Charm ] charm1 := verifier . charms [ svc1 . Charm ] if charm0 == nil || charm1 == nil { return } relProv0 , okProv0 := charm0 . Meta ( ) . Provides [ ep0 . relation ] if ! okProv0 && ep0 . relation == infoRelation . Name { relProv0 , okProv0 = infoRelation , true } relReq0 , okReq0 := charm0 . Meta ( ) . Requires [ ep0 . relation ] if ! okProv0 && ! okReq0 { verifier . addErrorf ( " " , svc0 . Charm , ep0 . application , ep0 . relation ) } relProv1 , okProv1 := charm1 . Meta ( ) . Provides [ ep1 . relation ] if ! okProv1 && ep1 . relation == infoRelation . Name { relProv1 , okProv1 = infoRelation , true } relReq1 , okReq1 := charm1 . Meta ( ) . Requires [ ep1 . relation ] if ! okProv1 && ! okReq1 { verifier . addErrorf ( " " , svc1 . Charm , ep1 . application , ep1 . relation ) } var relProv , relReq Relation var epProv , epReq endpoint switch { case okProv0 && okReq1 : relProv , relReq = relProv0 , relReq1 epProv , epReq = ep0 , ep1 case okReq0 && okProv1 : relProv , relReq = relProv1 , relReq0 epProv , epReq = ep1 , ep0 case okProv0 && okProv1 : verifier . addErrorf ( " " , ep0 , ep1 ) return case okReq0 && okReq1 : verifier . addErrorf ( " " , ep0 , ep1 ) return default : return } if relProv . Interface != relReq . Interface { verifier . addErrorf ( " " , epProv , epReq , relProv . Interface , relReq . Interface ) } }
verifyRelation verifies a single relation.
verifyRelation verifies a single relation .
// An error will be produced by verifyRelations for this case. // An error will be produced by verifyApplications for this case. // The juju-info relation is provided implicitly by every // charm - use it if required. // The juju-info relation is provided implicitly by every // charm - use it if required. // Errors were added above.