Commit ae4966f2 authored by Thong Kuah's avatar Thong Kuah Committed by Mike Greiling

Select deployments that only has the app label

As Auto DevOps deployments both label and annotations, that will be
included in the deploy board so need to warn at all.
parent c6f54ab1
...@@ -57,6 +57,7 @@ export default { ...@@ -57,6 +57,7 @@ export default {
:user-callouts-path="userCalloutsPath" :user-callouts-path="userCalloutsPath"
:lock-promotion-svg-path="lockPromotionSvgPath" :lock-promotion-svg-path="lockPromotionSvgPath"
:help-canary-deployments-path="helpCanaryDeploymentsPath" :help-canary-deployments-path="helpCanaryDeploymentsPath"
:deploy-boards-help-path="deployBoardsHelpPath"
/> />
<table-pagination <table-pagination
......
...@@ -43,6 +43,11 @@ export default { ...@@ -43,6 +43,11 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
deployBoardsHelpPath: {
type: String,
required: false,
default: '',
},
}, },
created() { created() {
...@@ -112,6 +117,7 @@ export default { ...@@ -112,6 +117,7 @@ export default {
:user-callouts-path="userCalloutsPath" :user-callouts-path="userCalloutsPath"
:lock-promotion-svg-path="lockPromotionSvgPath" :lock-promotion-svg-path="lockPromotionSvgPath"
:help-canary-deployments-path="helpCanaryDeploymentsPath" :help-canary-deployments-path="helpCanaryDeploymentsPath"
:deploy-boards-help-path="deployBoardsHelpPath"
@onChangePage="onChangePage" @onChangePage="onChangePage"
> >
<empty-state <empty-state
......
...@@ -22,6 +22,11 @@ export default { ...@@ -22,6 +22,11 @@ export default {
required: true, required: true,
default: () => [], default: () => [],
}, },
deployBoardsHelpPath: {
type: String,
required: false,
default: '',
},
canReadEnvironment: { canReadEnvironment: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -106,8 +111,10 @@ export default { ...@@ -106,8 +111,10 @@ export default {
<div class="deploy-board-container"> <div class="deploy-board-container">
<deploy-board <deploy-board
:deploy-board-data="model.deployBoardData" :deploy-board-data="model.deployBoardData"
:deploy-boards-help-path="deployBoardsHelpPath"
:is-loading="model.isLoadingDeployBoard" :is-loading="model.isLoadingDeployBoard"
:is-empty="model.isEmptyDeployBoard" :is-empty="model.isEmptyDeployBoard"
:has-legacy-app-label="model.hasLegacyAppLabel"
:logs-path="model.logs_path" :logs-path="model.logs_path"
/> />
</div> </div>
......
...@@ -20,6 +20,7 @@ export default () => ...@@ -20,6 +20,7 @@ export default () =>
endpoint: environmentsData.environmentsDataEndpoint, endpoint: environmentsData.environmentsDataEndpoint,
newEnvironmentPath: environmentsData.newEnvironmentPath, newEnvironmentPath: environmentsData.newEnvironmentPath,
helpPagePath: environmentsData.helpPagePath, helpPagePath: environmentsData.helpPagePath,
deployBoardsHelpPath: environmentsData.deployBoardsHelpPath,
cssContainerClass: environmentsData.cssClass, cssContainerClass: environmentsData.cssClass,
canCreateEnvironment: parseBoolean(environmentsData.canCreateEnvironment), canCreateEnvironment: parseBoolean(environmentsData.canCreateEnvironment),
canReadEnvironment: parseBoolean(environmentsData.canReadEnvironment), canReadEnvironment: parseBoolean(environmentsData.canReadEnvironment),
...@@ -31,6 +32,7 @@ export default () => ...@@ -31,6 +32,7 @@ export default () =>
endpoint: this.endpoint, endpoint: this.endpoint,
newEnvironmentPath: this.newEnvironmentPath, newEnvironmentPath: this.newEnvironmentPath,
helpPagePath: this.helpPagePath, helpPagePath: this.helpPagePath,
deployBoardsHelpPath: this.deployBoardsHelpPath,
cssContainerClass: this.cssContainerClass, cssContainerClass: this.cssContainerClass,
canCreateEnvironment: this.canCreateEnvironment, canCreateEnvironment: this.canCreateEnvironment,
canReadEnvironment: this.canReadEnvironment, canReadEnvironment: this.canReadEnvironment,
......
...@@ -25,5 +25,10 @@ export default { ...@@ -25,5 +25,10 @@ export default {
required: false, required: false,
default: null, default: null,
}, },
deployBoardsHelpPath: {
type: String,
required: false,
default: '',
},
}, },
}; };
...@@ -6,4 +6,5 @@ ...@@ -6,4 +6,5 @@
"can-create-environment" => can?(current_user, :create_environment, @project).to_s, "can-create-environment" => can?(current_user, :create_environment, @project).to_s,
"new-environment-path" => new_project_environment_path(@project), "new-environment-path" => new_project_environment_path(@project),
"help-page-path" => help_page_path("ci/environments"), "help-page-path" => help_page_path("ci/environments"),
"deploy-boards-help-path" => help_page_path("user/project/deploy_boards", anchor: "enabling-deploy-boards"),
"css-class" => container_class } } "css-class" => container_class } }
...@@ -43,6 +43,14 @@ module Gitlab ...@@ -43,6 +43,14 @@ module Gitlab
}) })
end end
def filter_by_legacy_label(items, app, env)
legacy_items = filter_by_label(items, { app: env })
non_legacy_items = filter_by_project_environment(legacy_items, app, env)
legacy_items - non_legacy_items
end
# Converts a pod (as returned by the kubernetes API) into a terminal # Converts a pod (as returned by the kubernetes API) into a terminal
def terminals_for_pod(api_url, namespace, pod) def terminals_for_pod(api_url, namespace, pod)
metadata = pod.fetch("metadata", {}) metadata = pod.fetch("metadata", {})
......
...@@ -67,6 +67,30 @@ describe Gitlab::Kubernetes do ...@@ -67,6 +67,30 @@ describe Gitlab::Kubernetes do
end end
end end
describe '#filter_by_legacy_label' do
let(:non_matching_pod) { kube_pod(environment_slug: 'production', project_slug: 'my-cool-app') }
let(:non_matching_pod_2) do
kube_pod(environment_slug: 'production', project_slug: 'my-cool-app').tap do |pod|
pod['metadata']['labels']['app'] = 'production'
end
end
let(:matching_pod) do
kube_pod.tap do |pod|
pod['metadata']['annotations'].delete('app.gitlab.com/env')
pod['metadata']['annotations'].delete('app.gitlab.com/app')
pod['metadata']['labels']['app'] = 'production'
end
end
it 'returns matching labels' do
items = [non_matching_pod, non_matching_pod_2, matching_pod]
expect(filter_by_legacy_label(items, 'my-cool-app', 'production')).to contain_exactly(matching_pod)
end
end
describe '#to_kubeconfig' do describe '#to_kubeconfig' do
let(:token) { 'TOKEN' } let(:token) { 'TOKEN' }
let(:ca_pem) { 'PEM' } let(:ca_pem) { 'PEM' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment