class WarpEngine::Configuration::CIDSL
Builds a CI adapter: its connection settings, a tools image every platform shares unless it names its own, and one platform line each.
ci :woodpecker do url ENV["WOODPECKER_URL"] api_token ENV["WOODPECKER_API_TOKEN"] platform :godot, builder: "registry.example/godot-builder:4.6" end
Every connection setting (url, api_token, repo_owner, public_key, public_key_url, update_server, webhook_secret) is a method taking the value; it raises ArgumentError when the chosen adapter has no such setting.
Constants
- ADAPTERS
-
The adapter kinds and the class each builds.
- PLATFORM_KEYS
-
The keys a
platformline accepts. - SETTINGS
-
The connection settings each adapter kind accepts.
Public Class Methods
Source
# File lib/warp_engine/configuration/ci_dsl.rb, line 32 def self.build(kind, &block) builder = new(kind) builder.instance_eval(&block) builder.adapter end
Evaluates block for the adapter kind and returns the built adapter.
Source
# File lib/warp_engine/configuration/ci_dsl.rb, line 40 def initialize(kind) @kind = kind.to_sym raise ArgumentError, "unknown CI adapter: #{kind.inspect} (#{ADAPTERS.keys.join(', ')})" unless ADAPTERS.key?(@kind) @settings = {} @defaults = {} @platforms = {} end
Creates a builder for the adapter kind (:woodpecker or :gitlab). Raises ArgumentError for any other kind.
Public Instance Methods
Source
# File lib/warp_engine/configuration/ci_dsl.rb, line 73 def adapter ADAPTERS.fetch(@kind).constantize.new(**@settings, platforms: @platforms) end
Returns a new adapter instance built from the collected settings and platforms.
Source
# File lib/warp_engine/configuration/ci_dsl.rb, line 63 def platform(name, **spec) unknown = spec.keys - PLATFORM_KEYS raise ArgumentError, "unknown platform keys for #{name}: #{unknown.join(', ')}" if unknown.any? raise ArgumentError, "platform #{name} needs a builder" if spec[:builder].blank? @platforms[name.to_s] = @defaults.merge(spec) end
Configures one platform for the adapter; spec takes the PLATFORM_KEYS, builder being required. Raises ArgumentError on an unknown key or a missing builder.
Source
# File lib/warp_engine/configuration/ci_dsl.rb, line 58 def tools(image) = @defaults[:tools] = image
Sets the default tools image of every platform that names none.