github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/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 "Charms": 1, 20 "CharmRevisionUpdater": 0, 21 "Client": 0, 22 "Deployer": 0, 23 "DiskFormatter": 1, 24 "DiskManager": 1, 25 "Environment": 0, 26 "EnvironmentManager": 1, 27 "Firewaller": 1, 28 "HighAvailability": 1, 29 "ImageManager": 1, 30 "KeyManager": 0, 31 "KeyUpdater": 0, 32 "LeadershipService": 1, 33 "Logger": 0, 34 "Machiner": 0, 35 "MetricsManager": 0, 36 "Networker": 0, 37 "NotifyWatcher": 0, 38 "Pinger": 0, 39 "Provisioner": 0, 40 "Reboot": 1, 41 "RelationUnitsWatcher": 0, 42 "Rsyslog": 0, 43 "Service": 1, 44 "Storage": 1, 45 "StringsWatcher": 0, 46 "Upgrader": 0, 47 "Uniter": 2, 48 "UserManager": 0, 49 } 50 51 // bestVersion tries to find the newest version in the version list that we can 52 // use. 53 func bestVersion(desiredVersion int, versions []int) int { 54 best := 0 55 for _, version := range versions { 56 if version <= desiredVersion && version > best { 57 best = version 58 } 59 } 60 return best 61 }