Skip to content

docs: add coder login to CI docs #9038

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

Merged
merged 4 commits into from
Aug 11, 2023
Merged

Conversation

ericpaulsen
Copy link
Member

a customer asked how to non-interactively authenticate the coder templates push command we have in our CI documentation. this PR documents this step by adding the coder login <url> --token $CODER_SESSION_TOKEN command.

@ericpaulsen ericpaulsen added the docs Area: coder.com/docs label Aug 11, 2023
@ericpaulsen ericpaulsen self-assigned this Aug 11, 2023
matifali
matifali previously approved these changes Aug 11, 2023
@@ -20,6 +20,7 @@ export CODER_TEMPLATE_DIR=.coder/templates/kubernetes
export CODER_TEMPLATE_VERSION=$(git rev-parse --short HEAD)

# Push the new template version to Coder
coder login <access-url> --token $CODER_SESSION_TOKEN
Copy link
Member

@matifali matifali Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or they can set $CODER_URL as a sceret/environment variable in CI. Then they do not need <access-url>

Also we do not need to login if we have $CODER_SESSION_TOKEN and $CODER_URL available as environment varibales
See how we do this for dogfood,

./coder templates push $CODER_TEMPLATE_NAME --directory $CODER_TEMPLATE_DIR --yes --name=$CODER_TEMPLATE_VERSION --message="$CODER_TEMPLATE_MESSAGE"

also in update-coder-template github action,
https://github.com/matifali/update-coder-template/blob/main/push_template.sh

Copy link
Member Author

@ericpaulsen ericpaulsen Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matifali this is not working for me:

coder templates create auth-test
running command "coder templates push": You are not logged in. Try logging in using 'coder login <url>'.:
    github.com/coder/coder/cli.init                                                                      
        /home/runner/actions-runner/_work/coder/coder/cli/root.go:74                                     

✗  echo $CODER_SESSION_TOKEN
KbqY3sl...hGS8lPj
 echo $CODER_URL
eric.oss.demo.coder.com

Copy link
Member

@matifali matifali Aug 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are you setting the variables. You need to use

export CODER_SESSION_TOKEN=KbqY3sl...hGS8lPj
export CODER_URL=eric.oss.demo.coder.com
coder templates create auth-test

@matifali matifali dismissed their stale review August 11, 2023 14:22

wrongly approved

@matifali
Copy link
Member

@ericpaulsen we don't need to login because we already have the $CODER_SESSION_TOKEN
coder templates push work without a need to login. So I don't think we need to add this to docs.

@ericpaulsen
Copy link
Member Author

@matifali this worked for me:

coder templates create auth-test --token $CODER_SESSION_TOKEN --url $CODER_URL

although our docs do not include the --token and --url flags in the coder templates push command. does this need to be corrected?

@matifali
Copy link
Member

matifali commented Aug 11, 2023

@ericpaulsen they are mot required. Coder cli can automatically read these environment variables.
also if you are passing them as --url and --token then you don’t need have those environment variables.

1st approach

coder templates create auth-test 

given $CODER_SESSION_TOKEN and $CODER_URL are available

2nd approach

coder templates create auth-test --token some-token --url dev.coder.com

Copy link
Contributor

@sharkymark sharkymark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could also pass the --url for each coder command along with --token

@ericpaulsen
Copy link
Member Author

@matifali the 1st approach does not work for me, as shown in this comment. i will push a commit with the --url and --token flags.

@ericpaulsen ericpaulsen enabled auto-merge (squash) August 11, 2023 20:43
@ericpaulsen ericpaulsen merged commit 6af6e85 into main Aug 11, 2023
@ericpaulsen ericpaulsen deleted the fix-change-management-docs branch August 11, 2023 20:55
@github-actions github-actions bot locked and limited conversation to collaborators Aug 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
docs Area: coder.com/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants