Ejemplo n.º 1
0
func setupTestProject(t *testing.T) *ecsProject {
	envLookup, err := utils.GetDefaultEnvironmentLookup()
	if err != nil {
		t.Fatal("Unexpected error in setting up a project", err)
	}
	resourceLookup, err := utils.GetDefaultResourceLookup()
	if err != nil {
		t.Fatal("Unexpected error in setting up a project", err)
	}

	composeContext := flag.NewFlagSet("ecs-cli", 0)
	composeContext.String(ProjectNameFlag, testProjectName, "")
	parentContext := cli.NewContext(nil, composeContext, nil)
	cliContext := cli.NewContext(nil, nil, parentContext)

	ecsContext := &Context{
		CLIContext: cliContext,
	}
	ecsContext.EnvironmentLookup = envLookup
	ecsContext.ResourceLookup = resourceLookup
	libcomposeProject := project.NewProject(&ecsContext.Context, nil, nil)

	return &ecsProject{
		context: ecsContext,
		Project: *libcomposeProject,
	}
}
Ejemplo n.º 2
0
// populateLibcomposeContext sets the required Libcompose lookup utilities to the context
func (projectFactory projectFactory) populateLibcomposeContext(ecsContext *ecscompose.Context) error {
	envLookup, err := utils.GetDefaultEnvironmentLookup()
	if err != nil {
		return err
	}
	ecsContext.EnvironmentLookup = envLookup

	resourceLookup, err := utils.GetDefaultResourceLookup()
	if err != nil {
		return err
	}
	ecsContext.ResourceLookup = resourceLookup
	return nil
}