Skip to content

Follow-up from !30458: commands should return array by default

The following discussion from !30458 (merged) should be addressed:

  • @dzaporozhets started a discussion:

    Its not like I have better idea but I want to say I was confused with this line. To understand why it's to_a on second argument and why we are ok with doing nil.to_a, I need to take a look at delete_knative_services, delete_knative_istio_metrics and DeleteCommand implementation.

    Maybe a better solution for the future is to convert all kubectl methods to return empty array instead of nil if there is no commands to execute. For example:

    def delete_knative_istio_metrics
      if cluster.application_prometheus_available?  
        ["kubectl delete --ignore-not-found -f #{METRICS_CONFIG}"] 
      else
        []
      end
    end

    If you feel the same way you can create a ~"technical debt" for that. It would not block this MR as you followed existing style of code.

Edited by João Alexandre Cunha