Skip to content

Commit

Permalink
feat: adds UI specific type extensions to bpmetadata (#1425)
Browse files Browse the repository at this point in the history
Co-authored-by: Awais Malik <awmalik@google.com>
  • Loading branch information
g-awmalik and g-awmalik committed Mar 10, 2023
1 parent a87b654 commit 00d6ec3
Show file tree
Hide file tree
Showing 5 changed files with 497 additions and 56 deletions.
2 changes: 1 addition & 1 deletion cli/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SHELL := /bin/bash

# Changing this value will trigger a new release
VERSION=v0.5.5
VERSION=v0.6.0
BINARY=bin/cft
GITHUB_REPO=github.com/GoogleCloudPlatform/cloud-foundation-toolkit
PLATFORMS := linux windows darwin
Expand Down
2 changes: 1 addition & 1 deletion cli/bpmetadata/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (c *BlueprintContent) create(bpPath string, rootPath string, readmeContent
for _, li := range documentation.listItems {
doc := BlueprintListContent{
Title: li.text,
Url: li.url,
URL: li.url,
}

docListToSet = append(docListToSet, doc)
Expand Down
261 changes: 207 additions & 54 deletions cli/bpmetadata/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,108 +4,176 @@ import (
"sigs.k8s.io/kustomize/kyaml/yaml"
)

// BlueprintMetadata defines the overall structure for blueprint metadata details
// BlueprintMetadata defines the overall structure for blueprint metadata.
type BlueprintMetadata struct {
Meta yaml.ResourceMeta `json:",inline" yaml:",inline"`
Spec BlueprintMetadataSpec
}

// BlueprintMetadataSpec defines the spec portion of the blueprint metadata
// BlueprintMetadataSpec defines the spec portion of the blueprint metadata.
// All immediate types within BlueprintMetadataSpec are inline and will
// not appear as nodes in metadata.
type BlueprintMetadataSpec struct {
Info BlueprintInfo `json:",inline" yaml:",inline"`
Content BlueprintContent `json:",inline" yaml:",inline"`
Interfaces BlueprintInterface `json:",inline" yaml:",inline"`
Requirements BlueprintRequirements `json:",inline" yaml:",inline"`
UI BlueprintUI `json:",inline" yaml:",inline"`
}

// BlueprintInfo defines informational detail for the blueprint
type BlueprintInfo struct {
Title string
Source *BlueprintRepoDetail
Version string `json:",omitempty" yaml:",omitempty"`
ActuationTool BlueprintActuationTool `json:"actuationTool,omitempty" yaml:"actuationTool,omitempty"`
Description *BlueprintDescription `json:",omitempty" yaml:",omitempty"`
Icon string `json:",omitempty" yaml:",omitempty"`
DeploymentTime BlueprintTimeEstimate `json:"deploymentTime,omitempty" yaml:"deploymentTime,omitempty"`
CostEstimate BlueprintCostEstimate `json:",omitempty" yaml:",omitempty"`
CloudProducts []BlueprintCloudProduct `json:",omitempty" yaml:",omitempty"`
QuotaDetails []BlueprintQuotaDetail `json:",omitempty" yaml:",omitempty"`
}
// Title for the blueprint.
// Autogenerated: First H1 text in readme.md.
Title string

// BlueprintContent defines the detail for blueprint related content such as
// related documentation, diagrams, examples etc.
type BlueprintContent struct {
// Diagrams are manually entered
Architecture BlueprintArchitecture `json:"architecture,omitempty" yaml:"architecture,omitempty"`
Diagrams []BlueprintDiagram `json:",omitempty" yaml:",omitempty"`
Documentation []BlueprintListContent `json:",omitempty" yaml:",omitempty"`
SubBlueprints []BlueprintMiscContent `json:"subBlueprints,omitempty" yaml:"subBlueprints,omitempty"`
Examples []BlueprintMiscContent `json:",omitempty" yaml:",omitempty"`
}
// Blueprint source location and source type.
// Autogen details in BlueprintRepoDetail.
Source *BlueprintRepoDetail

// BlueprintInterface the input and output variables for the blueprint
type BlueprintInterface struct {
Variables []BlueprintVariable `json:",omitempty" yaml:",omitempty"`
// VariableGroups are manually entered
VariableGroups []BlueprintVariableGroup `json:"variableGroups,omitempty" yaml:"variableGroups,omitempty"`
Outputs []BlueprintOutput `json:",omitempty" yaml:",omitempty"`
}
// Last released semantic version for the packaged blueprint.
// Autogenerated: From the `module_name` attribute of the `provider_meta "google"` block.
// E.g.
// provider_meta "google" {
// module_name = "blueprints/terraform/terraform-google-log-analysis/v0.1.5"
// }
Version string `json:",omitempty" yaml:",omitempty"`

// BlueprintRequirements defines the roles required and the assocaited services
// that need to be enabled to provision blueprint resources
type BlueprintRequirements struct {
Roles []BlueprintRoles
Services []string
// Actuation tool e.g. Terraform and its required version.
// Autogen details in BlueprintActuationTool.
ActuationTool BlueprintActuationTool `json:"actuationTool,omitempty" yaml:"actuationTool,omitempty"`

// Various types of descriptions associated with the blueprint.
// Autogen details in BlueprintDescription.
Description *BlueprintDescription `json:",omitempty" yaml:",omitempty"`

// Path to an image representing the icon for the blueprint.
// Will be set as "assets/icon.png". Can be manually authored otherwise.
Icon string `json:",omitempty" yaml:",omitempty"`

// The time estimate for configuring and deploying the blueprint.
// Autogen details in BlueprintTimeEstimate.
DeploymentTime BlueprintTimeEstimate `json:"deploymentTime,omitempty" yaml:"deploymentTime,omitempty"`

// The cost estimate for the blueprint based on preconfigured variables.
// Autogen details in BlueprintCostEstimate.
CostEstimate BlueprintCostEstimate `json:",omitempty" yaml:",omitempty"`

// A list of GCP cloud products used in the blueprint.
// Manually authored.
CloudProducts []BlueprintCloudProduct `json:",omitempty" yaml:",omitempty"`

// A configuration of fixed and dymanic GCP quotas that apply to the soltuion.
// Manually authored.
QuotaDetails []BlueprintQuotaDetail `json:",omitempty" yaml:",omitempty"`

// Details on the author producing the blueprint.
// Manually authored.
Author BlueprintAuthor `json:",omitempty" yaml:",omitempty"`

// Details on sotfware installed as part of the blueprint.
// Manually authored.
SoftwareGroups []BlueprintSoftwareGroup `json:",omitempty" yaml:",omitempty"`

// Support offered, if any for the blueprint.
// Manually authored.
SupportInfo BlueprintSupport `json:",omitempty" yaml:",omitempty"`
}

type BlueprintRepoDetail struct {
Repo string
// Autogenerated: URL from the .git dir.
// Can be manually overriden with a custom URL if needed.
Repo string

// Set as "git" for now until more types are supported.
SourceType string `json:"sourceType" yaml:"sourceType"`
}

type BlueprintActuationTool struct {
Flavor string `json:"type,omitempty" yaml:"type,omitempty"`
// Set as "Terraform" for now until more flavors are supported.
Flavor string `json:"type,omitempty" yaml:"type,omitempty"`

// Required version for the actuation tool.
// Autogenerated: For Terraform this is the `required_version` set in
// `terraform` block. E.g.
// terraform {
// required_version = ">= 0.13"
// }
Version string `json:",omitempty" yaml:",omitempty"`
}

type BlueprintDescription struct {
Tagline string `json:",omitempty" yaml:",omitempty"`
Detailed string `json:",omitempty" yaml:",omitempty"`
PreDeploy string `json:"preDeploy,omitempty" yaml:"preDeploy,omitempty"`
// Autogenerated: All types of descriptions are set with the markdown content
// immediately after the each type's heading declaration in readme.md.

// Autogenerated: Markdown after "### Tagline".
Tagline string `json:",omitempty" yaml:",omitempty"`

// Autogenerated: Markdown after "### Detailed".
Detailed string `json:",omitempty" yaml:",omitempty"`

// Autogenerated: Markdown after "### PreDeploy".
PreDeploy string `json:"preDeploy,omitempty" yaml:"preDeploy,omitempty"`

// Autogenerated: Markdown after "### Html".
HTML string `json:"html,omitempty" yaml:"html,omitempty"`

// Autogenerated: Markdown after "### EulaUrls".
EulaURLs []string `json:"eulaUrls,omitempty" yaml:"eulaUrls,omitempty"`

// Autogenerated: Markdown after "### Architecture"
// Deprecated. Use BlueprintContent.Architecture instead.
Architecture []string `json:"architecture,omitempty" yaml:"architecture,omitempty"`
}

// A time estimate in secs required for configuring and deploying the blueprint.
type BlueprintTimeEstimate struct {
// Autogenerated: Set using the content defined under "### DeploymentTime" E.g.
// ### DeploymentTime
// - Configuration: X secs
// - Deployment: Y secs
ConfigurationSecs int `json:"configuration,omitempty" yaml:"configuration,omitempty"`
DeploymentSecs int `json:"deployment,omitempty" yaml:"deployment,omitempty"`
}

// The cost estimate for the blueprint based on preconfigured variables.
type BlueprintCostEstimate struct {
// Autogenerated: Set using the content defined under "### Cost" as a link
// with a description E.g.
// ### Cost
// [View cost details](https://cloud.google.com/products/calculator?hl=en_US&_ga=2.1665458.-226505189.1675191136#id=02fb0c45-cc29-4567-8cc6-f72ac9024add)
Description string `json:",omitempty" yaml:",omitempty"`
Url string `json:",omitempty" yaml:",omitempty"`
URL string `json:",omitempty" yaml:",omitempty"`
}

// A GCP cloud product used in the blueprint.
// Manually authored.
type BlueprintCloudProduct struct {
ProductId string `json:",omitempty" yaml:",omitempty"`
PageUrl string `json:",omitempty" yaml:",omitempty"`
Label string `json:",omitempty" yaml:",omitempty"`
LocationKey bool `json:",omitempty" yaml:",omitempty"`
// A top-level (e.g. "Compute Engine") or secondary (e.g. "Binary Authorization")
// product used in the blueprint.
ProductId string `json:",omitempty" yaml:",omitempty"`

// Url for the product.
PageURL string `json:",omitempty" yaml:",omitempty"`

// A label string for the product, if it is not an integrated GCP product.
// E.g. "Data Studio"
Label string `json:",omitempty" yaml:",omitempty"`
}

type QuotaResourceType string

const (
GceInstance QuotaResourceType = "GCE_INSTANCE"
GceDisk QuotaResourceType = "GCE_DISK"
GCEInstance QuotaResourceType = "GCE_INSTANCE"
GCEDisk QuotaResourceType = "GCE_DISK"
)

type QuotaType string

const (
MachineType QuotaType = "MACHINE_TYPE"
Cpus QuotaType = "CPUs"
CPUs QuotaType = "CPUs"
DiskType QuotaType = "DISK_TYPE"
DiskSizeGb QuotaType = "SIZE_GB"
DiskSizeGB QuotaType = "SIZE_GB"
)

type BlueprintQuotaDetail struct {
Expand All @@ -123,17 +191,102 @@ type BlueprintQuotaDetail struct {
QuotaType map[QuotaType]string `json:"quotaType" yaml:"quotaType"`
}

type BlueprintAuthor struct {
// Name of template author or organization.
Title string `yaml:"author"`

// Description of the author.
Description string `yaml:"author,omitempty"`

// Link to the author's website.
URL string `yaml:"url,omitempty"`
}

type SoftwareGroupType string

const (
UnspecifiedSG SoftwareGroupType = "UNSPECIFIED"
OS SoftwareGroupType = "OS"
)

// A group of related software components for the blueprint.
type BlueprintSoftwareGroup struct {
// Pre-defined software types.
Type SoftwareGroupType `yaml:"type"`

// Software components belonging to this group.
Software []BlueprintSoftware `yaml:"software"`
}

// A description of a piece of a single software component
// installed by the blueprint.
type BlueprintSoftware struct {
// User-visible title.
Title string `yaml:"title"`

// Software version.
Version string `yaml:"title,omitempty"`

// Link to development site or marketing page for this software.
URL string `yaml:"url,omitempty"`

// Link to license page.
LicenseURL string `yaml:"licenseUrl,omitempty"`
}

// A description of a support option
type BlueprintSupport struct {
//Description of the support option.
Description string `yaml:"description,omitempty"`

// Link to the page providing this support option.
URL string `yaml:"url"`

// The organization or group that provides the support option (e.g.:
// "Community", "Google").
Entity string `yaml:"entity,omitempty"`

// Whether to show the customer's support ID.
ShowSupportId bool `yaml:"showSupportId,omitempty"`
}

// BlueprintContent defines the detail for blueprint related content such as
// related documentation, diagrams, examples etc.
type BlueprintContent struct {
// Diagrams are manually entered.
Architecture BlueprintArchitecture `json:"architecture,omitempty" yaml:"architecture,omitempty"`
Diagrams []BlueprintDiagram `json:",omitempty" yaml:",omitempty"`
Documentation []BlueprintListContent `json:",omitempty" yaml:",omitempty"`
SubBlueprints []BlueprintMiscContent `json:"subBlueprints,omitempty" yaml:"subBlueprints,omitempty"`
Examples []BlueprintMiscContent `json:",omitempty" yaml:",omitempty"`
}

// BlueprintInterface defines the input and output variables for the blueprint.
type BlueprintInterface struct {
Variables []BlueprintVariable `json:",omitempty" yaml:",omitempty"`
// VariableGroups are manually entered.
VariableGroups []BlueprintVariableGroup `json:"variableGroups,omitempty" yaml:"variableGroups,omitempty"`
Outputs []BlueprintOutput `json:",omitempty" yaml:",omitempty"`
}

// BlueprintRequirements defines the roles required and the assocaited services
// that need to be enabled to provision blueprint resources.
type BlueprintRequirements struct {
Roles []BlueprintRoles
Services []string
}

type BlueprintMiscContent struct {
Name string
Location string
}

type BlueprintArchitecture struct {
DiagramUrl string `json:"diagram,omitempty" yaml:"diagram,omitempty"`
DiagramURL string `json:"diagram,omitempty" yaml:"diagram,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

// BlueprintDiagram is manually entered
// BlueprintDiagram is manually entered.
type BlueprintDiagram struct {
Name string
AltText string `json:"altText,omitempty" yaml:"altText,omitempty"`
Expand All @@ -142,7 +295,7 @@ type BlueprintDiagram struct {

type BlueprintListContent struct {
Title string
Url string `json:",omitempty" yaml:",omitempty"`
URL string `json:",omitempty" yaml:",omitempty"`
}

type BlueprintVariable struct {
Expand All @@ -153,7 +306,7 @@ type BlueprintVariable struct {
Required bool
}

// BlueprintVariableGroup is manually entered
// BlueprintVariableGroup is manually entered.
type BlueprintVariableGroup struct {
Name string
Description string `json:",omitempty" yaml:",omitempty"`
Expand Down
Loading

0 comments on commit 00d6ec3

Please sign in to comment.