Make manager initialization use dynamic services

pull/573/head
jackgr 9 years ago
parent 2c20a3185f
commit 4bf9ac6e9b

@ -83,21 +83,14 @@ func setupDependencies(c *router.Context) error {
return nil
}
const (
expanderName = "expander-service"
expanderPort = "8080"
expanderURL = "http://localhost:8081"
deployerPort = "8080"
)
func newManager(c *router.Context) manager.Manager {
cfg := c.Config
service := repo.NewInmemRepoService()
cp := c.CredentialProvider
rp := repo.NewRepoProvider(service, repo.NewGCSRepoProvider(cp), cp)
expander := manager.NewExpander(util.GetServiceURL(expanderURL, expanderName, expanderPort), rp)
deployer := manager.NewDeployer(util.GetServiceURL(cfg.DeployerURL, cfg.DeployerName, deployerPort))
address := strings.TrimPrefix(util.GetServiceURL(cfg.MongoAddress, cfg.MongoName, cfg.MongoPort), "http://")
expander := manager.NewExpander(cfg.ExpanderPort, cfg.ExpanderURL, rp)
deployer := manager.NewDeployer(util.GetServiceURLOrDie(cfg.DeployerName, cfg.DeployerPort, cfg.DeployerURL))
address := strings.TrimPrefix(util.GetServiceURLOrDie(cfg.MongoName, cfg.MongoPort, cfg.MongoAddress), "http://")
repository := createRepository(address)
return manager.NewManager(expander, deployer, repository, rp, service, c.CredentialProvider)
}

@ -31,7 +31,10 @@ import (
var (
port = flag.Int("port", 8080, "The port to listen on")
maxLength = flag.Int64("maxLength", 1024, "The maximum length (KB) of a template.")
expanderPort = flag.String("expanderPort", "8081", "The IP port of the default expander service.")
expanderURL = flag.String("expanderURL", "", "The URL for the default expander service.")
deployerName = flag.String("deployer", "resourcifier-service", "The DNS name of the deployer service.")
deployerPort = flag.String("deployerPort", "8082", "The IP port of the deployer service.")
deployerURL = flag.String("deployerURL", "", "The URL for the deployer service.")
credentialFile = flag.String("credentialFile", "", "Local file to use for credentials.")
credentialSecrets = flag.Bool("credentialSecrets", true, "Use secrets for credentials.")
@ -71,7 +74,10 @@ func parseFlags() *router.Config {
return &router.Config{
Address: fmt.Sprintf(":%d", *port),
MaxTemplateLength: *maxLength,
ExpanderPort: *expanderPort,
ExpanderURL: *expanderURL,
DeployerName: *deployerName,
DeployerPort: *deployerPort,
DeployerURL: *deployerURL,
CredentialFile: *credentialFile,
CredentialSecrets: *credentialSecrets,

@ -31,8 +31,14 @@ type Config struct {
Address string
// MaxTemplateLength is the maximum length of a template.
MaxTemplateLength int64
// ExpanderPort is the default expander's IP port
ExpanderPort string
// ExpanderURL is the default expander's URL
ExpanderURL string
// DeployerName is the deployer's DNS name
DeployerName string
// DeployerPort is the deployer's IP port
DeployerPort string
// DeployerURL is the deployer's URL
DeployerURL string
// CredentialFile is the file to the credentials.

Loading…
Cancel
Save