github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/worker/uniter/operation/storage.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package operation
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"github.com/juju/names"
    10  )
    11  
    12  type updateStorage struct {
    13  	tags []names.StorageTag
    14  
    15  	storageUpdater StorageUpdater
    16  
    17  	DoesNotRequireMachineLock
    18  }
    19  
    20  // String is part of the Operation interface.
    21  func (u *updateStorage) String() string {
    22  	return fmt.Sprintf("update storage %v", u.tags)
    23  }
    24  
    25  // Prepare does nothing; it is part of the Operation interface.
    26  func (u *updateStorage) Prepare(_ State) (*State, error) {
    27  	return nil, nil
    28  }
    29  
    30  // Execute ensures the operation's storage tags are known and tracked. This
    31  // doesn't directly change any persistent state; state is updated when
    32  // storage hooks are executed.
    33  //
    34  // Execute is part of the Operation interface.
    35  func (u *updateStorage) Execute(_ State) (*State, error) {
    36  	return nil, u.storageUpdater.UpdateStorage(u.tags)
    37  }
    38  
    39  // Commit does nothing; it is part of the Operation interface.
    40  func (u *updateStorage) Commit(_ State) (*State, error) {
    41  	return nil, nil
    42  }