forked from vmware-archive/octant
-
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.
Create a wrapper for dynamic cache (vmware-archive#568)
The cache for dynamic cache will keep an up to date record of all the objects in a cluster that have been queried. This will speed up the time it takes to generate object graphs 8x or more.
- Loading branch information
Showing
39 changed files
with
806 additions
and
234 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
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,46 @@ | ||
package util | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
kLabels "k8s.io/apimachinery/pkg/labels" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
// Key is a key for the cache. | ||
type Key struct { | ||
Namespace string | ||
APIVersion string | ||
Kind string | ||
Name string | ||
Selector kLabels.Selector | ||
} | ||
|
||
func (k Key) String() string { | ||
var sb strings.Builder | ||
|
||
sb.WriteString("CacheKey[") | ||
if k.Namespace != "" { | ||
fmt.Fprintf(&sb, "Namespace=%q, ", k.Namespace) | ||
} | ||
fmt.Fprintf(&sb, "APIVersion=%q, ", k.APIVersion) | ||
fmt.Fprintf(&sb, "Kind=%q", k.Kind) | ||
|
||
if k.Name != "" { | ||
fmt.Fprintf(&sb, ", Name=%q", k.Name) | ||
} | ||
|
||
if k.Selector != nil { | ||
fmt.Fprintf(&sb, ", Selector=%q", k.Selector.String()) | ||
} | ||
|
||
sb.WriteString("]") | ||
|
||
return sb.String() | ||
} | ||
|
||
// GroupVersionKind converts the Key to a GroupVersionKind. | ||
func (k Key) GroupVersionKind() schema.GroupVersionKind { | ||
return schema.FromAPIVersionAndKind(k.APIVersion, k.Kind) | ||
} |
Oops, something went wrong.