Repository navigation
feat(moduleauthority): WorkloadTokenFile names the module's projected token wherever Codefly runs it - #41
Merged
Conversation
… token wherever Codefly runs it Since codefly CLI v0.1.187 (codefly-dev/cli#977) a native `codefly run` stands in for the cell and projects each module workload's token to a file it names in CODEFLY__WORKLOAD_TOKEN_FILE, because a process cannot read the pod mount path. Every module consumer hardcoded /var/run/secrets/codefly/token and so minted nothing under a native run. WorkloadTokenFile() returns the file the variable names when it is set to a non-blank value, and the pod mount otherwise. The variable and the mount are exported (WorkloadTokenFileVariable, PodWorkloadTokenFile); solution-runtime-go reads the same variable. The token is still read before every mint. The CHANGELOG's stale "Unreleased" heading is renamed to v0.1.2, the tag that carries it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
One owner for "where is this module's projected token". Since codefly CLI v0.1.187 (codefly-dev/cli#977), a native
codefly runstands in for the cell. It projects each module workload's token to a file and names that file inCODEFLY__WORKLOAD_TOKEN_FILE, because a process cannot read the pod mount path (clicmd/run/native_cluster.go,workloadTokenFileVariable). Every module consumer ofmoduleauthorityhardcodes/var/run/secrets/codefly/token, so under a native run it opens a path that does not exist and mints nothing. This SDK owns the module's credential source, so the lookup belongs here and not in each module.What changed
moduleauthority.WorkloadTokenFile() ProjectedTokenFilereturns the fileCODEFLY__WORKLOAD_TOKEN_FILEnames when it is set to a non-blank value (trimmed), and/var/run/secrets/codefly/tokenotherwise. It resolves the path only. The token is still read before every mint, so rotation behaves as before.WorkloadTokenFileVariable(CODEFLY__WORKLOAD_TOKEN_FILE) andPodWorkloadTokenFile(/var/run/secrets/codefly/token).ProjectedTokenFileis unchanged and still has no default. Its doc comment and the README'smoduleauthorityexample now point atWorkloadTokenFile().Unreleased / Addedentry. The heading previously labelled "Unreleased" is renamed tov0.1.2, because tag v0.1.2 (e539835) already carries that section.Tests
moduleauthority/workload_token_test.go:TestWorkloadTokenFileFollowsTheVariableAndFallsBackToTheMount: an unset variable gives the pod mount, a blank one gives the pod mount, and a named file is returned trimmed and its token is read throughProjectedToken().TestWorkloadTokenNamesAreTheCodeflyContract: pins both names, because they are contracts with the CLI and the cell render, not choices made here.Reuse
codefly-dev/solution-runtime-goalready reads (ProjectedTokenFileEnvironmentVariableinsolution.go). It is not a new name.ProjectedTokenFilesource with its 64 KiB bound and its empty-token refusal. No second token reader was written.workload-identity/TOKEN_FILEworkspace-configuration lookup that solution-runtime-go also does. That goes throughcodefly.For(ctx)from sdk-go, which this package does not import. A module consumer can still passProjectedTokenFile(path)for any other projection.Classification
This is a fix at the owner. The consumer that motivated it is obin-ai/module-record-store (
services/records/code/configure_platform.go). That repo pins saas-sdk-go v0.1.0 on core v0.7.0, while every tag from v0.1.2 on requires core v0.19.1, so it cannot consume this until the fleet's core move lands there. Until then it carries the same lookup locally, labelled as a stopgap naming this PR.Verified / not verified
go.mod(go build,go vet,go test -count=1,go test -race), plusgofmt -lwith no output outsidegen/.internal/apiboundaryandinternal/agentcontextboth pass.codefly runminting through this helper.gen/andSOURCE.txtare untouched, sogen-driftandhost-gateway-conformanceshould be unaffected. Not released: releasing follows this repo's own process.🤖 Generated with Claude Code