2017-05-08 01:20:38 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2018-01-22 11:16:03 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2017-05-08 01:20:38 +00:00
|
|
|
"github.com/rancher/go-rancher-metadata/metadata"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
metadataUrl = "http://rancher-metadata/2015-12-19"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
m := metadata.NewClient(metadataUrl)
|
|
|
|
|
|
|
|
version := "init"
|
|
|
|
|
|
|
|
for {
|
|
|
|
newVersion, err := m.GetVersion()
|
|
|
|
if err != nil {
|
|
|
|
logrus.Errorf("Error reading metadata version: %v", err)
|
|
|
|
} else if version == newVersion {
|
|
|
|
logrus.Debug("No changes in metadata version")
|
|
|
|
} else {
|
|
|
|
logrus.Debugf("Metadata version has changed, oldVersion=[%s], newVersion=[%s]", version, newVersion)
|
|
|
|
version = newVersion
|
|
|
|
}
|
|
|
|
time.Sleep(5 * time.Second)
|
|
|
|
}
|
|
|
|
}
|