in cli/bpmetadata/cmd.go [323:396]
func (i *BlueprintInfo) create(bpPath string, r repoDetail, readmeContent []byte) error {
title, err := getMdContent(readmeContent, 1, 1, "", false)
if err != nil {
return fmt.Errorf("title tag missing in markdown, err: %w", err)
}
i.Title = title.literal
rootPath := r.Source.RepoRootPath
if rootPath == "" {
rootPath = r.Source.BlueprintRootPath
}
bpDir := strings.ReplaceAll(bpPath, rootPath, "")
i.Source = &BlueprintRepoDetail{
Repo: r.Source.URL,
SourceType: r.Source.SourceType,
Dir: bpDir,
}
versionInfo, err := getBlueprintVersion(path.Join(bpPath, tfVersionsFileName))
if err == nil {
i.Version = versionInfo.moduleVersion
i.ActuationTool = &BlueprintActuationTool{
Version: versionInfo.requiredTfVersion,
Flavor: "Terraform",
}
}
// create descriptions
i.Description = &BlueprintDescription{}
tagline, err := getMdContent(readmeContent, -1, -1, "Tagline", true)
if err == nil {
i.Description.Tagline = tagline.literal
}
detailed, err := getMdContent(readmeContent, -1, -1, "Detailed", true)
if err == nil {
i.Description.Detailed = detailed.literal
}
preDeploy, err := getMdContent(readmeContent, -1, -1, "PreDeploy", true)
if err == nil {
i.Description.PreDeploy = preDeploy.literal
}
var archListToSet []string
architecture, err := getMdContent(readmeContent, -1, -1, "Architecture", true)
if err == nil {
for _, li := range architecture.listItems {
archListToSet = append(archListToSet, li.text)
}
i.Description.Architecture = archListToSet
}
// create icon
iPath := path.Join(r.Source.BlueprintRootPath, iconFilePath)
exists, _ := fileExists(iPath)
if exists {
i.Icon = iconFilePath
}
d, err := getDeploymentDuration(readmeContent, "Deployment Duration")
if err == nil {
i.DeploymentDuration = d
}
c, err := getCostEstimate(readmeContent, "Cost")
if err == nil {
i.CostEstimate = c
}
return nil
}