pkg-export-k8s: Use export_docker::export_for_cli_matches()
Make use of the new docker exporter API to avoid code-duplication.
@@ -33,14 +33,10 @@ mod error;
mod manifest;
mod cli;
-use std::env;
-
-use hcore::channel;
use hcore::PROGRAM_NAME;
-use hcore::url as hurl;
use common::ui::UI;
-use export_docker::{Credentials, BuildSpec, Naming, Result};
+use export_docker::Result;
use manifest::Manifest;
@@ -61,39 +57,12 @@ fn start(ui: &mut UI) -> Result<()> {
debug!("clap cli args: {:?}", m);
if !m.is_present("NO_DOCKER_IMAGE") {
- gen_docker_img(ui, &m)?;
+ export_docker::export_for_cli_matches(ui, &m)?;
}
let mut manifest = Manifest::new_from_cli_matches(ui, &m)?;
manifest.generate()
}
-fn gen_docker_img(ui: &mut UI, matches: &clap::ArgMatches) -> Result<()> {
- let default_channel = channel::default();
- let default_url = hurl::default_bldr_url();
- let spec = BuildSpec::new_from_cli_matches(&matches, &default_channel, &default_url);
- let naming = Naming::new_from_cli_matches(&matches);
-
- let docker_image = export_docker::export(ui, spec, &naming)?;
- docker_image.create_report(
- ui,
- env::current_dir()?.join("results"),
- )?;
-
- if matches.is_present("PUSH_IMAGE") {
- let credentials = Credentials::new(
- naming.registry_type,
- matches.value_of("REGISTRY_USERNAME").unwrap(),
- matches.value_of("REGISTRY_PASSWORD").unwrap(),
- )?;
- docker_image.push(ui, &credentials, naming.registry_url)?;
- }
- if matches.is_present("RM_IMAGE") {
- docker_image.rm(ui)?;
- }
-
- Ok(())
-}
-
fn cli<'a, 'b>() -> clap::App<'a, 'b> {
let name: &str = &*PROGRAM_NAME;
let about = "Creates a Docker image and Kubernetes manifest for a Habitat package. Habitat \
