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:
Diffstat (limited to 'lib/gitlab/ci/input/inputs.rb')
-rw-r--r--lib/gitlab/ci/input/inputs.rb73
1 files changed, 0 insertions, 73 deletions
diff --git a/lib/gitlab/ci/input/inputs.rb b/lib/gitlab/ci/input/inputs.rb
deleted file mode 100644
index 1b544e63e7d..00000000000
--- a/lib/gitlab/ci/input/inputs.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module Ci
- module Input
- ##
- # Inputs::Input class represents user-provided inputs, configured using `with:` keyword.
- #
- # Input arguments are only valid with an associated component's inputs specification from component's header.
- #
- class Inputs
- UnknownSpecArgumentError = Class.new(StandardError)
-
- ARGUMENTS = [
- Input::Arguments::Required, # Input argument is required
- Input::Arguments::Default, # Input argument has a default value
- Input::Arguments::Options, # Input argument that needs to be allowlisted
- Input::Arguments::Unknown # Input argument has not been recognized
- ].freeze
-
- def initialize(spec, args)
- @spec = spec.to_h
- @args = args.to_h
- @inputs = []
- @errors = []
-
- validate!
- fabricate!
- end
-
- def errors
- @errors + @inputs.flat_map(&:errors)
- end
-
- def valid?
- errors.none?
- end
-
- def unknown
- @args.keys - @spec.keys
- end
-
- def count
- @inputs.count
- end
-
- def to_hash
- @inputs.inject({}) do |hash, argument|
- raise ArgumentError unless argument.valid?
-
- hash.merge(argument.to_hash)
- end
- end
-
- private
-
- def validate!
- @errors.push("unknown input arguments: #{unknown.inspect}") if unknown.any?
- end
-
- def fabricate!
- @spec.each do |key, spec|
- argument = ARGUMENTS.find { |klass| klass.matches?(spec) }
-
- raise UnknownSpecArgumentError if argument.nil?
-
- @inputs.push(argument.new(key, spec, @args[key]))
- end
- end
- end
- end
- end
-end