github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/worker/uniter/deployer.go (about) 1 // Copyright 2012-2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package uniter 5 6 import ( 7 "github.com/juju/errors" 8 9 "github.com/juju/juju/worker/uniter/charm" 10 ) 11 12 // deployerProxy exists because we're not yet comfortable that we can safely 13 // drop support for charm.gitDeployer. If we can, then the uniter doesn't 14 // need a deployer reference at all: and we can drop the Fix method, and even 15 // the Notify* methods on the Deployer interface, and simply hand the 16 // deployer we create over to the operationFactory at creation and forget 17 // about it. But. 18 // 19 // We will never be *completely* certain that gitDeployer can be dropped, 20 // because it's not done as an upgrade step (because we can't replace the 21 // deployer while conflicted, and upgrades are not gated on no-conflicts); 22 // and so long as there's a reasonable possibility that someone *might* have 23 // been running a pre-1.19.1 environment, and have either upgraded directly 24 // in a conflict state *or* have upgraded stepwise without fixing a conflict 25 // state, we should keep this complexity. 26 // 27 // In practice, that possibility is growing ever more remote, but we're not 28 // ready to pull the trigger yet. 29 type deployerProxy struct { 30 charm.Deployer 31 } 32 33 // Fix replaces a git-based charm deployer with a manifest-based one, if 34 // necessary. It should not be called unless the existing charm deployment 35 // is known to be in a stable state. 36 func (d *deployerProxy) Fix() error { 37 if err := charm.FixDeployer(&d.Deployer); err != nil { 38 return errors.Annotatef(err, "cannot convert git deployment to manifest deployment") 39 } 40 return nil 41 } 42 43 // NotifyRevert is part of the charm.Deployer interface. 44 func (d *deployerProxy) NotifyRevert() error { 45 if err := d.Deployer.NotifyRevert(); err != nil { 46 return err 47 } 48 // Now we've reverted, we can guarantee that the deployer is in a sane state; 49 // it's a great time to replace the git deployer (if we're still using it). 50 return d.Fix() 51 }