~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/api/facadeversions.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2014 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package api
 
5
 
 
6
// facadeVersions lists the best version of facades that we know about. This
 
7
// will be used to pick out a default version for communication, given the list
 
8
// of known versions that the API server tells us it is capable of supporting.
 
9
// This map should be updated whenever the API server exposes a new version (so
 
10
// that the client will use it whenever it is available).
 
11
// New facades should start at 1.
 
12
// Facades that existed before versioning start at 0.
 
13
var facadeVersions = map[string]int{
 
14
        "Action":                       2,
 
15
        "Agent":                        2,
 
16
        "AgentTools":                   1,
 
17
        "AllModelWatcher":              2,
 
18
        "AllWatcher":                   1,
 
19
        "Annotations":                  2,
 
20
        "Application":                  1,
 
21
        "ApplicationScaler":            1,
 
22
        "Backups":                      1,
 
23
        "Block":                        2,
 
24
        "CharmRevisionUpdater":         2,
 
25
        "Charms":                       2,
 
26
        "Cleaner":                      2,
 
27
        "Client":                       1,
 
28
        "Cloud":                        1,
 
29
        "Controller":                   3,
 
30
        "Deployer":                     1,
 
31
        "DiscoverSpaces":               2,
 
32
        "DiskManager":                  2,
 
33
        "EntityWatcher":                2,
 
34
        "FilesystemAttachmentsWatcher": 2,
 
35
        "Firewaller":                   3,
 
36
        "HighAvailability":             2,
 
37
        "HostKeyReporter":              1,
 
38
        "ImageManager":                 2,
 
39
        "ImageMetadata":                2,
 
40
        "InstancePoller":               3,
 
41
        "KeyManager":                   1,
 
42
        "KeyUpdater":                   1,
 
43
        "LeadershipService":            2,
 
44
        "LifeFlag":                     1,
 
45
        "LogForwarding":                1,
 
46
        "Logger":                       1,
 
47
        "MachineActions":               1,
 
48
        "MachineManager":               2,
 
49
        "Machiner":                     1,
 
50
        "MeterStatus":                  1,
 
51
        "MetricsAdder":                 2,
 
52
        "MetricsDebug":                 2,
 
53
        "MetricsManager":               1,
 
54
        "MigrationFlag":                1,
 
55
        "MigrationMaster":              1,
 
56
        "MigrationMinion":              1,
 
57
        "MigrationStatusWatcher":       1,
 
58
        "MigrationTarget":              1,
 
59
        "ModelConfig":                  1,
 
60
        "ModelManager":                 2,
 
61
        "NotifyWatcher":                1,
 
62
        "Payloads":                     1,
 
63
        "PayloadsHookContext":          1,
 
64
        "Pinger":                       1,
 
65
        "Provisioner":                  3,
 
66
        "ProxyUpdater":                 1,
 
67
        "Reboot":                       2,
 
68
        "RelationUnitsWatcher":         1,
 
69
        "Resources":                    1,
 
70
        "ResourcesHookContext":         1,
 
71
        "Resumer":                      2,
 
72
        "RetryStrategy":                1,
 
73
        "Singular":                     1,
 
74
        "Spaces":                       2,
 
75
        "SSHClient":                    1,
 
76
        "StatusHistory":                2,
 
77
        "Storage":                      3,
 
78
        "StorageProvisioner":           3,
 
79
        "StringsWatcher":               1,
 
80
        "Subnets":                      2,
 
81
        "Undertaker":                   1,
 
82
        "UnitAssigner":                 1,
 
83
        "Uniter":                       4,
 
84
        "Upgrader":                     1,
 
85
        "UserManager":                  1,
 
86
        "VolumeAttachmentsWatcher":     2,
 
87
}
 
88
 
 
89
// bestVersion tries to find the newest version in the version list that we can
 
90
// use.
 
91
func bestVersion(desiredVersion int, versions []int) int {
 
92
        best := 0
 
93
        for _, version := range versions {
 
94
                if version <= desiredVersion && version > best {
 
95
                        best = version
 
96
                }
 
97
        }
 
98
        return best
 
99
}