Skip to content

Commit

Permalink
Rebase fix ups
Browse files Browse the repository at this point in the history
  • Loading branch information
dturn committed Nov 16, 2019
1 parent b6277a4 commit 149aaca
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 27 deletions.
13 changes: 1 addition & 12 deletions 1.0-Upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
```
```
2 changes: 1 addition & 1 deletion lib/krane/cli/deploy_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 8 additions & 10 deletions lib/krane/deploy_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,33 +84,31 @@ 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<String>] An array of template paths
# @param filenames [Array<String>] An array of filenames and/or directories containing templates (*required*)
# @param protected_namespaces [Array<String>] 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
@namespace_tags = []
@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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions test/exe/deploy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/exe/render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 149aaca

Please sign in to comment.