Class: Entitlements::Backend::GitHubOrg::Provider

Inherits:
BaseProvider
  • Object
show all
Includes:
Contracts::Core
Defined in:
lib/entitlements/backend/github_org/provider.rb

Constant Summary collapse

C =
::Contracts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ Provider

Returns a new instance of Provider.



23
24
25
26
27
28
29
30
31
32
# File 'lib/entitlements/backend/github_org/provider.rb', line 23

def initialize(config:)
  @github = Entitlements::Backend::GitHubOrg::Service.new(
    org: config.fetch("org"),
    addr: config.fetch("addr", nil),
    token: config.fetch("token"),
    ou: config.fetch("base"),
    ignore_not_found: config.fetch("ignore_not_found", false)
  )
  @role_cache = {}
end

Instance Attribute Details

#githubObject (readonly)

Returns the value of attribute github.



15
16
17
# File 'lib/entitlements/backend/github_org/provider.rb', line 15

def github
  @github
end

Instance Method Details

#commit(action) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/entitlements/backend/github_org/provider.rb', line 53

def commit(action)
  # `false` usually means "What's going on, there are changes but nothing to apply!" Here it is
  # more routine that there are removals that are not processed (because adding to one role removes
  # from the other), so `true` is more accurate.
  return true unless action.implementation
  github.sync(action.implementation, role_name(action.updated))
end

#invalidate_predictive_cacheObject



67
68
69
70
71
# File 'lib/entitlements/backend/github_org/provider.rb', line 67

def invalidate_predictive_cache
  @role_cache = {}
  github.invalidate_org_members_predictive_cache
  nil
end

#pending_membersObject



79
80
81
# File 'lib/entitlements/backend/github_org/provider.rb', line 79

def pending_members
  github.pending_members
end

#read(role_identifier) ⇒ Object



42
43
44
45
# File 'lib/entitlements/backend/github_org/provider.rb', line 42

def read(role_identifier)
  role_cn = role_name(role_identifier)
  @role_cache[role_cn] ||= role_to_group(role_cn)
end