-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom CRD: Set dynamic watch from controller flags (#1302)
- Loading branch information
1 parent
ced8496
commit ef6557a
Showing
6 changed files
with
89 additions
and
1 deletion.
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
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
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,30 @@ | ||
package util | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
// GvkListFlag is the custom flag to parse GroupVersionKind list for trial resources. | ||
type GvkListFlag []schema.GroupVersionKind | ||
|
||
// Set is the method to convert gvk to string value | ||
func (flag *GvkListFlag) String() string { | ||
gvkStrings := []string{} | ||
for _, x := range []schema.GroupVersionKind(*flag) { | ||
gvkStrings = append(gvkStrings, x.String()) | ||
} | ||
return strings.Join(gvkStrings, ",") | ||
} | ||
|
||
// Set is the method to set gvk from string flag value | ||
func (flag *GvkListFlag) Set(value string) error { | ||
gvk, _ := schema.ParseKindArg(value) | ||
if gvk == nil { | ||
return fmt.Errorf("Invalid GroupVersionKind: %v", value) | ||
} | ||
*flag = append(*flag, *gvk) | ||
return nil | ||
} |
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