From fc9437b2d0621369c3e7d52a6020ceafe22d0a79 Mon Sep 17 00:00:00 2001 From: Guido Westenberg Date: Mon, 25 Sep 2023 16:08:16 -0500 Subject: [PATCH] Rename default branch --- 1.0-Upgrade.md | 2 +- CHANGELOG.md | 2 +- CONTRIBUTING.md | 8 +++--- README.md | 12 ++++----- test/fixtures/slow-cloud/web-deploy-1.yml | 2 +- test/integration/krane_deploy_test.rb | 30 +++++++++++------------ 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/1.0-Upgrade.md b/1.0-Upgrade.md index 80a3a4db5..a6587e40e 100644 --- a/1.0-Upgrade.md +++ b/1.0-Upgrade.md @@ -7,7 +7,7 @@ * There are breaking changes in the public API (such as the renaming of the `KubernetesDeploy` namespace to `Krane`, and the change in default values for different arguments of the public interface). * StatsD metrics will now be generated with the `krane` prefix. * `krane deploy` now considers all namespaced resources eligible for pruning, including -custom resources. See [blacklist](https://github.com/Shopify/krane/blob/master/lib/krane/cluster_resource_discovery.rb#L20) for exceptions. +custom resources. See [blacklist](https://github.com/Shopify/krane/blob/main/lib/krane/cluster_resource_discovery.rb#L20) for exceptions. * `kubernetes-deploy` (now `krane deploy`) / `DeployTask` can no longer deploy global (non-namespaced) resources. A new command called `krane global-deploy` and a related class called `GlobalDeployTask` were added to replace that feature. * `krane deploy` will not render erb templates. Use `krane render | krane deploy --stdin` to reproduce this functionality. * If you attempt to install two gems that have conflicting executables, `gem install` will warn you but the most recently installed one will win. diff --git a/CHANGELOG.md b/CHANGELOG.md index 84fce44ae..aa4bc0b6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -288,7 +288,7 @@ It seems an issue when too many pods are referencing the same secret/configmap h # 1.0.0 We've renamed the gem and cli to Krane. -See our [migration guide](https://github.com/Shopify/krane/blob/master/1.0-Upgrade.md) to help navigate the breaking changes. +See our [migration guide](https://github.com/Shopify/krane/blob/main/1.0-Upgrade.md) to help navigate the breaking changes. ## 1.0.0.pre.2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1400ba077..0aa3574c3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,7 +22,7 @@ The following is a set of guidelines for contributing to krane. Please take a mo * [CI (External contributors)](#ci-external-contributors) ## Code of Conduct -This project and everyone participating in it are governed by the [Code of Conduct](https://github.com/Shopify/krane/blob/master/CODE_OF_CONDUCT.md). +This project and everyone participating in it are governed by the [Code of Conduct](https://github.com/Shopify/krane/blob/main/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [krane@shopify.com](mailto:krane@shopify.com). @@ -95,9 +95,9 @@ This gem uses subclasses of `KubernetesResource` to implement custom success/fai * `deploy_failed?` 3. Adjust the `TIMEOUT` constant to an appropriate value for this type. 4. Add the new class to list of resources in - [`deploy_task.rb`](https://github.com/Shopify/krane/blob/master/lib/krane/deploy_task.rb#L8) -5. Add the new resource to the [prune whitelist](https://github.com/Shopify/krane/blob/master/lib/krane/deploy_task.rb#L81) -6. Add a basic example of the type to the hello-cloud [fixture set](https://github.com/Shopify/krane/tree/master/test/fixtures/hello-cloud) and appropriate assertions to `#assert_all_up` in [`hello_cloud.rb`](https://github.com/Shopify/krane/blob/master/test/helpers/fixture_sets/hello_cloud.rb). This will get you coverage in several existing tests, such as `test_full_hello_cloud_set_deploy_succeeds`. + [`deploy_task.rb`](https://github.com/Shopify/krane/blob/main/lib/krane/deploy_task.rb#L8) +5. Add the new resource to the [prune whitelist](https://github.com/Shopify/krane/blob/main/lib/krane/deploy_task.rb#L81) +6. Add a basic example of the type to the hello-cloud [fixture set](https://github.com/Shopify/krane/tree/main/test/fixtures/hello-cloud) and appropriate assertions to `#assert_all_up` in [`hello_cloud.rb`](https://github.com/Shopify/krane/blob/main/test/helpers/fixture_sets/hello_cloud.rb). This will get you coverage in several existing tests, such as `test_full_hello_cloud_set_deploy_succeeds`. 7. Add tests for any edge cases you foresee. ### Contributor License Agreement diff --git a/README.md b/README.md index d2582c3f5..86016477c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# krane [![Build status](https://badge.buildkite.com/35c56e797c3bbd6ba50053aefdded0715898cd8e8c86f7e462.svg?branch=master)](https://buildkite.com/shopify/krane) +# krane [![Build status](https://badge.buildkite.com/35c56e797c3bbd6ba50053aefdded0715898cd8e8c86f7e462.svg?branch=main)](https://buildkite.com/shopify/krane) -> This project used to be called `kubernetes-deploy`. Check out our [migration guide](https://github.com/Shopify/krane/blob/master/1.0-Upgrade.md) for more information including details about breaking changes. +> This project used to be called `kubernetes-deploy`. Check out our [migration guide](https://github.com/Shopify/krane/blob/main/1.0-Upgrade.md) for more information including details about breaking changes. `krane` is a command line tool that helps you ship changes to a Kubernetes namespace and understand the result. At Shopify, we use it within our much-beloved, open-source [Shipit](https://github.com/Shopify/shipit-engine#kubernetes) deployment app. @@ -337,7 +337,7 @@ status: ### Deploy walkthrough -Let's walk through what happens when you run the `deploy` task with [this directory of templates](https://github.com/Shopify/krane/tree/master/test/fixtures/hello-cloud). This particular example uses ERB templates as well, so we'll use the [krane render](#krane-render) task to achieve that. +Let's walk through what happens when you run the `deploy` task with [this directory of templates](https://github.com/Shopify/krane/tree/main/test/fixtures/hello-cloud). This particular example uses ERB templates as well, so we'll use the [krane render](#krane-render) task to achieve that. You can test this out for yourself by running the following command: @@ -404,7 +404,7 @@ In this phase, we: Just like in the previous phase, we essentially run `kubectl apply` on those templates and periodically check the cluster for the current status of each resource so we can display error or success information. -If pruning is enabled (which, again, is the default), any [kind not listed in the blacklist](https://github.com/Shopify/krane/blob/master/lib/krane/cluster_resource_discovery.rb#L20) that we can find in the namespace but not in the templates will be removed. A particular message about pruning will be printed in the next phase if any resource matches this criteria. +If pruning is enabled (which, again, is the default), any [kind not listed in the blacklist](https://github.com/Shopify/krane/blob/main/lib/krane/cluster_resource_discovery.rb#L20) that we can find in the namespace but not in the templates will be removed. A particular message about pruning will be printed in the next phase if any resource matches this criteria. #### Result @@ -654,13 +654,13 @@ This is a limitation of the current implementation. # Contributing We :heart: contributors! To make it easier for you and us we've written a -[Contributing Guide](https://github.com/Shopify/krane/blob/master/CONTRIBUTING.md) +[Contributing Guide](https://github.com/Shopify/krane/blob/main/CONTRIBUTING.md) You can also reach out to us on our slack channel, #krane, at https://kubernetes.slack.com. All are welcome! ## Code of Conduct -Everyone is expected to follow our [Code of Conduct](https://github.com/Shopify/krane/blob/master/CODE_OF_CONDUCT.md). +Everyone is expected to follow our [Code of Conduct](https://github.com/Shopify/krane/blob/main/CODE_OF_CONDUCT.md). # License diff --git a/test/fixtures/slow-cloud/web-deploy-1.yml b/test/fixtures/slow-cloud/web-deploy-1.yml index 3434d938f..d9fb9105e 100644 --- a/test/fixtures/slow-cloud/web-deploy-1.yml +++ b/test/fixtures/slow-cloud/web-deploy-1.yml @@ -4,7 +4,7 @@ metadata: name: web labels: name: web - branch: master + branch: main app: slow-cloud annotations: shipit.shopify.io/restart: "true" diff --git a/test/integration/krane_deploy_test.rb b/test/integration/krane_deploy_test.rb index e1969db58..2ce4b83a9 100644 --- a/test/integration/krane_deploy_test.rb +++ b/test/integration/krane_deploy_test.rb @@ -157,10 +157,10 @@ def test_pruning_disabled def test_selector # Deploy the same thing twice with a different selector assert_deploy_success(deploy_fixtures("branched", subset: ["web.yml.erb"], - bindings: { "branch" => "master" }, - selector: Krane::LabelSelector.parse("branch=master"), + bindings: { "branch" => "main" }, + selector: Krane::LabelSelector.parse("branch=main"), render_erb: true)) - assert_logs_match("Using resource selector branch=master") + assert_logs_match("Using resource selector branch=main") assert_deploy_success(deploy_fixtures("branched", subset: ["web.yml.erb"], bindings: { "branch" => "staging" }, selector: Krane::LabelSelector.parse("branch=staging"), @@ -169,31 +169,31 @@ def test_selector deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace, label_selector: "app=branched") assert_equal(2, deployments.size) - assert_equal(%w(master staging), deployments.map { |d| d.metadata.labels.branch }.sort) + assert_equal(%w(main staging), deployments.map { |d| d.metadata.labels.branch }.sort) # Run again without selector to verify pruning works - assert_deploy_success(deploy_fixtures("branched", bindings: { "branch" => "master" }, render_erb: true)) + assert_deploy_success(deploy_fixtures("branched", bindings: { "branch" => "main" }, render_erb: true)) deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace, label_selector: "app=branched") # Filter out pruned resources pending deletion deployments.select! { |deployment| deployment.metadata.deletionTimestamp.nil? } assert_equal(1, deployments.size) - assert_equal("master", deployments.first.metadata.labels.branch) + assert_equal("main", deployments.first.metadata.labels.branch) end def test_selector_as_filter # Deploy only the resource matching the selector without validation error assert_deploy_success(deploy_fixtures("slow-cloud", subset: ['web-deploy-1.yml', 'web-deploy-3.yml'], - selector: Krane::LabelSelector.parse("branch=master"), + selector: Krane::LabelSelector.parse("branch=main"), selector_as_filter: true)) assert_logs_match_all([ - "Using resource selector branch=master", + "Using resource selector branch=main", "Only deploying resources filtered by labels in selector", ], in_order: true) # Ensure only the selected resource is deployed deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace) assert_equal(1, deployments.size) - assert_equal("master", deployments.first.metadata.labels.branch) + assert_equal("main", deployments.first.metadata.labels.branch) # Deploy another resource with a different selector assert_deploy_success(deploy_fixtures("slow-cloud", subset: ['web-deploy-1.yml', 'web-deploy-3.yml'], @@ -206,9 +206,9 @@ def test_selector_as_filter # Ensure the not selected resource is not pruned deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace) assert_equal(2, deployments.size) - deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace, label_selector: "branch=master") + deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace, label_selector: "branch=main") assert_equal(1, deployments.size) - assert_equal("master", deployments.first.metadata.labels.branch) + assert_equal("main", deployments.first.metadata.labels.branch) # Ensure the selected resource is deployed deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace, label_selector: "branch=staging") assert_equal(1, deployments.size) @@ -222,7 +222,7 @@ def test_mismatched_selector /Using resource selector branch=staging/, /Template validation failed/, /Invalid template: Deployment/, - /selector branch=staging does not match labels name=web,branch=master,app=slow-cloud/, + /selector branch=staging does not match labels name=web,branch=main,app=slow-cloud/, /> Template content:/, ], in_order: true) end @@ -669,7 +669,7 @@ def test_can_deploy_template_dir_with_only_secrets_ejson end def test_ejson_works_with_label_selectors - value = "master" + value = "main" selector = Krane::LabelSelector.parse("branch=#{value}") ejson_cloud = FixtureSetAssertions::EjsonCloud.new(@namespace) ejson_cloud.create_ejson_keys_secret @@ -1475,12 +1475,12 @@ def test_apply_failure_with_sensitive_resources_not_leak_sensitive_content end def test_validation_failure_on_sensitive_resources_does_not_print_template - selector = Krane::LabelSelector.parse("branch=master") + selector = Krane::LabelSelector.parse("branch=main") assert_deploy_failure(deploy_fixtures("hello-cloud", subset: %w(secret.yml), selector: selector)) assert_logs_match_all([ "Template validation failed", "Invalid template: Secret-hello-secret", - "selector branch=master passed in, but no labels were defined", + "selector branch=main passed in, but no labels were defined", ], in_order: true) refute_logs_match("password") refute_logs_match("YWRtaW4=")