- .github
- applyconfigurations
- discovery
- dynamic
- examples
- features
- gentype
- informers
- kubernetes
- kubernetes_test
- listers
- metadata
- openapi
- openapi3
- pkg
- plugin
-
rest
-
fake
-
testdata
-
watch
- OWNERS
- client.go
- client_test.go
- config.go
- config_test.go
- connection_test.go
- exec.go
- exec_test.go
- plugin.go
- plugin_test.go
- request.go
- request_test.go
- request_watchlist_test.go
- transport.go
- transport_test.go
- url_utils.go
- url_utils_test.go
- urlbackoff.go
- urlbackoff_test.go
- warnings.go
- with_retry.go
- with_retry_test.go
- zz_generated.deepcopy.go
-
fake
- restmapper
- scale
- testing
- third_party
- tools
- transport
- util
- CHANGELOG.md
- CONTRIBUTING.md
- INSTALL.md
- LICENSE
- OWNERS
- README.md
- SECURITY_CONTACTS
- code-of-conduct.md
- doc.go
- go.mod
- go.sum
Explanation
This code defines a ResourceMetricSourceApplyConfiguration
struct, which represents a declarative configuration of the ResourceMetricSource
type used in Kubernetes autoscaling.
The struct has two fields:
Name
: Av1.ResourceName
type, representing the resource to monitor (e.g., “cpu”, “memory”).Target
: AMetricTargetApplyConfiguration
pointer, holding the target values for the monitored resource.
The code provides several functions for building and configuring this struct:
ResourceMetricSource()
: Creates a newResourceMetricSourceApplyConfiguration
instance.WithName(value v1.ResourceName)
: Sets theName
field of the configuration to the specifiedvalue
.WithTarget(value *MetricTargetApplyConfiguration)
: Sets theTarget
field of the configuration to the specifiedvalue
.
These functions allow developers to easily construct and configure a ResourceMetricSourceApplyConfiguration
object, which can then be used in Kubernetes APIs for defining and managing autoscaling policies based on resource usage.
The code utilizes the apply
pattern, which allows for creating and updating Kubernetes objects in a declarative way, allowing for more concise and readable code. The use of “With” functions for setting fields ensures that the object configuration can be built up incrementally, making it more flexible and adaptable.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph