From bacfe10a7bf89b20c99ea708284c110cbcedfc75 Mon Sep 17 00:00:00 2001 From: ayush-lr Date: Fri, 16 Sep 2022 11:29:45 -0700 Subject: [PATCH 1/9] changes for env and app --- README.md | 4 +- bin/publish | 21 ++++++-- .../artifact_registry/driver_artifactory.rb | 45 ++++++++++++++++ .../artifact_registry/driver_base.rb | 5 ++ .../artifact_registry/driver_gcs.rb | 39 ++++++++++++++ lib/kube_deploy_tools/publish.rb | 54 +++++++++++++++++++ lib/kube_deploy_tools/publish/options.rb | 18 ++++++- spec/unit/publish_spec.rb | 23 ++++++++ 8 files changed, 201 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2d59ee8..4325c9b 100644 --- a/README.md +++ b/README.md @@ -128,10 +128,10 @@ bundle exec kdt generate bundle exec kdt generate -m -i -o # Can be tested only via running Unit tests -bundle exec kdt publish +bundle exec kdt publish -m spec/resources/deploy.yaml # Publish with extra argument capable of parallel runs in Jenkins - bundle exec kdt publish -o + bundle exec kdt publish -m spec/resources/deploy.yaml -o -e -a ``` ## Parallel Generate/Publish in Jenkins Pipeline diff --git a/bin/publish b/bin/publish index e0fa946..036c394 100755 --- a/bin/publish +++ b/bin/publish @@ -21,8 +21,19 @@ KubeDeployTools::Shellrunner.shellrunner = KubeDeployTools::Shellrunner.new config = KubeDeployTools::DeployConfigFile.new(options.manifest_file) artifact_registry = config.artifact_registries[config.artifact_registry] -KubeDeployTools::Publish.new( - manifest: options.manifest_file, - artifact_registry: artifact_registry, - output_dir: options.output_path, -).publish + +if options.env && options.app + KubeDeployTools::Publish.new( + manifest: options.manifest_file, + artifact_registry: artifact_registry, + output_dir: options.output_path, + ).publish_with_env_app(options.env, options.app) + +else + KubeDeployTools::Publish.new( + manifest: options.manifest_file, + artifact_registry: artifact_registry, + output_dir: options.output_path, + ).publish + +end \ No newline at end of file diff --git a/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb b/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb index 7ba2b00..b2c15fd 100644 --- a/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb +++ b/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb @@ -67,6 +67,51 @@ def upload(local_dir:, name:, flavor:, project:, build_number:) build_number: build_number, ) artifactory_url = "#{Artifactory.endpoint}/#{@repo}/#{registry_artifact_path}" + + + puts "artifactory_url == " + puts artifactory_url.inspect + + Logger.info("Uploading #{local_artifact_path} to #{artifactory_url}") + artifact = Artifactory::Resource::Artifact.new(local_path: local_artifact_path) + artifact.upload(@repo, registry_artifact_path) + end + + def upload_with_env_app(local_dir:, name:, flavor:, project:, build_number:, env:, app:) + # Pack up contents of each flavor_dir to a correctly named artifact. + flavor_dir = File.join(local_dir, "#{name}_#{flavor}") + + puts "flavor_dir == " + puts flavor_dir.inspect + + + package( + name: name, + flavor: flavor, + input_dir: flavor_dir, + output_dir: local_dir, + ) + + local_artifact_path = get_local_artifact_path( + local_dir: local_dir, + name: name, + flavor: flavor, + ) + + registry_artifact_path = get_registry_artifact_path_env_app( + project: project, + name: name, + flavor: flavor, + build_number: build_number, + env: env, + app: app, + ) + artifactory_url = "#{Artifactory.endpoint}/#{@repo}/#{registry_artifact_path}" + + + puts "artifactory_url == " + puts artifactory_url.inspect + Logger.info("Uploading #{local_artifact_path} to #{artifactory_url}") artifact = Artifactory::Resource::Artifact.new(local_path: local_artifact_path) artifact.upload(@repo, registry_artifact_path) diff --git a/lib/kube_deploy_tools/artifact_registry/driver_base.rb b/lib/kube_deploy_tools/artifact_registry/driver_base.rb index 362cf56..1ee185b 100644 --- a/lib/kube_deploy_tools/artifact_registry/driver_base.rb +++ b/lib/kube_deploy_tools/artifact_registry/driver_base.rb @@ -18,6 +18,11 @@ def upload(local_dir:, name:, flavor:, project:, build_number:) raise "#{self.class}#publish not implemented" end + # Same as above but with 2 more parameters: env, app + def upload_with_env_app(local_dir:, name:, flavor:, project:, build_number:, env:, app:) + raise "#{self.class}#publish not implemented" + end + # download should retrieve the artifact namespaced with the given # project and build number and identified by the name and flavor. # The artifact should be put into the output directory. diff --git a/lib/kube_deploy_tools/artifact_registry/driver_gcs.rb b/lib/kube_deploy_tools/artifact_registry/driver_gcs.rb index 38659fc..27d835f 100644 --- a/lib/kube_deploy_tools/artifact_registry/driver_gcs.rb +++ b/lib/kube_deploy_tools/artifact_registry/driver_gcs.rb @@ -46,6 +46,10 @@ def get_registry_artifact_path(name:, flavor:, project:, build_number:) "#{get_registry_build_path(project: project)}/#{build_number}/artifact/#{get_artifact_name(name: name, flavor: flavor)}" end + def get_registry_artifact_path_env_app(name:, flavor:, project:, build_number:, env:, app:) + "#{get_registry_build_path(project: project)}/#{build_number}/artifact/#{env}/#{app}/#{get_artifact_name(name: name, flavor: flavor)}" + end + def get_artifact_name(name:, flavor:) "manifests_#{name}_#{flavor}.yaml" end @@ -137,5 +141,40 @@ def upload(local_dir:, name:, flavor:, project:, build_number:) registry_artifact_path end + + def upload_with_env_app(local_dir:, name:, flavor:, project:, build_number:, env:, app:) + # Pack up contents of each flavor_dir to a correctly named artifact. + flavor_dir = File.join(local_dir, "#{name}_#{flavor}") + + package( + name: name, + flavor: flavor, + input_dir: flavor_dir, + output_dir: local_dir, + ) + + local_artifact_path = get_local_artifact_path( + local_dir: local_dir, + name: name, + flavor: flavor, + ) + + registry_artifact_path = get_registry_artifact_path_env_app( + project: project, + name: name, + flavor: flavor, + build_number: build_number, + env: env, + app: app, + ) + + Logger.info("Uploading #{local_artifact_path} to #{registry_artifact_path}") + out, err, status = Shellrunner.run_call('gsutil', '-m', 'cp', local_artifact_path, registry_artifact_path) + if !status.success? + raise "Failed to upload remote deploy artifact from #{local_artifact_path} to #{registry_artifact_path}" + end + + registry_artifact_path + end end end diff --git a/lib/kube_deploy_tools/publish.rb b/lib/kube_deploy_tools/publish.rb index d8cf6b8..7716851 100644 --- a/lib/kube_deploy_tools/publish.rb +++ b/lib/kube_deploy_tools/publish.rb @@ -19,13 +19,37 @@ def initialize(manifest:, artifact_registry:, output_dir:) end def publish() + + puts "@artifact_registry == " + puts @artifact_registry.inspect + @config.artifacts.each do |c| name = c.fetch('name') + puts "@manifest config name== " + puts name.inspect # Allow deploy.yaml to gate certain flavors to certain targets. cluster_flavors = @config.flavors.select { |key, value| c['flavors'].nil? || c['flavors'].include?(key) } + puts "@cluster_flavors== " + puts cluster_flavors.inspect cluster_flavors.each do |flavor, _| + puts "@output_dir == " + puts @output_dir.inspect + + puts "@name == " + puts name.inspect + + puts "flavor== " + puts flavor.inspect + + puts "@project== " + puts @project.inspect + + puts "@build_number== " + puts @build_number.inspect + + @artifact_registry.upload( local_dir: @output_dir, name: name, @@ -36,5 +60,35 @@ def publish() end end end + + + def publish_with_env_app(env, app) + + puts "artifact_registry == " + puts @artifact_registry.inspect + puts "output_dir == " + puts @output_dir.inspect + + @config.artifacts.each do |c| + name = c.fetch('name') + puts "manifest config name== " + puts name.inspect + + # Allow deploy.yaml to gate certain flavors to certain targets. + cluster_flavors = @config.flavors.select { |key, value| c['flavors'].nil? || c['flavors'].include?(key) } + + cluster_flavors.each do |flavor, _| + @artifact_registry.upload_with_env_app( + local_dir: @output_dir, + name: name, + flavor: flavor, + project: @project, + build_number: @build_number, + env: env, + app: app, + ) + end + end + end end end diff --git a/lib/kube_deploy_tools/publish/options.rb b/lib/kube_deploy_tools/publish/options.rb index df9caf3..e5e332b 100644 --- a/lib/kube_deploy_tools/publish/options.rb +++ b/lib/kube_deploy_tools/publish/options.rb @@ -3,7 +3,15 @@ module KubeDeployTools class Publish::Optparser class Options - attr_accessor :manifest_file, :output_path + attr_accessor :manifest_file, :output_path, :env, :app + + def env + @env || nil + end + + def app + @app || nil + end def initialize self.output_path = File.join('build', 'kubernetes') @@ -18,6 +26,14 @@ def define_options(parser) self.output_path = p end + parser.on('-e', '--env-name NAME', 'Env name') do |p| + self.env = p + end + + parser.on('-a', '--app-name NAME', 'App name') do |p| + self.app = p + end + parser.on('-') end end diff --git a/spec/unit/publish_spec.rb b/spec/unit/publish_spec.rb index 7b947df..c4a06f9 100644 --- a/spec/unit/publish_spec.rb +++ b/spec/unit/publish_spec.rb @@ -36,6 +36,7 @@ let(:artifact_registry) { config.artifact_registries[config.artifact_registry] } it 'publishes artifacts according to deploy.yaml' do + KubeDeployTools::Logger.logger = logger # Mock artifact upload @@ -44,6 +45,12 @@ # Expect to upload to kubernetes-snapshots-local/ expect(path).to start_with(PROJECT) + + puts "path == " + puts path.inspect + puts "File.basename(path)" + puts File.basename(path).inspect + # add only the basenames of the files to the set as the BUILD_ID # will vary on each build uploads.add(File.basename(path)) @@ -61,11 +68,27 @@ 'manifests_filtered-artifact_default.tar.gz', ] + Dir.mktmpdir do |dir| + puts "dir == " + puts dir.inspect + expected_uploads.each do |f| + + puts "File.join(dir, f) == " FileUtils.touch File.join(dir, f) + puts File.join(dir, f).inspect end + puts "MANIFEST_FILE == " + puts MANIFEST_FILE.inspect + + puts "artifact_registry == " + puts artifact_registry.inspect + + puts "output dir == " + puts dir.inspect + KubeDeployTools::Publish.new( manifest: MANIFEST_FILE, artifact_registry: artifact_registry, From 337c317741e667f81b73d6ef23355ecba5d2e8e4 Mon Sep 17 00:00:00 2001 From: ayush-lr Date: Fri, 16 Sep 2022 11:33:09 -0700 Subject: [PATCH 2/9] minor --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4325c9b..c923f00 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ bundle exec kdt generate # Additional options bundle exec kdt generate -m -i -o -# Can be tested only via running Unit tests +# Can be tested only via bundle exec kdt publish -m spec/resources/deploy.yaml # Publish with extra argument capable of parallel runs in Jenkins From 4be7a6533bdfde11a3aa2174d2590f6757cb9c45 Mon Sep 17 00:00:00 2001 From: ayush-lr Date: Fri, 16 Sep 2022 11:49:48 -0700 Subject: [PATCH 3/9] added a test case --- spec/unit/publish_spec.rb | 69 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/spec/unit/publish_spec.rb b/spec/unit/publish_spec.rb index c4a06f9..8523858 100644 --- a/spec/unit/publish_spec.rb +++ b/spec/unit/publish_spec.rb @@ -96,6 +96,75 @@ ).publish end + all_uploads = expected_uploads + expect(uploads).to contain_exactly(*all_uploads) + end +# end +# +# context 'Artifactory driver' do +# let(:artifact_registry) { config.artifact_registries[config.artifact_registry] } + + it 'publishes artifacts according to deploy.yaml & given env & app name' do + + KubeDeployTools::Logger.logger = logger + + # Mock artifact upload + uploads = Set.new + allow_any_instance_of(Artifactory::Resource::Artifact).to receive(:upload) do |artifact, repo, path| + # Expect to upload to kubernetes-snapshots-local/ + expect(path).to start_with(PROJECT) + + + puts "path == " + puts path.inspect + puts "File.basename(path)" + puts File.basename(path).inspect + + # add only the basenames of the files to the set as the BUILD_ID + # will vary on each build + uploads.add(File.basename(path)) + end + + expected_uploads = [ + 'manifests_colo-service-prod_default.tar.gz', + 'manifests_colo-service-staging_default.tar.gz', + 'manifests_local_default.tar.gz', + 'manifests_us-east-1-prod_default.tar.gz', + 'manifests_us-east-1-staging_default.tar.gz', + 'manifests_ingestion-prod_default.tar.gz', + 'manifests_pippio-production_default.tar.gz', + 'manifests_platforms-prod_default.tar.gz', + 'manifests_filtered-artifact_default.tar.gz', + ] + + + Dir.mktmpdir do |dir| + puts "dir == " + puts dir.inspect + + expected_uploads.each do |f| + + puts "File.join(dir, f) == " + FileUtils.touch File.join(dir, f) + puts File.join(dir, f).inspect + end + + puts "MANIFEST_FILE == " + puts MANIFEST_FILE.inspect + + puts "artifact_registry == " + puts artifact_registry.inspect + + puts "output dir == " + puts dir.inspect + + KubeDeployTools::Publish.new( + manifest: MANIFEST_FILE, + artifact_registry: artifact_registry, + output_dir: dir, + ).publish_with_env_app("env", "app") + end + all_uploads = expected_uploads expect(uploads).to contain_exactly(*all_uploads) end From 513472c3137ae15e72942cd8c818fe555ed4f455 Mon Sep 17 00:00:00 2001 From: ayush-lr Date: Fri, 16 Sep 2022 22:51:09 -0700 Subject: [PATCH 4/9] pending function added --- .../artifact_registry/driver_artifactory.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb b/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb index b2c15fd..0bfd313 100644 --- a/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb +++ b/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb @@ -43,6 +43,11 @@ def get_registry_artifact_path(name:, flavor:, project:, build_number:) "#{project}/#{build_number}/#{get_artifact_name(name: name, flavor: flavor)}" end + def get_registry_artifact_path_env_app(name:, flavor:, project:, build_number:, env:, app:) + "#{project}/#{build_number}/#{env}/#{app}/#{get_artifact_name(name: name, flavor: flavor)}" + end + + def upload(local_dir:, name:, flavor:, project:, build_number:) # Pack up contents of each flavor_dir to a correctly named artifact. flavor_dir = File.join(local_dir, "#{name}_#{flavor}") From fad7af28f263c63aebaea57711a7dbff2105260e Mon Sep 17 00:00:00 2001 From: ayush-lr Date: Fri, 16 Sep 2022 23:13:36 -0700 Subject: [PATCH 5/9] removed print statements --- .../artifact_registry/driver_artifactory.rb | 12 ---- lib/kube_deploy_tools/publish.rb | 29 -------- spec/unit/publish_spec.rb | 69 +++++++------------ 3 files changed, 26 insertions(+), 84 deletions(-) diff --git a/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb b/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb index 0bfd313..bfb1458 100644 --- a/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb +++ b/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb @@ -73,10 +73,6 @@ def upload(local_dir:, name:, flavor:, project:, build_number:) ) artifactory_url = "#{Artifactory.endpoint}/#{@repo}/#{registry_artifact_path}" - - puts "artifactory_url == " - puts artifactory_url.inspect - Logger.info("Uploading #{local_artifact_path} to #{artifactory_url}") artifact = Artifactory::Resource::Artifact.new(local_path: local_artifact_path) artifact.upload(@repo, registry_artifact_path) @@ -86,10 +82,6 @@ def upload_with_env_app(local_dir:, name:, flavor:, project:, build_number:, env # Pack up contents of each flavor_dir to a correctly named artifact. flavor_dir = File.join(local_dir, "#{name}_#{flavor}") - puts "flavor_dir == " - puts flavor_dir.inspect - - package( name: name, flavor: flavor, @@ -113,10 +105,6 @@ def upload_with_env_app(local_dir:, name:, flavor:, project:, build_number:, env ) artifactory_url = "#{Artifactory.endpoint}/#{@repo}/#{registry_artifact_path}" - - puts "artifactory_url == " - puts artifactory_url.inspect - Logger.info("Uploading #{local_artifact_path} to #{artifactory_url}") artifact = Artifactory::Resource::Artifact.new(local_path: local_artifact_path) artifact.upload(@repo, registry_artifact_path) diff --git a/lib/kube_deploy_tools/publish.rb b/lib/kube_deploy_tools/publish.rb index 7716851..076695d 100644 --- a/lib/kube_deploy_tools/publish.rb +++ b/lib/kube_deploy_tools/publish.rb @@ -20,35 +20,13 @@ def initialize(manifest:, artifact_registry:, output_dir:) def publish() - puts "@artifact_registry == " - puts @artifact_registry.inspect - @config.artifacts.each do |c| name = c.fetch('name') - puts "@manifest config name== " - puts name.inspect # Allow deploy.yaml to gate certain flavors to certain targets. cluster_flavors = @config.flavors.select { |key, value| c['flavors'].nil? || c['flavors'].include?(key) } - puts "@cluster_flavors== " - puts cluster_flavors.inspect cluster_flavors.each do |flavor, _| - puts "@output_dir == " - puts @output_dir.inspect - - puts "@name == " - puts name.inspect - - puts "flavor== " - puts flavor.inspect - - puts "@project== " - puts @project.inspect - - puts "@build_number== " - puts @build_number.inspect - @artifact_registry.upload( local_dir: @output_dir, @@ -64,15 +42,8 @@ def publish() def publish_with_env_app(env, app) - puts "artifact_registry == " - puts @artifact_registry.inspect - puts "output_dir == " - puts @output_dir.inspect - @config.artifacts.each do |c| name = c.fetch('name') - puts "manifest config name== " - puts name.inspect # Allow deploy.yaml to gate certain flavors to certain targets. cluster_flavors = @config.flavors.select { |key, value| c['flavors'].nil? || c['flavors'].include?(key) } diff --git a/spec/unit/publish_spec.rb b/spec/unit/publish_spec.rb index 8523858..44fd48b 100644 --- a/spec/unit/publish_spec.rb +++ b/spec/unit/publish_spec.rb @@ -45,12 +45,6 @@ # Expect to upload to kubernetes-snapshots-local/ expect(path).to start_with(PROJECT) - - puts "path == " - puts path.inspect - puts "File.basename(path)" - puts File.basename(path).inspect - # add only the basenames of the files to the set as the BUILD_ID # will vary on each build uploads.add(File.basename(path)) @@ -70,25 +64,12 @@ Dir.mktmpdir do |dir| - puts "dir == " - puts dir.inspect expected_uploads.each do |f| - puts "File.join(dir, f) == " FileUtils.touch File.join(dir, f) - puts File.join(dir, f).inspect end - puts "MANIFEST_FILE == " - puts MANIFEST_FILE.inspect - - puts "artifact_registry == " - puts artifact_registry.inspect - - puts "output dir == " - puts dir.inspect - KubeDeployTools::Publish.new( manifest: MANIFEST_FILE, artifact_registry: artifact_registry, @@ -99,12 +80,8 @@ all_uploads = expected_uploads expect(uploads).to contain_exactly(*all_uploads) end -# end -# -# context 'Artifactory driver' do -# let(:artifact_registry) { config.artifact_registries[config.artifact_registry] } - it 'publishes artifacts according to deploy.yaml & given env & app name' do + it 'publishes artifacts according to deploy.yaml and given env & app name' do KubeDeployTools::Logger.logger = logger @@ -114,12 +91,6 @@ # Expect to upload to kubernetes-snapshots-local/ expect(path).to start_with(PROJECT) - - puts "path == " - puts path.inspect - puts "File.basename(path)" - puts File.basename(path).inspect - # add only the basenames of the files to the set as the BUILD_ID # will vary on each build uploads.add(File.basename(path)) @@ -139,25 +110,12 @@ Dir.mktmpdir do |dir| - puts "dir == " - puts dir.inspect expected_uploads.each do |f| - puts "File.join(dir, f) == " FileUtils.touch File.join(dir, f) - puts File.join(dir, f).inspect end - puts "MANIFEST_FILE == " - puts MANIFEST_FILE.inspect - - puts "artifact_registry == " - puts artifact_registry.inspect - - puts "output dir == " - puts dir.inspect - KubeDeployTools::Publish.new( manifest: MANIFEST_FILE, artifact_registry: artifact_registry, @@ -197,6 +155,31 @@ expect(local_artifact_resources.length).to eq(2) end end + + it 'publishes artifacts according to deploy.yaml and given env & app name' do + KubeDeployTools::Logger.logger = logger + + Dir.tmpdir do |dir| + FileUtils.cp_r INPUT_DIR, dir, :verbose => true + KubeDeployTools::Publish.new( + manifest: MANIFEST_GCS_FILE, + artifact_registry: artifact_registry, + output_dir: dir, + ).publish_with_env_app("env", "app") + + artifacts = Find.find(dir). + select { |path| path =~ /.*manifests_.*\.yaml$/ } + + expect(artifacts.length).to eq(1) + + # Check that the local artifact contains 2 concatenated resources + local_artifact = artifacts.select { |path| path =~ /local/ }.first + local_artifact_contents = YAML.load_file(local_artifact) + local_artifact_resources = [] + YAML.load_stream(File.read local_artifact) { |doc| local_artifact_resources << doc } + expect(local_artifact_resources.length).to eq(2) + end + end end end From 03f2738c37c09bb925d4b2bdfec19128aa2c3e8e Mon Sep 17 00:00:00 2001 From: ayush-lr Date: Fri, 16 Sep 2022 23:18:05 -0700 Subject: [PATCH 6/9] readme updated --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c923f00..abbadb0 100644 --- a/README.md +++ b/README.md @@ -126,8 +126,10 @@ bundle exec kdt generate # Additional options bundle exec kdt generate -m -i -o + e.g: + bundle exec kdt generate -m spec/resources/deploy.yaml -# Can be tested only via +# Requires mock aritifactory to run. Test changes using `rake test` cmd instead bundle exec kdt publish -m spec/resources/deploy.yaml # Publish with extra argument capable of parallel runs in Jenkins From ca31ef2695385518d353409246ac43dca792b0fb Mon Sep 17 00:00:00 2001 From: ayush-lr Date: Fri, 16 Sep 2022 23:21:45 -0700 Subject: [PATCH 7/9] spacing remove --- lib/kube_deploy_tools/publish.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/kube_deploy_tools/publish.rb b/lib/kube_deploy_tools/publish.rb index 076695d..3310446 100644 --- a/lib/kube_deploy_tools/publish.rb +++ b/lib/kube_deploy_tools/publish.rb @@ -19,7 +19,6 @@ def initialize(manifest:, artifact_registry:, output_dir:) end def publish() - @config.artifacts.each do |c| name = c.fetch('name') @@ -27,7 +26,6 @@ def publish() cluster_flavors = @config.flavors.select { |key, value| c['flavors'].nil? || c['flavors'].include?(key) } cluster_flavors.each do |flavor, _| - @artifact_registry.upload( local_dir: @output_dir, name: name, From cad8083f1fe272231d893d381738df576c786e0f Mon Sep 17 00:00:00 2001 From: ayush-lr Date: Fri, 16 Sep 2022 23:24:02 -0700 Subject: [PATCH 8/9] spacing removed --- spec/unit/publish_spec.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/spec/unit/publish_spec.rb b/spec/unit/publish_spec.rb index 44fd48b..f42cb58 100644 --- a/spec/unit/publish_spec.rb +++ b/spec/unit/publish_spec.rb @@ -36,7 +36,6 @@ let(:artifact_registry) { config.artifact_registries[config.artifact_registry] } it 'publishes artifacts according to deploy.yaml' do - KubeDeployTools::Logger.logger = logger # Mock artifact upload @@ -62,11 +61,8 @@ 'manifests_filtered-artifact_default.tar.gz', ] - Dir.mktmpdir do |dir| - expected_uploads.each do |f| - FileUtils.touch File.join(dir, f) end @@ -82,7 +78,6 @@ end it 'publishes artifacts according to deploy.yaml and given env & app name' do - KubeDeployTools::Logger.logger = logger # Mock artifact upload @@ -108,11 +103,8 @@ 'manifests_filtered-artifact_default.tar.gz', ] - Dir.mktmpdir do |dir| - expected_uploads.each do |f| - FileUtils.touch File.join(dir, f) end From c430770cd539f0df09417a53cc3657c845102807 Mon Sep 17 00:00:00 2001 From: ayush-lr Date: Fri, 16 Sep 2022 23:50:31 -0700 Subject: [PATCH 9/9] minor --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index abbadb0..8887165 100644 --- a/README.md +++ b/README.md @@ -146,8 +146,8 @@ could be overwritten by another parallel step. Following steps can be added in the jenkins pipeline for parallel generation/ publishing the manifest files. ```bash String uniqOutputPath = "build/kubernetes/${BRANCH_NAME}/build/${BUILD_ID}/${env}/${app}/" -bundle exec kdt generate -i kubernetes/${env}/${app} -o ${uniqOutputPath} -bundle exec kdt publish -o ${uniqOutputPath} +bundle exec kdt generate -i kubernetes/${env}/${app} -o ${uniqOutputPath} +bundle exec kdt publish -o ${uniqOutputPath} -e ${env} -a ${app} ``` ## FAQ