-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13ff277
commit 76e5a90
Showing
4 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
## kn revision delete | ||
|
||
Delete a revision. | ||
|
||
### Synopsis | ||
|
||
Delete a revision. | ||
|
||
``` | ||
kn revision delete NAME [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
# Delete a revision 'svc1-abcde' in default namespace | ||
kn revision delete svc1-abcde | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for delete | ||
-n, --namespace string List the requested object(s) in given namespace. | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string config file (default is $HOME/.kn/config.yaml) | ||
--kubeconfig string kubectl config file (default is $HOME/.kube/config) | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kn revision](kn_revision.md) - Revision command group | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright © 2019 The Knative Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package revision | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/knative/client/pkg/kn/commands" | ||
"github.com/spf13/cobra" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// NewRevisionDeleteCommand represent 'revision delete' command | ||
func NewRevisionDeleteCommand(p *commands.KnParams) *cobra.Command { | ||
RevisionDeleteCommand := &cobra.Command{ | ||
Use: "delete NAME", | ||
Short: "Delete a revision.", | ||
Example: ` | ||
# Delete a revision 'svc1-abcde' in default namespace | ||
kn revision delete svc1-abcde`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) != 1 { | ||
return errors.New("requires the revision name.") | ||
} | ||
client, err := p.ServingFactory() | ||
if err != nil { | ||
return err | ||
} | ||
namespace, err := p.GetNamespace(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = client.Revisions(namespace).Delete( | ||
args[0], | ||
&v1.DeleteOptions{}, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Fprintf(cmd.OutOrStdout(), "Revision '%s' successfully deleted in namespace '%s'.\n", args[0], namespace) | ||
return nil | ||
}, | ||
} | ||
commands.AddNamespaceFlags(RevisionDeleteCommand.Flags(), false) | ||
return RevisionDeleteCommand | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters