Skip to content

Commit

Permalink
WIP for class method services
Browse files Browse the repository at this point in the history
  • Loading branch information
suprjinx committed Sep 13, 2024
1 parent f255a45 commit 6b9c4be
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/interactors/authenticate_identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AuthenticateIdentity
end

def call
if identity = Services::AuthService.new.authenticate!(context.token)
if identity = Services::AuthService.authenticate!(context.token)
context.identity = identity
else
context.fail!(message: "Invalid token")
Expand Down
2 changes: 1 addition & 1 deletion app/interactors/obtain_cert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class ObtainCert
include FailOnError

def call
if cert = Services::CertificateService.new.issue_cert(context.request)
if cert = Services::CertificateService.issue_cert(context.request)
context.cert = cert
else
context.fail!(message: "Failed to issue certificate")
Expand Down
2 changes: 1 addition & 1 deletion app/interactors/refresh_domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class RefreshDomain
include Interactor

def call
domain_info = Services::DomainOwnershipService.new.get_domain_info(context.request.common_name)
domain_info = Services::DomainOwnershipService.get_domain_info(context.request.common_name)
domain_record = Domain.find_or_create_by!(fqdn: context.request.common_name)
if !domain_info
domain_record.destroy!
Expand Down
4 changes: 4 additions & 0 deletions app/lib/services/app_registry_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def get_domain_info(fqdn)
rescue Faraday::ResourceNotFound => e
nil
end

Check failure on line 20 in app/lib/services/app_registry_service.rb

View workflow job for this annotation

GitHub Actions / build_test

Layout/TrailingWhitespace: Trailing whitespace detected.
def self.get_domain_info(fqdn)
new.get_domain_info(fqdn)
end

private

Expand Down
4 changes: 4 additions & 0 deletions app/lib/services/auth_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def authenticate!(token)
identity
end

def self.authenticate!(token)
new.authenticate!(token)
end

private

def decode(token)
Expand Down
6 changes: 6 additions & 0 deletions app/lib/services/certificate_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ module Services
class CertificateService
attr_reader :impl

def self.issue_cert(cert_issue_request)
new.issue_cert(cert_issue_request)
end

private

Check failure on line 10 in app/lib/services/certificate_service.rb

View workflow job for this annotation

GitHub Actions / build_test

Layout/TrailingWhitespace: Trailing whitespace detected.
def initialize
# TODO this should select an implementation service based on config
@impl = VaultService.new
Expand Down
6 changes: 6 additions & 0 deletions app/lib/services/domain_ownership_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ module Services
class DomainOwnershipService
attr_reader :impl

def self.get_domain_info(fqdn)
new.get_domain_info(fqdn)
end

Check failure on line 8 in app/lib/services/domain_ownership_service.rb

View workflow job for this annotation

GitHub Actions / build_test

Layout/TrailingWhitespace: Trailing whitespace detected.
private

Check failure on line 10 in app/lib/services/domain_ownership_service.rb

View workflow job for this annotation

GitHub Actions / build_test

Layout/TrailingWhitespace: Trailing whitespace detected.
def initialize
# TODO this should select an implementation service based on config
@impl = AppRegistryService.new
Expand Down
7 changes: 6 additions & 1 deletion app/lib/services/vault_service.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module Services
class VaultService
def self.issue_cert(cert_issue_request)
new.issue_cert(cert_issue_request)
end

Check failure on line 6 in app/lib/services/vault_service.rb

View workflow job for this annotation

GitHub Actions / build_test

Layout/TrailingWhitespace: Trailing whitespace detected.
private
attr_reader :client

Check failure on line 9 in app/lib/services/vault_service.rb

View workflow job for this annotation

GitHub Actions / build_test

Layout/TrailingWhitespace: Trailing whitespace detected.
def initialize
# TODO create a new token for use in the session
@client = Vault::Client.new(
Expand Down

0 comments on commit 6b9c4be

Please sign in to comment.