summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-09-14 10:52:25 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-09-18 13:57:14 +0200
commit59f87e7317137c302f71eb6746262c1f4fee84d9 (patch)
tree3770be63c93d3d009deb1c085f4d1eeef33e1cfe /lib
parentbff004d44b7af2cb5be608d7a74d2429f23782e1 (diff)
downloadgitlab-ce-59f87e7317137c302f71eb6746262c1f4fee84d9.tar.gz
Implement CI/CD kubernetes policy specification
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ci/build/policy/kubernetes.rb19
-rw-r--r--lib/gitlab/ci/build/policy/specification.rb28
2 files changed, 47 insertions, 0 deletions
diff --git a/lib/gitlab/ci/build/policy/kubernetes.rb b/lib/gitlab/ci/build/policy/kubernetes.rb
new file mode 100644
index 00000000000..bf3a95e08f0
--- /dev/null
+++ b/lib/gitlab/ci/build/policy/kubernetes.rb
@@ -0,0 +1,19 @@
+module Gitlab
+ module Ci
+ module Build
+ module Policy
+ class Kubernetes < Policy::Specification
+ def initialize(spec)
+ unless spec.to_sym == :active
+ raise UnknownPolicyError
+ end
+ end
+
+ def satisfied_by?(pipeline, **_)
+ pipeline.has_kubernetes_active?
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/ci/build/policy/specification.rb b/lib/gitlab/ci/build/policy/specification.rb
new file mode 100644
index 00000000000..0bb06ee8381
--- /dev/null
+++ b/lib/gitlab/ci/build/policy/specification.rb
@@ -0,0 +1,28 @@
+module Gitlab
+ module Ci
+ module Build
+ module Policy
+ ##
+ # Abstract class that defines an intereface of job policy
+ # specification.
+ #
+ # Used for job's only/except policy configuration.
+ #
+ class Specification
+ UnknownPolicyError = Class.new(StandardError)
+
+ def initialize(spec)
+ @spec = spec
+ end
+
+ def satisfied_by?(pipeline, **metadata)
+ raise NotImplementedError
+ end
+
+ def self.fabricate_all(*specs)
+ end
+ end
+ end
+ end
+ end
+end