lib/heirloom/cli/shared.rb in heirloom-0.8.3 vs lib/heirloom/cli/shared.rb in heirloom-0.9.0
- old
+ new
@@ -122,12 +122,12 @@
exit 1
end
end
def ensure_archive_exists(args)
- config = args[:config]
archive = args[:archive]
+ config = args[:config]
logger = config.logger
unless archive.exists?
logger.error "Archive does not exist."
exit 1
@@ -183,9 +183,44 @@
:config => config
if available
true
else
logger.error "Bucket prefix #{bucket_prefix} not available across regions #{regions.join}."
+ exit 1
+ end
+ end
+
+ def ensure_entry_does_not_exist_in_catalog(args)
+ config = args[:config]
+ catalog = args[:catalog]
+ entry = args[:entry]
+ force = args[:force]
+ logger = config.logger
+ region = config.metadata_region
+
+ if catalog.entry_exists_in_catalog?(entry) && !force
+ logger.error "Entry #{entry} exists in catalog. Use --force to overwrite."
+ exit 1
+ end
+ end
+
+ def ensure_valid_name(args)
+ config = args[:config]
+ name = args[:name]
+ logger = config.logger
+ unless name =~ /^[0-9a-z\-\_]+$/
+ logger.error "Invalid name '#{name}'. Can only contain lower case letters, numbers, dashes and underscores."
+ exit 1
+ end
+ end
+
+ def ensure_valid_bucket_prefix(args)
+ config = args[:config]
+ bucket_prefix = args[:bucket_prefix]
+ logger = config.logger
+
+ unless bucket_prefix =~ /^[0-9a-z\-]+$/
+ logger.error "Invalid bucket prefix '#{bucket_prefix}'. Can only contain lower case letters, numbers and dashes."
exit 1
end
end
def latest_id(args)