Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
33d459aa
Commit
33d459aa
authored
Mar 14, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY remaining instances of predefined variables
parent
1d57db0d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
34 deletions
+35
-34
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+4
-5
app/models/ci/runner.rb
app/models/ci/runner.rb
+4
-5
app/models/clusters/platforms/kubernetes.rb
app/models/clusters/platforms/kubernetes.rb
+12
-12
app/models/environment.rb
app/models/environment.rb
+3
-4
app/models/project_services/kubernetes_service.rb
app/models/project_services/kubernetes_service.rb
+12
-8
No files found.
app/models/ci/pipeline.rb
View file @
33d459aa
...
@@ -473,11 +473,10 @@ module Ci
...
@@ -473,11 +473,10 @@ module Ci
end
end
def
predefined_variables
def
predefined_variables
[
Gitlab
::
Ci
::
Variables
::
Collection
.
new
{
key:
'CI_PIPELINE_ID'
,
value:
id
.
to_s
,
public:
true
},
.
append
(
key:
'CI_PIPELINE_ID'
,
value:
id
.
to_s
)
{
key:
'CI_CONFIG_PATH'
,
value:
ci_yaml_file_path
,
public:
true
},
.
append
(
key:
'CI_CONFIG_PATH'
,
value:
ci_yaml_file_path
)
{
key:
'CI_PIPELINE_SOURCE'
,
value:
source
.
to_s
,
public:
true
}
.
append
(
key:
'CI_PIPELINE_SOURCE'
,
value:
source
.
to_s
)
]
end
end
def
queued_duration
def
queued_duration
...
...
app/models/ci/runner.rb
View file @
33d459aa
...
@@ -132,11 +132,10 @@ module Ci
...
@@ -132,11 +132,10 @@ module Ci
end
end
def
predefined_variables
def
predefined_variables
[
Gitlab
::
Ci
::
Variables
::
Collection
.
new
{
key:
'CI_RUNNER_ID'
,
value:
id
.
to_s
,
public:
true
},
.
append
(
key:
'CI_RUNNER_ID'
,
value:
id
.
to_s
)
{
key:
'CI_RUNNER_DESCRIPTION'
,
value:
description
,
public:
true
},
.
append
(
key:
'CI_RUNNER_DESCRIPTION'
,
value:
description
)
{
key:
'CI_RUNNER_TAGS'
,
value:
tag_list
.
to_s
,
public:
true
}
.
append
(
key:
'CI_RUNNER_TAGS'
,
value:
tag_list
.
to_s
)
]
end
end
def
tick_runner_queue
def
tick_runner_queue
...
...
app/models/clusters/platforms/kubernetes.rb
View file @
33d459aa
...
@@ -56,19 +56,19 @@ module Clusters
...
@@ -56,19 +56,19 @@ module Clusters
def
predefined_variables
def
predefined_variables
config
=
YAML
.
dump
(
kubeconfig
)
config
=
YAML
.
dump
(
kubeconfig
)
variables
=
[
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
tap
do
|
variables
|
{
key:
'KUBE_URL'
,
value:
api_url
,
public:
true
},
variables
{
key:
'KUBE_TOKEN'
,
value:
token
,
public:
false
},
.
append
(
key:
'KUBE_URL'
,
value:
api_url
)
{
key:
'KUBE_NAMESPACE'
,
value:
actual_namespace
,
public:
true
},
.
append
(
key:
'KUBE_TOKEN'
,
value:
token
,
public:
false
)
{
key:
'KUBECONFIG'
,
value:
config
,
public:
false
,
file:
true
}
.
append
(
key:
'KUBE_NAMESPACE'
,
value:
actual_namespace
)
]
.
append
(
key:
'KUBECONFIG'
,
value:
config
,
public:
false
,
file:
true
)
if
ca_pem
.
present?
if
ca_pem
.
present?
variables
<<
{
key:
'KUBE_CA_PEM'
,
value:
ca_pem
,
public:
true
}
variables
variables
<<
{
key:
'KUBE_CA_PEM_FILE'
,
value:
ca_pem
,
public:
true
,
file:
true
}
.
append
(
key:
'KUBE_CA_PEM'
,
value:
ca_pem
)
.
append
(
key:
'KUBE_CA_PEM_FILE'
,
value:
ca_pem
,
file:
true
)
end
end
end
variables
end
end
# Constructs a list of terminals from the reactive cache
# Constructs a list of terminals from the reactive cache
...
...
app/models/environment.rb
View file @
33d459aa
...
@@ -65,10 +65,9 @@ class Environment < ActiveRecord::Base
...
@@ -65,10 +65,9 @@ class Environment < ActiveRecord::Base
end
end
def
predefined_variables
def
predefined_variables
[
Gitlab
::
Ci
::
Variables
::
Collection
.
new
{
key:
'CI_ENVIRONMENT_NAME'
,
value:
name
,
public:
true
},
.
append
(
key:
'CI_ENVIRONMENT_NAME'
,
value:
name
)
{
key:
'CI_ENVIRONMENT_SLUG'
,
value:
slug
,
public:
true
}
.
append
(
key:
'CI_ENVIRONMENT_SLUG'
,
value:
slug
)
]
end
end
def
recently_updated_on_branch?
(
ref
)
def
recently_updated_on_branch?
(
ref
)
...
...
app/models/project_services/kubernetes_service.rb
View file @
33d459aa
...
@@ -105,14 +105,18 @@ class KubernetesService < DeploymentService
...
@@ -105,14 +105,18 @@ class KubernetesService < DeploymentService
def
predefined_variables
def
predefined_variables
config
=
YAML
.
dump
(
kubeconfig
)
config
=
YAML
.
dump
(
kubeconfig
)
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
tap
do
|
collection
|
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
tap
do
|
variables
|
collection
.
append
(
key:
'KUBE_URL'
,
value:
api_url
,
public:
true
)
variables
collection
.
append
(
key:
'KUBE_TOKEN'
,
value:
token
,
public:
false
)
.
append
(
key:
'KUBE_URL'
,
value:
api_url
)
collection
.
append
(
key:
'KUBE_NAMESPACE'
,
value:
actual_namespace
,
public:
true
)
.
append
(
key:
'KUBE_TOKEN'
,
value:
token
,
public:
false
)
collection
.
append
(
key:
'KUBECONFIG'
,
value:
config
,
public:
false
,
file:
true
)
.
append
(
key:
'KUBE_NAMESPACE'
,
value:
actual_namespace
)
.
append
(
key:
'KUBECONFIG'
,
value:
config
,
public:
false
,
file:
true
)
collection
.
append
(
key:
'KUBE_CA_PEM'
,
value:
ca_pem
,
public:
true
)
collection
.
append
(
key:
'KUBE_CA_PEM_FILE'
,
value:
ca_pem
,
public:
true
,
file:
true
)
if
ca_pem
.
present?
variables
.
append
(
key:
'KUBE_CA_PEM'
,
value:
ca_pem
)
.
append
(
key:
'KUBE_CA_PEM_FILE'
,
value:
ca_pem
,
file:
true
)
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment