Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-03 21:06:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-03 21:06:49 +0300
commitab7cf450ba19cf80b9534f25dc707b33845e3014 (patch)
treebbfa6aba83c48aea68d79c4179ce576b6eec326d /lib/gitlab
parent4204cf308596e0e26f578a6e2da88f49c0f4aad9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb14
-rw-r--r--lib/gitlab/git/commit.rb15
-rw-r--r--lib/gitlab/kubernetes/cluster_role.rb29
-rw-r--r--lib/gitlab/kubernetes/kube_client.rb8
4 files changed, 63 insertions, 3 deletions
diff --git a/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb b/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb
index 9950e1dec55..b47238a3083 100644
--- a/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb
+++ b/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb
@@ -8,7 +8,7 @@ module Gitlab
def unmet?
deployment_cluster.present? &&
deployment_cluster.managed? &&
- missing_namespace?
+ (missing_namespace? || missing_knative_version_role_binding?)
end
def complete!
@@ -23,6 +23,10 @@ module Gitlab
kubernetes_namespace.nil? || kubernetes_namespace.service_account_token.blank?
end
+ def missing_knative_version_role_binding?
+ knative_version_role_binding.nil?
+ end
+
def deployment_cluster
build.deployment&.cluster
end
@@ -31,6 +35,14 @@ module Gitlab
build.deployment.environment
end
+ def knative_version_role_binding
+ strong_memoize(:knative_version_role_binding) do
+ Clusters::KnativeVersionRoleBindingFinder.new(
+ deployment_cluster
+ ).execute
+ end
+ end
+
def kubernetes_namespace
strong_memoize(:kubernetes_namespace) do
Clusters::KubernetesNamespaceFinder.new(
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb
index 6210223917b..b2dc9a8a3c8 100644
--- a/lib/gitlab/git/commit.rb
+++ b/lib/gitlab/git/commit.rb
@@ -370,15 +370,26 @@ module Gitlab
# subject from the message to make it clearer when there's one
# available but not the other.
@message = message_from_gitaly_body
- @authored_date = Time.at(commit.author.date.seconds).utc
+ @authored_date = init_date_from_gitaly(commit.author)
@author_name = commit.author.name.dup
@author_email = commit.author.email.dup
- @committed_date = Time.at(commit.committer.date.seconds).utc
+
+ @committed_date = init_date_from_gitaly(commit.committer)
@committer_name = commit.committer.name.dup
@committer_email = commit.committer.email.dup
@parent_ids = Array(commit.parent_ids)
end
+ # Gitaly provides a UNIX timestamp in author.date.seconds, and a timezone
+ # offset in author.timezone. If the latter isn't present, assume UTC.
+ def init_date_from_gitaly(author)
+ if author.timezone.present?
+ Time.strptime("#{author.date.seconds} #{author.timezone}", '%s %z')
+ else
+ Time.at(author.date.seconds).utc
+ end
+ end
+
def serialize_keys
SERIALIZE_KEYS
end
diff --git a/lib/gitlab/kubernetes/cluster_role.rb b/lib/gitlab/kubernetes/cluster_role.rb
new file mode 100644
index 00000000000..4d40736a0b5
--- /dev/null
+++ b/lib/gitlab/kubernetes/cluster_role.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Kubernetes
+ class ClusterRole
+ attr_reader :name, :rules
+
+ def initialize(name:, rules:)
+ @name = name
+ @rules = rules
+ end
+
+ def generate
+ ::Kubeclient::Resource.new(
+ metadata: metadata,
+ rules: rules
+ )
+ end
+
+ private
+
+ def metadata
+ {
+ name: name
+ }
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/kubernetes/kube_client.rb b/lib/gitlab/kubernetes/kube_client.rb
index 66c28a9b702..b23ca095414 100644
--- a/lib/gitlab/kubernetes/kube_client.rb
+++ b/lib/gitlab/kubernetes/kube_client.rb
@@ -56,6 +56,7 @@ module Gitlab
# group client
delegate :create_cluster_role_binding,
:get_cluster_role_binding,
+ :get_cluster_role_bindings,
:update_cluster_role_binding,
to: :rbac_client
@@ -68,6 +69,13 @@ module Gitlab
# RBAC methods delegates to the apis/rbac.authorization.k8s.io api
# group client
+ delegate :create_cluster_role,
+ :get_cluster_role,
+ :update_cluster_role,
+ to: :rbac_client
+
+ # RBAC methods delegates to the apis/rbac.authorization.k8s.io api
+ # group client
delegate :create_role_binding,
:get_role_binding,
:update_role_binding,