Skip to content

Commit

Permalink
decouple from CNFManager and utils
Browse files Browse the repository at this point in the history
  • Loading branch information
williscool committed Jun 16, 2023
1 parent 3b60dbe commit 5899f25
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/tasks/workload/configuration.cr
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,9 @@ task "operator_installed" do |_, args|
Log.for("verbose").info { "operator_installed" } if check_verbose(args)
Log.debug { "cnf_config: #{config}" }

subscription_names = Operator::OLM.get_all_subscription_names(args, config)
resources = CNFManager.cnf_resources(args, config) { |resource| resource }

subscription_names = Operator::OLM.get_all_subscription_names(resources)

Log.info { "Subscription Names: #{subscription_names}" }

Expand Down Expand Up @@ -771,7 +773,10 @@ task "operator_privileged" do |_, args|
Log.for("verbose").info { "operator_installed" } if check_verbose(args)
Log.debug { "cnf_config: #{config}" }

installed_csvs = Operator::OLM.get_all_successfully_installed_csvs(args, config)

resources = CNFManager.cnf_resources(args, config) { |resource| resource }

installed_csvs = Operator::OLM.get_all_successfully_installed_csvs(resources)

Log.info { "Installed CSVs: #{installed_csvs}" }

Expand Down
15 changes: 7 additions & 8 deletions utils/operator.cr
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
require "../src/tasks/utils/utils.cr"
require "kubectl_client"

module Operator
module OLM
def self.get_all_subscription_names(args, config)
#TODO: just pass the resource list and then we can remove the CNFManager dependency and only need the KubectlClient
subscription_names = CNFManager.cnf_resources(args, config) do |resource|
def self.get_all_subscription_names(resources)
subscription_names = resources.map do |resource|
kind = resource.dig("kind").as_s
if kind && kind.downcase == "subscription"
{"name" => resource.dig("metadata", "name"), "namespace" => resource.dig("metadata", "namespace")}
Expand All @@ -29,8 +28,8 @@ module Operator
end.compact
end

def self.get_all_csv_names(args, config)
self.get_all_csv_names_from_subscription_names(self.get_all_subscription_names(args, config))
def self.get_all_csv_names(resources)
self.get_all_csv_names_from_subscription_names(self.get_all_subscription_names(resources))
end

def self.get_all_csv_wait_for_resource_statuses_from_csv_names(csv_names)
Expand All @@ -44,8 +43,8 @@ module Operator
end
end

def self.get_all_successfully_installed_csvs(args, config)
self.get_all_csv_wait_for_resource_statuses_from_csv_names(self.get_all_csv_names(args, config)).select do |csv|
def self.get_all_successfully_installed_csvs(resources)
self.get_all_csv_wait_for_resource_statuses_from_csv_names(self.get_all_csv_names(resources)).select do |csv|
csv["wait_for_resource_status"] == "success"
end
end
Expand Down

0 comments on commit 5899f25

Please sign in to comment.