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

WIP Secret Source Implementation #4514

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

WIP Secret Source Implementation #4514

wants to merge 1 commit into from

Conversation

mstoykov
Copy link
Contributor

@mstoykov mstoykov commented Feb 5, 2025

What?

Adds an extensible secret sources. Basically #4139 but without http secret source as that turned out to have too many configuration problems. But it has a mock secret source which basically gets them form the cli arguments - probably should be renamed.

Usage:

import { secrets } from "k6";

export default () => {
	const my_secret = secrets.get("cool"); // get secret from a source with the provided identifier
	console.log(my_secret);
	secrets.get("else"); // get secret from a source with the provided identifier
	console.log(my_secret);
}
go run . run --secret-source=mock=cool=some:else=source script.js

image

or with a secret file:

cool=some
else=source
go run . run --secret-source=file=file.secret script.js

The extension points are under ./secretsource and mostly around the Get method which gets a secret and returns it.

The rest of k6 makes certain to not request it again and redact it from logs.

TODO:

  • Should we throw an exception or return undefined on errors, or at least on not found secrets.
  • Multiple secret sources is almost done bu not quite
  • Unit Tests and likely some integration ones will be nice
  • Have HTTP secret source? Maybe for later version
  • Configuration currently only happens from CLI flags whihc might not be ideal and is definitely problematic as , is special so you need ot use some other character for separation like : in the mock configuraiton.
  • Having Name be parsed by the internal parts before we actually make the secret source
  • Having a way to define a Default secret source when named ones are also possible.
  • Some Benchmarks will be nice
  • Docs of any kind

Why?

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

@mstoykov mstoykov linked an issue Feb 5, 2025 that may be closed by this pull request
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.

Secrets Source extensions
1 participant