mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-19 18:29:52 +00:00
Allow to skip resources using the GVK notation (#92)
* Allow to skip resources using the GVK notation * Update flags description, add integration tests and update readme Co-authored-by: Yann Hamon <yann@mandragor.org>
This commit is contained in:
parent
466ec73ed7
commit
d8e348a597
6 changed files with 52 additions and 10 deletions
|
|
@ -20,6 +20,18 @@ type Signature struct {
|
|||
Kind, Version, Namespace, Name string
|
||||
}
|
||||
|
||||
// GroupVersionKind returns a string with the GVK encoding of a resource signature.
|
||||
// This encoding slightly differs from the Kubernetes upstream implementation
|
||||
// in order to be suitable for being used in the kubeconform command-line arguments.
|
||||
func (sig *Signature) GroupVersionKind() string {
|
||||
return fmt.Sprintf("%s/%s", sig.Version, sig.Kind)
|
||||
}
|
||||
|
||||
// QualifiedName returns a string for a signature in the format version/kind/namespace/name
|
||||
func (sig *Signature) QualifiedName() string {
|
||||
return fmt.Sprintf("%s/%s/%s/%s", sig.Version, sig.Kind, sig.Namespace, sig.Name)
|
||||
}
|
||||
|
||||
// Signature computes a signature for a resource, based on its Kind, Version, Namespace & Name
|
||||
func (res *Resource) Signature() (*Signature, error) {
|
||||
if res.sig != nil {
|
||||
|
|
@ -119,8 +131,3 @@ func (res *Resource) Resources() []Resource {
|
|||
|
||||
return []Resource{*res}
|
||||
}
|
||||
|
||||
// QualifiedName returns a string for a signature in the format version/kind/namespace/name
|
||||
func (sig *Signature) QualifiedName() string {
|
||||
return fmt.Sprintf("%s/%s/%s/%s", sig.Version, sig.Kind, sig.Namespace, sig.Name)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue