diff options
author | Douwe Maan <douwe@gitlab.com> | 2019-01-04 20:29:01 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2019-01-04 20:29:01 +0300 |
commit | 303f049358645312c6f77d08750e489475494201 (patch) | |
tree | 1a0a80849d9c711dac76b0344b37d17146029be5 /lib | |
parent | d85e04e45247a64c704a44a2c8abecba94972061 (diff) | |
parent | 8707827d3925441a838ba425e65dfdb8d3845a31 (diff) |
Merge branch 'feature/gb/expose-ci-api-url-variable' into 'master'
Expose `CI_API_V4_URL` CI/CD variable
Closes #54621
See merge request gitlab-org/gitlab-ce!23936
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/helpers/version.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/api/helpers/version.rb b/lib/api/helpers/version.rb new file mode 100644 index 00000000000..7f53094e90c --- /dev/null +++ b/lib/api/helpers/version.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module API + module Helpers + class Version + include Helpers::RelatedResourcesHelpers + + def initialize(version) + @version = version.to_s + + unless API.versions.include?(version) + raise ArgumentError, 'Unknown API version!' + end + end + + def root_path + File.join('/', API.prefix.to_s, @version) + end + + def root_url + @root_url ||= expose_url(root_path) + end + + def to_s + @version + end + end + end +end |