Skip to content

Commit

Permalink
feat(verify): add option to opt out of docker login
Browse files Browse the repository at this point in the history
adds option `login` the by pass the login step all together.

Semver: minor
  • Loading branch information
esatterwhite committed Dec 21, 2020
1 parent 0764212 commit de17169
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ omitted, it is assumed the docker daemon is already authenticated with the targe
| docker.project | _Optional_. The project or repository name to publish the image to | For scoped packages, the scope will be used, otherwise `null`
| docker.dockerfile | _Optional_. The path, relative to `$PWD` to a Docker file to build the target image with | `Dockerfile`
| docker.context | _Optional_. A path, relative to `$PWD` to use as the build context A | `.`
| docker.login | _Optional_. Set to false it by pass docker login if the docker daemon is already authorized | `true`

## Usage

Expand Down
2 changes: 2 additions & 0 deletions lib/build-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ async function buildConfig(build_id, config, context) {
, tags = ['latest', '{major}-latest', '{version}']
, args = {}
, registry = null
, login = true
, image
} = (object.get(config, 'docker') || {})

Expand Down Expand Up @@ -50,6 +51,7 @@ async function buildConfig(build_id, config, context) {
}
, name: image || name
, build: build_id
, login: login
, context: config.context || '.'
}
}
5 changes: 5 additions & 0 deletions lib/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ async function verify(opts, context) {
return false
}

if (opts.login === false) {
debug('docker login === false. Skipping login')
return false
}

let set = 0
if (USERNAME) set += 1
if (PASSWORD) set += 1
Expand Down
21 changes: 21 additions & 0 deletions test/integration/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,27 @@ test('steps::verify', async (t) => {
tt.resolves(verify(config, context))
})

t.test('docker no login', async (tt) => {
const context = {
env: {
...process.env
, DOCKER_REGISTRY_USER: 'iamweasel'
}
, cwd: process.cwd()
, logger: {
success: sinon.stub()
, info: sinon.stub()
}
}
const config = await buildConfig(build_id, {
docker: {
registry: DOCKER_REGISTRY_HOST
, login: false
}
}, context)
tt.resolves(verify(config, context))
})

t.test('docker password, no username', async (tt) => {
const context = {
env: {
Expand Down

0 comments on commit de17169

Please sign in to comment.