45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/chef/knife/scrub_attributes.rb', line 45
def run
unless prefix = name_args.first
show_usage
ui.fatal 'You must specify a prefix of attributes to scrub'
exit 1
end
search = Chef::Search::Query.new
search.search('node', config[:query]) do |node|
= Scrub::AttributeExtractor.create(node)
unless .has_key?(prefix)
ui.msg format(node, "normal attribute #{prefix} not present")
next
end
value = .fetch(prefix)
if config[:dry_run]
ui.msg format(node, "normal attribute #{prefix}: #{value.inspect}")
next
end
unless ui.confirm format(node, "Do you want to delete #{value.inspect}")
next
end
if deleted = .delete(prefix)
node.save
ui.msg format(node, "deleted normal attribute #{deleted.inspect}")
else
ui.msg format(node, "could not delete normal attribute #{prefix}")
end
end
end
|