diff --git a/lib/rb_shift/openshift_kind.rb b/lib/rb_shift/openshift_kind.rb index cfc222b..9673482 100644 --- a/lib/rb_shift/openshift_kind.rb +++ b/lib/rb_shift/openshift_kind.rb @@ -49,6 +49,10 @@ def update(patch = nil) execute "patch #{self.class.class_name} #{name} -p #{patch.shellescape}" end + def change_label(label) + @obj[:metadata][:labels].merge!(label) + end + def execute(command, **opts) parent.execute(command, **opts) if parent.respond_to? :execute end diff --git a/lib/rb_shift/route.rb b/lib/rb_shift/route.rb index 345d2b6..dfd4905 100644 --- a/lib/rb_shift/route.rb +++ b/lib/rb_shift/route.rb @@ -13,5 +13,10 @@ def address protocol = termination ? 'https' : 'http' "#{protocol}://#{host.chomp '/'}" end + + def change_service(name, port) + @obj[:spec][:to][:name] = name + @obj[:spec][:port][:targetPort] = port + end end end diff --git a/lib/rb_shift/service.rb b/lib/rb_shift/service.rb index 3cfeb67..6a0bbf8 100644 --- a/lib/rb_shift/service.rb +++ b/lib/rb_shift/service.rb @@ -11,6 +11,14 @@ def routes(update = false) @_routes end + def filter_routes_by_labels(update = false, labels: {}) + routes = routes(update) + routes.select do |_, value| + (labels.to_a - value.metadata.labels.to_a).empty? + end + + end + def create_route(name, hostname, termination = 'edge', **opts) log.info "Creating route #{name} #{hostname} for service #{self.name}" if termination