Skip to content

Commit

Permalink
feat: extends metadata schema for bpmetadata (#1413)
Browse files Browse the repository at this point in the history
Co-authored-by: Awais Malik <[email protected]>
  • Loading branch information
g-awmalik and g-awmalik authored Mar 2, 2023
1 parent f6460ae commit 61cd09b
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 8 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.3
VERSION=v0.5.4
BINARY=bin/cft
GITHUB_REPO=github.com/GoogleCloudPlatform/cloud-foundation-toolkit
PLATFORMS := linux windows darwin
Expand Down
74 changes: 67 additions & 7 deletions cli/bpmetadata/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package bpmetadata

import "sigs.k8s.io/kustomize/kyaml/yaml"
import (
"sigs.k8s.io/kustomize/kyaml/yaml"
)

// BlueprintMetadata defines the overall structure for blueprint metadata details
type BlueprintMetadata struct {
Expand All @@ -18,18 +20,23 @@ type BlueprintMetadataSpec struct {

// 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"`
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"`
}

// 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"`
Expand Down Expand Up @@ -68,11 +75,64 @@ type BlueprintDescription struct {
Architecture []string `json:"architecture,omitempty" yaml:"architecture,omitempty"`
}

type BlueprintTimeEstimate struct {
ConfigurationSecs int `json:"configuration,omitempty" yaml:"configuration,omitempty"`
DeploymentSecs int `json:"deployment,omitempty" yaml:"deployment,omitempty"`
}

type BlueprintCostEstimate struct {
Description string `json:",omitempty" yaml:",omitempty"`
Url string `json:",omitempty" yaml:",omitempty"`
}

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"`
}

type QuotaResourceType string

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

type QuotaType string

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

type BlueprintQuotaDetail struct {
// DynamicVariable, if provided, associates the provided input variable
// with the corresponding resource and quota type. In its absence, the quota
// detail is assumed to be fixed.
DynamicVariable string `json:"variable,omitempty" yaml:"variable,omitempty"`

// ResourceType is the type of resource the quota will be applied to i.e.
// GCE Instance or Disk etc.
ResourceType QuotaResourceType `json:"type" yaml:"type"`

// QuotaType is a key/value pair of the actual quotas an their corresponding
// values.
QuotaType map[QuotaType]string `json:"quotaType" yaml:"quotaType"`
}

type BlueprintMiscContent struct {
Name string
Location string
}

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

// BlueprintDiagram is manually entered
type BlueprintDiagram struct {
Name string
Expand Down

0 comments on commit 61cd09b

Please sign in to comment.