Skip to content

Conversation

@chrisghill
Copy link
Member

No description provided.


Artifacts represent infrastructure resources and connections in Massdriver. They can be provisioned by bundles or manually imported.

## Commands
Copy link
Member Author

Choose a reason for hiding this comment

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

All these command blocks are redundant - Cobra already shows a list of available commands. Additionally many of them were out of date and missing new commands recently added.

version
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I just moved these in the file so that the sections were in alphabetical order.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new mass package reset command that allows users to reset a package status back to 'Initialized'. This is designed as an escape hatch for packages in unrecoverable states, such as being stuck in 'Pending' or unable to be decommissioned.

Key changes:

  • Added new ResetPackage API function that calls the resetPackage GraphQL mutation with hardcoded options (deleteDeployments: true, deleteState: false, deleteParams: false)
  • Implemented CLI command mass package reset with help documentation
  • Generated GraphQL bindings for the resetPackage mutation

Reviewed changes

Copilot reviewed 15 out of 23 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pkg/api/package.go Added ResetPackage function with hardcoded reset options
pkg/commands/pkg/reset.go Added RunReset command handler that calls API reset
pkg/commands/pkg/reset_test.go Added test for RunReset function
pkg/api/package_test.go Added test for ResetPackage API function
cmd/package.go Registered new pkgResetCmd with cobra CLI
pkg/api/zz_generated.go Generated GraphQL types and functions for resetPackage mutation
pkg/api/genqlient.graphql Added resetPackage GraphQL mutation definition
pkg/api/schema.graphql Schema updates for integrations and other API changes
docs/helpdocs/package/reset.md User documentation for reset command
docs/generated/mass_package_reset.md Generated CLI documentation
docs/helpdocs/*.md Removed command lists from documentation files
docs/generated/*.md Updated generated documentation to reflect changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return gqlmock.MockMutationResponse("resetPackage", map[string]any{
"id": "pkg-uuid1",
"slug": "ecomm-prod-cache",
"status": "ready",
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The test expects the package status to be "ready", but according to the API documentation in pkg/api/zz_generated.go line 4711, the reset operation "will" set the package status to INITIALIZED. The test should expect "INITIALIZED" instead of "ready" to accurately reflect the behavior of the reset operation.

Copilot uses AI. Check for mistakes.
if pkg.Slug != "ecomm-prod-cache" {
t.Errorf("got %v, wanted %v", pkg.Slug, "ecomm-prod-cache")
}
if pkg.Status != "ready" {
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The test expects the package status to be "ready", but according to the API documentation, the resetPackage mutation sets the package status to INITIALIZED. The expected status should be "INITIALIZED" or use the PackageStatusInitialized constant instead of "ready".

Copilot uses AI. Check for mistakes.
"result": map[string]any{
"id": "pkg-uuid1",
"slug": "ecomm-prod-cache",
"status": "ready",
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The test expects the package status to be "ready", but according to the API documentation, the resetPackage mutation sets the package status to INITIALIZED. The expected status should be "INITIALIZED" or use the PackageStatusInitialized constant instead of "ready".

Copilot uses AI. Check for mistakes.
if pkg.Slug != "ecomm-prod-cache" {
t.Errorf("got %v, wanted %v", pkg.Slug, "ecomm-prod-cache")
}
if pkg.Status != "ready" {
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The test expects the package status to be "ready", but according to the API documentation, the resetPackage mutation sets the package status to INITIALIZED. The expected status should be "INITIALIZED" or use the PackageStatusInitialized constant instead of "ready".

Copilot uses AI. Check for mistakes.
Comment on lines +92 to +94
deleteState := false
deleteParams := false
deleteDeployments := true
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The ResetPackage function hardcodes deleteState, deleteParams, and deleteDeployments with no way for callers to customize these options. This limits flexibility for users who may want different reset behaviors. Consider either:

  1. Adding parameters to the function signature to allow callers to specify these options
  2. Adding a more flexible ResetPackageWithOptions function alongside this one
  3. Documenting why these specific defaults were chosen (particularly why deleteDeployments is true while the others are false)

Copilot uses AI. Check for mistakes.
Comment on lines 470 to 492
func runPkgReset(cmd *cobra.Command, args []string) error {
ctx := context.Background()

packageSlugOrID := args[0]

cmd.SilenceUsage = true

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

pkg, err := pkg.RunReset(ctx, mdClient, packageSlugOrID)
if err != nil {
return err
}

var name = lipgloss.NewStyle().SetString(pkg.Slug).Foreground(lipgloss.Color("#7D56F4"))
msg := fmt.Sprintf("✅ Package %s reset successfully", name)
fmt.Println(msg)

return nil
}
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The package reset command performs a potentially destructive operation (deletes deployment history by default) without any confirmation prompt. Similar to the destroy command (lines 439-450), this command should prompt the user for confirmation before proceeding, unless a --force flag is provided. This is especially important since the operation deletes deployments and the API documentation warns this is "an escape hatch and can lose data".

Copilot uses AI. Check for mistakes.
"github.com/massdriver-cloud/massdriver-sdk-go/massdriver/client"
)

// Resets a package with options to delete state, params, and deployments.
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The comment states "Resets a package with options to delete state, params, and deployments" but the function doesn't actually provide any options - the values are hardcoded in the function body. The comment should be updated to accurately reflect that this function resets a package with deleteDeployments set to true and deleteState/deleteParams set to false, or the function should be enhanced to actually accept these options as parameters.

Suggested change
// Resets a package with options to delete state, params, and deployments.
// RunReset resets a package using the default reset behavior:
// deleteDeployments=true, deleteState=false, deleteParams=false.

Copilot uses AI. Check for mistakes.
@chrisghill chrisghill merged commit 2d325b9 into main Jan 7, 2026
3 of 4 checks passed
@chrisghill chrisghill deleted the feature/mass-package-reset branch January 7, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants