forked from Azure/azure-extensions-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
promote.go
52 lines (40 loc) · 1.28 KB
/
promote.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"strings"
log "github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
)
func promoteToRegions(c *cli.Context) {
regions := c.StringSlice(flRegion.Name)
if len(regions) == 0 {
log.Fatalf("At least one region must be specified!")
return
}
normalizedRegions := normalizeRegionList(regions)
if err := promoteExtension(c, func() (extensionManifest, error) {
return newExtensionImageManifest(checkFlag(c, flManifest.Name), normalizedRegions)
}); err != nil {
log.Fatal(err)
}
log.Infof("Extension is promoted to PROD in %s. See replication-status.", strings.Join(regions, ","))
}
func promoteToAllRegions(c *cli.Context) {
if err := promoteExtension(c, func() (extensionManifest, error) {
return newExtensionImageGlobalManifest(checkFlag(c, flManifest.Name))
}); err != nil {
log.Fatal(err)
}
log.Info("Extension is promoted to all regions. See replication-status.")
}
func promoteExtension(c *cli.Context, factory func() (extensionManifest, error)) error {
manifest, err := factory()
if err != nil {
return err
}
b, err := manifest.Marshal()
if err != nil {
return err
}
return publishExtension(c, "UpdateExtension", b,
mkClient(checkFlag(c, flMgtURL.Name), checkFlag(c, flSubsID.Name), checkFlag(c, flSubsCert.Name)).UpdateExtension)
}