Example #1
0
// AddSourceRepositoriesToRefBuilder adds the provided repositories to the reference builder, identifies which
// should be built using Docker, and then returns the full list of source repositories.
func AddSourceRepositoriesToRefBuilder(b *app.ReferenceBuilder, repos []string, g *GenerationInputs) (app.SourceRepositories, error) {
	for _, s := range repos {
		if repo, ok := b.AddSourceRepository(s); ok {
			repo.SetContextDir(g.ContextDir)
			if g.Strategy == "docker" {
				repo.BuildWithDocker()
			}
		}
	}
	if len(g.Dockerfile) > 0 {
		if len(g.Strategy) != 0 && g.Strategy != "docker" {
			return nil, errors.New("when directly referencing a Dockerfile, the strategy must must be 'docker'")
		}
		if err := AddDockerfileToSourceRepositories(b, g.Dockerfile); err != nil {
			return nil, err
		}
	}
	_, result, errs := b.Result()
	return result, kutilerrors.NewAggregate(errs)
}