func()

in controllers/codebase/service/chain/put_project.go [461:490]


func (h *PutProject) notEmptyProjectProvisioning(ctx context.Context, codebase *codebaseApi.Codebase, wd string) error {
	log := ctrl.LoggerFrom(ctx)

	log.Info("Start initial provisioning for non-empty project")

	repoUrl, err := util.GetRepoUrl(codebase)
	if err != nil {
		return fmt.Errorf("failed to build repo url: %w", err)
	}

	repu, repp, err := GetRepositoryCredentialsIfExists(codebase, h.client)
	// we are ok if no credentials is found, assuming this is a public repo
	if err != nil && !k8sErrors.IsNotFound(err) {
		return fmt.Errorf("failed to get repository credentials: %w", err)
	}

	if !h.git.CheckPermissions(ctx, repoUrl, repu, repp) {
		return fmt.Errorf("failed to get access to the repository %v for user %v", repoUrl, *repu)
	}

	if err = h.tryToCloneRepo(ctx, repoUrl, repu, repp, wd); err != nil {
		return fmt.Errorf("failed to clone template project: %w", err)
	}

	if err = h.squashCommits(ctx, wd, codebase.Spec.Strategy); err != nil {
		return fmt.Errorf("failed to squash commits in a template repo: %w", err)
	}

	return nil
}