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.
This commit is contained in:
parent
c6f54ab12b
commit
ae4966f29a
8 changed files with 54 additions and 0 deletions
|
@ -57,6 +57,7 @@ export default {
|
|||
:user-callouts-path="userCalloutsPath"
|
||||
:lock-promotion-svg-path="lockPromotionSvgPath"
|
||||
:help-canary-deployments-path="helpCanaryDeploymentsPath"
|
||||
:deploy-boards-help-path="deployBoardsHelpPath"
|
||||
/>
|
||||
|
||||
<table-pagination
|
||||
|
|
|
@ -43,6 +43,11 @@ export default {
|
|||
type: String,
|
||||
required: true,
|
||||
},
|
||||
deployBoardsHelpPath: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
|
@ -112,6 +117,7 @@ export default {
|
|||
:user-callouts-path="userCalloutsPath"
|
||||
:lock-promotion-svg-path="lockPromotionSvgPath"
|
||||
:help-canary-deployments-path="helpCanaryDeploymentsPath"
|
||||
:deploy-boards-help-path="deployBoardsHelpPath"
|
||||
@onChangePage="onChangePage"
|
||||
>
|
||||
<empty-state
|
||||
|
|
|
@ -22,6 +22,11 @@ export default {
|
|||
required: true,
|
||||
default: () => [],
|
||||
},
|
||||
deployBoardsHelpPath: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
canReadEnvironment: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
|
@ -106,8 +111,10 @@ export default {
|
|||
<div class="deploy-board-container">
|
||||
<deploy-board
|
||||
:deploy-board-data="model.deployBoardData"
|
||||
:deploy-boards-help-path="deployBoardsHelpPath"
|
||||
:is-loading="model.isLoadingDeployBoard"
|
||||
:is-empty="model.isEmptyDeployBoard"
|
||||
:has-legacy-app-label="model.hasLegacyAppLabel"
|
||||
:logs-path="model.logs_path"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -20,6 +20,7 @@ export default () =>
|
|||
endpoint: environmentsData.environmentsDataEndpoint,
|
||||
newEnvironmentPath: environmentsData.newEnvironmentPath,
|
||||
helpPagePath: environmentsData.helpPagePath,
|
||||
deployBoardsHelpPath: environmentsData.deployBoardsHelpPath,
|
||||
cssContainerClass: environmentsData.cssClass,
|
||||
canCreateEnvironment: parseBoolean(environmentsData.canCreateEnvironment),
|
||||
canReadEnvironment: parseBoolean(environmentsData.canReadEnvironment),
|
||||
|
@ -31,6 +32,7 @@ export default () =>
|
|||
endpoint: this.endpoint,
|
||||
newEnvironmentPath: this.newEnvironmentPath,
|
||||
helpPagePath: this.helpPagePath,
|
||||
deployBoardsHelpPath: this.deployBoardsHelpPath,
|
||||
cssContainerClass: this.cssContainerClass,
|
||||
canCreateEnvironment: this.canCreateEnvironment,
|
||||
canReadEnvironment: this.canReadEnvironment,
|
||||
|
|
|
@ -25,5 +25,10 @@ export default {
|
|||
required: false,
|
||||
default: null,
|
||||
},
|
||||
deployBoardsHelpPath: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -6,4 +6,5 @@
|
|||
"can-create-environment" => can?(current_user, :create_environment, @project).to_s,
|
||||
"new-environment-path" => new_project_environment_path(@project),
|
||||
"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 } }
|
||||
|
|
|
@ -43,6 +43,14 @@ module Gitlab
|
|||
})
|
||||
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
|
||||
def terminals_for_pod(api_url, namespace, pod)
|
||||
metadata = pod.fetch("metadata", {})
|
||||
|
|
|
@ -67,6 +67,30 @@ describe Gitlab::Kubernetes do
|
|||
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
|
||||
let(:token) { 'TOKEN' }
|
||||
let(:ca_pem) { 'PEM' }
|
||||
|
|
Loading…
Reference in a new issue