diff --git a/1.0-Upgrade.md b/1.0-Upgrade.md index 7eb7f56b3..d6a4a874b 100644 --- a/1.0-Upgrade.md +++ b/1.0-Upgrade.md @@ -13,16 +13,6 @@ ## Public API changes -<<<<<<< HEAD -Important changes: -- Removed `KubernetesDeploy#*`: use the appropriate `Krane::*` class instead. -- Removed `template_dir` from `DeployTask#initialize`: use `template_paths` instead. -- Removed `allow_protected_ns` from `DeployTask#run`: use `protected_namespaces` instead. -- Removed `template_dir` from `RenderTask#initialize` and `only_filenames` from `RenderTask#run`: use `template_paths` instead. -- Removed `allow_globals` from `DeployTask`: use `GlobalDeployTask` instead. - -If you want to see the current state of this API, check the comment-based docs on these classes or the [rendered documentation at RubyGems.org](https://www.rubydoc.info/gems/kubernetes-deploy/1.0.0/KubernetesDeploy/DeployTask). -======= Besides the renaming of the `KubernetesDeploy` namespace to `Krane`, we made the public interfaces of the major public classes (`DeployTask`, `RenderTask`, `RunnerTask`, and `RestartTask`) match the CLI flag names more closely. If you're curious about this API, check the comment-based docs on these classes or the [rendered documentation at RubyGems.org](https://www.rubydoc.info/gems/kubernetes-deploy/1.0.0/KubernetesDeploy/DeployTask). @@ -74,7 +64,6 @@ Old name | New name | Comments --- | --- | --- template_paths | filenames | max_watch_seconds | global_timeout | This is now a duration that can be expressed in a more user-friendly language (e.g. `30s` or `1h`) ->>>>>>> 86f0aa9... Add information about public API changes ## Command-line interface changes @@ -163,4 +152,4 @@ $ cat my-template.yml app: krane provisioner: kubernetes.io/no-provisioner $ krane global-deploy my-k8s-context -f my-template.yml --selector app=krane -``` \ No newline at end of file +``` diff --git a/lib/krane/cli/deploy_command.rb b/lib/krane/cli/deploy_command.rb index beb9b10dc..1eb915265 100644 --- a/lib/krane/cli/deploy_command.rb +++ b/lib/krane/cli/deploy_command.rb @@ -68,7 +68,7 @@ def self.from_options(namespace, context, options) namespace: namespace, context: context, current_sha: options['current-sha'], - filenames: filenames, + filenames: paths, bindings: bindings_parser.parse, logger: logger, global_timeout: ::Krane::DurationParser.new(options["global-timeout"]).parse!.to_i, diff --git a/lib/krane/deploy_task.rb b/lib/krane/deploy_task.rb index e42c1ea85..148c7c099 100644 --- a/lib/krane/deploy_task.rb +++ b/lib/krane/deploy_task.rb @@ -84,25 +84,23 @@ def server_version # Initializes the deploy task # - # @param namespace [String] Kubernetes namespace - # @param context [String] Kubernetes context + # @param namespace [String] Kubernetes namespace (*required*) + # @param context [String] Kubernetes context (*required*) # @param current_sha [String] The SHA of the commit # @param logger [Object] Logger object (defaults to an instance of Krane::FormattedLogger) # @param kubectl_instance [Kubectl] Kubectl instance # @param bindings [Hash] Bindings parsed by Krane::BindingsParser - # @param max_watch_seconds [Integer] Timeout in seconds + # @param global_timeout [Integer] Timeout in seconds # @param selector [Hash] Selector(s) parsed by Krane::LabelSelector - # @param template_paths [Array] An array of template paths + # @param filenames [Array] An array of filenames and/or directories containing templates (*required*) # @param protected_namespaces [Array] Array of protected Kubernetes namespaces (defaults # to Krane::DeployTask::PROTECTED_NAMESPACES) # @param render_erb [Boolean] Enable ERB rendering def initialize(namespace:, context:, current_sha:, logger: nil, kubectl_instance: nil, bindings: {}, - max_watch_seconds: nil, selector: nil, template_paths: [], protected_namespaces: nil, + global_timeout: nil, selector: nil, filenames: [], protected_namespaces: nil, render_erb: true) - template_paths = (template_paths.map { |path| File.expand_path(path) }).compact - @logger = logger || Krane::FormattedLogger.build(namespace, context) - @template_sets = TemplateSets.from_dirs_and_files(paths: template_paths, logger: @logger) + @template_sets = TemplateSets.from_dirs_and_files(paths: filenames, logger: @logger) @task_config = Krane::TaskConfig.new(context, namespace, @logger) @bindings = bindings @namespace = namespace @@ -110,7 +108,7 @@ def initialize(namespace:, context:, current_sha:, logger: nil, kubectl_instance @context = context @current_sha = current_sha @kubectl = kubectl_instance - @max_watch_seconds = max_watch_seconds + @global_timeout = global_timeout @selector = selector @protected_namespaces = protected_namespaces || PROTECTED_NAMESPACES @render_erb = render_erb @@ -185,7 +183,7 @@ def run!(verify_result: true, prune: true) def resource_deployer @resource_deployer ||= Krane::ResourceDeployer.new(task_config: @task_config, - prune_whitelist: prune_whitelist, max_watch_seconds: @max_watch_seconds, + prune_whitelist: prune_whitelist, global_timeout: @global_timeout, selector: @selector, statsd_tags: statsd_tags, current_sha: @current_sha) end diff --git a/test/exe/deploy_test.rb b/test/exe/deploy_test.rb index 8a244d3a0..4f2db213d 100644 --- a/test/exe/deploy_test.rb +++ b/test/exe/deploy_test.rb @@ -63,7 +63,7 @@ def test_deploy_parses_std_in_without_filenames Dir.mktmpdir do |tmp_path| $stdin.expects("read").returns("") Dir.expects(:mktmpdir).with("krane").yields(tmp_path) - set_krane_deploy_expectations(new_args: { template_paths: [tmp_path] }) + set_krane_deploy_expectations(new_args: { filenames: [tmp_path] }) krane_deploy!(flags: '--stdin') end end @@ -79,7 +79,7 @@ def test_deploy_parses_std_in Dir.mktmpdir do |tmp_path| $stdin.expects("read").returns("") Dir.expects(:mktmpdir).with("krane").yields(tmp_path) - set_krane_deploy_expectations(new_args: { template_paths: ['/my/file/path', tmp_path] }) + set_krane_deploy_expectations(new_args: { filenames: ['/my/file/path', tmp_path] }) krane_deploy!(flags: '-f /my/file/path --stdin') end end diff --git a/test/exe/render_test.rb b/test/exe/render_test.rb index 21f43c06e..981ca328b 100644 --- a/test/exe/render_test.rb +++ b/test/exe/render_test.rb @@ -22,7 +22,7 @@ def test_render_parses_std_in file_path = "/dev/null" $stdin.expects("read").returns("") Dir.expects(:mktmpdir).with("krane").yields(tmp_path) - install_krane_render_expectations(template_paths: [file_path, tmp_path]) + install_krane_render_expectations(filenames: [file_path, tmp_path]) krane_render!("--filenames #{file_path} --stdin") end end @@ -31,7 +31,7 @@ def test_render_parses_std_in_without_filenames Dir.mktmpdir do |tmp_path| $stdin.expects("read").returns("") Dir.expects(:mktmpdir).with("krane").yields(tmp_path).once - install_krane_render_expectations(template_paths: [tmp_path]) + install_krane_render_expectations(filenames: [tmp_path]) krane_render!("--stdin") end end