Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking login when push is false #6

Open
ktschmincke opened this issue Jan 19, 2016 · 1 comment
Open

Checking login when push is false #6

ktschmincke opened this issue Jan 19, 2016 · 1 comment

Comments

@ktschmincke
Copy link

The true in the runIf function call below makes the plugin check for login every time, regardless if I want to push a container or not. This should be changed to opts.push so that it's only running if I decide I want to push. It also removes the requirement for the username and pushLocation to be present if push is set to false.

runIf(true, function(){
  var loginOpts = ['login']
  if(opts.pushLocation !== DOCKER_HUB_URL) {
    loginOpts.push(opts.pushLocation)
  }

  var dockerLogin = spawn('docker', loginOpts)
  dockerLogin.stdout.on('data', function(data){
    data = data || ''
    var usernameRegex = /\(.*\)/
    if(usernameRegex.exec(data) && usernameRegex.exec(data).length > 0) {
      if(usernameRegex.exec(data)[0] !== '(' + opts.username + ')'){
        grunt.fatal('Please Login First')
      }
      next()
    } else {
      grunt.fatal('Please login to the docker registry - ' + opts.pushLocation)
    }
  })
})
@td-edge
Copy link

td-edge commented Jan 19, 2016

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants