grafana / xk6-kubernetes

Client extension for interacting with Kubernetes clusters from your k6 tests.
Apache License 2.0
62 stars 20 forks source link

Added Apply functions #21

Closed zv0n closed 2 years ago

zv0n commented 2 years ago

I have added Apply function to Kubernetes classes. This function tries to parse a provided YAML string and if the type of the parsed object is the same as the class, the function creates the object on the Kubernetes server.

I have added this change because I could not figure out how to pass Kubernetes objects to the Create function through javascript.

javaducky commented 2 years ago

Hello @zv0n. Thank you so much for your contribution!

I'm taking a look at reviewing and wondered if you could do us the favor of including example scripts along with these changes?

Thank you!

zv0n commented 2 years ago

Hi @javaducky, I've added the examples. I made a single js file for deployment, service, and ingress because to me it seemed to make more sense than creating e.g. an ingress without having an existing service. I can however split the file into 3 separate ones if you'd prefer that.

javaducky commented 2 years ago

Thank you for adding that so quickly!

Having the combined examples are fine; no need to fully separate. In the future, we'll get some unit tests added around all this functionality which can have broken out test cases, but for now, this is awesome! Using the YAML config definitely feels more appropriate than attempting object creation with javascript syntax 😄.