forked from karmada-io/karmada
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: zhzhuang-zju <m17799853869@163.com>
- Loading branch information
1 parent
c9e0ad7
commit 12a075e
Showing
4 changed files
with
528 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,54 @@ | ||
/* | ||
Copyright 2024 The Karmada 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 label | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"k8s.io/cli-runtime/pkg/genericiooptions" | ||
kubectllabel "k8s.io/kubectl/pkg/cmd/label" | ||
"k8s.io/kubectl/pkg/util/templates" | ||
|
||
"github.com/karmada-io/karmada/pkg/karmadactl/util" | ||
) | ||
|
||
var ( | ||
labelExample = templates.Examples(` | ||
# Update propagationpolicy 'foo' with the label 'priority' and the value '0' | ||
[1]%s label pp foo priority=0 | ||
# Update propagationpolicy 'foo' with the label 'priority' and the value '1', overwriting any existing value | ||
[1]%s label --overwrite pp foo priority=1 | ||
# Update all propagationpolicies in the namespace | ||
[1]%s label pp --all priority=0 | ||
# Update a propagationpolicy identified by the type and name in "propagationpolicy.json" | ||
[1]%s label -f propagationpolicy.json priority=0 | ||
# Update propagationpolicy 'foo' only if the resource is unchanged from version 1 | ||
[1]%s label pp priority=0 --resource-version=1 | ||
# Update propagationpolicy 'foo' by removing a label named 'bar' if it exists | ||
# Does not require the --overwrite flag | ||
[1]%s label pp foo bar-`) | ||
) | ||
|
||
// NewCmdLabel returns new initialized instance of label sub command | ||
func NewCmdLabel(f util.Factory, parentCommnd string, ioStreams genericiooptions.IOStreams) *cobra.Command { | ||
cmd := kubectllabel.NewCmdLabel(f, ioStreams) | ||
cmd.Example = fmt.Sprintf(labelExample, parentCommnd) | ||
return cmd | ||
} |
Oops, something went wrong.