-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
customize object metadata for generated roles/clusterroles (#105)
Implements #92
- Loading branch information
1 parent
505d5c7
commit 813bd86
Showing
3 changed files
with
55 additions
and
13 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,28 @@ | ||
package cmd | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
type MetadataFlag struct { | ||
metadata metav1.ObjectMeta | ||
} | ||
|
||
func (f *MetadataFlag) String() string { | ||
b, err := json.Marshal(f.metadata) | ||
if err != nil { | ||
return "failed to marshal metadata object" | ||
} | ||
return string(b) | ||
} | ||
|
||
func (f *MetadataFlag) Set(v string) error { | ||
f.metadata = metav1.ObjectMeta{} | ||
return json.Unmarshal([]byte(v), &f.metadata) | ||
} | ||
|
||
func (f *MetadataFlag) Type() string { | ||
return "json" | ||
} |
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