github.com/billybanfield/evergreen@v0.0.0-20170525200750-eeee692790f7/model/host/static_hosts.go (about) 1 package host 2 3 import ( 4 "github.com/evergreen-ci/evergreen" 5 "gopkg.in/mgo.v2" 6 "gopkg.in/mgo.v2/bson" 7 ) 8 9 // DecommissionInactiveStaticHosts decommissions static hosts 10 // in the database provided their ids aren't contained in the 11 // passed in activeStaticHosts slice 12 func DecommissionInactiveStaticHosts(activeStaticHosts []string) error { 13 if activeStaticHosts == nil { 14 return nil 15 } 16 err := UpdateAll( 17 bson.M{ 18 IdKey: bson.M{ 19 "$nin": activeStaticHosts, 20 }, 21 ProviderKey: evergreen.HostTypeStatic, 22 }, 23 bson.M{ 24 "$set": bson.M{ 25 StatusKey: evergreen.HostDecommissioned, 26 }, 27 }, 28 ) 29 if err == mgo.ErrNotFound { 30 return nil 31 } 32 return err 33 }