Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions cmd/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/massdriver-cloud/mass/docs/helpdocs"
"github.com/massdriver-cloud/mass/pkg/api"
"github.com/massdriver-cloud/mass/pkg/cli"
"github.com/massdriver-cloud/mass/pkg/commands/pkg"
"github.com/massdriver-cloud/mass/pkg/files"
"github.com/massdriver-cloud/mass/pkg/prettylogs"
Expand Down Expand Up @@ -133,10 +134,21 @@ func NewCmdPkg() *cobra.Command {
}
pkgResetCmd.Flags().BoolP("force", "f", false, "Skip confirmation prompt")

pkgListCmd := &cobra.Command{
Use: `list <project>-<env>`,
Short: "List packages in an environment",
Aliases: []string{"ls"},
Example: `mass package list ecomm-prod`,
Long: helpdocs.MustRender("package/list"),
Args: cobra.ExactArgs(1),
RunE: runPkgList,
}

pkgCmd.AddCommand(pkgConfigureCmd)
pkgCmd.AddCommand(pkgDeployCmd)
pkgCmd.AddCommand(pkgExportCmd)
pkgCmd.AddCommand(pkgGetCmd)
pkgCmd.AddCommand(pkgListCmd)
pkgCmd.AddCommand(pkgPatchCmd)
pkgCmd.AddCommand(pkgCreateCmd)
pkgCmd.AddCommand(pkgVersionCmd)
Expand Down Expand Up @@ -517,3 +529,39 @@ func runPkgReset(cmd *cobra.Command, args []string) error {

return nil
}

func runPkgList(cmd *cobra.Command, args []string) error {
ctx := context.Background()

environmentSlug := args[0]

cmd.SilenceUsage = true

mdClient, mdClientErr := client.New()
if mdClientErr != nil {
return fmt.Errorf("error initializing massdriver client: %w", mdClientErr)
}

env, err := api.GetEnvironment(ctx, mdClient, environmentSlug)
if err != nil {
return err
}

tbl := cli.NewTable("ID", "Name", "Bundle", "Status")

for _, p := range env.Packages {
name := ""
if p.Manifest != nil {
name = p.Manifest.Name
}
bundleName := ""
if p.Bundle != nil {
bundleName = p.Bundle.Name
}
tbl.AddRow(p.Slug, name, bundleName, p.Status)
}

tbl.Print()

return nil
}
1 change: 1 addition & 0 deletions docs/generated/mass_package.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Packages are used to:
* [mass package destroy](/cli/commands/mass_package_destroy) - Destroy (decommission) a package
* [mass package export](/cli/commands/mass_package_export) - Export packages
* [mass package get](/cli/commands/mass_package_get) - Get a package
* [mass package list](/cli/commands/mass_package_list) - List packages in an environment
* [mass package patch](/cli/commands/mass_package_patch) - Patch individual package parameter values
* [mass package reset](/cli/commands/mass_package_reset) - Reset package status to 'Initialized'
* [mass package version](/cli/commands/mass_package_version) - Set package version
49 changes: 49 additions & 0 deletions docs/generated/mass_package_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
id: mass_package_list.md
slug: /cli/commands/mass_package_list
title: Mass Package List
sidebar_label: Mass Package List
---
## mass package list

List packages in an environment

### Synopsis

# List Packages

Lists all packages in a Massdriver environment.

## Usage

```bash
mass package list <project>-<env>
```

## Examples

```bash
# List all packages in the "ecomm" project's "prod" environment
mass package list ecomm-prod
```


```
mass package list <project>-<env> [flags]
```

### Examples

```
mass package list ecomm-prod
```

### Options

```
-h, --help help for list
```

### SEE ALSO

* [mass package](/cli/commands/mass_package) - Manage packages of IaC deployed in environments.
16 changes: 16 additions & 0 deletions docs/helpdocs/package/list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# List Packages

Lists all packages in a Massdriver environment.

## Usage

```bash
mass package list <project>-<env>
```

## Examples

```bash
# List all packages in the "ecomm" project's "prod" environment
mass package list ecomm-prod
```
1 change: 1 addition & 0 deletions pkg/api/genqlient.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ query getEnvironmentById($organizationId: ID!, $id: ID!) {
}
packages {
id
slug
params
artifacts {
id
Expand Down
9 changes: 9 additions & 0 deletions pkg/api/zz_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading