Skip to content
Open
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
16 changes: 8 additions & 8 deletions cmd/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ func NewCmdApp() *cobra.Command {
Aliases: []string{"cfg"},
Deprecated: "This has been moved under `package`. This command will be removed in v2.",
Args: cobra.ExactArgs(1),
RunE: runPkgConfigure,
RunE: runInstanceConfigure,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should drop application command for our v1 release.

}

appConfigureCmd.Flags().StringVarP(&pkgParamsPath, "params", "p", pkgParamsPath, "Path to params JSON file. This file supports bash interpolation.")
appConfigureCmd.Flags().StringVarP(&instanceParamsPath, "params", "p", instanceParamsPath, "Path to params JSON file. This file supports bash interpolation.")

appDeployCmd := &cobra.Command{
Use: `deploy <project>-<env>-<manifest>`,
Deprecated: "This has been moved under `package`. This command will be removed in v2.",
Args: cobra.ExactArgs(1),
RunE: runPkgDeploy,
RunE: runInstanceDeploy,
}

appDeployCmd.Flags().StringP("message", "m", "", "Add a message when deploying")
Expand All @@ -37,24 +37,24 @@ func NewCmdApp() *cobra.Command {
Deprecated: "This has been moved under `package`. This command will be removed in v2.",
Aliases: []string{"cfg"},
Args: cobra.ExactArgs(1),
RunE: runPkgPatch,
RunE: runInstancePatch,
}

appPatchCmd.Flags().StringArrayVarP(&pkgPatchQueries, "set", "s", []string{}, "Sets a package parameter value using JQ expressions.")
appPatchCmd.Flags().StringArrayVarP(&instancePatchQueries, "set", "s", []string{}, "Sets a package parameter value using JQ expressions.")

// app and infra are the same, lets reuse a get command/template here.
pkgGetCmd := &cobra.Command{
appGetCmd := &cobra.Command{
Use: `get <project>-<env>-<manifest>`,
Deprecated: "This has been moved under `package`. This command will be removed in v2.",
Aliases: []string{"g"},
Args: cobra.ExactArgs(1), // Enforce exactly one argument
RunE: runPkgGet,
RunE: runInstanceGet,
}

appCmd.AddCommand(appDeployCmd)
appCmd.AddCommand(appConfigureCmd)
appCmd.AddCommand(appPatchCmd)
appCmd.AddCommand(pkgGetCmd)
appCmd.AddCommand(appGetCmd)

return appCmd
}
2 changes: 1 addition & 1 deletion cmd/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/charmbracelet/glamour"
"github.com/massdriver-cloud/mass/docs/helpdocs"
"github.com/massdriver-cloud/mass/internal/api"
"github.com/massdriver-cloud/mass/internal/api/v0"
"github.com/massdriver-cloud/mass/internal/artifact"
artifactcmd "github.com/massdriver-cloud/mass/internal/commands/artifact"
"github.com/massdriver-cloud/massdriver-sdk-go/massdriver/client"
Expand Down
2 changes: 1 addition & 1 deletion cmd/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

