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

feat: add Cloudsmith auth #710

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

feat: add Cloudsmith auth #710

wants to merge 9 commits into from

Conversation

rowanmanning
Copy link
Member

@rowanmanning rowanmanning commented Nov 13, 2024

Description

This adds in the orb to authenticate with Cloudsmith via OIDC. I'm not sure what the next step is to be honest, because the orb works differently to the AWS login one. The only way to auth with Cloudsmith via this orb is by setting two environment variables:

  • CLOUDSMITH_ORGANISATION
  • CLOUDSMITH_SERVICE_ACCOUNT

I'd rather these be Tool Kit options because that means the values (non-secrets) are stored as config in our apps. It also means we can default the financial-times one more easily.

What I don't know how to do is to convert a Tool Kit option to environment variables before we auth and pass them along in a way that means we don't try to auth with Cloudsmith if the options aren't present. Help?

Checklist:

  • My branch has been rebased onto the latest commit on main (don't merge main into your branch)
  • My commit messages are conventional commits, for example: feat(circleci): add support for nightly workflows, fix: set Heroku app name for staging apps too

@ivomurrell
Copy link
Contributor

What I don't know how to do is to convert a Tool Kit option to environment variables before we auth and pass them along in a way that means we don't try to auth with Cloudsmith if the options aren't present. Help?

I think we should add the values as other parameters for the orb job and set them as environment variables. We can then pass those parameters in the CircleCI config generated by Tool Kit.

@ivomurrell
Copy link
Contributor

I've pushed a commit to this branch to illustrate my idea – hope that's okay!

@rowanmanning rowanmanning force-pushed the cloudsmith-orb branch 2 times, most recently from 155f2bc to e39055b Compare November 14, 2024 15:22
@rowanmanning rowanmanning marked this pull request as ready for review November 14, 2024 15:22
@rowanmanning rowanmanning requested a review from a team as a code owner November 14, 2024 15:22
Copy link
Contributor

@ivomurrell ivomurrell left a comment

Choose a reason for hiding this comment

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

I'll fix the issues myself don't worry 😁

plugins/circleci-deploy/.toolkitrc.yml Outdated Show resolved Hide resolved
plugins/circleci-deploy/.toolkitrc.yml Outdated Show resolved Hide resolved
@ivomurrell ivomurrell changed the base branch from main to circleci-workflow-jobs November 27, 2024 14:57
@ivomurrell ivomurrell force-pushed the circleci-workflow-jobs branch from fac03cd to e33e579 Compare November 27, 2024 16:18
Base automatically changed from circleci-workflow-jobs to main November 27, 2024 16:20
@ivomurrell ivomurrell force-pushed the cloudsmith-orb branch 2 times, most recently from fc135e1 to 8f968e3 Compare December 3, 2024 17:28
@ivomurrell
Copy link
Contributor

ivomurrell commented Dec 3, 2024

@rowanmanning do you have any suggestions for better descriptions for the new Cloudsmith options? 😅 I haven't done enough research into how Cloudsmith works yet to be able to write these intelligently

@rowanmanning
Copy link
Member Author

Meh nah I think they're fine for now, feel a bit redundant but we can always tweak later if we thinking of something better

@@ -30,6 +30,10 @@ options:
!toolkit/if-defined '@dotcom-tool-kit/serverless.awsAccountId':
aws-account-id: !toolkit/option '@dotcom-tool-kit/serverless.awsAccountId'
system-code: !toolkit/option '@dotcom-tool-kit/serverless.systemCode'
!toolkit/if-defined '@dotcom-tool-kit/cloudsmith.organisation':
cloudsmith-org: !toolkit/option '@dotcom-tool-kit/cloudsmith.organisation'
Copy link
Member

Choose a reason for hiding this comment

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

question: Could these parameters be CircleCI contexts or environment variables in Doppler?

Copy link
Member Author

Choose a reason for hiding this comment

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

I looked at environment variables but:

  1. I think it's better for this option to sit alongside the code, it mirrors how we do other things like configuring the doppler project.
  2. Params simplify migration because you can hopefully make the switch with only Tool Kit config changes and nothing else (e.g. no further instructions to add stuff to Doppler)
  3. It's really only the the cloudsmith-service-account which rarely (almost never) changes, unless a repo changes team ownership. The cloudsmith-org is hard-coded which isn't as possible to do via environment variables

rowanmanning and others added 9 commits December 16, 2024 11:45
This adds in the orb to authenticate with Cloudsmith via OIDC. Our
Cloudsmith orb requires two environment variables to work:

  * CLOUDSMITH_ORGANISATION
  * CLOUDSMITH_SERVICE_ACCOUNT

To allow us to specify these in Tool Kit config instead (which is a lot
cleaner, the config lives in the code etc) we need to define a schema
for a nonexistent `cloudsmith` plugin and then pass params through into
the CircleCI config.

Co-Authored-By: Alex Muller <[email protected]>
Co-Authored-By: Ivo Murrell <[email protected]>
Tool Kit will not allow you to declare options for plugins that don't
exist (to avoid the likely case that there was a typo), but we want to
declare Cloudsmith specific options that are used to generate CircleCI
config. Declare a barebones plugin to facilitate this.
Tool Kit will be able to merge the additional custom CircleCI config
into the configuration already defined by the circleci-deploy plugin.
This will allow users to explicitly opt into the cloudsmith logic by
installing the plugin, and compartmentalises the configuration.
This is primarily so that our git hook can automatically fill in
autogenerated docs where appropriate.
We'll likely never the flexibility to set a different organisation.

Co-Authored-By: Rowan Manning <[email protected]>
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

Successfully merging this pull request may close these issues.

3 participants