mirror of
https://github.com/dsx-ai-factory/nvke.git
synced 2026-12-07 04:35:58 +08:00
The binary, its directory, its config directory and its environment variables take the new name. For one release the previous names still work: every NVKECTL_* setting is also read under its NKECTL_* name with a deprecation warning (the NKECTL_CWE_* names of the generation before are no longer read), a config file left under nkectl/ is read and copied to nvkectl/ once, and releases publish both nvkectl-<os>-<arch> and nkectl-<os>-<arch>, to GitHub and to S3 under the existing prefix. The e2e helper package, the e2e test, the smoke and fetch scripts and the bootstrap e2e workflow follow the binary; the fetch script accepts a release that carries only the old asset name. The CLI's own documents and the two installation documents that print the download URLs change with it. Kept on purpose: the NVCR repository name until an nvkectl repository exists in the NGC org, the S3 prefix the publishing role's policy names, and the prose in the other documents. BREAKING CHANGE: the CLI is installed and invoked as nvkectl. The previous binary name, environment variable names and config directory are honoured for one release, as described above. Closes #1455 Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
63 lines
1.8 KiB
Go
63 lines
1.8 KiB
Go
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package command
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/dsx-ai-factory/nvke/cli/internal/operator"
|
|
)
|
|
|
|
// NewDeleteCmds returns the "nvkectl delete machineimage|clusterrelease|
|
|
// nodepoolrelease" subcommands.
|
|
func NewDeleteCmds(clientFn ClientFn) []*cobra.Command {
|
|
cmds := make([]*cobra.Command, 0, len(kindInfos))
|
|
for _, k := range kindInfos {
|
|
cmds = append(cmds, newDeleteCmd(k, clientFn))
|
|
}
|
|
return cmds
|
|
}
|
|
|
|
func newDeleteCmd(k kindInfo, clientFn ClientFn) *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: k.use + " <name>",
|
|
Aliases: []string{k.plural()},
|
|
Short: "Delete " + k.what,
|
|
Long: fmt.Sprintf(`Delete a %s from the active site's management cluster.
|
|
|
|
Deletion is immediate and there is no prompt.
|
|
|
|
nvkectl does not check whether %s the %s,
|
|
and anything that does fails to provision or upgrade once it is gone.%s
|
|
|
|
Example:
|
|
nvkectl delete %s <name>`, k.noun, k.usedBy, k.noun, k.retireAdvice(), k.use),
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
c, err := clientFn()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := c.Delete(cmd.Context(), k.kind, args[0]); err != nil {
|
|
return err
|
|
}
|
|
fmt.Fprintf(cmd.OutOrStdout(), "%s %q deleted\n", capitalize(k.noun), args[0])
|
|
fmt.Fprintf(cmd.ErrOrStderr(),
|
|
"Note: nvkectl does not check whether %s this %s.\n", k.usedBy, k.noun)
|
|
return nil
|
|
},
|
|
}
|
|
}
|
|
|
|
// retireAdvice is the help sentence about retiring a resource that is still in
|
|
// use. Only releases have a lifecycle to deprecate.
|
|
func (k kindInfo) retireAdvice() string {
|
|
if k.kind == operator.KindMachineImage {
|
|
return ""
|
|
}
|
|
return "\n\nTo retire a release that is still in use, deprecate it instead ('nvkectl deprecate')."
|
|
}
|