Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion common/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ func exchangeOidcTokenAndSetAccessToken(cc *ConfigCommand) error {
SetAudience(cc.oidcSetupParams.Audience).
SetApplicationKey(cc.oidcSetupParams.ApplicationKey).
SetProjectKey(cc.oidcSetupParams.ProjectKey).
SetRepository(cc.oidcSetupParams.Repository).
SetVcsRevision(os.Getenv(coreutils.CIVcsRevision)).
SetVcsUrl(os.Getenv(coreutils.CIVcsUrl)).
SetVcsBranch(os.Getenv(coreutils.CIVcsBranch)).
SetJobId(cc.oidcSetupParams.JobId).
SetRunId(cc.oidcSetupParams.RunId).
SetVcsRevision(cc.oidcSetupParams.VcsRevision).
Expand Down
32 changes: 10 additions & 22 deletions general/token/oidctokenexchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ type OidcParams struct {
ApplicationKey string
JobId string
RunId string
Repository string
VcsRevision string
VcsUrl string
VcsBranch string
VcsRevision string
}

type ExchangeCommandOutputStruct struct {
Expand Down Expand Up @@ -132,23 +131,18 @@ func (otc *OidcTokenExchangeCommand) SetJobId(jobId string) *OidcTokenExchangeCo
return otc
}

func (otc *OidcTokenExchangeCommand) SetRepository(repo string) *OidcTokenExchangeCommand {
otc.Repository = repo
func (otc *OidcTokenExchangeCommand) SetVcsRevision(revision string) *OidcTokenExchangeCommand {
otc.VcsRevision = revision
return otc
}

func (otc *OidcTokenExchangeCommand) SetVcsUrl(vcsUrl string) *OidcTokenExchangeCommand {
otc.VcsUrl = vcsUrl
func (otc *OidcTokenExchangeCommand) SetVcsUrl(url string) *OidcTokenExchangeCommand {
otc.VcsUrl = url
return otc
}

func (otc *OidcTokenExchangeCommand) SetVcsBranch(vcsBranch string) *OidcTokenExchangeCommand {
otc.VcsBranch = vcsBranch
return otc
}

func (otc *OidcTokenExchangeCommand) SetVcsRevision(vcsRevision string) *OidcTokenExchangeCommand {
otc.VcsRevision = vcsRevision
func (otc *OidcTokenExchangeCommand) SetVcsBranch(branch string) *OidcTokenExchangeCommand {
otc.VcsBranch = branch
return otc
}

Expand Down Expand Up @@ -207,17 +201,11 @@ func (otc *OidcTokenExchangeCommand) getOidcTokenParams() services.CreateOidcTok
oidcTokenParams.ApplicationKey = otc.ApplicationKey
oidcTokenParams.RunId = otc.RunId
oidcTokenParams.JobId = otc.JobId
oidcTokenParams.Repo = otc.Repository
oidcTokenParams.Repo = otc.VcsUrl
oidcTokenParams.Revision = otc.VcsRevision
oidcTokenParams.Branch = otc.VcsBranch
oidcTokenParams.Audience = otc.Audience
oidcTokenParams.ProviderName = otc.ProviderName
oidcTokenParams.ProviderType = otc.ProviderType.String()
oidcTokenParams.Context = &services.Context{
VcsCommit: &services.VcsCommit{
VcsUrl: otc.VcsUrl,
Branch: otc.VcsBranch,
Revision: otc.VcsRevision,
},
}

return oidcTokenParams
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/jedib0t/go-pretty/v6 v6.6.8
github.com/jfrog/build-info-go v1.11.0
github.com/jfrog/gofrog v1.7.6
github.com/jfrog/jfrog-client-go v1.55.1-0.20250925090554-63938590da62
github.com/jfrog/jfrog-client-go v1.55.1-0.20250925123235-756731f0df63
github.com/magiconair/properties v1.8.10
github.com/manifoldco/promptui v0.9.0
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ github.com/jfrog/build-info-go v1.11.0 h1:qEONCgaHKlW3e2y0zIwTZVbgS/ERZrPlBWEbOY
github.com/jfrog/build-info-go v1.11.0/go.mod h1:szdz9+WzB7+7PGnILLUgyY+OF5qD5geBT7UGNIxibyw=
github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
github.com/jfrog/jfrog-client-go v1.55.1-0.20250925090554-63938590da62 h1:Zuu/tRXKmta4WFkCMAAUKgzs9Je0VXqg90/qJIBsbrk=
github.com/jfrog/jfrog-client-go v1.55.1-0.20250925090554-63938590da62/go.mod h1:UYhn61e3VNb7Oo4dWpzI9TaObxTbdFosagEfcPlkvmg=
github.com/jfrog/jfrog-client-go v1.55.1-0.20250925123235-756731f0df63 h1:jA1EVmPljElsEb8pGboWgf1oDVGj52l8u5hYRmwYMz4=
github.com/jfrog/jfrog-client-go v1.55.1-0.20250925123235-756731f0df63/go.mod h1:UYhn61e3VNb7Oo4dWpzI9TaObxTbdFosagEfcPlkvmg=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down
21 changes: 10 additions & 11 deletions utils/coreutils/coreconsts.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,21 @@ const (

// Although these vars are constant, they are defined inside a vars section and not a constants section because the tests modify these values.
var (
HomeDir = "JFROG_CLI_HOME_DIR"
BuildName = "JFROG_CLI_BUILD_NAME"
BuildNumber = "JFROG_CLI_BUILD_NUMBER"
BuildUrl = "JFROG_CLI_BUILD_URL"
EnvExclude = "JFROG_CLI_ENV_EXCLUDE"
Project = "JFROG_CLI_BUILD_PROJECT"
ApplicationKey = "JFROG_CLI_APPLICATION_KEY"
SourceCodeRepository = "JFROG_CLI_SOURCECODE_REPOSITORY"
SigningKey = "JFROG_CLI_SIGNING_KEY"
KeyAlias = "JFROG_CLI_KEY_ALIAS"
HomeDir = "JFROG_CLI_HOME_DIR"
BuildName = "JFROG_CLI_BUILD_NAME"
BuildNumber = "JFROG_CLI_BUILD_NUMBER"
BuildUrl = "JFROG_CLI_BUILD_URL"
EnvExclude = "JFROG_CLI_ENV_EXCLUDE"
Project = "JFROG_CLI_BUILD_PROJECT"
ApplicationKey = "JFROG_CLI_APPLICATION_KEY"
SigningKey = "JFROG_CLI_SIGNING_KEY"
KeyAlias = "JFROG_CLI_KEY_ALIAS"
//#nosec G101
EncryptionKey = "JFROG_CLI_ENCRYPTION_KEY"
// For CI runs
CIJobID = "JFROG_CLI_CI_JOB_ID"
CIRunID = "JFROG_CLI_CI_RUN_ID"
CIVcsUrl = "JFROG_CLI_CI_VCS_URL"
CIVcsRevision = "JFROG_CLI_CI_VCS_REVISION"
CIVcsBranch = "JFROG_CLI_CI_BRANCH"
CIVcsUrl = "JFROG_CLI_CI_VCS_URL"
)
2 changes: 1 addition & 1 deletion utils/usage/visibility/commands_count_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewCommandsCountMetric(commandName string) services.VisibilityMetric {
ProviderType: os.Getenv(coreutils.OidcProviderType),
JobID: os.Getenv(coreutils.CIJobID),
RunID: os.Getenv(coreutils.CIRunID),
GitRepo: os.Getenv(coreutils.SourceCodeRepository),
GitRepo: os.Getenv(coreutils.CIVcsUrl),
GhTokenForCodeScanningAlertsProvided: os.Getenv("JFROG_CLI_USAGE_GH_TOKEN_FOR_CODE_SCANNING_ALERTS_PROVIDED"),
Flags: "",
Platform: "",
Expand Down
14 changes: 7 additions & 7 deletions utils/usage/visibility/commands_count_metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
func TestCreateCommandsCountMetric(t *testing.T) {
// Set environment variables for the test using SetEnvWithCallbackAndAssert
envVars := map[string]string{
coreutils.CIJobID: "job123",
coreutils.CIRunID: "run456",
coreutils.SourceCodeRepository: "test-repo",
coreutils.OidcProviderType: token.GitHub.String(),
coreutils.CIJobID: "job123",
coreutils.CIRunID: "run456",
coreutils.CIVcsUrl: "test-repo",
coreutils.OidcProviderType: token.GitHub.String(),
"JFROG_CLI_USAGE_GH_TOKEN_FOR_CODE_SCANNING_ALERTS_PROVIDED": "TRUE",
}
cleanupFuncs := []func(){}
Expand Down Expand Up @@ -169,9 +169,9 @@ func TestCommandsCountLabelsJSONSerialization(t *testing.T) {
func TestEnhancedMetricsEnvironmentIntegration(t *testing.T) {
// Set environment variables for the test (using the keys consumed by the code)
envVars := map[string]string{
coreutils.CIJobID: "test-job-123",
coreutils.CIRunID: "test-run-456",
coreutils.SourceCodeRepository: "owner/repo",
coreutils.CIJobID: "test-job-123",
coreutils.CIRunID: "test-run-456",
coreutils.CIVcsUrl: "owner/repo",
}
cleanupFuncs := []func(){}
for key, value := range envVars {
Expand Down
Loading