diff --git a/cmd/package.go b/cmd/package.go index bbb699bb..6c5becab 100644 --- a/cmd/package.go +++ b/cmd/package.go @@ -47,7 +47,6 @@ func NewCmdPkg() *cobra.Command { Args: cobra.ExactArgs(1), RunE: runPkgConfigure, } - pkgConfigureCmd.Flags().StringVarP(&pkgParamsPath, "params", "p", pkgParamsPath, "Path to params json, tfvars or yaml file. This file supports bash interpolation.") pkgDeployCmd := &cobra.Command{ Use: `deploy --`, @@ -78,7 +77,7 @@ func NewCmdPkg() *cobra.Command { Args: cobra.ExactArgs(1), RunE: runPkgGet, } - pkgGetCmd.Flags().StringP("output", "o", "text", "Output format (text or json)") + pkgGetCmd.Flags().StringP("output", "o", "text", "Output format (text or json). Defaults to text (markdown).") pkgPatchCmd := &cobra.Command{ Use: `patch --`, @@ -149,7 +148,7 @@ func runPkgGet(cmd *cobra.Command, args []string) error { return fmt.Errorf("error initializing massdriver client: %w", mdClientErr) } - pkg, err := api.GetPackageByName(ctx, mdClient, pkgID) + pkg, err := api.GetPackage(ctx, mdClient, pkgID) if err != nil { return err } @@ -229,8 +228,15 @@ func runPkgConfigure(cmd *cobra.Command, args []string) error { packageSlugOrID := args[0] params := map[string]any{} - if err := files.Read(pkgParamsPath, ¶ms); err != nil { - return err + if pkgParamsPath == "-" { + // Read from stdin + if err := json.NewDecoder(os.Stdin).Decode(¶ms); err != nil { + return fmt.Errorf("failed to decode JSON from stdin: %w", err) + } + } else { + if err := files.Read(pkgParamsPath, ¶ms); err != nil { + return err + } } mdClient, mdClientErr := client.New() @@ -246,7 +252,7 @@ func runPkgConfigure(cmd *cobra.Command, args []string) error { fmt.Printf("✅ Package `%s` configured successfully\n", configuredPkg.Slug) // Get package details to build URL - pkgDetails, err := api.GetPackageByName(ctx, mdClient, configuredPkg.Slug) + pkgDetails, err := api.GetPackage(ctx, mdClient, configuredPkg.Slug) if err == nil && pkgDetails.Environment != nil && pkgDetails.Environment.Project != nil && pkgDetails.Manifest != nil { urlHelper, urlErr := api.NewURLHelper(ctx, mdClient) if urlErr == nil { @@ -385,7 +391,7 @@ func runPkgVersion(cmd *cobra.Command, args []string) error { fmt.Printf("✅ Package `%s` version set successfully\n", updatedPkg.Slug) // Get package details to build URL - pkgDetails, err := api.GetPackageByName(ctx, mdClient, updatedPkg.Slug) + pkgDetails, err := api.GetPackage(ctx, mdClient, updatedPkg.Slug) if err == nil && pkgDetails.Environment != nil && pkgDetails.Environment.Project != nil && pkgDetails.Manifest != nil { urlHelper, urlErr := api.NewURLHelper(ctx, mdClient) if urlErr == nil { @@ -413,7 +419,7 @@ func runPkgDestroy(cmd *cobra.Command, args []string) error { } // Get package details for confirmation and URL - pkg, err := api.GetPackageByName(ctx, mdClient, packageSlugOrID) + pkg, err := api.GetPackage(ctx, mdClient, packageSlugOrID) if err != nil { return err } diff --git a/cmd/templates/package.get.md.tmpl b/cmd/templates/package.get.md.tmpl index 7d8e7f07..0d802ad6 100644 --- a/cmd/templates/package.get.md.tmpl +++ b/cmd/templates/package.get.md.tmpl @@ -1,10 +1,218 @@ # Package: {{.Slug}} -**Bundle:** {{.Bundle.Name}} +**Status:** {{.Status}} -**Environment:** {{.Environment.Slug}} +{{if .Bundle}} +**Bundle:** {{.Bundle.Name}}{{if .Bundle.Version}} ({{.Bundle.Version}}){{end}} +{{end}} + +{{if .Manifest}} +**Manifest:** {{.Manifest.Name}} ({{.Manifest.Slug}}) +{{if .Manifest.Description}} +{{.Manifest.Description}} +{{end}} +{{end}} + +{{if .Environment}} +**Environment:** {{.Environment.Slug}}{{if .Environment.Name}} ({{.Environment.Name}}){{end}} +{{if .Environment.Project}} +**Project:** {{.Environment.Project.Slug}}{{if .Environment.Project.Name}} ({{.Environment.Project.Name}}){{end}} +{{end}} +{{end}} + +## Version Information + +{{if .Version}} +**Version Constraint:** {{.Version}} +{{end}} +{{if .ResolvedVersion}} +**Resolved Version:** {{.ResolvedVersion}} +{{end}} +{{if .DeployedVersion}} +**Deployed Version:** {{.DeployedVersion}} +{{end}} +{{if .ReleaseStrategy}} +**Release Strategy:** {{.ReleaseStrategy}} +{{end}} +{{if .AvailableUpgrade}} +**Available Upgrade:** {{.AvailableUpgrade}} +{{end}} + +## Timestamps + +{{if .CreatedAt}} +**Created:** {{.CreatedAt.Format "2006-01-02 15:04:05 MST"}} +{{end}} +{{if .UpdatedAt}} +**Last Updated:** {{.UpdatedAt.Format "2006-01-02 15:04:05 MST"}} +{{end}} + +## Deployments + +{{if .ActiveDeployment}} +### Active Deployment + +- **ID:** {{.ActiveDeployment.ID}} +- **Status:** {{.ActiveDeployment.Status}} +- **Action:** {{.ActiveDeployment.Action}} +- **Version:** {{.ActiveDeployment.Version}} +{{if .ActiveDeployment.Message}} +- **Message:** {{.ActiveDeployment.Message}} +{{end}} +{{if .ActiveDeployment.DeployedBy}} +- **Deployed By:** {{.ActiveDeployment.DeployedBy}} +{{end}} +- **Created:** {{.ActiveDeployment.CreatedAt.Format "2006-01-02 15:04:05 MST"}} +{{if .ActiveDeployment.ElapsedTime}} +- **Elapsed Time:** {{.ActiveDeployment.ElapsedTime}}s +{{end}} +{{end}} + +{{if .LatestDeployment}} +### Latest Deployment + +- **ID:** {{.LatestDeployment.ID}} +- **Status:** {{.LatestDeployment.Status}} +- **Action:** {{.LatestDeployment.Action}} +- **Version:** {{.LatestDeployment.Version}} +{{if .LatestDeployment.Message}} +- **Message:** {{.LatestDeployment.Message}} +{{end}} +{{if .LatestDeployment.DeployedBy}} +- **Deployed By:** {{.LatestDeployment.DeployedBy}} +{{end}} +- **Created:** {{.LatestDeployment.CreatedAt.Format "2006-01-02 15:04:05 MST"}} +{{if .LatestDeployment.ElapsedTime}} +- **Elapsed Time:** {{.LatestDeployment.ElapsedTime}}s +{{end}} +{{end}} + +{{if .Deployments}} +### Recent Deployments + +{{range .Deployments}} +- **{{.Status}}** - {{.Action}} ({{.Version}}) - {{.CreatedAt.Format "2006-01-02 15:04:05 MST"}} +{{end}} +{{end}} + +## Artifacts + +{{if .Artifacts}} +{{range .Artifacts}} +- **{{.Name}}** ({{.Type}}){{if .Field}} - Field: {{.Field}}{{end}} +{{end}} +{{else}} +No artifacts +{{end}} + +## Connections + +{{if .Connections}} +{{range .Connections}} +- **{{.PackageField}}**{{if .Artifact}} → {{.Artifact.Name}} ({{.Artifact.Type}}){{end}} +{{end}} +{{else}} +No connections +{{end}} + +## Remote References + +{{if .RemoteReferences}} +{{range .RemoteReferences}} +- **{{.Artifact.Name}}** ({{.Artifact.Type}}){{if .Artifact.Field}} - Field: {{.Artifact.Field}}{{end}} +{{end}} +{{else}} +No remote references +{{end}} + +## Alarms + +{{if .Alarms}} +{{range .Alarms}} +### {{.DisplayName}} + +- **Status:** {{if .CurrentState}}{{.CurrentState.Status}}{{else}}Unknown{{end}} +- **Cloud Resource ID:** {{.CloudResourceID}} +{{if .Namespace}} +- **Namespace:** {{.Namespace}} +{{end}} +{{if .Name}} +- **Metric:** {{.Name}} +{{end}} +{{if .Statistic}} +- **Statistic:** {{.Statistic}} +{{end}} +{{if .Threshold}} +- **Threshold:** {{.Threshold}} +{{end}} +{{if .ComparisonOperator}} +- **Operator:** {{.ComparisonOperator}} +{{end}} +{{if .Dimensions}} +- **Dimensions:** +{{range .Dimensions}} + - {{.Name}}: {{.Value}} +{{end}} +{{end}} +{{if .CurrentState}} +- **Last State Change:** {{.CurrentState.OccurredAt.Format "2006-01-02 15:04:05 MST"}} +{{if .CurrentState.Message}} +- **Message:** {{.CurrentState.Message}} +{{end}} +{{end}} +{{end}} +{{else}} +No alarms configured +{{end}} + +## Secret Fields + +{{if .SecretFields}} +{{range .SecretFields}} +- **{{.Name}}**{{if .Title}} ({{.Title}}){{end}} + - Required: {{.Required}} + - JSON: {{.JSON}} +{{if .Description}} + - Description: {{.Description}} +{{end}} +{{if .ValueMetadata}} + - Set: Yes (SHA256: {{.ValueMetadata.SHA256}}) + - Set At: {{.ValueMetadata.CreatedAt.Format "2006-01-02 15:04:05 MST"}} +{{else}} + - Set: No +{{end}} +{{end}} +{{else}} +No secret fields +{{end}} + +## Cost + +{{if .Cost}} +{{if .Cost.Monthly}} +**Monthly Average:** ${{printf "%.2f" .Cost.Monthly.Average.Amount}} +{{end}} +{{if .Cost.Daily}} +**Daily Average:** ${{printf "%.2f" .Cost.Daily.Average.Amount}} +{{end}} +{{else}} +No cost data available +{{end}} + +## Decommission Status + +{{if .Decommissionable}} +**Can be decommissioned:** {{.Decommissionable.Result}} +{{if .Decommissionable.Messages}} +**Messages:** +{{range .Decommissionable.Messages}} +- {{.}} +{{end}} +{{end}} +{{end}} ## Parameters + ```json {{.ParamsJSON}} ``` diff --git a/docs/generated/mass_package_configure.md b/docs/generated/mass_package_configure.md index a9282d92..40f3161a 100644 --- a/docs/generated/mass_package_configure.md +++ b/docs/generated/mass_package_configure.md @@ -16,6 +16,16 @@ Your IaC must be published as a [bundle](https://docs.massdriver.cloud/bundles) This command will replace the full configuration of an infrastructure package in Massdriver. +## Usage + +```bash +mass package configure [flags] +``` + +## Flags + +- `-p, --params`: Path to params JSON, tfvars, or YAML file. Use `-` to read from stdin. Defaults to `./params.json`. This file supports bash interpolation. + ## Examples You can configure the package using the `slug` identifier. @@ -24,8 +34,27 @@ The `slug` can be found by hovering over the bundle in the Massdriver diagram. T _Note:_ Parameter files support bash interpolation. -```shell +```bash +# Configure package with params file mass package configure ecomm-prod-vpc --params=params.json + +# Configure package with params file using short flag +mass package configure ecomm-prod-vpc -p params.json + +# Configure package by reading params from stdin +mass package configure ecomm-prod-vpc --params=- + +# Configure package with tfvars file +mass package configure ecomm-prod-vpc --params=terraform.tfvars + +# Configure package with YAML file +mass package configure ecomm-prod-vpc --params=params.yaml + +# Pipe params from another command +echo '{"version": "1.0.0"}' | mass package configure ecomm-prod-vpc --params=- + +# Clone configurations between environments +mass package get ecomm-staging-vpc -o json | jq .params | mass package cfg ecomm-dev-vpc --params - ``` @@ -43,7 +72,7 @@ mass package configure ecomm-prod-vpc --params=params.json ``` -h, --help help for configure - -p, --params string Path to params json, tfvars or yaml file. This file supports bash interpolation. (default "./params.json") + -p, --params string Path to params json, tfvars or yaml file. Use '-' to read from stdin. This file supports bash interpolation. (default "./params.json") ``` ### SEE ALSO diff --git a/docs/generated/mass_package_get.md b/docs/generated/mass_package_get.md index ae80c990..8cd433f5 100644 --- a/docs/generated/mass_package_get.md +++ b/docs/generated/mass_package_get.md @@ -19,14 +19,30 @@ Your infrastructure must be published as a [bundle](https://docs.massdriver.clou ## Usage ```bash -mass package get +mass package get [flags] ``` +## Flags + +- `-o, --output`: Output format (text or json). Defaults to text (markdown). + ## Examples ```bash # Get details for a VPC package in the ecommerce production environment mass package get ecomm-prod-vpc + +# Get package as JSON and extract just the params using jq +mass package get ecomm-prod-vpc -o json | jq .params + +# Get package status from JSON output +mass package get ecomm-prod-vpc -o json | jq .status + +# Get package environment details +mass package get ecomm-prod-vpc -o json | jq .environment + +# Save package configuration to a file +mass package get ecomm-prod-vpc -o json > package.json ``` The package slug can be found by hovering over the bundle in the Massdriver diagram. It follows the format: `--`. @@ -46,7 +62,7 @@ mass package get ecomm-prod-vpc ``` -h, --help help for get - -o, --output string Output format (text or json) (default "text") + -o, --output string Output format (text or json). Defaults to text (markdown). (default "text") ``` ### SEE ALSO diff --git a/docs/helpdocs/package/configure.md b/docs/helpdocs/package/configure.md index d53c3e86..b76d5987 100644 --- a/docs/helpdocs/package/configure.md +++ b/docs/helpdocs/package/configure.md @@ -4,6 +4,16 @@ Your IaC must be published as a [bundle](https://docs.massdriver.cloud/bundles) This command will replace the full configuration of an infrastructure package in Massdriver. +## Usage + +```bash +mass package configure [flags] +``` + +## Flags + +- `-p, --params`: Path to params JSON, tfvars, or YAML file. Use `-` to read from stdin. Defaults to `./params.json`. This file supports bash interpolation. + ## Examples You can configure the package using the `slug` identifier. @@ -12,6 +22,25 @@ The `slug` can be found by hovering over the bundle in the Massdriver diagram. T _Note:_ Parameter files support bash interpolation. -```shell +```bash +# Configure package with params file mass package configure ecomm-prod-vpc --params=params.json + +# Configure package with params file using short flag +mass package configure ecomm-prod-vpc -p params.json + +# Configure package by reading params from stdin +mass package configure ecomm-prod-vpc --params=- + +# Configure package with tfvars file +mass package configure ecomm-prod-vpc --params=terraform.tfvars + +# Configure package with YAML file +mass package configure ecomm-prod-vpc --params=params.yaml + +# Pipe params from another command +echo '{"version": "1.0.0"}' | mass package configure ecomm-prod-vpc --params=- + +# Clone configurations between environments +mass package get ecomm-staging-vpc -o json | jq .params | mass package cfg ecomm-dev-vpc --params - ``` diff --git a/docs/helpdocs/package/get.md b/docs/helpdocs/package/get.md index c92eb905..f7987126 100644 --- a/docs/helpdocs/package/get.md +++ b/docs/helpdocs/package/get.md @@ -7,14 +7,30 @@ Your infrastructure must be published as a [bundle](https://docs.massdriver.clou ## Usage ```bash -mass package get +mass package get [flags] ``` +## Flags + +- `-o, --output`: Output format (text or json). Defaults to text (markdown). + ## Examples ```bash # Get details for a VPC package in the ecommerce production environment mass package get ecomm-prod-vpc + +# Get package as JSON and extract just the params using jq +mass package get ecomm-prod-vpc -o json | jq .params + +# Get package status from JSON output +mass package get ecomm-prod-vpc -o json | jq .status + +# Get package environment details +mass package get ecomm-prod-vpc -o json | jq .environment + +# Save package configuration to a file +mass package get ecomm-prod-vpc -o json > package.json ``` The package slug can be found by hovering over the bundle in the Massdriver diagram. It follows the format: `--`. diff --git a/pkg/api/deployment.go b/pkg/api/deployment.go index 7d4487ba..7255581f 100644 --- a/pkg/api/deployment.go +++ b/pkg/api/deployment.go @@ -2,13 +2,23 @@ package api import ( "context" + "time" "github.com/massdriver-cloud/massdriver-sdk-go/massdriver/client" ) type Deployment struct { - ID string `json:"id"` - Status string `json:"status"` + ID string `json:"id"` + Status string `json:"status"` + Action string `json:"action,omitempty"` + Version string `json:"version,omitempty"` + Message string `json:"message,omitempty"` + Params map[string]any `json:"params,omitempty"` + DeployedBy string `json:"deployedBy,omitempty"` + CreatedAt time.Time `json:"createdAt,omitempty"` + UpdatedAt time.Time `json:"updatedAt,omitempty"` + LastTransitionedAt *time.Time `json:"lastTransitionedAt,omitempty"` + ElapsedTime int `json:"elapsedTime,omitempty"` } func GetDeployment(ctx context.Context, mdClient *client.Client, id string) (*Deployment, error) { diff --git a/pkg/api/genqlient.graphql b/pkg/api/genqlient.graphql index 3a23c729..034b8fb7 100644 --- a/pkg/api/genqlient.graphql +++ b/pkg/api/genqlient.graphql @@ -312,23 +312,23 @@ query getPackage($organizationId: ID!, $id: ID!) { slug status params - artifacts { - id - name - field - } - remoteReferences { - artifact { - id - name - field - } - } + paramsSchema + createdAt + updatedAt + version + resolvedVersion + releaseStrategy + deployedVersion + availableUpgrade bundle { id name spec specVersion + version + description + icon + sourceUrl } manifest { id @@ -340,9 +340,129 @@ query getPackage($organizationId: ID!, $id: ID!) { environment { id slug + name project { id slug + name + } + } + artifacts { + id + name + field + type + specs + } + remoteReferences { + artifact { + id + name + field + type + } + } + connections { + id + packageField + artifact { + id + name + type + field + } + createdAt + updatedAt + } + latestDeployment { + id + status + action + version + message + deployedBy + createdAt + updatedAt + lastTransitionedAt + elapsedTime + } + activeDeployment { + id + status + action + version + message + deployedBy + createdAt + updatedAt + lastTransitionedAt + elapsedTime + } + deployments { + id + status + action + version + message + deployedBy + createdAt + updatedAt + lastTransitionedAt + elapsedTime + } + alarms { + id + cloudResourceId + displayName + namespace + name + statistic + dimensions { + name + value + } + comparisonOperator + threshold + period + currentState { + id + status + message + notification + occurredAt + } + } + secretFields { + name + required + json + title + description + valueMetadata { + id + name + sha256 + createdAt + } + } + decommissionable { + result + messages { + message + } + } + cost { + monthly { + average { + amount + currency + } + } + daily { + average { + amount + currency + } } } } diff --git a/pkg/api/package.go b/pkg/api/package.go index 2c3c282b..2d948f21 100644 --- a/pkg/api/package.go +++ b/pkg/api/package.go @@ -4,21 +4,94 @@ import ( "context" "encoding/json" "fmt" + "time" "github.com/massdriver-cloud/massdriver-sdk-go/massdriver/client" "github.com/mitchellh/mapstructure" ) type Package struct { - ID string `json:"id"` - Slug string `json:"slug"` - Status string `json:"status"` - Artifacts []Artifact `json:"artifacts,omitempty"` - RemoteReferences []RemoteReference `json:"remoteReferences,omitempty"` - Bundle *Bundle `json:"bundle,omitempty" mapstructure:"bundle,omitempty"` - Params map[string]any `json:"params"` - Manifest *Manifest `json:"manifest" mapstructure:"manifest,omitempty"` - Environment *Environment `json:"environment,omitempty" mapstructure:"environment,omitempty"` + ID string `json:"id"` + Slug string `json:"slug"` + Status string `json:"status"` + Params map[string]any `json:"params"` + ParamsSchema map[string]any `json:"paramsSchema,omitempty"` + CreatedAt time.Time `json:"createdAt,omitempty"` + UpdatedAt time.Time `json:"updatedAt,omitempty"` + Version string `json:"version,omitempty"` + ResolvedVersion string `json:"resolvedVersion,omitempty"` + ReleaseStrategy string `json:"releaseStrategy,omitempty"` + DeployedVersion string `json:"deployedVersion,omitempty"` + AvailableUpgrade string `json:"availableUpgrade,omitempty"` + Artifacts []Artifact `json:"artifacts,omitempty"` + RemoteReferences []RemoteReference `json:"remoteReferences,omitempty"` + Connections []Connection `json:"connections,omitempty"` + Bundle *Bundle `json:"bundle,omitempty" mapstructure:"bundle,omitempty"` + Manifest *Manifest `json:"manifest" mapstructure:"manifest,omitempty"` + Environment *Environment `json:"environment,omitempty" mapstructure:"environment,omitempty"` + LatestDeployment *Deployment `json:"latestDeployment,omitempty"` + ActiveDeployment *Deployment `json:"activeDeployment,omitempty"` + Deployments []Deployment `json:"deployments,omitempty"` + Alarms []Alarm `json:"alarms,omitempty"` + SecretFields []SecretField `json:"secretFields,omitempty"` + Decommissionable *PackageDeletionLifecycle `json:"decommissionable,omitempty"` + Cost *Cost `json:"cost,omitempty"` +} + +type Connection struct { + ID string `json:"id,omitempty"` + PackageField string `json:"packageField,omitempty"` + Artifact *Artifact `json:"artifact,omitempty"` + CreatedAt time.Time `json:"createdAt,omitempty"` + UpdatedAt time.Time `json:"updatedAt,omitempty"` +} + +type Alarm struct { + ID string `json:"id"` + CloudResourceID string `json:"cloudResourceId"` + DisplayName string `json:"displayName"` + Namespace string `json:"namespace,omitempty"` + Name string `json:"name,omitempty"` + Statistic string `json:"statistic,omitempty"` + Dimensions []Dimension `json:"dimensions,omitempty"` + ComparisonOperator string `json:"comparisonOperator,omitempty"` + Threshold float64 `json:"threshold,omitempty"` + Period int `json:"period,omitempty"` + CurrentState *AlarmState `json:"currentState,omitempty"` +} + +type Dimension struct { + Name string `json:"name"` + Value string `json:"value"` +} + +type AlarmState struct { + ID string `json:"id"` + Status string `json:"status"` + Message string `json:"message"` + Notification map[string]any `json:"notification"` + OccurredAt time.Time `json:"occurredAt"` +} + +type SecretField struct { + Name string `json:"name"` + Required bool `json:"required"` + JSON bool `json:"json"` + Title string `json:"title,omitempty"` + Description string `json:"description,omitempty"` + ValueMetadata *SecretMetadata `json:"valueMetadata,omitempty"` +} + +type SecretMetadata struct { + ID string `json:"id"` + Name string `json:"name"` + SHA256 string `json:"sha256"` + CreatedAt time.Time `json:"createdAt"` +} + +type PackageDeletionLifecycle struct { + Result bool `json:"result"` + Messages []string `json:"messages,omitempty"` } func (p *Package) ParamsJSON() (string, error) { @@ -29,23 +102,307 @@ func (p *Package) ParamsJSON() (string, error) { return string(paramsJSON), nil } -func GetPackageByName(ctx context.Context, mdClient *client.Client, name string) (*Package, error) { - response, err := getPackage(ctx, mdClient.GQL, mdClient.Config.OrganizationID, name) +func (p *Package) ParamsSchemaJSON() (string, error) { + if p.ParamsSchema == nil { + return "{}", nil + } + paramsSchemaJSON, err := json.MarshalIndent(p.ParamsSchema, "", " ") if err != nil { - return nil, fmt.Errorf("error when querying for package %s - ensure your project, target and package abbreviations are correct:\n\t%w", name, err) + return "", fmt.Errorf("failed to marshal params schema to JSON: %w", err) } - - return toPackage(response.Package) + return string(paramsSchemaJSON), nil } func toPackage(p any) (*Package, error) { - pkg := Package{} - if err := mapstructure.Decode(p, &pkg); err != nil { - return nil, fmt.Errorf("failed to decode package: %w", err) + // Type assert to the generated type + genPkg, ok := p.(getPackagePackage) + if !ok { + // Fallback to mapstructure for flexibility + pkg := Package{} + if err := mapstructure.Decode(p, &pkg); err != nil { + return nil, fmt.Errorf("failed to decode package: %w", err) + } + return &pkg, nil + } + + // Convert bundle + var bundle *Bundle + if genPkg.Bundle.Id != "" { + b, err := toBundle(genPkg.Bundle) + if err == nil { + bundle = b + } + } + + // Convert manifest + var manifest *Manifest + if genPkg.Manifest.Id != "" { + m, err := toManifest(genPkg.Manifest) + if err == nil { + manifest = m + } + } + + // Convert environment + var environment *Environment + if genPkg.Environment.Id != "" { + e, err := toEnvironment(genPkg.Environment) + if err == nil { + environment = e + // Convert project if present + if genPkg.Environment.Project.Id != "" { + proj, err := toProject(genPkg.Environment.Project) + if err == nil { + environment.Project = proj + } + } + } + } + + // Convert artifacts + artifacts := make([]Artifact, len(genPkg.Artifacts)) + for i, a := range genPkg.Artifacts { + artifacts[i] = Artifact{ + ID: a.Id, + Name: a.Name, + Type: a.Type, + Field: a.Field, + } + } + + // Convert remote references + remoteReferences := make([]RemoteReference, len(genPkg.RemoteReferences)) + for i, rr := range genPkg.RemoteReferences { + remoteReferences[i] = RemoteReference{ + Artifact: Artifact{ + ID: rr.Artifact.Id, + Name: rr.Artifact.Name, + Type: rr.Artifact.Type, + Field: rr.Artifact.Field, + }, + } + } + + // Convert connections + connections := make([]Connection, len(genPkg.Connections)) + for i, c := range genPkg.Connections { + conn := Connection{ + ID: c.Id, + PackageField: c.PackageField, + CreatedAt: c.CreatedAt, + UpdatedAt: c.UpdatedAt, + } + if c.Artifact.Id != "" { + conn.Artifact = &Artifact{ + ID: c.Artifact.Id, + Name: c.Artifact.Name, + Type: c.Artifact.Type, + Field: c.Artifact.Field, + } + } + connections[i] = conn + } + + // Convert deployments + var latestDeployment *Deployment + if genPkg.LatestDeployment.Id != "" { + latestDeployment = toDeploymentFromLatest(genPkg.LatestDeployment) + } + + var activeDeployment *Deployment + if genPkg.ActiveDeployment.Id != "" { + activeDeployment = toDeploymentFromActive(genPkg.ActiveDeployment) + } + + deployments := make([]Deployment, len(genPkg.Deployments)) + for i, d := range genPkg.Deployments { + deployments[i] = *toDeploymentFromList(d) + } + + // Convert alarms + alarms := make([]Alarm, len(genPkg.Alarms)) + for i, a := range genPkg.Alarms { + alarm := Alarm{ + ID: a.Id, + CloudResourceID: a.CloudResourceId, + DisplayName: a.DisplayName, + Namespace: a.Namespace, + Name: a.Name, + Statistic: a.Statistic, + ComparisonOperator: a.ComparisonOperator, + Threshold: a.Threshold, + Period: a.Period, + } + // Convert dimensions + dimensions := make([]Dimension, len(a.Dimensions)) + for j, d := range a.Dimensions { + dimensions[j] = Dimension{ + Name: d.Name, + Value: d.Value, + } + } + alarm.Dimensions = dimensions + // Convert current state + if a.CurrentState.Id != "" { + alarm.CurrentState = &AlarmState{ + ID: a.CurrentState.Id, + Status: string(a.CurrentState.Status), + Message: a.CurrentState.Message, + Notification: a.CurrentState.Notification, + OccurredAt: a.CurrentState.OccurredAt, + } + } + alarms[i] = alarm + } + + // Convert secret fields + secretFields := make([]SecretField, len(genPkg.SecretFields)) + for i, sf := range genPkg.SecretFields { + secretField := SecretField{ + Name: sf.Name, + Required: sf.Required, + JSON: sf.Json, + Title: sf.Title, + Description: sf.Description, + } + if sf.ValueMetadata.Id != "" { + secretField.ValueMetadata = &SecretMetadata{ + ID: sf.ValueMetadata.Id, + Name: sf.ValueMetadata.Name, + SHA256: sf.ValueMetadata.Sha256, + CreatedAt: sf.ValueMetadata.CreatedAt, + } + } + secretFields[i] = secretField + } + + // Convert decommissionable + var decommissionable *PackageDeletionLifecycle + if genPkg.Decommissionable.Result || len(genPkg.Decommissionable.Messages) > 0 { + messages := make([]string, len(genPkg.Decommissionable.Messages)) + for i, m := range genPkg.Decommissionable.Messages { + messages[i] = m.Message + } + decommissionable = &PackageDeletionLifecycle{ + Result: genPkg.Decommissionable.Result, + Messages: messages, + } } + + // Convert cost + var cost *Cost + if genPkg.Cost.Monthly.Average.Amount > 0 || genPkg.Cost.Daily.Average.Amount > 0 { + cost = &Cost{ + Monthly: &CostType{ + Average: &CostSummary{ + Amount: genPkg.Cost.Monthly.Average.Amount, + }, + }, + Daily: &CostType{ + Average: &CostSummary{ + Amount: genPkg.Cost.Daily.Average.Amount, + }, + }, + } + } + + pkg := Package{ + ID: genPkg.Id, + Slug: genPkg.Slug, + Status: string(genPkg.Status), + Params: genPkg.Params, + ParamsSchema: genPkg.ParamsSchema, + CreatedAt: genPkg.CreatedAt, + UpdatedAt: genPkg.UpdatedAt, + Version: genPkg.Version, + ResolvedVersion: genPkg.ResolvedVersion, + ReleaseStrategy: string(genPkg.ReleaseStrategy), + DeployedVersion: genPkg.DeployedVersion, + AvailableUpgrade: genPkg.AvailableUpgrade, + Artifacts: artifacts, + RemoteReferences: remoteReferences, + Connections: connections, + Bundle: bundle, + Manifest: manifest, + Environment: environment, + LatestDeployment: latestDeployment, + ActiveDeployment: activeDeployment, + Deployments: deployments, + Alarms: alarms, + SecretFields: secretFields, + Decommissionable: decommissionable, + Cost: cost, + } + return &pkg, nil } +func toDeploymentFromLatest(d getPackagePackageLatestDeployment) *Deployment { + var lastTransitionedAt *time.Time + if !d.LastTransitionedAt.IsZero() { + lastTransitionedAt = &d.LastTransitionedAt + } + return &Deployment{ + ID: d.Id, + Status: string(d.Status), + Action: string(d.Action), + Version: d.Version, + Message: d.Message, + DeployedBy: d.DeployedBy, + CreatedAt: d.CreatedAt, + UpdatedAt: d.UpdatedAt, + LastTransitionedAt: lastTransitionedAt, + ElapsedTime: d.ElapsedTime, + } +} + +func toDeploymentFromActive(d getPackagePackageActiveDeployment) *Deployment { + var lastTransitionedAt *time.Time + if !d.LastTransitionedAt.IsZero() { + lastTransitionedAt = &d.LastTransitionedAt + } + return &Deployment{ + ID: d.Id, + Status: string(d.Status), + Action: string(d.Action), + Version: d.Version, + Message: d.Message, + DeployedBy: d.DeployedBy, + CreatedAt: d.CreatedAt, + UpdatedAt: d.UpdatedAt, + LastTransitionedAt: lastTransitionedAt, + ElapsedTime: d.ElapsedTime, + } +} + +func toDeploymentFromList(d getPackagePackageDeploymentsDeployment) *Deployment { + var lastTransitionedAt *time.Time + if !d.LastTransitionedAt.IsZero() { + lastTransitionedAt = &d.LastTransitionedAt + } + return &Deployment{ + ID: d.Id, + Status: string(d.Status), + Action: string(d.Action), + Version: d.Version, + Message: d.Message, + DeployedBy: d.DeployedBy, + CreatedAt: d.CreatedAt, + UpdatedAt: d.UpdatedAt, + LastTransitionedAt: lastTransitionedAt, + ElapsedTime: d.ElapsedTime, + } +} + +func GetPackage(ctx context.Context, mdClient *client.Client, name string) (*Package, error) { + response, err := getPackage(ctx, mdClient.GQL, mdClient.Config.OrganizationID, name) + if err != nil { + return nil, fmt.Errorf("error when querying for package %s - ensure your project, target and package abbreviations are correct:\n\t%w", name, err) + } + + return toPackage(response.Package) +} + func ConfigurePackage(ctx context.Context, mdClient *client.Client, name string, params map[string]any) (*Package, error) { response, err := configurePackage(ctx, mdClient.GQL, mdClient.Config.OrganizationID, name, params) diff --git a/pkg/api/package_test.go b/pkg/api/package_test.go index 96efa550..8d4cad65 100644 --- a/pkg/api/package_test.go +++ b/pkg/api/package_test.go @@ -9,7 +9,7 @@ import ( "github.com/massdriver-cloud/massdriver-sdk-go/massdriver/client" ) -func TestGetPackageByName(t *testing.T) { +func TestGetPackage(t *testing.T) { pkgName := "ecomm-prod-cache" gqlClient := gqlmock.NewClientWithSingleJSONResponse(map[string]any{ @@ -32,28 +32,23 @@ func TestGetPackageByName(t *testing.T) { GQL: gqlClient, } - got, err := api.GetPackageByName(t.Context(), &mdClient, pkgName) + got, err := api.GetPackage(t.Context(), &mdClient, pkgName) if err != nil { t.Fatal(err) } - want := &api.Package{ - Slug: "ecomm-prod-cache", - Bundle: &api.Bundle{ - ID: "bundle-id", - }, - Manifest: &api.Manifest{ - ID: "manifest-id", - }, - Environment: &api.Environment{ - ID: "target-id", - Project: &api.Project{}, - }, + if got.Slug != "ecomm-prod-cache" { + t.Errorf("got Slug %s, wanted ecomm-prod-cache", got.Slug) } - - if !reflect.DeepEqual(got, want) { - t.Errorf("got %v, wanted %v", got, want) + if got.Bundle == nil || got.Bundle.ID != "bundle-id" { + t.Errorf("got Bundle %v, wanted bundle-id", got.Bundle) + } + if got.Manifest == nil || got.Manifest.ID != "manifest-id" { + t.Errorf("got Manifest %v, wanted manifest-id", got.Manifest) + } + if got.Environment == nil || got.Environment.ID != "target-id" { + t.Errorf("got Environment %v, wanted target-id", got.Environment) } } diff --git a/pkg/api/scalars/json_test.go b/pkg/api/scalars/json_test.go index 6b5d9cab..347d6f8e 100644 --- a/pkg/api/scalars/json_test.go +++ b/pkg/api/scalars/json_test.go @@ -18,9 +18,10 @@ func TestMarshalJSON(t *testing.T) { } } -func TestUnmarshalJSON(t *testing.T) { +func TestUnmarshalJSONObject(t *testing.T) { want := map[string]any{"foo": "bar"} + // Test JSON scalar returned as object data := []byte(`{"foo": "bar"}`) got := map[string]any{} diff --git a/pkg/api/schema.graphql b/pkg/api/schema.graphql index 52996c92..ded06ae0 100644 --- a/pkg/api/schema.graphql +++ b/pkg/api/schema.graphql @@ -742,6 +742,9 @@ type NodeContext { "Manifest Name" name: String! + "Icon of the package" + icon: String + "Type of the node (organization\/bundle)" type: String! diff --git a/pkg/api/zz_generated.go b/pkg/api/zz_generated.go index 6ee97fc6..717e93a0 100644 --- a/pkg/api/zz_generated.go +++ b/pkg/api/zz_generated.go @@ -12,6 +12,17 @@ import ( "github.com/massdriver-cloud/mass/pkg/api/scalars" ) +type AlarmStatus string + +const ( + // The metric is within normal operating parameters and below the alarm threshold. + AlarmStatusOk AlarmStatus = "OK" + // The metric has exceeded the configured threshold and triggered the alarm condition. + AlarmStatusAlarm AlarmStatus = "ALARM" + // There is not enough data collected yet to determine the alarm state. This typically occurs when an alarm is first created or after a period of no data. + AlarmStatusInsufficientData AlarmStatus = "INSUFFICIENT_DATA" +) + // How connecting this type works on the diagram. type ArtifactDefinitionUiConnectionOrientation string @@ -45,6 +56,18 @@ func (v *Credential) GetArtifactDefinitionType() string { return v.ArtifactDefin // GetArtifactId returns Credential.ArtifactId, and is useful for accessing the field via an interface. func (v *Credential) GetArtifactId() string { return v.ArtifactId } +// Action type of a deployment +type DeploymentAction string + +const ( + // Provision new infrastructure + DeploymentActionProvision DeploymentAction = "PROVISION" + // Decommission existing infrastructure + DeploymentActionDecommission DeploymentAction = "DECOMMISSION" + // Plan deployment without executing + DeploymentActionPlan DeploymentAction = "PLAN" +) + // Status of a deployment type DeploymentStatus string @@ -3251,15 +3274,54 @@ type getPackagePackage struct { // Current status of the package Status PackageStatus `json:"status"` // Package configuration parameters - Params map[string]any `json:"-"` + Params map[string]any `json:"-"` + ParamsSchema map[string]any `json:"-"` + // When the package was created + CreatedAt time.Time `json:"createdAt"` + // When the package was last updated + UpdatedAt time.Time `json:"updatedAt"` + // The version constraint for this package. This determines which bundle release version the package should use. + // Supports semver constraints (~1.2, ~1), exact versions (1.2.3), and release channels (latest). + // See `VersionConstraint` type documentation for supported formats and examples. + Version string `json:"version"` + // The actual semantic version of the bundle release currently configured for this package. + // This is the resolved version based on the `version` constraint and will be used for the next deployment. + // Example: if `version` is "~1.2", `resolvedVersion` might be "1.2.5". + ResolvedVersion string `json:"resolvedVersion"` + // The release strategy for this package. Determines whether the package should receive + // stable releases only or also development releases. + ReleaseStrategy ReleaseStrategy `json:"releaseStrategy"` + // The semantic version that was last executed. + // This reflects what has been provisioned to infrastructure, which may differ from `resolvedVersion` + // if the package hasn't been deployed since the version was changed. Returns nil if never deployed. + DeployedVersion string `json:"deployedVersion"` + // The newest version available for upgrade based on the package's `version` constraint. + // Returns nil if no upgrade is available or if already on the latest matching version. + // For strict semver constraints (1.2.3), checks for patch-level upgrades (~1.2). + // For release channels (~1.2, ~1, latest), checks for the newest matching version. + AvailableUpgrade string `json:"availableUpgrade"` + Bundle getPackagePackageBundle `json:"bundle"` + Manifest getPackagePackageManifest `json:"manifest"` + // The environment this package will be deployed to + Environment getPackagePackageEnvironment `json:"environment"` // Artifacts provisioned by this package Artifacts []getPackagePackageArtifactsArtifact `json:"artifacts"` // Artifacts from a remote source like another project or a resource not managed by massdriver RemoteReferences []getPackagePackageRemoteReferencesRemoteReference `json:"remoteReferences"` - Bundle getPackagePackageBundle `json:"bundle"` - Manifest getPackagePackageManifest `json:"manifest"` - // The environment this package will be deployed to - Environment getPackagePackageEnvironment `json:"environment"` + Connections []getPackagePackageConnectionsConnection `json:"connections"` + // The latest deployment for this package + LatestDeployment getPackagePackageLatestDeployment `json:"latestDeployment"` + // Currently active deployment for this package + ActiveDeployment getPackagePackageActiveDeployment `json:"activeDeployment"` + Deployments []getPackagePackageDeploymentsDeployment `json:"deployments"` + // Cloud alarms configured through IaC for this package + Alarms []getPackagePackageAlarmsAlarm `json:"alarms"` + // Secret configuration for application packages + SecretFields []getPackagePackageSecretFieldsSecretField `json:"secretFields"` + // Checks if this package can be decommissioned. + Decommissionable getPackagePackageDecommissionablePackageDeletionLifecycle `json:"decommissionable"` + // Cloud provider costs for this package + Cost getPackagePackageCost `json:"cost"` } // GetId returns getPackagePackage.Id, and is useful for accessing the field via an interface. @@ -3274,13 +3336,29 @@ func (v *getPackagePackage) GetStatus() PackageStatus { return v.Status } // GetParams returns getPackagePackage.Params, and is useful for accessing the field via an interface. func (v *getPackagePackage) GetParams() map[string]any { return v.Params } -// GetArtifacts returns getPackagePackage.Artifacts, and is useful for accessing the field via an interface. -func (v *getPackagePackage) GetArtifacts() []getPackagePackageArtifactsArtifact { return v.Artifacts } +// GetParamsSchema returns getPackagePackage.ParamsSchema, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetParamsSchema() map[string]any { return v.ParamsSchema } -// GetRemoteReferences returns getPackagePackage.RemoteReferences, and is useful for accessing the field via an interface. -func (v *getPackagePackage) GetRemoteReferences() []getPackagePackageRemoteReferencesRemoteReference { - return v.RemoteReferences -} +// GetCreatedAt returns getPackagePackage.CreatedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetCreatedAt() time.Time { return v.CreatedAt } + +// GetUpdatedAt returns getPackagePackage.UpdatedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetUpdatedAt() time.Time { return v.UpdatedAt } + +// GetVersion returns getPackagePackage.Version, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetVersion() string { return v.Version } + +// GetResolvedVersion returns getPackagePackage.ResolvedVersion, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetResolvedVersion() string { return v.ResolvedVersion } + +// GetReleaseStrategy returns getPackagePackage.ReleaseStrategy, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetReleaseStrategy() ReleaseStrategy { return v.ReleaseStrategy } + +// GetDeployedVersion returns getPackagePackage.DeployedVersion, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetDeployedVersion() string { return v.DeployedVersion } + +// GetAvailableUpgrade returns getPackagePackage.AvailableUpgrade, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetAvailableUpgrade() string { return v.AvailableUpgrade } // GetBundle returns getPackagePackage.Bundle, and is useful for accessing the field via an interface. func (v *getPackagePackage) GetBundle() getPackagePackageBundle { return v.Bundle } @@ -3291,6 +3369,50 @@ func (v *getPackagePackage) GetManifest() getPackagePackageManifest { return v.M // GetEnvironment returns getPackagePackage.Environment, and is useful for accessing the field via an interface. func (v *getPackagePackage) GetEnvironment() getPackagePackageEnvironment { return v.Environment } +// GetArtifacts returns getPackagePackage.Artifacts, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetArtifacts() []getPackagePackageArtifactsArtifact { return v.Artifacts } + +// GetRemoteReferences returns getPackagePackage.RemoteReferences, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetRemoteReferences() []getPackagePackageRemoteReferencesRemoteReference { + return v.RemoteReferences +} + +// GetConnections returns getPackagePackage.Connections, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetConnections() []getPackagePackageConnectionsConnection { + return v.Connections +} + +// GetLatestDeployment returns getPackagePackage.LatestDeployment, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetLatestDeployment() getPackagePackageLatestDeployment { + return v.LatestDeployment +} + +// GetActiveDeployment returns getPackagePackage.ActiveDeployment, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetActiveDeployment() getPackagePackageActiveDeployment { + return v.ActiveDeployment +} + +// GetDeployments returns getPackagePackage.Deployments, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetDeployments() []getPackagePackageDeploymentsDeployment { + return v.Deployments +} + +// GetAlarms returns getPackagePackage.Alarms, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetAlarms() []getPackagePackageAlarmsAlarm { return v.Alarms } + +// GetSecretFields returns getPackagePackage.SecretFields, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetSecretFields() []getPackagePackageSecretFieldsSecretField { + return v.SecretFields +} + +// GetDecommissionable returns getPackagePackage.Decommissionable, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetDecommissionable() getPackagePackageDecommissionablePackageDeletionLifecycle { + return v.Decommissionable +} + +// GetCost returns getPackagePackage.Cost, and is useful for accessing the field via an interface. +func (v *getPackagePackage) GetCost() getPackagePackageCost { return v.Cost } + func (v *getPackagePackage) UnmarshalJSON(b []byte) error { if string(b) == "null" { @@ -3299,7 +3421,8 @@ func (v *getPackagePackage) UnmarshalJSON(b []byte) error { var firstPass struct { *getPackagePackage - Params json.RawMessage `json:"params"` + Params json.RawMessage `json:"params"` + ParamsSchema json.RawMessage `json:"paramsSchema"` graphql.NoUnmarshalJSON } firstPass.getPackagePackage = v @@ -3321,6 +3444,19 @@ func (v *getPackagePackage) UnmarshalJSON(b []byte) error { } } } + + { + dst := &v.ParamsSchema + src := firstPass.ParamsSchema + if len(src) != 0 && string(src) != "null" { + err = scalars.UnmarshalJSON( + src, dst) + if err != nil { + return fmt.Errorf( + "unable to unmarshal getPackagePackage.ParamsSchema: %w", err) + } + } + } return nil } @@ -3333,15 +3469,47 @@ type __premarshalgetPackagePackage struct { Params json.RawMessage `json:"params"` - Artifacts []getPackagePackageArtifactsArtifact `json:"artifacts"` + ParamsSchema json.RawMessage `json:"paramsSchema"` - RemoteReferences []getPackagePackageRemoteReferencesRemoteReference `json:"remoteReferences"` + CreatedAt time.Time `json:"createdAt"` + + UpdatedAt time.Time `json:"updatedAt"` + + Version string `json:"version"` + + ResolvedVersion string `json:"resolvedVersion"` + + ReleaseStrategy ReleaseStrategy `json:"releaseStrategy"` + + DeployedVersion string `json:"deployedVersion"` + + AvailableUpgrade string `json:"availableUpgrade"` Bundle getPackagePackageBundle `json:"bundle"` Manifest getPackagePackageManifest `json:"manifest"` Environment getPackagePackageEnvironment `json:"environment"` + + Artifacts []getPackagePackageArtifactsArtifact `json:"artifacts"` + + RemoteReferences []getPackagePackageRemoteReferencesRemoteReference `json:"remoteReferences"` + + Connections []getPackagePackageConnectionsConnection `json:"connections"` + + LatestDeployment getPackagePackageLatestDeployment `json:"latestDeployment"` + + ActiveDeployment getPackagePackageActiveDeployment `json:"activeDeployment"` + + Deployments []getPackagePackageDeploymentsDeployment `json:"deployments"` + + Alarms []getPackagePackageAlarmsAlarm `json:"alarms"` + + SecretFields []getPackagePackageSecretFieldsSecretField `json:"secretFields"` + + Decommissionable getPackagePackageDecommissionablePackageDeletionLifecycle `json:"decommissionable"` + + Cost getPackagePackageCost `json:"cost"` } func (v *getPackagePackage) MarshalJSON() ([]byte, error) { @@ -3370,70 +3538,209 @@ func (v *getPackagePackage) __premarshalJSON() (*__premarshalgetPackagePackage, "unable to marshal getPackagePackage.Params: %w", err) } } - retval.Artifacts = v.Artifacts - retval.RemoteReferences = v.RemoteReferences + { + + dst := &retval.ParamsSchema + src := v.ParamsSchema + var err error + *dst, err = scalars.MarshalJSON( + &src) + if err != nil { + return nil, fmt.Errorf( + "unable to marshal getPackagePackage.ParamsSchema: %w", err) + } + } + retval.CreatedAt = v.CreatedAt + retval.UpdatedAt = v.UpdatedAt + retval.Version = v.Version + retval.ResolvedVersion = v.ResolvedVersion + retval.ReleaseStrategy = v.ReleaseStrategy + retval.DeployedVersion = v.DeployedVersion + retval.AvailableUpgrade = v.AvailableUpgrade retval.Bundle = v.Bundle retval.Manifest = v.Manifest retval.Environment = v.Environment + retval.Artifacts = v.Artifacts + retval.RemoteReferences = v.RemoteReferences + retval.Connections = v.Connections + retval.LatestDeployment = v.LatestDeployment + retval.ActiveDeployment = v.ActiveDeployment + retval.Deployments = v.Deployments + retval.Alarms = v.Alarms + retval.SecretFields = v.SecretFields + retval.Decommissionable = v.Decommissionable + retval.Cost = v.Cost return &retval, nil } -// getPackagePackageArtifactsArtifact includes the requested fields of the GraphQL type Artifact. -type getPackagePackageArtifactsArtifact struct { - Id string `json:"id"` - Name string `json:"name"` - // The bundle's artifact field (output field) that produced this artifact. - Field string `json:"field"` +// getPackagePackageActiveDeployment includes the requested fields of the GraphQL type Deployment. +// The GraphQL type's documentation follows. +// +// A deployment represents an instance of a bundle being deployed to a target environment +type getPackagePackageActiveDeployment struct { + Id string `json:"id"` + Status DeploymentStatus `json:"status"` + Action DeploymentAction `json:"action"` + Version string `json:"version"` + Message string `json:"message"` + DeployedBy string `json:"deployedBy"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + LastTransitionedAt time.Time `json:"lastTransitionedAt"` + // Elapsed time in seconds + ElapsedTime int `json:"elapsedTime"` } -// GetId returns getPackagePackageArtifactsArtifact.Id, and is useful for accessing the field via an interface. -func (v *getPackagePackageArtifactsArtifact) GetId() string { return v.Id } +// GetId returns getPackagePackageActiveDeployment.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageActiveDeployment) GetId() string { return v.Id } -// GetName returns getPackagePackageArtifactsArtifact.Name, and is useful for accessing the field via an interface. -func (v *getPackagePackageArtifactsArtifact) GetName() string { return v.Name } +// GetStatus returns getPackagePackageActiveDeployment.Status, and is useful for accessing the field via an interface. +func (v *getPackagePackageActiveDeployment) GetStatus() DeploymentStatus { return v.Status } -// GetField returns getPackagePackageArtifactsArtifact.Field, and is useful for accessing the field via an interface. -func (v *getPackagePackageArtifactsArtifact) GetField() string { return v.Field } +// GetAction returns getPackagePackageActiveDeployment.Action, and is useful for accessing the field via an interface. +func (v *getPackagePackageActiveDeployment) GetAction() DeploymentAction { return v.Action } -// getPackagePackageBundle includes the requested fields of the GraphQL type Bundle. +// GetVersion returns getPackagePackageActiveDeployment.Version, and is useful for accessing the field via an interface. +func (v *getPackagePackageActiveDeployment) GetVersion() string { return v.Version } + +// GetMessage returns getPackagePackageActiveDeployment.Message, and is useful for accessing the field via an interface. +func (v *getPackagePackageActiveDeployment) GetMessage() string { return v.Message } + +// GetDeployedBy returns getPackagePackageActiveDeployment.DeployedBy, and is useful for accessing the field via an interface. +func (v *getPackagePackageActiveDeployment) GetDeployedBy() string { return v.DeployedBy } + +// GetCreatedAt returns getPackagePackageActiveDeployment.CreatedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageActiveDeployment) GetCreatedAt() time.Time { return v.CreatedAt } + +// GetUpdatedAt returns getPackagePackageActiveDeployment.UpdatedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageActiveDeployment) GetUpdatedAt() time.Time { return v.UpdatedAt } + +// GetLastTransitionedAt returns getPackagePackageActiveDeployment.LastTransitionedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageActiveDeployment) GetLastTransitionedAt() time.Time { + return v.LastTransitionedAt +} + +// GetElapsedTime returns getPackagePackageActiveDeployment.ElapsedTime, and is useful for accessing the field via an interface. +func (v *getPackagePackageActiveDeployment) GetElapsedTime() int { return v.ElapsedTime } + +// getPackagePackageAlarmsAlarm includes the requested fields of the GraphQL type Alarm. // The GraphQL type's documentation follows. // -// A specific version of a bundle -type getPackagePackageBundle struct { - // Unique identifier +// An alarm is a condition that triggers a notification. It is defined by a metric, a comparison operator, a threshold, and a period. +type getPackagePackageAlarmsAlarm struct { + // Unique identifier for the alarm. Id string `json:"id"` - // Name of the bundle + // The cloud provider's unique identifier for this alarm. Examples: AWS: 'arn:aws:cloudwatch:us-west-2:123456789012:alarm:test-alarm', Azure: '/subscriptions/.../alerts/12345678-1234-1234-1234-1234567890ab' + CloudResourceId string `json:"cloudResourceId"` + // Human-readable name for the alarm. + DisplayName string `json:"displayName"` + // The cloud provider's metric namespace that categorizes the metric. Examples: AWS: 'AWS/EC2', 'AWS/RDS', Azure: 'Microsoft.Storage/storageAccounts', GCP: 'cloudsql_database' + Namespace string `json:"namespace"` + // The specific metric being monitored. Examples: AWS: 'CPUUtilization', 'ApproximateNumberOfMessagesVisible', Azure: 'Transactions', 'allpercentprocessortime', GCP: 'cloudsql.googleapis.com/database/cpu/utilization' Name string `json:"name"` - // Raw massdriver.yaml spec - Spec map[string]any `json:"-"` - // Version of the bundle specification - SpecVersion string `json:"specVersion"` + // The statistical function applied to the metric data. Examples: AWS: 'Average', 'Sum', 'Maximum', Azure: 'Average', 'Total', 'Maximum', GCP: (typically not used) + Statistic string `json:"statistic"` + // Key-value pairs that identify the specific resource being monitored. Examples: AWS: [{'name': 'InstanceId', 'value': 'i-1234567890abcdef0'}], Azure: [{'name': 'ApiName', 'value': 'GetBlob'}] + Dimensions []getPackagePackageAlarmsAlarmDimensionsDimension `json:"dimensions"` + // The operator used to compare the metric value against the threshold. Examples: GREATER_THAN, LESS_THAN + ComparisonOperator string `json:"comparisonOperator"` + // The value that triggers the alarm when crossed by the metric value. The comparison is made using the comparison_operator. + Threshold float64 `json:"threshold"` + // The time window in seconds over which the metric is evaluated. + Period int `json:"period"` + // The most recent state of the alarm. If no states exist, returns INSUFFICIENT_DATA. Otherwise, returns the most recent state based on occurred_at timestamp. + CurrentState getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState `json:"currentState"` } -// GetId returns getPackagePackageBundle.Id, and is useful for accessing the field via an interface. -func (v *getPackagePackageBundle) GetId() string { return v.Id } +// GetId returns getPackagePackageAlarmsAlarm.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarm) GetId() string { return v.Id } -// GetName returns getPackagePackageBundle.Name, and is useful for accessing the field via an interface. -func (v *getPackagePackageBundle) GetName() string { return v.Name } +// GetCloudResourceId returns getPackagePackageAlarmsAlarm.CloudResourceId, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarm) GetCloudResourceId() string { return v.CloudResourceId } -// GetSpec returns getPackagePackageBundle.Spec, and is useful for accessing the field via an interface. -func (v *getPackagePackageBundle) GetSpec() map[string]any { return v.Spec } +// GetDisplayName returns getPackagePackageAlarmsAlarm.DisplayName, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarm) GetDisplayName() string { return v.DisplayName } -// GetSpecVersion returns getPackagePackageBundle.SpecVersion, and is useful for accessing the field via an interface. -func (v *getPackagePackageBundle) GetSpecVersion() string { return v.SpecVersion } +// GetNamespace returns getPackagePackageAlarmsAlarm.Namespace, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarm) GetNamespace() string { return v.Namespace } -func (v *getPackagePackageBundle) UnmarshalJSON(b []byte) error { +// GetName returns getPackagePackageAlarmsAlarm.Name, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarm) GetName() string { return v.Name } + +// GetStatistic returns getPackagePackageAlarmsAlarm.Statistic, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarm) GetStatistic() string { return v.Statistic } + +// GetDimensions returns getPackagePackageAlarmsAlarm.Dimensions, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarm) GetDimensions() []getPackagePackageAlarmsAlarmDimensionsDimension { + return v.Dimensions +} + +// GetComparisonOperator returns getPackagePackageAlarmsAlarm.ComparisonOperator, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarm) GetComparisonOperator() string { return v.ComparisonOperator } + +// GetThreshold returns getPackagePackageAlarmsAlarm.Threshold, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarm) GetThreshold() float64 { return v.Threshold } + +// GetPeriod returns getPackagePackageAlarmsAlarm.Period, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarm) GetPeriod() int { return v.Period } + +// GetCurrentState returns getPackagePackageAlarmsAlarm.CurrentState, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarm) GetCurrentState() getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState { + return v.CurrentState +} + +// getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState includes the requested fields of the GraphQL type PackageAlarmState. +// The GraphQL type's documentation follows. +// +// A state record for a package alarm +type getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState struct { + // Unique identifier for this alarm state record. + Id string `json:"id"` + // The current status of the alarm (OK, ALARM, or INSUFFICIENT_DATA). + Status AlarmStatus `json:"status"` + // Message describing the current state or reason for the alarm. + Message string `json:"message"` + // Raw notification data from the cloud provider that triggered this state change. + Notification map[string]any `json:"-"` + // ISO 8601 timestamp when this state change occurred. + OccurredAt time.Time `json:"occurredAt"` +} + +// GetId returns getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState) GetId() string { return v.Id } + +// GetStatus returns getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState.Status, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState) GetStatus() AlarmStatus { + return v.Status +} + +// GetMessage returns getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState.Message, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState) GetMessage() string { + return v.Message +} + +// GetNotification returns getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState.Notification, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState) GetNotification() map[string]any { + return v.Notification +} + +// GetOccurredAt returns getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState.OccurredAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState) GetOccurredAt() time.Time { + return v.OccurredAt +} + +func (v *getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState) UnmarshalJSON(b []byte) error { if string(b) == "null" { return nil } var firstPass struct { - *getPackagePackageBundle - Spec json.RawMessage `json:"spec"` + *getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState + Notification json.RawMessage `json:"notification"` graphql.NoUnmarshalJSON } - firstPass.getPackagePackageBundle = v + firstPass.getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState = v err := json.Unmarshal(b, &firstPass) if err != nil { @@ -3441,31 +3748,33 @@ func (v *getPackagePackageBundle) UnmarshalJSON(b []byte) error { } { - dst := &v.Spec - src := firstPass.Spec + dst := &v.Notification + src := firstPass.Notification if len(src) != 0 && string(src) != "null" { err = scalars.UnmarshalJSON( src, dst) if err != nil { return fmt.Errorf( - "unable to unmarshal getPackagePackageBundle.Spec: %w", err) + "unable to unmarshal getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState.Notification: %w", err) } } } return nil } -type __premarshalgetPackagePackageBundle struct { +type __premarshalgetPackagePackageAlarmsAlarmCurrentStatePackageAlarmState struct { Id string `json:"id"` - Name string `json:"name"` + Status AlarmStatus `json:"status"` - Spec json.RawMessage `json:"spec"` + Message string `json:"message"` - SpecVersion string `json:"specVersion"` + Notification json.RawMessage `json:"notification"` + + OccurredAt time.Time `json:"occurredAt"` } -func (v *getPackagePackageBundle) MarshalJSON() ([]byte, error) { +func (v *getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState) MarshalJSON() ([]byte, error) { premarshaled, err := v.__premarshalJSON() if err != nil { return nil, err @@ -3473,83 +3782,609 @@ func (v *getPackagePackageBundle) MarshalJSON() ([]byte, error) { return json.Marshal(premarshaled) } -func (v *getPackagePackageBundle) __premarshalJSON() (*__premarshalgetPackagePackageBundle, error) { - var retval __premarshalgetPackagePackageBundle +func (v *getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState) __premarshalJSON() (*__premarshalgetPackagePackageAlarmsAlarmCurrentStatePackageAlarmState, error) { + var retval __premarshalgetPackagePackageAlarmsAlarmCurrentStatePackageAlarmState retval.Id = v.Id - retval.Name = v.Name + retval.Status = v.Status + retval.Message = v.Message { - dst := &retval.Spec - src := v.Spec + dst := &retval.Notification + src := v.Notification var err error *dst, err = scalars.MarshalJSON( &src) if err != nil { return nil, fmt.Errorf( - "unable to marshal getPackagePackageBundle.Spec: %w", err) + "unable to marshal getPackagePackageAlarmsAlarmCurrentStatePackageAlarmState.Notification: %w", err) } } - retval.SpecVersion = v.SpecVersion + retval.OccurredAt = v.OccurredAt return &retval, nil } -// getPackagePackageEnvironment includes the requested fields of the GraphQL type Environment. -type getPackagePackageEnvironment struct { - Id string `json:"id"` - Slug string `json:"slug"` - Project getPackagePackageEnvironmentProject `json:"project"` +// getPackagePackageAlarmsAlarmDimensionsDimension includes the requested fields of the GraphQL type Dimension. +// The GraphQL type's documentation follows. +// +// A dimension for cloud metrics +type getPackagePackageAlarmsAlarmDimensionsDimension struct { + // Name of the dimension + Name string `json:"name"` + // Value of the dimension + Value string `json:"value"` } -// GetId returns getPackagePackageEnvironment.Id, and is useful for accessing the field via an interface. -func (v *getPackagePackageEnvironment) GetId() string { return v.Id } - -// GetSlug returns getPackagePackageEnvironment.Slug, and is useful for accessing the field via an interface. -func (v *getPackagePackageEnvironment) GetSlug() string { return v.Slug } +// GetName returns getPackagePackageAlarmsAlarmDimensionsDimension.Name, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarmDimensionsDimension) GetName() string { return v.Name } -// GetProject returns getPackagePackageEnvironment.Project, and is useful for accessing the field via an interface. -func (v *getPackagePackageEnvironment) GetProject() getPackagePackageEnvironmentProject { - return v.Project -} +// GetValue returns getPackagePackageAlarmsAlarmDimensionsDimension.Value, and is useful for accessing the field via an interface. +func (v *getPackagePackageAlarmsAlarmDimensionsDimension) GetValue() string { return v.Value } -// getPackagePackageEnvironmentProject includes the requested fields of the GraphQL type Project. -type getPackagePackageEnvironmentProject struct { +// getPackagePackageArtifactsArtifact includes the requested fields of the GraphQL type Artifact. +type getPackagePackageArtifactsArtifact struct { Id string `json:"id"` - Slug string `json:"slug"` + Name string `json:"name"` + // The bundle's artifact field (output field) that produced this artifact. + Field string `json:"field"` + Type string `json:"type"` + Specs map[string]any `json:"-"` } -// GetId returns getPackagePackageEnvironmentProject.Id, and is useful for accessing the field via an interface. -func (v *getPackagePackageEnvironmentProject) GetId() string { return v.Id } - -// GetSlug returns getPackagePackageEnvironmentProject.Slug, and is useful for accessing the field via an interface. -func (v *getPackagePackageEnvironmentProject) GetSlug() string { return v.Slug } +// GetId returns getPackagePackageArtifactsArtifact.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageArtifactsArtifact) GetId() string { return v.Id } -// getPackagePackageManifest includes the requested fields of the GraphQL type Manifest. -// The GraphQL type's documentation follows. -// -// A bundle used in a project with a specific context (e.g. redis 'cache' vs 'sessions' instance) -type getPackagePackageManifest struct { - Id string `json:"id"` - Name string `json:"name"` - Slug string `json:"slug"` - Suffix string `json:"suffix"` - Description string `json:"description"` -} +// GetName returns getPackagePackageArtifactsArtifact.Name, and is useful for accessing the field via an interface. +func (v *getPackagePackageArtifactsArtifact) GetName() string { return v.Name } -// GetId returns getPackagePackageManifest.Id, and is useful for accessing the field via an interface. -func (v *getPackagePackageManifest) GetId() string { return v.Id } +// GetField returns getPackagePackageArtifactsArtifact.Field, and is useful for accessing the field via an interface. +func (v *getPackagePackageArtifactsArtifact) GetField() string { return v.Field } -// GetName returns getPackagePackageManifest.Name, and is useful for accessing the field via an interface. -func (v *getPackagePackageManifest) GetName() string { return v.Name } +// GetType returns getPackagePackageArtifactsArtifact.Type, and is useful for accessing the field via an interface. +func (v *getPackagePackageArtifactsArtifact) GetType() string { return v.Type } -// GetSlug returns getPackagePackageManifest.Slug, and is useful for accessing the field via an interface. -func (v *getPackagePackageManifest) GetSlug() string { return v.Slug } +// GetSpecs returns getPackagePackageArtifactsArtifact.Specs, and is useful for accessing the field via an interface. +func (v *getPackagePackageArtifactsArtifact) GetSpecs() map[string]any { return v.Specs } -// GetSuffix returns getPackagePackageManifest.Suffix, and is useful for accessing the field via an interface. -func (v *getPackagePackageManifest) GetSuffix() string { return v.Suffix } +func (v *getPackagePackageArtifactsArtifact) UnmarshalJSON(b []byte) error { -// GetDescription returns getPackagePackageManifest.Description, and is useful for accessing the field via an interface. -func (v *getPackagePackageManifest) GetDescription() string { return v.Description } + if string(b) == "null" { + return nil + } + + var firstPass struct { + *getPackagePackageArtifactsArtifact + Specs json.RawMessage `json:"specs"` + graphql.NoUnmarshalJSON + } + firstPass.getPackagePackageArtifactsArtifact = v + + err := json.Unmarshal(b, &firstPass) + if err != nil { + return err + } + + { + dst := &v.Specs + src := firstPass.Specs + if len(src) != 0 && string(src) != "null" { + err = scalars.UnmarshalJSON( + src, dst) + if err != nil { + return fmt.Errorf( + "unable to unmarshal getPackagePackageArtifactsArtifact.Specs: %w", err) + } + } + } + return nil +} + +type __premarshalgetPackagePackageArtifactsArtifact struct { + Id string `json:"id"` + + Name string `json:"name"` + + Field string `json:"field"` + + Type string `json:"type"` + + Specs json.RawMessage `json:"specs"` +} + +func (v *getPackagePackageArtifactsArtifact) MarshalJSON() ([]byte, error) { + premarshaled, err := v.__premarshalJSON() + if err != nil { + return nil, err + } + return json.Marshal(premarshaled) +} + +func (v *getPackagePackageArtifactsArtifact) __premarshalJSON() (*__premarshalgetPackagePackageArtifactsArtifact, error) { + var retval __premarshalgetPackagePackageArtifactsArtifact + + retval.Id = v.Id + retval.Name = v.Name + retval.Field = v.Field + retval.Type = v.Type + { + + dst := &retval.Specs + src := v.Specs + var err error + *dst, err = scalars.MarshalJSON( + &src) + if err != nil { + return nil, fmt.Errorf( + "unable to marshal getPackagePackageArtifactsArtifact.Specs: %w", err) + } + } + return &retval, nil +} + +// getPackagePackageBundle includes the requested fields of the GraphQL type Bundle. +// The GraphQL type's documentation follows. +// +// A specific version of a bundle +type getPackagePackageBundle struct { + // Unique identifier + Id string `json:"id"` + // Name of the bundle + Name string `json:"name"` + // Raw massdriver.yaml spec + Spec map[string]any `json:"-"` + // Version of the bundle specification + SpecVersion string `json:"specVersion"` + // Semantic version of this bundle release + Version string `json:"version"` + // Description of the bundle + Description string `json:"description"` + // Icon SVG + Icon string `json:"icon"` + // URL to the source code repository + SourceUrl string `json:"sourceUrl"` +} + +// GetId returns getPackagePackageBundle.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageBundle) GetId() string { return v.Id } + +// GetName returns getPackagePackageBundle.Name, and is useful for accessing the field via an interface. +func (v *getPackagePackageBundle) GetName() string { return v.Name } + +// GetSpec returns getPackagePackageBundle.Spec, and is useful for accessing the field via an interface. +func (v *getPackagePackageBundle) GetSpec() map[string]any { return v.Spec } + +// GetSpecVersion returns getPackagePackageBundle.SpecVersion, and is useful for accessing the field via an interface. +func (v *getPackagePackageBundle) GetSpecVersion() string { return v.SpecVersion } + +// GetVersion returns getPackagePackageBundle.Version, and is useful for accessing the field via an interface. +func (v *getPackagePackageBundle) GetVersion() string { return v.Version } + +// GetDescription returns getPackagePackageBundle.Description, and is useful for accessing the field via an interface. +func (v *getPackagePackageBundle) GetDescription() string { return v.Description } + +// GetIcon returns getPackagePackageBundle.Icon, and is useful for accessing the field via an interface. +func (v *getPackagePackageBundle) GetIcon() string { return v.Icon } + +// GetSourceUrl returns getPackagePackageBundle.SourceUrl, and is useful for accessing the field via an interface. +func (v *getPackagePackageBundle) GetSourceUrl() string { return v.SourceUrl } + +func (v *getPackagePackageBundle) UnmarshalJSON(b []byte) error { + + if string(b) == "null" { + return nil + } + + var firstPass struct { + *getPackagePackageBundle + Spec json.RawMessage `json:"spec"` + graphql.NoUnmarshalJSON + } + firstPass.getPackagePackageBundle = v + + err := json.Unmarshal(b, &firstPass) + if err != nil { + return err + } + + { + dst := &v.Spec + src := firstPass.Spec + if len(src) != 0 && string(src) != "null" { + err = scalars.UnmarshalJSON( + src, dst) + if err != nil { + return fmt.Errorf( + "unable to unmarshal getPackagePackageBundle.Spec: %w", err) + } + } + } + return nil +} + +type __premarshalgetPackagePackageBundle struct { + Id string `json:"id"` + + Name string `json:"name"` + + Spec json.RawMessage `json:"spec"` + + SpecVersion string `json:"specVersion"` + + Version string `json:"version"` + + Description string `json:"description"` + + Icon string `json:"icon"` + + SourceUrl string `json:"sourceUrl"` +} + +func (v *getPackagePackageBundle) MarshalJSON() ([]byte, error) { + premarshaled, err := v.__premarshalJSON() + if err != nil { + return nil, err + } + return json.Marshal(premarshaled) +} + +func (v *getPackagePackageBundle) __premarshalJSON() (*__premarshalgetPackagePackageBundle, error) { + var retval __premarshalgetPackagePackageBundle + + retval.Id = v.Id + retval.Name = v.Name + { + + dst := &retval.Spec + src := v.Spec + var err error + *dst, err = scalars.MarshalJSON( + &src) + if err != nil { + return nil, fmt.Errorf( + "unable to marshal getPackagePackageBundle.Spec: %w", err) + } + } + retval.SpecVersion = v.SpecVersion + retval.Version = v.Version + retval.Description = v.Description + retval.Icon = v.Icon + retval.SourceUrl = v.SourceUrl + return &retval, nil +} + +// getPackagePackageConnectionsConnection includes the requested fields of the GraphQL type Connection. +// The GraphQL type's documentation follows. +// +// A connection between a package and an artifact +type getPackagePackageConnectionsConnection struct { + // Unique identifier for the connection + Id string `json:"id"` + // The field in the package that this connection is bound to + PackageField string `json:"packageField"` + // The artifact being connected + Artifact getPackagePackageConnectionsConnectionArtifact `json:"artifact"` + // When the connection was created + CreatedAt time.Time `json:"createdAt"` + // When the connection was last updated + UpdatedAt time.Time `json:"updatedAt"` +} + +// GetId returns getPackagePackageConnectionsConnection.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageConnectionsConnection) GetId() string { return v.Id } + +// GetPackageField returns getPackagePackageConnectionsConnection.PackageField, and is useful for accessing the field via an interface. +func (v *getPackagePackageConnectionsConnection) GetPackageField() string { return v.PackageField } + +// GetArtifact returns getPackagePackageConnectionsConnection.Artifact, and is useful for accessing the field via an interface. +func (v *getPackagePackageConnectionsConnection) GetArtifact() getPackagePackageConnectionsConnectionArtifact { + return v.Artifact +} + +// GetCreatedAt returns getPackagePackageConnectionsConnection.CreatedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageConnectionsConnection) GetCreatedAt() time.Time { return v.CreatedAt } + +// GetUpdatedAt returns getPackagePackageConnectionsConnection.UpdatedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageConnectionsConnection) GetUpdatedAt() time.Time { return v.UpdatedAt } + +// getPackagePackageConnectionsConnectionArtifact includes the requested fields of the GraphQL type Artifact. +type getPackagePackageConnectionsConnectionArtifact struct { + Id string `json:"id"` + Name string `json:"name"` + Type string `json:"type"` + // The bundle's artifact field (output field) that produced this artifact. + Field string `json:"field"` +} + +// GetId returns getPackagePackageConnectionsConnectionArtifact.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageConnectionsConnectionArtifact) GetId() string { return v.Id } + +// GetName returns getPackagePackageConnectionsConnectionArtifact.Name, and is useful for accessing the field via an interface. +func (v *getPackagePackageConnectionsConnectionArtifact) GetName() string { return v.Name } + +// GetType returns getPackagePackageConnectionsConnectionArtifact.Type, and is useful for accessing the field via an interface. +func (v *getPackagePackageConnectionsConnectionArtifact) GetType() string { return v.Type } + +// GetField returns getPackagePackageConnectionsConnectionArtifact.Field, and is useful for accessing the field via an interface. +func (v *getPackagePackageConnectionsConnectionArtifact) GetField() string { return v.Field } + +// getPackagePackageCost includes the requested fields of the GraphQL type Cost. +// The GraphQL type's documentation follows. +// +// Cost information for a resource +type getPackagePackageCost struct { + // Monthly cost summary + Monthly getPackagePackageCostMonthlySummary `json:"monthly"` + // Daily cost summary + Daily getPackagePackageCostDailySummary `json:"daily"` +} + +// GetMonthly returns getPackagePackageCost.Monthly, and is useful for accessing the field via an interface. +func (v *getPackagePackageCost) GetMonthly() getPackagePackageCostMonthlySummary { return v.Monthly } + +// GetDaily returns getPackagePackageCost.Daily, and is useful for accessing the field via an interface. +func (v *getPackagePackageCost) GetDaily() getPackagePackageCostDailySummary { return v.Daily } + +// getPackagePackageCostDailySummary includes the requested fields of the GraphQL type Summary. +// The GraphQL type's documentation follows. +// +// Summary of costs over a time period +type getPackagePackageCostDailySummary struct { + // Average cost sample for the period + Average getPackagePackageCostDailySummaryAverageCostSample `json:"average"` +} + +// GetAverage returns getPackagePackageCostDailySummary.Average, and is useful for accessing the field via an interface. +func (v *getPackagePackageCostDailySummary) GetAverage() getPackagePackageCostDailySummaryAverageCostSample { + return v.Average +} + +// getPackagePackageCostDailySummaryAverageCostSample includes the requested fields of the GraphQL type CostSample. +// The GraphQL type's documentation follows. +// +// A single cost measurement +type getPackagePackageCostDailySummaryAverageCostSample struct { + // The cost amount + Amount float64 `json:"amount"` + // The currency code (e.g. USD) + Currency string `json:"currency"` +} + +// GetAmount returns getPackagePackageCostDailySummaryAverageCostSample.Amount, and is useful for accessing the field via an interface. +func (v *getPackagePackageCostDailySummaryAverageCostSample) GetAmount() float64 { return v.Amount } + +// GetCurrency returns getPackagePackageCostDailySummaryAverageCostSample.Currency, and is useful for accessing the field via an interface. +func (v *getPackagePackageCostDailySummaryAverageCostSample) GetCurrency() string { return v.Currency } + +// getPackagePackageCostMonthlySummary includes the requested fields of the GraphQL type Summary. +// The GraphQL type's documentation follows. +// +// Summary of costs over a time period +type getPackagePackageCostMonthlySummary struct { + // Average cost sample for the period + Average getPackagePackageCostMonthlySummaryAverageCostSample `json:"average"` +} + +// GetAverage returns getPackagePackageCostMonthlySummary.Average, and is useful for accessing the field via an interface. +func (v *getPackagePackageCostMonthlySummary) GetAverage() getPackagePackageCostMonthlySummaryAverageCostSample { + return v.Average +} + +// getPackagePackageCostMonthlySummaryAverageCostSample includes the requested fields of the GraphQL type CostSample. +// The GraphQL type's documentation follows. +// +// A single cost measurement +type getPackagePackageCostMonthlySummaryAverageCostSample struct { + // The cost amount + Amount float64 `json:"amount"` + // The currency code (e.g. USD) + Currency string `json:"currency"` +} + +// GetAmount returns getPackagePackageCostMonthlySummaryAverageCostSample.Amount, and is useful for accessing the field via an interface. +func (v *getPackagePackageCostMonthlySummaryAverageCostSample) GetAmount() float64 { return v.Amount } + +// GetCurrency returns getPackagePackageCostMonthlySummaryAverageCostSample.Currency, and is useful for accessing the field via an interface. +func (v *getPackagePackageCostMonthlySummaryAverageCostSample) GetCurrency() string { + return v.Currency +} + +// getPackagePackageDecommissionablePackageDeletionLifecycle includes the requested fields of the GraphQL type PackageDeletionLifecycle. +// The GraphQL type's documentation follows. +// +// Lifecycle information for package deletion +type getPackagePackageDecommissionablePackageDeletionLifecycle struct { + // Whether deletion is possible + Result bool `json:"result"` + // List of deletion errors if any + Messages []getPackagePackageDecommissionablePackageDeletionLifecycleMessagesPackageDeletionLifecycleArtifactError `json:"messages"` +} + +// GetResult returns getPackagePackageDecommissionablePackageDeletionLifecycle.Result, and is useful for accessing the field via an interface. +func (v *getPackagePackageDecommissionablePackageDeletionLifecycle) GetResult() bool { return v.Result } + +// GetMessages returns getPackagePackageDecommissionablePackageDeletionLifecycle.Messages, and is useful for accessing the field via an interface. +func (v *getPackagePackageDecommissionablePackageDeletionLifecycle) GetMessages() []getPackagePackageDecommissionablePackageDeletionLifecycleMessagesPackageDeletionLifecycleArtifactError { + return v.Messages +} + +// getPackagePackageDecommissionablePackageDeletionLifecycleMessagesPackageDeletionLifecycleArtifactError includes the requested fields of the GraphQL type PackageDeletionLifecycleArtifactError. +// The GraphQL type's documentation follows. +// +// Error information for package deletion +type getPackagePackageDecommissionablePackageDeletionLifecycleMessagesPackageDeletionLifecycleArtifactError struct { + // Error message + Message string `json:"message"` +} + +// GetMessage returns getPackagePackageDecommissionablePackageDeletionLifecycleMessagesPackageDeletionLifecycleArtifactError.Message, and is useful for accessing the field via an interface. +func (v *getPackagePackageDecommissionablePackageDeletionLifecycleMessagesPackageDeletionLifecycleArtifactError) GetMessage() string { + return v.Message +} + +// getPackagePackageDeploymentsDeployment includes the requested fields of the GraphQL type Deployment. +// The GraphQL type's documentation follows. +// +// A deployment represents an instance of a bundle being deployed to a target environment +type getPackagePackageDeploymentsDeployment struct { + Id string `json:"id"` + Status DeploymentStatus `json:"status"` + Action DeploymentAction `json:"action"` + Version string `json:"version"` + Message string `json:"message"` + DeployedBy string `json:"deployedBy"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + LastTransitionedAt time.Time `json:"lastTransitionedAt"` + // Elapsed time in seconds + ElapsedTime int `json:"elapsedTime"` +} + +// GetId returns getPackagePackageDeploymentsDeployment.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageDeploymentsDeployment) GetId() string { return v.Id } + +// GetStatus returns getPackagePackageDeploymentsDeployment.Status, and is useful for accessing the field via an interface. +func (v *getPackagePackageDeploymentsDeployment) GetStatus() DeploymentStatus { return v.Status } + +// GetAction returns getPackagePackageDeploymentsDeployment.Action, and is useful for accessing the field via an interface. +func (v *getPackagePackageDeploymentsDeployment) GetAction() DeploymentAction { return v.Action } + +// GetVersion returns getPackagePackageDeploymentsDeployment.Version, and is useful for accessing the field via an interface. +func (v *getPackagePackageDeploymentsDeployment) GetVersion() string { return v.Version } + +// GetMessage returns getPackagePackageDeploymentsDeployment.Message, and is useful for accessing the field via an interface. +func (v *getPackagePackageDeploymentsDeployment) GetMessage() string { return v.Message } + +// GetDeployedBy returns getPackagePackageDeploymentsDeployment.DeployedBy, and is useful for accessing the field via an interface. +func (v *getPackagePackageDeploymentsDeployment) GetDeployedBy() string { return v.DeployedBy } + +// GetCreatedAt returns getPackagePackageDeploymentsDeployment.CreatedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageDeploymentsDeployment) GetCreatedAt() time.Time { return v.CreatedAt } + +// GetUpdatedAt returns getPackagePackageDeploymentsDeployment.UpdatedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageDeploymentsDeployment) GetUpdatedAt() time.Time { return v.UpdatedAt } + +// GetLastTransitionedAt returns getPackagePackageDeploymentsDeployment.LastTransitionedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageDeploymentsDeployment) GetLastTransitionedAt() time.Time { + return v.LastTransitionedAt +} + +// GetElapsedTime returns getPackagePackageDeploymentsDeployment.ElapsedTime, and is useful for accessing the field via an interface. +func (v *getPackagePackageDeploymentsDeployment) GetElapsedTime() int { return v.ElapsedTime } + +// getPackagePackageEnvironment includes the requested fields of the GraphQL type Environment. +type getPackagePackageEnvironment struct { + Id string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + Project getPackagePackageEnvironmentProject `json:"project"` +} + +// GetId returns getPackagePackageEnvironment.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageEnvironment) GetId() string { return v.Id } + +// GetSlug returns getPackagePackageEnvironment.Slug, and is useful for accessing the field via an interface. +func (v *getPackagePackageEnvironment) GetSlug() string { return v.Slug } + +// GetName returns getPackagePackageEnvironment.Name, and is useful for accessing the field via an interface. +func (v *getPackagePackageEnvironment) GetName() string { return v.Name } + +// GetProject returns getPackagePackageEnvironment.Project, and is useful for accessing the field via an interface. +func (v *getPackagePackageEnvironment) GetProject() getPackagePackageEnvironmentProject { + return v.Project +} + +// getPackagePackageEnvironmentProject includes the requested fields of the GraphQL type Project. +type getPackagePackageEnvironmentProject struct { + Id string `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` +} + +// GetId returns getPackagePackageEnvironmentProject.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageEnvironmentProject) GetId() string { return v.Id } + +// GetSlug returns getPackagePackageEnvironmentProject.Slug, and is useful for accessing the field via an interface. +func (v *getPackagePackageEnvironmentProject) GetSlug() string { return v.Slug } + +// GetName returns getPackagePackageEnvironmentProject.Name, and is useful for accessing the field via an interface. +func (v *getPackagePackageEnvironmentProject) GetName() string { return v.Name } + +// getPackagePackageLatestDeployment includes the requested fields of the GraphQL type Deployment. +// The GraphQL type's documentation follows. +// +// A deployment represents an instance of a bundle being deployed to a target environment +type getPackagePackageLatestDeployment struct { + Id string `json:"id"` + Status DeploymentStatus `json:"status"` + Action DeploymentAction `json:"action"` + Version string `json:"version"` + Message string `json:"message"` + DeployedBy string `json:"deployedBy"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + LastTransitionedAt time.Time `json:"lastTransitionedAt"` + // Elapsed time in seconds + ElapsedTime int `json:"elapsedTime"` +} + +// GetId returns getPackagePackageLatestDeployment.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageLatestDeployment) GetId() string { return v.Id } + +// GetStatus returns getPackagePackageLatestDeployment.Status, and is useful for accessing the field via an interface. +func (v *getPackagePackageLatestDeployment) GetStatus() DeploymentStatus { return v.Status } + +// GetAction returns getPackagePackageLatestDeployment.Action, and is useful for accessing the field via an interface. +func (v *getPackagePackageLatestDeployment) GetAction() DeploymentAction { return v.Action } + +// GetVersion returns getPackagePackageLatestDeployment.Version, and is useful for accessing the field via an interface. +func (v *getPackagePackageLatestDeployment) GetVersion() string { return v.Version } + +// GetMessage returns getPackagePackageLatestDeployment.Message, and is useful for accessing the field via an interface. +func (v *getPackagePackageLatestDeployment) GetMessage() string { return v.Message } + +// GetDeployedBy returns getPackagePackageLatestDeployment.DeployedBy, and is useful for accessing the field via an interface. +func (v *getPackagePackageLatestDeployment) GetDeployedBy() string { return v.DeployedBy } + +// GetCreatedAt returns getPackagePackageLatestDeployment.CreatedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageLatestDeployment) GetCreatedAt() time.Time { return v.CreatedAt } + +// GetUpdatedAt returns getPackagePackageLatestDeployment.UpdatedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageLatestDeployment) GetUpdatedAt() time.Time { return v.UpdatedAt } + +// GetLastTransitionedAt returns getPackagePackageLatestDeployment.LastTransitionedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageLatestDeployment) GetLastTransitionedAt() time.Time { + return v.LastTransitionedAt +} + +// GetElapsedTime returns getPackagePackageLatestDeployment.ElapsedTime, and is useful for accessing the field via an interface. +func (v *getPackagePackageLatestDeployment) GetElapsedTime() int { return v.ElapsedTime } + +// getPackagePackageManifest includes the requested fields of the GraphQL type Manifest. +// The GraphQL type's documentation follows. +// +// A bundle used in a project with a specific context (e.g. redis 'cache' vs 'sessions' instance) +type getPackagePackageManifest struct { + Id string `json:"id"` + Name string `json:"name"` + Slug string `json:"slug"` + Suffix string `json:"suffix"` + Description string `json:"description"` +} + +// GetId returns getPackagePackageManifest.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageManifest) GetId() string { return v.Id } + +// GetName returns getPackagePackageManifest.Name, and is useful for accessing the field via an interface. +func (v *getPackagePackageManifest) GetName() string { return v.Name } + +// GetSlug returns getPackagePackageManifest.Slug, and is useful for accessing the field via an interface. +func (v *getPackagePackageManifest) GetSlug() string { return v.Slug } + +// GetSuffix returns getPackagePackageManifest.Suffix, and is useful for accessing the field via an interface. +func (v *getPackagePackageManifest) GetSuffix() string { return v.Suffix } + +// GetDescription returns getPackagePackageManifest.Description, and is useful for accessing the field via an interface. +func (v *getPackagePackageManifest) GetDescription() string { return v.Description } // getPackagePackageRemoteReferencesRemoteReference includes the requested fields of the GraphQL type RemoteReference. type getPackagePackageRemoteReferencesRemoteReference struct { @@ -3567,6 +4402,7 @@ type getPackagePackageRemoteReferencesRemoteReferenceArtifact struct { Name string `json:"name"` // The bundle's artifact field (output field) that produced this artifact. Field string `json:"field"` + Type string `json:"type"` } // GetId returns getPackagePackageRemoteReferencesRemoteReferenceArtifact.Id, and is useful for accessing the field via an interface. @@ -3578,6 +4414,85 @@ func (v *getPackagePackageRemoteReferencesRemoteReferenceArtifact) GetName() str // GetField returns getPackagePackageRemoteReferencesRemoteReferenceArtifact.Field, and is useful for accessing the field via an interface. func (v *getPackagePackageRemoteReferencesRemoteReferenceArtifact) GetField() string { return v.Field } +// GetType returns getPackagePackageRemoteReferencesRemoteReferenceArtifact.Type, and is useful for accessing the field via an interface. +func (v *getPackagePackageRemoteReferencesRemoteReferenceArtifact) GetType() string { return v.Type } + +// getPackagePackageSecretFieldsSecretField includes the requested fields of the GraphQL type SecretField. +// The GraphQL type's documentation follows. +// +// Application secret definitions. These fields are defined in your applications massdriver.yaml file. +// +// Secrets are only applied to `application` type bundles. +type getPackagePackageSecretFieldsSecretField struct { + // The name of the secret. Generally in the form of an environment variable. + Name string `json:"name"` + // Is the secret required? + Required bool `json:"required"` + // Is the secret a JSON object? + Json bool `json:"json"` + // Secret field definition friendly display name. + Title string `json:"title"` + // Secret field definition description. + Description string `json:"description"` + // Metadata for the secret value set on this field. + ValueMetadata getPackagePackageSecretFieldsSecretFieldValueMetadataSecretMetadata `json:"valueMetadata"` +} + +// GetName returns getPackagePackageSecretFieldsSecretField.Name, and is useful for accessing the field via an interface. +func (v *getPackagePackageSecretFieldsSecretField) GetName() string { return v.Name } + +// GetRequired returns getPackagePackageSecretFieldsSecretField.Required, and is useful for accessing the field via an interface. +func (v *getPackagePackageSecretFieldsSecretField) GetRequired() bool { return v.Required } + +// GetJson returns getPackagePackageSecretFieldsSecretField.Json, and is useful for accessing the field via an interface. +func (v *getPackagePackageSecretFieldsSecretField) GetJson() bool { return v.Json } + +// GetTitle returns getPackagePackageSecretFieldsSecretField.Title, and is useful for accessing the field via an interface. +func (v *getPackagePackageSecretFieldsSecretField) GetTitle() string { return v.Title } + +// GetDescription returns getPackagePackageSecretFieldsSecretField.Description, and is useful for accessing the field via an interface. +func (v *getPackagePackageSecretFieldsSecretField) GetDescription() string { return v.Description } + +// GetValueMetadata returns getPackagePackageSecretFieldsSecretField.ValueMetadata, and is useful for accessing the field via an interface. +func (v *getPackagePackageSecretFieldsSecretField) GetValueMetadata() getPackagePackageSecretFieldsSecretFieldValueMetadataSecretMetadata { + return v.ValueMetadata +} + +// getPackagePackageSecretFieldsSecretFieldValueMetadataSecretMetadata includes the requested fields of the GraphQL type SecretMetadata. +// The GraphQL type's documentation follows. +// +// Metadata for a secret. Values are not viewable/retrievable once set. +type getPackagePackageSecretFieldsSecretFieldValueMetadataSecretMetadata struct { + // A unique identifier for the secret value. + Id string `json:"id"` + // The secret name from the massdriver.yaml file. + Name string `json:"name"` + // SHA-256 of the secret value. + Sha256 string `json:"sha256"` + // When the secret was set. + CreatedAt time.Time `json:"createdAt"` +} + +// GetId returns getPackagePackageSecretFieldsSecretFieldValueMetadataSecretMetadata.Id, and is useful for accessing the field via an interface. +func (v *getPackagePackageSecretFieldsSecretFieldValueMetadataSecretMetadata) GetId() string { + return v.Id +} + +// GetName returns getPackagePackageSecretFieldsSecretFieldValueMetadataSecretMetadata.Name, and is useful for accessing the field via an interface. +func (v *getPackagePackageSecretFieldsSecretFieldValueMetadataSecretMetadata) GetName() string { + return v.Name +} + +// GetSha256 returns getPackagePackageSecretFieldsSecretFieldValueMetadataSecretMetadata.Sha256, and is useful for accessing the field via an interface. +func (v *getPackagePackageSecretFieldsSecretFieldValueMetadataSecretMetadata) GetSha256() string { + return v.Sha256 +} + +// GetCreatedAt returns getPackagePackageSecretFieldsSecretFieldValueMetadataSecretMetadata.CreatedAt, and is useful for accessing the field via an interface. +func (v *getPackagePackageSecretFieldsSecretFieldValueMetadataSecretMetadata) GetCreatedAt() time.Time { + return v.CreatedAt +} + // getPackageResponse is returned by getPackage on success. type getPackageResponse struct { Package getPackagePackage `json:"package"` @@ -5295,23 +6210,23 @@ query getPackage ($organizationId: ID!, $id: ID!) { slug status params - artifacts { - id - name - field - } - remoteReferences { - artifact { - id - name - field - } - } + paramsSchema + createdAt + updatedAt + version + resolvedVersion + releaseStrategy + deployedVersion + availableUpgrade bundle { id name spec specVersion + version + description + icon + sourceUrl } manifest { id @@ -5323,9 +6238,129 @@ query getPackage ($organizationId: ID!, $id: ID!) { environment { id slug + name project { id slug + name + } + } + artifacts { + id + name + field + type + specs + } + remoteReferences { + artifact { + id + name + field + type + } + } + connections { + id + packageField + artifact { + id + name + type + field + } + createdAt + updatedAt + } + latestDeployment { + id + status + action + version + message + deployedBy + createdAt + updatedAt + lastTransitionedAt + elapsedTime + } + activeDeployment { + id + status + action + version + message + deployedBy + createdAt + updatedAt + lastTransitionedAt + elapsedTime + } + deployments { + id + status + action + version + message + deployedBy + createdAt + updatedAt + lastTransitionedAt + elapsedTime + } + alarms { + id + cloudResourceId + displayName + namespace + name + statistic + dimensions { + name + value + } + comparisonOperator + threshold + period + currentState { + id + status + message + notification + occurredAt + } + } + secretFields { + name + required + json + title + description + valueMetadata { + id + name + sha256 + createdAt + } + } + decommissionable { + result + messages { + message + } + } + cost { + monthly { + average { + amount + currency + } + } + daily { + average { + amount + currency + } } } } diff --git a/pkg/commands/pkg/configure.go b/pkg/commands/pkg/configure.go index 4da52c95..37435e6d 100644 --- a/pkg/commands/pkg/configure.go +++ b/pkg/commands/pkg/configure.go @@ -11,7 +11,7 @@ import ( // Updates a packages configuration parameters. func RunConfigure(ctx context.Context, mdClient *client.Client, name string, params map[string]any) (*api.Package, error) { - pkg, err := api.GetPackageByName(ctx, mdClient, name) + pkg, err := api.GetPackage(ctx, mdClient, name) if err != nil { return nil, err diff --git a/pkg/commands/pkg/deploy.go b/pkg/commands/pkg/deploy.go index 6146715b..8cbaea74 100644 --- a/pkg/commands/pkg/deploy.go +++ b/pkg/commands/pkg/deploy.go @@ -14,7 +14,7 @@ var DeploymentStatusSleep = time.Duration(10) * time.Second var DeploymentTimeout = time.Duration(5) * time.Minute func RunDeploy(ctx context.Context, mdClient *client.Client, name, message string) (*api.Deployment, error) { - pkg, err := api.GetPackageByName(ctx, mdClient, name) + pkg, err := api.GetPackage(ctx, mdClient, name) if err != nil { return nil, err } diff --git a/pkg/commands/pkg/deploy_test.go b/pkg/commands/pkg/deploy_test.go index 9454702d..61cb2ff0 100644 --- a/pkg/commands/pkg/deploy_test.go +++ b/pkg/commands/pkg/deploy_test.go @@ -11,10 +11,19 @@ import ( func TestRunDeploy(t *testing.T) { responses := []any{ - gqlmock.MockQueryResponse("getPackageByNamingConvention", api.Package{ - Manifest: &api.Manifest{ID: "manifest-id"}, - Environment: &api.Environment{ID: "target-id"}, - }), + gqlmock.QueryResponse{ + Data: map[string]any{ + "package": map[string]any{ + "slug": "ecomm-prod-cache", + "manifest": map[string]any{ + "id": "manifest-id", + }, + "environment": map[string]any{ + "id": "target-id", + }, + }, + }, + }, gqlmock.MockMutationResponse("deployPackage", api.Deployment{ ID: "deployment-id", Status: "STARTED", diff --git a/pkg/commands/pkg/export.go b/pkg/commands/pkg/export.go index 95a640e2..21e22f93 100644 --- a/pkg/commands/pkg/export.go +++ b/pkg/commands/pkg/export.go @@ -111,7 +111,7 @@ func (dsf *DefaultStateFetcher) FetchState(ctx context.Context, packageID string } func RunExport(ctx context.Context, mdClient *client.Client, packageSlugOrID string) error { - pkg, err := api.GetPackageByName(ctx, mdClient, packageSlugOrID) + pkg, err := api.GetPackage(ctx, mdClient, packageSlugOrID) if err != nil { return fmt.Errorf("failed to get package %s: %w", packageSlugOrID, err) } diff --git a/pkg/commands/pkg/patch.go b/pkg/commands/pkg/patch.go index 2e7ebbb5..062ac7d0 100644 --- a/pkg/commands/pkg/patch.go +++ b/pkg/commands/pkg/patch.go @@ -11,7 +11,7 @@ import ( // Updates a packages configuration parameters. func RunPatch(ctx context.Context, mdClient *client.Client, name string, setValues []string) (*api.Package, error) { - pkg, err := api.GetPackageByName(ctx, mdClient, name) + pkg, err := api.GetPackage(ctx, mdClient, name) if err != nil { return nil, err