diff --git a/lib/build-config.js b/lib/build-config.js index 0edb14e..8d9422e 100644 --- a/lib/build-config.js +++ b/lib/build-config.js @@ -26,6 +26,7 @@ async function buildConfig(build_id, config, context) { , dockerVerifyCmd: verifycmd = null , dockerNetwork: network = 'default' , dockerAutoClean: clean = true + , dockerBuildQuiet: quiet = true } = config let name = null @@ -72,6 +73,7 @@ async function buildConfig(build_id, config, context) { , env: context.env , context: dockerContext , network: network + , quiet: typeCast(quiet) === true , clean: typeCast(clean) === true } } diff --git a/lib/docker/image.js b/lib/docker/image.js index 48426d6..dd80ea5 100644 --- a/lib/docker/image.js +++ b/lib/docker/image.js @@ -17,6 +17,7 @@ class Image { , cwd = process.cwd() , context = '.' , network = 'default' + , quiet = true } = opts || {} if (!name || typeof name !== 'string') { @@ -37,6 +38,8 @@ class Image { , project: project , registry: registry } + + if (quiet) this.flag('quiet', null) } get id() { @@ -129,14 +132,13 @@ class Image { return [ 'build' , `--network=${this.network}` - , '--quiet' , '--tag' , this.name , ...this.flags , '-f' , this.dockerfile , this.context - ] + ].filter(Boolean) } async run(cmd) { diff --git a/lib/prepare.js b/lib/prepare.js index e6c36e6..9a2b6dd 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -18,6 +18,7 @@ async function dockerPrepare(opts, context) { , cwd: cwd , context: opts.context , network: opts.network + , quiet: opts.quiet }) const vars = buildTemplateVars(opts, context) diff --git a/lib/publish.js b/lib/publish.js index 3a03b64..8373cd7 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -16,6 +16,7 @@ async function publish(opts, context) { , build_id: opts.build , cwd: cwd , context: opts.context + , quiet: opts.quiet }) const vars = buildTemplateVars(opts, context) diff --git a/test/unit/build-config.js b/test/unit/build-config.js index 11f8509..f076821 100644 --- a/test/unit/build-config.js +++ b/test/unit/build-config.js @@ -43,6 +43,7 @@ test('build-config', async (t) => { , project: null , build: 'id' , context: '.' + , quiet: true , clean: true }) }) @@ -74,6 +75,7 @@ test('build-config', async (t) => { , project: 'internal' , build: 'id' , context: '.' + , quiet: true , clean: true }) }) @@ -103,6 +105,7 @@ test('build-config', async (t) => { , build: 'id' , context: '.' , clean: true + , quiet: true }) } @@ -112,6 +115,7 @@ test('build-config', async (t) => { , dockerImage: 'override' , dockerFile: 'Dockerfile.test' , dockerPublish: false + , dockerBuildQuiet: 'false' }, { cwd: path.join(t.testdirName, 'scoped') }) @@ -135,6 +139,7 @@ test('build-config', async (t) => { , build: 'id' , context: '.' , clean: true + , quiet: false }) } @@ -145,6 +150,7 @@ test('build-config', async (t) => { , dockerFile: 'Dockerfile.test' , dockerTags: 'latest,{{major}}-latest , fake, {{version}}' , dockerAutoClean: false + , dockerBuildQuiet: 'false' }, { cwd: path.join(t.testdirName, 'scoped') }) @@ -166,6 +172,7 @@ test('build-config', async (t) => { , project: null , build: 'id' , context: '.' + , quiet: false , clean: false }) } diff --git a/test/unit/docker/image.js b/test/unit/docker/image.js index c70fbb4..22479b9 100644 --- a/test/unit/docker/image.js +++ b/test/unit/docker/image.js @@ -176,9 +176,9 @@ test('Image', async (t) => { tt.same(img.build_cmd, [ 'build' , '--network=default' - , '--quiet' , '--tag' , 'quay.io/esatterwhite/test:abacadaba' + , '--quiet' , '-f' , path.join(process.cwd(), 'Dockerfile') , process.cwd() @@ -198,9 +198,9 @@ test('Image', async (t) => { tt.same(img.build_cmd, [ 'build' , '--network=default' - , '--quiet' , '--tag' , 'us.gcr.io/esatterwhite/foobar:1010101' + , '--quiet' , '-f' , path.join(__dirname, 'Dockerfile') , path.join(__dirname, 'fake') @@ -222,9 +222,9 @@ test('Image', async (t) => { tt.same(img.build_cmd, [ 'build' , '--network=default' - , '--quiet' , '--tag' , 'us.gcr.io/esatterwhite/foobar:1010101' + , '--quiet' , '--build-arg' , 'ARG_1=yes' , '--build-arg' @@ -234,6 +234,33 @@ test('Image', async (t) => { , path.join(__dirname, 'fake') ], 'build command') } + { + const img = new docker.Image({ + name: 'foobar' + , registry: 'us.gcr.io' + , project: 'esatterwhite' + , build_id: '1010101' + , cwd: __dirname + , context: path.join(__dirname, 'fake') + , quiet: false + }) + + img.arg('ARG_2', 'no') + img.arg('VALUE_FROM_ENV', true) + tt.same(img.build_cmd, [ + 'build' + , '--network=default' + , '--tag' + , 'us.gcr.io/esatterwhite/foobar:1010101' + , '--build-arg' + , 'ARG_2=no' + , '--build-arg' + , 'VALUE_FROM_ENV' + , '-f' + , path.join(__dirname, 'Dockerfile') + , path.join(__dirname, 'fake') + ], 'build command - quiet = false') + } }) t.test('image#build()', async (tt) => {