"github.com/charmbracelet/glamour"
"github.com/massdriver-cloud/mass/docs/helpdocs"
"github.com/massdriver-cloud/mass/internal/api"
"github.com/massdriver-cloud/mass/internal/api/v0"
"github.com/massdriver-cloud/mass/internal/bundle"
"github.com/massdriver-cloud/mass/internal/cli"
cmdbundle "github.com/massdriver-cloud/mass/internal/commands/bundle"
Expand Down
2 changes: 1 addition & 1 deletion cmd/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/massdriver-cloud/mass/docs/helpdocs"
"github.com/massdriver-cloud/mass/internal/api"
"github.com/massdriver-cloud/mass/internal/api/v0"
"github.com/massdriver-cloud/mass/internal/cli"
"github.com/massdriver-cloud/massdriver-sdk-go/massdriver/client"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion cmd/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/charmbracelet/glamour"
"github.com/massdriver-cloud/mass/docs/helpdocs"
"github.com/massdriver-cloud/mass/internal/api"
"github.com/massdriver-cloud/mass/internal/api/v0"
"github.com/massdriver-cloud/mass/internal/cli"
"github.com/massdriver-cloud/mass/internal/definition"
"github.com/massdriver-cloud/mass/internal/prettylogs"
Expand Down
44 changes: 25 additions & 19 deletions cmd/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (

"github.com/charmbracelet/glamour"
"github.com/massdriver-cloud/mass/docs/helpdocs"
"github.com/massdriver-cloud/mass/internal/api"
apiv0 "github.com/massdriver-cloud/mass/internal/api/v0"
"github.com/massdriver-cloud/mass/internal/api/v1"
"github.com/massdriver-cloud/mass/internal/cli"
"github.com/massdriver-cloud/mass/internal/commands/environment"

Expand Down Expand Up @@ -57,13 +58,13 @@ func NewCmdEnvironment() *cobra.Command {
}

environmentCreateCmd := &cobra.Command{
Use: "create [slug]",
Use: "create [ID]",
Short: "Create an environment",
Long: helpdocs.MustRender("environment/create"),
Args: cobra.ExactArgs(1),
RunE: runEnvironmentCreate,
}
environmentCreateCmd.Flags().StringP("name", "n", "", "Environment name (defaults to slug if not provided)")
environmentCreateCmd.Flags().StringP("name", "n", "", "Environment name (defaults to ID if not provided)")

environmentDefaultCmd := &cobra.Command{
Use: "default [environment] [artifact-id]",
Expand Down Expand Up @@ -149,12 +150,12 @@ func runEnvironmentList(cmd *cobra.Command, args []string) error {
return fmt.Errorf("error initializing massdriver client: %w", mdClientErr)
}

environments, err := api.GetEnvironmentsByProject(ctx, mdClient, projectID)
environments, err := apiv0.GetEnvironmentsByProject(ctx, mdClient, projectID)
if err != nil {
return err
}

tbl := cli.NewTable("ID/Slug", "Name", "Description", "Monthly $", "Daily $")
tbl := cli.NewTable("ID", "Name", "Description", "Monthly $", "Daily $")
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table header was updated to "ID", but the rows below still add env.Slug as the first column. Update either the header (back to "Slug"/"ID/Slug") or the row value (to env.ID) so the output matches what’s displayed.

Suggested change
tbl := cli.NewTable("ID", "Name", "Description", "Monthly $", "Daily $")
tbl := cli.NewTable("Slug", "Name", "Description", "Monthly $", "Daily $")

Copilot uses AI. Check for mistakes.

for _, env := range environments {
monthly := ""
Expand Down Expand Up @@ -207,38 +208,43 @@ func renderEnvironment(environment *api.Environment) error {
func runEnvironmentCreate(cmd *cobra.Command, args []string) error {
ctx := context.Background()

fullSlug := args[0]
fullID := args[0]
name, err := cmd.Flags().GetString("name")
if err != nil {
return err
}

// Parse project-env format: extract project and env slugs separately
parts := strings.Split(fullSlug, "-")
// Parse project-env format: extract project and env IDs separately
parts := strings.Split(fullID, "-")
if len(parts) < 2 {
return fmt.Errorf("unable to determine project from slug %s (expected format: project-env)", fullSlug)
return fmt.Errorf("unable to determine project from ID %s (expected format: project-env)", fullID)
}
projectIDOrSlug := parts[0]
envSlug := strings.Join(parts[1:], "-")
projectID := parts[0]
envID := strings.Join(parts[1:], "-")

if name == "" {
name = envSlug
name = envID
}

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

env, err := api.CreateEnvironment(ctx, mdClient, projectIDOrSlug, name, envSlug, "")
input := api.CreateEnvironmentInput{
Id: envID,
Name: name,
}

env, err := api.CreateEnvironment(ctx, mdClient, projectID, input)
if err != nil {
return err
}

fmt.Printf("✅ Environment `%s` created successfully\n", fullSlug)
urlHelper, urlErr := api.NewURLHelper(ctx, mdClient)
fmt.Printf("✅ Environment `%s` created successfully\n", fullID)
urlHelper, urlErr := apiv0.NewURLHelper(ctx, mdClient)
if urlErr == nil {
fmt.Printf("🔗 %s\n", urlHelper.EnvironmentURL(projectIDOrSlug, env.Slug))
fmt.Printf("🔗 %s\n", urlHelper.EnvironmentURL(projectID, env.ID))
}
return nil
}
Expand All @@ -256,19 +262,19 @@ func runEnvironmentDefault(cmd *cobra.Command, args []string) error {
return fmt.Errorf("error initializing massdriver client: %w", mdClientErr)
}

err := api.SetEnvironmentDefault(ctx, mdClient, environmentID, artifactID)
err := apiv0.SetEnvironmentDefault(ctx, mdClient, environmentID, artifactID)
if err != nil {
return err
}

environment, err := api.GetEnvironment(ctx, mdClient, environmentID)
environment, err := apiv0.GetEnvironment(ctx, mdClient, environmentID)
if err != nil {
return fmt.Errorf("failed to get environment: %w", err)
}

fullEnvSlug := fmt.Sprintf("%s-%s", environment.Project.Slug, environment.Slug)
fmt.Printf("✅ Environment `%s` default connection set successfully\n", fullEnvSlug)
urlHelper, urlErr := api.NewURLHelper(ctx, mdClient)
urlHelper, urlErr := apiv0.NewURLHelper(ctx, mdClient)
if urlErr == nil {
fmt.Printf("🔗 %s\n", urlHelper.EnvironmentURL(environment.Project.Slug, environment.Slug))
}
Expand Down
16 changes: 8 additions & 8 deletions cmd/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ func NewCmdInfra() *cobra.Command {
Aliases: []string{"cfg"},
Deprecated: "This has been moved under `package`. This command will be removed in v2.",
Args: cobra.ExactArgs(1),
RunE: runPkgConfigure,
RunE: runInstanceConfigure,
}

infraConfigureCmd.Flags().StringVarP(&pkgParamsPath, "params", "p", pkgParamsPath, "Path to params JSON file. This file supports bash interpolation.")
infraConfigureCmd.Flags().StringVarP(&instanceParamsPath, "params", "p", instanceParamsPath, "Path to params JSON file. This file supports bash interpolation.")

infraDeployCmd := &cobra.Command{
Use: `deploy <project>-<env>-<manifest>`,
Deprecated: "This has been moved under `package`. This command will be removed in v2.",
Args: cobra.ExactArgs(1),
RunE: runPkgDeploy,
RunE: runInstanceDeploy,
}

infraDeployCmd.Flags().StringP("message", "m", "", "Add a message when deploying")
Expand All @@ -36,24 +36,24 @@ func NewCmdInfra() *cobra.Command {
Deprecated: "This has been moved under `package`. This command will be removed in v2.",
Aliases: []string{"cfg"},
Args: cobra.ExactArgs(1),
RunE: runPkgPatch,
RunE: runInstancePatch,
}

infraPatchCmd.Flags().StringArrayVarP(&pkgPatchQueries, "set", "s", []string{}, "Sets a package parameter value using JQ expressions.")
infraPatchCmd.Flags().StringArrayVarP(&instancePatchQueries, "set", "s", []string{}, "Sets a package parameter value using JQ expressions.")

// app and infra are the same, lets reuse a get command/template here.
pkgGetCmd := &cobra.Command{
infraGetCmd := &cobra.Command{
Use: `get <project>-<env>-<manifest>`,
Deprecated: "This has been moved under `package`. This command will be removed in v2.",
Aliases: []string{"g"},
Args: cobra.ExactArgs(1), // Enforce exactly one argument
RunE: runPkgGet,
RunE: runInstanceGet,
}

infraCmd.AddCommand(infraConfigureCmd)
infraCmd.AddCommand(infraDeployCmd)
infraCmd.AddCommand(infraPatchCmd)
infraCmd.AddCommand(pkgGetCmd)
infraCmd.AddCommand(infraGetCmd)

return infraCmd
}
Loading
Loading