-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathfleet_configuration_version_delete.go
More file actions
49 lines (42 loc) · 1.51 KB
/
fleet_configuration_version_delete.go
File metadata and controls
49 lines (42 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package fleetcontrol
import (
"fmt"
"github.com/spf13/cobra"
"github.com/newrelic/newrelic-cli/internal/client"
)
// handleFleetDeleteVersion implements the 'delete-version' command to delete a configuration version.
//
// This command deletes a specific version of a fleet configuration.
// This operation cannot be undone. The configuration entity itself will remain.
//
// The command:
// 1. Validates flag values (done automatically by framework via YAML rules)
// 2. Derives organization ID if not provided
// 3. Calls the New Relic API to delete the version
//
// Parameters:
// - cmd: The cobra command being executed
// - args: Command arguments (not used)
// - flags: Validated flag values from YAML configuration
//
// Returns:
// - Error if version deletion fails, nil on success
func handleFleetDeleteVersion(cmd *cobra.Command, args []string, flags *FlagValues) error {
// Get typed flag values - no hardcoded strings!
f := flags.DeleteVersion()
// Get organization ID (provided or fetched from API)
orgID, err := GetOrganizationID(f.OrganizationID)
if err != nil {
return PrintError(fmt.Errorf("failed to determine organization ID: %w", err))
}
// Call New Relic API to delete the version
err = client.NRClient.FleetControl.FleetControlDeleteConfigurationVersion(
f.VersionID,
orgID,
)
if err != nil {
return PrintError(fmt.Errorf("failed to delete configuration version: %w", err))
}
// Print success message to stdout with status wrapper
return PrintConfigurationDeleteSuccess(f.VersionID)
}