cmd/swarm: add flag for application name (swarm or swarm-private)

This commit is contained in:
Anton Evangelatov 2018-11-27 14:28:24 +01:00
parent 695a5cce1e
commit f76f00002f
3 changed files with 11 additions and 4 deletions

View file

@ -33,7 +33,7 @@ func cliFeedUploadAndSync(c *cli.Context) error {
defer func(now time.Time) { log.Info("total time", "time", time.Since(now), "size (kb)", filesize) }(time.Now()) defer func(now time.Time) { log.Info("total time", "time", time.Since(now), "size (kb)", filesize) }(time.Now())
generateEndpoints(scheme, cluster, from, to) generateEndpoints(scheme, cluster, appName, from, to)
log.Info("generating and uploading feeds to " + endpoints[0] + " and syncing") log.Info("generating and uploading feeds to " + endpoints[0] + " and syncing")

View file

@ -29,6 +29,7 @@ var (
endpoints []string endpoints []string
includeLocalhost bool includeLocalhost bool
cluster string cluster string
appName string
scheme string scheme string
filesize int filesize int
from int from int
@ -49,6 +50,12 @@ func main() {
Usage: "cluster to point to (prod or a given namespace)", Usage: "cluster to point to (prod or a given namespace)",
Destination: &cluster, Destination: &cluster,
}, },
cli.StringFlag{
Name: "app",
Value: "swarm",
Usage: "application to point to (swarm or swarm-private)",
Destination: &appName,
},
cli.IntFlag{ cli.IntFlag{
Name: "cluster-from", Name: "cluster-from",
Value: 8501, Value: 8501,

View file

@ -39,14 +39,14 @@ import (
cli "gopkg.in/urfave/cli.v1" cli "gopkg.in/urfave/cli.v1"
) )
func generateEndpoints(scheme string, cluster string, from int, to int) { func generateEndpoints(scheme string, cluster string, app string, from int, to int) {
if cluster == "prod" { if cluster == "prod" {
for port := from; port <= to; port++ { for port := from; port <= to; port++ {
endpoints = append(endpoints, fmt.Sprintf("%s://%v.swarm-gateways.net", scheme, port)) endpoints = append(endpoints, fmt.Sprintf("%s://%v.swarm-gateways.net", scheme, port))
} }
} else { } else {
for port := from; port <= to; port++ { for port := from; port <= to; port++ {
endpoints = append(endpoints, fmt.Sprintf("%s://swarm-%v-%s.stg.swarm-gateways.net", scheme, port, cluster)) endpoints = append(endpoints, fmt.Sprintf("%s://%s-%v-%s.stg.swarm-gateways.net", scheme, app, port, cluster))
} }
} }
@ -61,7 +61,7 @@ func cliUploadAndSync(c *cli.Context) error {
defer func(now time.Time) { log.Info("total time", "time", time.Since(now), "size (kb)", filesize) }(time.Now()) defer func(now time.Time) { log.Info("total time", "time", time.Since(now), "size (kb)", filesize) }(time.Now())
generateEndpoints(scheme, cluster, from, to) generateEndpoints(scheme, cluster, appName, from, to)
log.Info("uploading to " + endpoints[0] + " and syncing") log.Info("uploading to " + endpoints[0] + " and syncing")