예제 #1
0
func constructProjectUpgrade(logger *logrus.Entry, env *client.Environment, upgradeOpts client.EnvironmentUpgrade, url, accessKey, secretKey string) (*project.Project, error) {
	variables := env.Environment
	if variables == nil {
		variables = map[string]interface{}{}
	}

	for k, v := range upgradeOpts.Environment {
		variables[k] = v
	}

	context := rancher.Context{
		Context: project.Context{
			ProjectName:  env.Name,
			ComposeBytes: []byte(upgradeOpts.DockerCompose),
			EnvironmentLookup: &lookup.MapEnvLookup{
				Env: variables,
			},
		},
		Url:                 fmt.Sprintf("%s/projects/%s/schemas", url, env.AccountId),
		AccessKey:           accessKey,
		SecretKey:           secretKey,
		RancherComposeBytes: []byte(upgradeOpts.RancherCompose),
		Upgrade:             true,
	}

	p, err := rancher.NewProject(&context)
	if err != nil {
		return nil, err
	}

	p.AddListener(NewListenLogger(logger, p))
	return p, p.Parse()
}
예제 #2
0
func constructProject(logger *logrus.Entry, stack *client.Stack, url, accessKey, secretKey string) (*rancher.Context, *project.Project, error) {
	context := rancher.Context{
		Context: project.Context{
			ProjectName: stack.Name,
			ComposeBytes: [][]byte{
				[]byte(stack.DockerCompose),
			},
			ResourceLookup: &lookup.FileResourceLookup{},
			EnvironmentLookup: &lookup.MapEnvLookup{
				Env: stack.Environment,
			},
		},
		Url:                 fmt.Sprintf("%s/projects/%s/schemas", url, stack.AccountId),
		AccessKey:           accessKey,
		SecretKey:           secretKey,
		RancherComposeBytes: []byte(stack.RancherCompose),
		Binding:             stack.Binding,
	}

	p, err := rancher.NewProject(&context)
	if err != nil {
		return nil, nil, err
	}

	p.AddListener(NewListenLogger(logger, p))
	return &context, p, nil
}
예제 #3
0
func (p *ProjectFactory) Create(c *cli.Context) (*project.Project, error) {
	context := &rancher.Context{
		RancherComposeFile: c.GlobalString("rancher-file"),
		Url:                c.GlobalString("url"),
		AccessKey:          c.GlobalString("access-key"),
		SecretKey:          c.GlobalString("secret-key"),
		Uploader:           &rancher.S3Uploader{},
	}
	command.Populate(&context.Context, c)

	return rancher.NewProject(context)
}
예제 #4
0
func (p *ProjectFactory) Create(c *cli.Context) (project.APIProject, error) {
	rancherComposeFile, err := rancher.ResolveRancherCompose(c.GlobalString("file"),
		c.GlobalString("rancher-file"))
	if err != nil {
		return nil, err
	}

	qLookup, err := rLookup.NewQuestionLookup(rancherComposeFile, &lookup.OsEnvLookup{})
	if err != nil {
		return nil, err
	}

	envLookup, err := rLookup.NewFileEnvLookup(c.GlobalString("env-file"), qLookup)
	if err != nil {
		return nil, err
	}

	context := &rancher.Context{
		Context: project.Context{
			ResourceLookup:    &rLookup.FileResourceLookup{},
			EnvironmentLookup: envLookup,
			LoggerFactory:     logger.NewColorLoggerFactory(),
		},
		RancherComposeFile: c.GlobalString("rancher-file"),
		Url:                c.GlobalString("url"),
		AccessKey:          c.GlobalString("access-key"),
		SecretKey:          c.GlobalString("secret-key"),
		PullCached:         c.Bool("cached"),
		Uploader:           &rancher.S3Uploader{},
		Args:               c.Args(),
		BindingsFile:       c.GlobalString("bindings-file"),
	}
	qLookup.Context = context

	command.Populate(&context.Context, c)

	context.Upgrade = c.Bool("upgrade") || c.Bool("force-upgrade")
	context.ForceUpgrade = c.Bool("force-upgrade")
	context.Rollback = c.Bool("rollback")
	context.BatchSize = int64(c.Int("batch-size"))
	context.Interval = int64(c.Int("interval"))
	context.ConfirmUpgrade = c.Bool("confirm-upgrade")
	context.Pull = c.Bool("pull")

	return rancher.NewProject(context)
}
예제 #5
0
func constructProject(logger *logrus.Entry, env *client.Environment, url, accessKey, secretKey string) (*rancher.Context, *project.Project, error) {
	context := rancher.Context{
		Context: project.Context{
			ProjectName:  env.Name,
			ComposeBytes: []byte(env.DockerCompose),
			EnvironmentLookup: &lookup.MapEnvLookup{
				Env: env.Environment,
			},
		},
		Url:                 fmt.Sprintf("%s/projects/%s/schemas", url, env.AccountId),
		AccessKey:           accessKey,
		SecretKey:           secretKey,
		RancherComposeBytes: []byte(env.RancherCompose),
	}

	p, err := rancher.NewProject(&context)
	if err != nil {
		return nil, nil, err
	}

	p.AddListener(NewListenLogger(logger, p))
	return &context, p, p.Parse()
}
예제 #6
0
func constructProjectUpgrade(logger *logrus.Entry, stack *client.Stack, upgradeOpts client.StackUpgrade, url, accessKey, secretKey string) (*project.Project, map[string]interface{}, error) {
	variables := map[string]interface{}{}
	for k, v := range stack.Environment {
		variables[k] = v
	}

	for k, v := range upgradeOpts.Environment {
		variables[k] = v
	}

	context := rancher.Context{
		Context: project.Context{
			ProjectName: stack.Name,
			ComposeBytes: [][]byte{
				[]byte(upgradeOpts.DockerCompose),
			},
			ResourceLookup: &lookup.FileResourceLookup{},
			EnvironmentLookup: &lookup.MapEnvLookup{
				Env: variables,
			},
		},
		Url:                 fmt.Sprintf("%s/projects/%s/schemas", url, stack.AccountId),
		AccessKey:           accessKey,
		SecretKey:           secretKey,
		RancherComposeBytes: []byte(upgradeOpts.RancherCompose),
		Upgrade:             true,
		Binding:             stack.Binding,
	}

	p, err := rancher.NewProject(&context)
	if err != nil {
		return nil, nil, err
	}

	p.AddListener(NewListenLogger(logger, p))
	return p, variables, nil
}