Class: BoringBuilder::Exporters::BoringCache
- Inherits:
-
Object
- Object
- BoringBuilder::Exporters::BoringCache
- Defined in:
- lib/boringbuilder/exporters/boring_cache.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #export(asset) ⇒ Object
-
#initialize(project, client, environment: ENV) ⇒ BoringCache
constructor
A new instance of BoringCache.
- #name ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(project, client, environment: ENV) ⇒ BoringCache
Returns a new instance of BoringCache.
10 11 12 13 14 |
# File 'lib/boringbuilder/exporters/boring_cache.rb', line 10 def initialize(project, client, environment: ENV) @project = project @client = client @cache = ::BoringBuilder::BoringCache.new(project, client, environment: environment) end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
8 9 10 |
# File 'lib/boringbuilder/exporters/boring_cache.rb', line 8 def cache @cache end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/boringbuilder/exporters/boring_cache.rb', line 8 def client @client end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
8 9 10 |
# File 'lib/boringbuilder/exporters/boring_cache.rb', line 8 def project @project end |
Instance Method Details
#export(asset) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/boringbuilder/exporters/boring_cache.rb', line 29 def export(asset) validate! publisher = client.container.from(cache.cli_image) publisher = cache.prepare_artifact_publisher(publisher) path, publisher = mount_asset(publisher, asset) output = publisher.with_exec(publish_command(path, asset.kind)).stdout artifact = JSON.parse(output).fetch("artifact") validate_artifact!(artifact) Receipt.new(artifact_id: artifact.fetch("id"), artifact_name: artifact.fetch("name")) rescue JSON::ParserError, KeyError => e raise ExportError, "BoringCache Artifact returned an invalid receipt: #{e.}" end |
#name ⇒ Object
16 |
# File 'lib/boringbuilder/exporters/boring_cache.rb', line 16 def name = :boringcache |
#validate! ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/boringbuilder/exporters/boring_cache.rb', line 18 def validate! if configuration.artifact_name&.strip == "" raise ConfigurationError, "BoringCache Artifact name cannot be empty" end raise ConfigurationError, "The boringcache exporter requires BORINGCACHE_SAVE_TOKEN" unless cache.save_token? return self if cache.workspace_configured? raise ConfigurationError, "The boringcache exporter requires a workspace environment variable or .boringcache.toml" end |