github.com/Pankov404/juju@v0.0.0-20150703034450-be266991dceb/api/facadeversions.go (about) 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": 0, 15 "Agent": 1, 16 "AllWatcher": 0, 17 "Annotations": 1, 18 "Backups": 0, 19 "Block": 1, 20 "Charms": 1, 21 "CharmRevisionUpdater": 0, 22 "Client": 0, 23 "Cleaner": 1, 24 "Deployer": 0, 25 "DiskManager": 1, 26 "Environment": 0, 27 "EnvironmentManager": 1, 28 "FilesystemAttachmentsWatcher": 1, 29 "Firewaller": 1, 30 "HighAvailability": 1, 31 "ImageManager": 1, 32 "InstancePoller": 1, 33 "KeyManager": 0, 34 "KeyUpdater": 0, 35 "LeadershipService": 1, 36 "Logger": 0, 37 "MachineManager": 1, 38 "Machiner": 0, 39 "MetricsManager": 0, 40 "Networker": 0, 41 "NotifyWatcher": 0, 42 "Pinger": 0, 43 "Provisioner": 1, 44 "Reboot": 1, 45 "RelationUnitsWatcher": 0, 46 "Resumer": 1, 47 "Rsyslog": 0, 48 "Service": 1, 49 "Storage": 1, 50 "StorageProvisioner": 1, 51 "StringsWatcher": 0, 52 "Upgrader": 0, 53 "Uniter": 2, 54 "UserManager": 0, 55 "VolumeAttachmentsWatcher": 1, 56 } 57 58 // bestVersion tries to find the newest version in the version list that we can 59 // use. 60 func bestVersion(desiredVersion int, versions []int) int { 61 best := 0 62 for _, version := range versions { 63 if version <= desiredVersion && version > best { 64 best = version 65 } 66 } 67 return best 68 }