Skip to content
Snippets Groups Projects

Receptive cluster agents

Closed Tiger Watson requested to merge receptive-cluster-agents into master
Files
27
@@ -13,11 +13,12 @@ class UrlConfiguration < ApplicationRecord
validates :url, url: { schemes: %w[grpc grpcs] }
validates :ca_cert, certificate: true, allow_blank: true
validates :tls_host, host: true, allow_blank: true
with_options if: :certificate_auth? do
validates :client_cert, certificate: true
validates :client_key, certificate_key: true
validates :ca_cert, certificate: true, allow_blank: true
validates :tls_host, host: true, allow_blank: true
validates :private_key, absence: true
end
@@ -25,7 +26,7 @@ class UrlConfiguration < ApplicationRecord
with_options if: :public_key_auth? do
validates :private_key, presence: true
validates :client_cert, :client_key, :ca_cert, :tls_host, absence: true
validates :client_cert, :client_key, absence: true
end
nullify_if_blank :client_key, :client_cert, :ca_cert, :tls_host
@@ -42,6 +43,9 @@ class UrlConfiguration < ApplicationRecord
revoked: 1
}
after_create :set_agent_receptive!
after_destroy :unset_agent_receptive!
private
def public_key_auth?
@@ -51,6 +55,14 @@ def public_key_auth?
def certificate_auth?
!public_key_auth?
end
def set_agent_receptive!
agent.update!(is_receptive: true)
end
def unset_agent_receptive!
agent.update!(is_receptive: false)
end
end
end
end
Loading