Sha256: 09e673525643c9e365af38fef2123c1f9c56719f9739a9ebf682474062cc5f36
Contents?: true
Size: 1.09 KB
Versions: 8
Compression:
Stored size: 1.09 KB
Contents
class KuberKit::Core::Artifacts::ArtifactStore NotFoundError = Class.new(KuberKit::NotFoundError) AlreadyAddedError = Class.new(KuberKit::Error) def add(artifact) @@artifacts ||= {} if !artifact.is_a?(KuberKit::Core::Artifacts::AbstractArtifact) raise ArgumentError.new("should be an instance of KuberKit::Core::Artifacts::AbstractArtifact, got: #{artifact.inspect}") end unless @@artifacts[artifact.name].nil? raise AlreadyAddedError, "artifact #{artifact.name} was already added" end @@artifacts[artifact.name] = artifact end def get(artifact_name) artifact = get_from_configuration(artifact_name) || get_global(artifact_name) artifact end def get_global(artifact_name) @@artifacts ||= {} artifact = @@artifacts[artifact_name] if artifact.nil? raise NotFoundError, "artifact '#{artifact_name}' not found" end artifact end def get_from_configuration(artifact_name) artifacts = KuberKit.current_configuration.artifacts artifacts[artifact_name] end def reset! @@artifacts = {} end end
Version data entries
8 entries across 8 versions & 1 rubygems