Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance store, fetch, and exec hook Functions to Include All Node Object Variables #3321

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/oxidized/hook/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def make_env(ctx)
"OX_REPO_NAME" => ctx.node.repo.to_s,
"OX_ERR_TYPE" => ctx.node.err_type.to_s,
"OX_ERR_REASON" => ctx.node.err_reason.to_s
"OX_NODE_VARS" => JSON.dump(ctx.node.vars)
)
end
if ctx.job
Expand Down
4 changes: 2 additions & 2 deletions lib/oxidized/output/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def setup

def store(node, outputs, opt = {})
file = ::File.expand_path @cfg.directory
file = ::File.join ::File.dirname(file), opt[:group] if opt[:group]
file = ::File.join ::File.dirname(file), node.group if node.group
FileUtils.mkdir_p file
file = ::File.join file, node
file = ::File.join file, node.name
::File.write(file, outputs.to_cfg)
@commitref = file
end
Expand Down
12 changes: 6 additions & 6 deletions lib/oxidized/output/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def setup
end
end

def store(file, outputs, opt = {})
def store(node.name, outputs, opt = {})
@msg = opt[:msg]
@user = opt[:user] || @cfg.user
@email = opt[:email] || @cfg.email
@user = node.user || @cfg.user
@email = node.email || @cfg.email
@opt = opt
@commitref = nil
repo = @cfg.repo
Expand All @@ -48,17 +48,17 @@ def store(file, outputs, opt = {})
type_repo = File.join(File.dirname(repo), type + '.git')
outputs.type(type).each do |output|
(type_cfg << output; next) unless output.name # rubocop:disable Style/Semicolon
type_file = file + '--' + output.name
type_file = node.name + '--' + output.name
if @cfg.type_as_directory?
type_file = type + '/' + type_file
type_repo = repo
end
update type_repo, type_file, output
end
update type_repo, file, type_cfg
update type_repo, node.name, type_cfg
end

update repo, file, outputs.to_cfg
update repo, node.name, outputs.to_cfg
end

# Returns the configuration of group/node_name
Expand Down
12 changes: 6 additions & 6 deletions lib/oxidized/output/gitcrypt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def unlock(repo)
end
end

def store(file, outputs, opt = {})
def store(node, outputs, opt = {})
@msg = opt[:msg]
@user = opt[:user] || @cfg.user
@email = opt[:email] || @cfg.email
@user = node.user || @cfg.user
@email = node.email || @cfg.email
@opt = opt
@commitref = nil
repo = @cfg.repo
Expand All @@ -76,17 +76,17 @@ def store(file, outputs, opt = {})
type_repo = File.join(File.dirname(repo), type + '.git')
outputs.type(type).each do |output|
(type_cfg << output; next) unless output.name # rubocop:disable Style/Semicolon
type_file = file + '--' + output.name
type_file = node.name + '--' + output.name
if @cfg.type_as_directory?
type_file = type + '/' + type_file
type_repo = repo
end
update type_repo, type_file, output
end
update type_repo, file, type_cfg
update type_repo, node.name, type_cfg
end

update repo, file, outputs.to_cfg
update repo, node.name, outputs.to_cfg
end

def fetch(node, group)
Expand Down
3 changes: 1 addition & 2 deletions lib/oxidized/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ def process_success(node, job)
msg += " from #{node.from}" if node.from
msg += " with message '#{node.msg}'" if node.msg
output = node.output.new
if output.store node.name, job.config,
msg: msg, email: node.email, user: node.user, group: node.group
if output.store node, job.config, msg: msg
node.modified
Oxidized.logger.info "Configuration updated for #{node.group}/#{node.name}"
Oxidized.hooks.handle :post_store, node: node,
Expand Down