func getRepoDetailsFromRootBp()

in cli/bpmetadata/repo.go [80:120]


func getRepoDetailsFromRootBp(bpPath string) repoDetail {
	rootBp := getBlueprintRootPath(bpPath)
	b, err := UnmarshalMetadata(rootBp, metadataFileName)
	if errors.Is(err, os.ErrNotExist) {
		return repoDetail{
			Source: &repoSource{
				BlueprintRootPath: rootBp,
			},
		}
	}

	if err != nil && strings.Contains(err.Error(), "proto:") {
		return repoDetail{
			Source: &repoSource{
				BlueprintRootPath: rootBp,
			},
		}
	}

	// There is metadata for root but does not have source info
	// which means this is a non-git hosted blueprint
	if b.Spec.Info.Source == nil {
		return repoDetail{
			RepoName: b.Metadata.Name,
			Source: &repoSource{
				BlueprintRootPath: rootBp,
			},
		}
	}

	// If we get here, root metadata exists and has git info
	return repoDetail{
		RepoName: b.Metadata.Name,
		Source: &repoSource{
			URL:               b.Spec.Info.Source.Repo,
			SourceType:        "git",
			BlueprintRootPath: rootBp,
			RepoRootPath:      strings.Replace(rootBp, b.Spec.Info.Source.Dir, "", 1),
		},
	}
}