~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/state/block.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
        ChangeBlock
51
51
)
52
52
 
53
 
var typeNames = map[BlockType]multiwatcher.BlockType{
54
 
        DestroyBlock: multiwatcher.BlockDestroy,
55
 
        RemoveBlock:  multiwatcher.BlockRemove,
56
 
        ChangeBlock:  multiwatcher.BlockChange,
57
 
}
 
53
var (
 
54
        typeNames = map[BlockType]multiwatcher.BlockType{
 
55
                DestroyBlock: multiwatcher.BlockDestroy,
 
56
                RemoveBlock:  multiwatcher.BlockRemove,
 
57
                ChangeBlock:  multiwatcher.BlockChange,
 
58
        }
 
59
        blockMigrationValue = map[BlockType]string{
 
60
                DestroyBlock: "destroy-model",
 
61
                RemoveBlock:  "remove-object",
 
62
                ChangeBlock:  "all-changes",
 
63
        }
 
64
)
58
65
 
59
66
// AllTypes returns all supported block types.
60
67
func AllTypes() []BlockType {
78
85
        return string(t.ToParams())
79
86
}
80
87
 
 
88
// MigrationValue converts the block type value into a useful human readable
 
89
// string for model migration.
 
90
func (t BlockType) MigrationValue() string {
 
91
        if value, ok := blockMigrationValue[t]; ok {
 
92
                return value
 
93
        }
 
94
        return "unknown"
 
95
}
 
96
 
81
97
// ParseBlockType returns BlockType from humanly readable type representation.
82
98
func ParseBlockType(str string) BlockType {
83
99
        for _, one := range AllTypes() {
256
272
        if err != nil {
257
273
                return nil, errors.Annotatef(err, "getting new block id")
258
274
        }
 
275
        // NOTE: if at any time in the future, we change blocks so that the
 
276
        // Tag is different from the model, then the migration of blocks will
 
277
        // need to change format.
259
278
        newDoc := blockDoc{
260
279
                DocID:     st.docID(id),
261
280
                ModelUUID: st.ModelUUID(),