Use helm to index repo
parent
81c0c105ff
commit
a0959ed344
|
@ -12,12 +12,12 @@ steps:
|
|||
- CHECKOUT:
|
||||
template: argo-checkout
|
||||
- PREPARE:
|
||||
image: ruby
|
||||
image: hypnoglow/kubernetes-helm:v2.6.1
|
||||
resources:
|
||||
mem_mib: 500
|
||||
cpu_cores: 0.1
|
||||
command: ["sh", "-c"]
|
||||
args: [ruby /src/scripts/publish.rb]
|
||||
args: [cd /src && helm init --client-only && ./scripts/publish.sh]
|
||||
inputs:
|
||||
artifacts:
|
||||
CODE:
|
||||
|
|
|
@ -2,25 +2,13 @@ require 'yaml'
|
|||
require 'pathname'
|
||||
|
||||
root_dir = Pathname.new("#{File.dirname(__FILE__)}/..").cleanpath
|
||||
output_index_path = "#{root_dir}/output/index.yaml"
|
||||
|
||||
`mkdir -p #{root_dir}/output`
|
||||
|
||||
list = Dir.glob("#{root_dir}/charts/**/*Chart.yaml")
|
||||
|
||||
repo_index = if File.exists?(output_index_path) then YAML.load_file(output_index_path) else { 'apiVersion' => 'v1', 'entries' => {}} end
|
||||
|
||||
list.each do |filename|
|
||||
chart_name = File.basename(File.dirname(filename))
|
||||
chart_versions = repo_index['entries'][chart_name] || []
|
||||
repo_index['entries'][chart_name] = chart_versions
|
||||
version_info = YAML.load_file(filename)
|
||||
existing_info = chart_versions.find{ |item| item['version'] == version_info['version'] }
|
||||
if existing_info then
|
||||
chart_versions[chart_versions.index(existing_info)] = version_info
|
||||
else
|
||||
chart_versions.push version_info
|
||||
end
|
||||
`tar -cvzf #{root_dir}/output/#{chart_name}-#{version_info['version']}.tgz #{File.dirname(filename)} -C #{File.dirname(filename)} .`
|
||||
File.open(output_index_path, 'w') { |file| file.write(repo_index.to_yaml( :Indent => 4, :UseHeader => true, :UseVersion => true )) }
|
||||
`helm repo index #{root_dir}/output`
|
||||
end
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
SRCROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
|
||||
mkdir -p $SRCROOT/output
|
||||
|
||||
for dir in $SRCROOT/charts/*;
|
||||
do
|
||||
echo "Processing $dir"
|
||||
version=$(cat $dir/Chart.yaml | grep version: | awk '{print $2}')
|
||||
tar -cvzf $SRCROOT/output/$(basename $dir)-$version.tgz $dir -C $dir .
|
||||
cd $SRCROOT/output && helm repo index .
|
||||
done
|
Loading…
Reference in New Issue