Drone CLI's `--token` option does not work

If I create a machine user with CLI and try to specify a token for that user:

drone user add testuser --machine --token ONE_TOKEN
Successfully added user testuser
Generated account token ANOTHER_TOKEN

What happens is that the user is created with another (randomly generated) token.

This is problematic, because if I want to create a user automatically (e.g. creating a user for Autoscaler with Ansible), it’s tricky to get the token out of the printed text (which is not a stable API), instead of specifying it.

Looking into the code it seems that the words token and hash are a bit mixed up and that is causing the problem.

First a user object is created with a Token:

This is marshalled as token:

Then it’s sent to the server:

But when the server unmarshals it:

It doesn’t find it:

And more importantly, it doesn’t even look at token, but at hash instead:

So it generates a random one:

And sends it back as token:

Finally, the client prints it:

1 Like

Now, that someone else has bumped into this issue as well, I’d like to ping this topic.

I’m not sure, what’s customary here, but after being ignored for more than a month, can I get an “acknowledged”, “won’t fix”, “fix it yourself” or any other reaction please?

complaining is customary, sending a pull request is desired.