cli/lib/rbld_engine.rb in rbld-1.3.7 vs cli/lib/rbld_engine.rb in rbld-1.3.8

- old
+ new

@@ -286,11 +286,11 @@ end rebuild_errors \ UnsupportedDockerService: 'Unsupported docker service: %s', InaccessibleDockerService: 'Unable to reach the docker engine', - EnvironmentIsModified: 'Environment is modified, commit or checkout first', + EnvironmentIsModified: 'Environment is modified, %s', EnvironmentNotKnown: 'Unknown environment %s', NoChangesToCommit: 'No changes to commit for %s', EnvironmentDeploymentFailure: 'Failed to deploy from %s', EnvironmentAlreadyExists: 'Environment %s already exists', EnvironmentNotFoundInTheRegistry: 'Environment %s does not exist in the registry', @@ -452,10 +452,12 @@ end end class API extend Forwardable + REMOVE_MODIFIED_ERROR = 'use --force to delete anyway' + PUBLISH_MODIFIED_ERROR = 'commit or checkout first' def initialize(docker_api = Docker, cfg = Rebuild::Config.new) @docker_api, @cfg = docker_api, cfg tweak_excon @@ -463,11 +465,11 @@ check_connectivity @cache = PresentEnvironments.new end def remove!(env_name) - env = unmodified_env( env_name ) + env = unmodified_env( env_name , REMOVE_MODIFIED_ERROR ) env.img.remove! @cache.refresh! end def load!(filename) @@ -521,11 +523,11 @@ @cache.refresh! end def publish(env_name) - env = unmodified_env( env_name ) + env = unmodified_env( env_name, PUBLISH_MODIFIED_ERROR ) rbld_print.progress "Checking for collisions..." raise EnvironmentPublishCollision, env_name \ unless registry.search( env_name.name, env_name.tag ).empty? @@ -763,12 +765,12 @@ env = @cache.get(name) raise EnvironmentNotKnown, name.full unless env env end - def unmodified_env(name) + def unmodified_env(name, comment) env = existing_env( name ) - raise EnvironmentIsModified if env.modified? + raise EnvironmentIsModified, comment if env.modified? env end def nonexisting_env(name) raise EnvironmentAlreadyExists, name.full if @cache.get(name)