Skip to content

Commit

Permalink
Merge pull request #65 from zbrookle/add_kind_to_cross_version_obj_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
zbrookle authored Mar 4, 2021
2 parents 07e7bbb + 9b564ff commit 4cf13fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
3 changes: 2 additions & 1 deletion avionix/kube/autoscaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ class CrossVersionObjectReference(Autoscaling):
:param api_version: API version of the referent
"""

def __init__(self, name: str, api_version: Optional[str] = None):
def __init__(self, name: str, kind: str, api_version: Optional[str] = None):
super().__init__(api_version)
self.name = name
self.kind = kind


class HorizontalPodAutoscalerSpec(HelmYaml):
Expand Down
17 changes: 8 additions & 9 deletions avionix/tests/test_autoscaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@


def test_horizontal_pod_autoscaler(chart_info):
builder = ChartBuilder(
chart_info,
kubernetes_objects=[
HorizontalPodAutoscaler(
ObjectMeta(name="test-autoscaler"),
HorizontalPodAutoscalerSpec(1, CrossVersionObjectReference("test")),
)
],
autoscaler = HorizontalPodAutoscaler(
ObjectMeta(name="test-autoscaler"),
HorizontalPodAutoscalerSpec(1, CrossVersionObjectReference("test", "Pod")),
)
builder = ChartBuilder(chart_info, kubernetes_objects=[autoscaler],)
with ChartInstallationContext(builder):
autoscaling_info = kubectl_get("horizontalpodautoscaler")
assert autoscaling_info["NAME"][0] == "test-autoscaler"
assert autoscaling_info["REFERENCE"][0] == "CrossVersionObjectReference/test"
assert (
autoscaling_info["REFERENCE"][0]
== f"{autoscaler.spec.scaleTargetRef.kind}/test"
)
assert autoscaling_info["MAXPODS"][0] == "1"

0 comments on commit 4cf13fb

Please sign in to comment.