class Puppetfactory::Plugins::Gitlab
Public Class Methods
new(options)
click to toggle source
Calls superclass method
Puppetfactory::Plugins::new
# File lib/puppetfactory/plugins/gitlab.rb, line 6 def initialize(options) super(options) @suffix = options[:usersuffix] begin # Use default gitlab root password to get session token login = {:login => 'root', :password => '5iveL!fe'} resp = JSON.parse(RestClient.post('http://localhost:8888/api/v3/session', login)) @token = resp['private_token'] rescue => e raise "GitLab authentication error! (#{e.message})" end end
Public Instance Methods
create(username, password)
click to toggle source
# File lib/puppetfactory/plugins/gitlab.rb, line 21 def create(username, password) begin if password.length < 8 raise "Password must be at least 8 characters" end RestClient.post('http://localhost:8888/api/v3/users', { :email => "#{username}.#{@suffix}", :password => password, :username => username, :name => username, :confirm => false, :private_token => @token # TODO: this invocation does not look like the invocation below? }) end $logger.info "Created GitLab user #{username}." rescue => e $logger.error "Error creating GitLab user #{username}: #{e.message}" return false end