Puppet Function: gitlab_get_id
- Defined in:
-
lib/puppet/functions/gitlab_get_id.rb
- Function type:
- Ruby 4.x API
Overview
gitlab_get_id(String $entity, String $varname) ⇒ Any
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/puppet/functions/gitlab_get_id.rb', line 18
Puppet::Functions.create_function(:gitlab_get_id, Puppet::Functions::InternalFunction) do
dispatch :single do
param 'String', :entity
param 'String', :varname
end
def single(entity, varname)
endpoint = config['GITLAB_API_ENDPOINT']
private_token = config['GITLAB_API_PRIVATE_TOKEN']
httparty = config['GITLAB_API_HTTPARTY_OPTIONS'].gsub("'", '')
Gitlab.endpoint = endpoint
Gitlab.private_token = private_token
Gitlab.httparty = eval(httparty)
entitys="#{entity}s"
list = Gitlab.send(entitys)
list.each do |item|
record = item.to_h
record[id] if record[name] == varname
end
end
end
|