Skip to content

Commit b6fd000

Browse files
authored
Merge branch 'master' into apptrust-auth-config
2 parents 4307ac2 + db72a3e commit b6fd000

File tree

8 files changed

+300
-8
lines changed

8 files changed

+300
-8
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
version: 2
2-
updates:
1+
version: 2
2+
updates:
33
- package-ecosystem: "gomod"
44
directory: "/"
55
schedule:
@@ -18,5 +18,6 @@
1818
groups:
1919
github-actions:
2020
update-types:
21+
- major
2122
- minor
22-
- patch
23+
- patch

.github/workflows/dependabot-auto-merge.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,45 @@ jobs:
1313
runs-on: ubuntu-latest
1414
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'jfrog/jfrog-cli-core'
1515
steps:
16+
- name: Checkout PR code
17+
uses: actions/checkout@v5
18+
with:
19+
ref: ${{ github.event.pull_request.head.sha }}
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Add 'ignore for release' label
23+
run: |
24+
gh pr edit ${{ github.event.pull_request.number }} --add-label "ignore for release"
25+
env:
26+
GH_TOKEN: ${{ secrets.CLI_ACTION_TOKEN }}
27+
28+
- name: Approve PR
29+
run: gh pr review --approve "$PR_URL"
30+
env:
31+
PR_URL: ${{github.event.pull_request.html_url}}
32+
GH_TOKEN: ${{secrets.CLI_ACTION_TOKEN}}
33+
1634
- name: Dependabot metadata
1735
id: metadata
1836
uses: dependabot/[email protected]
1937
with:
2038
github-token: "${{ secrets.GITHUB_TOKEN }}"
39+
40+
- name: Run make update-all for go dependencies
41+
if: steps.metadata.outputs.dependency-group == 'go'
42+
run: make update-all
43+
44+
- name: Check for changes and commit
45+
if: steps.metadata.outputs.dependency-group == 'go'
46+
run: |
47+
if [ -n "$(git status --porcelain)" ]; then
48+
git config --local user.email "[email protected]"
49+
git config --local user.name "github-actions[bot]"
50+
git add .
51+
git commit -m "Update JFrog dependencies via make update-all"
52+
git push
53+
fi
54+
2155
- name: Enable auto-merge for Dependabot PRs
2256
run: gh pr merge --auto --squash "$PR_URL"
2357
env:

.github/workflows/monitor-stale.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ on:
55
operations-per-run:
66
description: "Number of operations per run"
77
required: false
8-
default: "30"
8+
default: "50"
99
schedule:
1010
- cron: "0 0 * * *" # Runs once a day at midnight
1111
jobs:
1212
monitor-issues-and-pull-requests:
1313
runs-on: ubuntu-latest
1414
permissions:
15+
actions: write
1516
issues: write
17+
pull-requests: write
1618
steps:
1719
- uses: actions/stale@v10
1820
with:
19-
# Ignore issues with these labels
20-
exempt-issue-labels: "feature request,question"
2121
# Days of inactivity before marking an issue as stale
2222
days-before-stale: 180
2323
# Days of inactivity before closing an issue
@@ -31,5 +31,5 @@ jobs:
3131
close-pr-message: "This pull-request was closed due to 7 days of inactivity after being marked as stale. Feel free to reopen it if it remains relevant."
3232
ascending: true
3333
# Get from input or resolve to default
34-
operations-per-run: ${{ github.event.inputs.operations-per-run || '30' }}
34+
operations-per-run: ${{ github.event.inputs.operations-per-run || '50' }}
3535
repo-token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Update JFrog Dependencies
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
jobs:
11+
update-dependencies:
12+
name: Update JFrog Dependencies
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Generate timestamp
16+
id: timestamp
17+
run: echo "timestamp=$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT
18+
19+
- name: Checkout main branch
20+
uses: actions/checkout@v5
21+
with:
22+
ref: master
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Create and checkout new branch
26+
id: branch
27+
run: |
28+
BRANCH_NAME="use-latest-jf-dependencies-${{ steps.timestamp.outputs.timestamp }}"
29+
git config --local user.email "[email protected]"
30+
git config --local user.name "github-actions[bot]"
31+
git checkout -b "$BRANCH_NAME"
32+
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
33+
34+
- name: Run make update-all
35+
run: make update-all
36+
37+
- name: Check for changes and commit
38+
id: changes
39+
run: |
40+
if [ -n "$(git status --porcelain)" ]; then
41+
git add .
42+
git commit -m "Update JFrog dependencies to latest versions
43+
44+
- Updated archiver to latest version
45+
- Updated client-go to latest main branch
46+
- Updated gofrog to latest main branch
47+
- Ran go mod tidy to clean up dependencies
48+
49+
Generated by workflow: ${{ github.workflow }}"
50+
git push origin "${{ steps.branch.outputs.branch_name }}"
51+
echo "has_changes=true" >> $GITHUB_OUTPUT
52+
else
53+
echo "has_changes=false" >> $GITHUB_OUTPUT
54+
echo "No changes detected, skipping PR creation"
55+
fi
56+
57+
- name: Create Pull Request
58+
if: steps.changes.outputs.has_changes == 'true'
59+
run: |
60+
gh pr create \
61+
--title "Update JFrog dependencies to latest versions" \
62+
--body "This PR updates all JFrog dependencies to their latest versions:
63+
64+
- **build-info-go**: Updated to latest main branch
65+
- **client-go**: Updated to latest main branch
66+
- **gofrog**: Updated to latest main branch
67+
- **go.mod**: Cleaned up with \`go mod tidy\`
68+
69+
Generated automatically by workflow: \`${{ github.workflow }}\`
70+
71+
**Branch**: \`${{ steps.branch.outputs.branch_name }}\`
72+
**Timestamp**: \`${{ steps.timestamp.outputs.timestamp }}\`" \
73+
--base master \
74+
--head "${{ steps.branch.outputs.branch_name }}"
75+
env:
76+
GH_TOKEN: ${{ secrets.CLI_ACTION_TOKEN }}
77+
78+
- name: Get PR number
79+
if: steps.changes.outputs.has_changes == 'true'
80+
id: pr_number
81+
run: |
82+
PR_NUMBER=$(gh pr list --head "${{ steps.branch.outputs.branch_name }}" --json number --jq '.[0].number')
83+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
84+
env:
85+
GH_TOKEN: ${{ secrets.CLI_ACTION_TOKEN }}
86+
87+
- name: Approve Pull Request
88+
if: steps.changes.outputs.has_changes == 'true'
89+
run: |
90+
gh pr review --approve "${{ steps.pr_number.outputs.pr_number }}"
91+
env:
92+
GH_TOKEN: ${{ secrets.CLI_ACTION_TOKEN }}
93+
94+
- name: Enable auto-merge
95+
if: steps.changes.outputs.has_changes == 'true'
96+
run: |
97+
gh pr merge --auto --squash "${{ steps.pr_number.outputs.pr_number }}"
98+
env:
99+
GH_TOKEN: ${{ secrets.CLI_ACTION_TOKEN }}

Makefile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Makefile for jfrog-client-go
2+
3+
.PHONY: $(MAKECMDGOALS)
4+
5+
# Default target
6+
help:
7+
@echo "Available targets:"
8+
@echo " update-all - Update all JFrog dependencies to latest versions"
9+
@echo " update-build-info-go - Update build-info-go to latest main branch"
10+
@echo " update-client-go - Update client-go to latest main branch"
11+
@echo " update-gofrog - Update gofrog to latest main branch"
12+
@echo " clean - Clean build artifacts"
13+
@echo " test - Run tests"
14+
@echo " build - Build the project"
15+
16+
# Update all JFrog dependencies
17+
update-all: update-build-info-go update-client-go update-gofrog
18+
@echo "All JFrog dependencies updated successfully!"
19+
@GOPROXY=direct go mod tidy
20+
21+
# Update build-info-go to latest main branch (using direct proxy to bypass Artifactory)
22+
update-build-info-go:
23+
@echo "Updating build-info-go to latest main branch..."
24+
@GOPROXY=direct go get github.com/jfrog/build-info-go@main
25+
@echo "build-info-go updated successfully!"
26+
27+
# Update gofrog to latest main branch
28+
update-client-go:
29+
@echo "Updating client-go to latest main branch..."
30+
@GOPROXY=direct go get github.com/jfrog/jfrog-client-go@master
31+
@echo "client-go updated successfully!"
32+
33+
# Update gofrog to latest main branch
34+
update-gofrog:
35+
@echo "Updating gofrog to latest main branch..."
36+
@GOPROXY=direct go get github.com/jfrog/gofrog@master
37+
@echo "gofrog updated successfully!"
38+
39+
# Clean build artifacts
40+
clean:
41+
@echo "Cleaning build artifacts..."
42+
@go clean
43+
@go clean -cache
44+
@go clean -modcache
45+
46+
# Run tests
47+
test:
48+
@echo "Running tests..."
49+
@go test ./...
50+
51+
# Build the project
52+
build:
53+
@echo "Building project..."
54+
@go build ./...

plugins/common/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func CreateServerDetailsFromFlags(c *components.Context) (details *config.Server
6161
details.ServerId = os.Getenv(coreutils.ServerID)
6262
}
6363
details.InsecureTls = c.GetBoolFlagValue("insecure-tls")
64+
details.DisableTokenRefresh = c.GetBoolFlagValue("disable-token-refresh")
6465
return
6566
}
6667

utils/config/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ type ServerDetails struct {
603603
IsDefault bool `json:"isDefault,omitempty"`
604604
InsecureTls bool `json:"-"`
605605
WebLogin bool `json:"webLogin,omitempty"`
606+
DisableTokenRefresh bool `json:"disableTokenRefresh,omitempty"`
606607
}
607608

608609
// Deprecated
@@ -814,7 +815,7 @@ func (serverDetails *ServerDetails) createAuthConfig(details auth.ServiceDetails
814815
// If refresh token is not empty, set a refresh handler and skip other credentials.
815816
// First we check access's token, if empty we check artifactory's token.
816817
switch {
817-
case serverDetails.RefreshToken != "":
818+
case serverDetails.RefreshToken != "" && !serverDetails.DisableTokenRefresh:
818819
// Save serverId for refreshing if needed. If empty serverId is saved, default will be used.
819820
tokenRefreshServerId = serverDetails.ServerId
820821
details.AppendPreRequestFunction(AccessTokenRefreshPreRequestInterceptor)

utils/config/config_test.go

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
1717
"github.com/jfrog/jfrog-cli-core/v2/utils/log"
18+
artifactoryAuth "github.com/jfrog/jfrog-client-go/artifactory/auth"
1819
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
1920
"github.com/stretchr/testify/assert"
2021
)
@@ -421,3 +422,104 @@ func assertCertsMigration(t *testing.T) {
421422
// Verify only the certs were moved
422423
assert.Len(t, files, 2)
423424
}
425+
426+
func TestCreateAuthConfigAppendPreRequestFunctionBehavior(t *testing.T) {
427+
test := []struct {
428+
name string
429+
serverDetails *ServerDetails
430+
shouldCallAppendPreRequest bool
431+
}{
432+
{
433+
name: "DisableTokenRefreshTrue_NoRefreshTokens",
434+
serverDetails: &ServerDetails{
435+
ServerId: "test-server",
436+
AccessToken: "access-token-123",
437+
User: "testuser",
438+
Password: "testpass",
439+
DisableTokenRefresh: true,
440+
},
441+
shouldCallAppendPreRequest: false,
442+
},
443+
{
444+
name: "DisableTokenRefreshTrue_WithRefreshToken",
445+
serverDetails: &ServerDetails{
446+
ServerId: "test-server",
447+
AccessToken: "access-token-123",
448+
RefreshToken: "refresh-token-456",
449+
User: "testuser",
450+
Password: "testpass",
451+
DisableTokenRefresh: true,
452+
},
453+
shouldCallAppendPreRequest: false,
454+
},
455+
{
456+
name: "DisableTokenRefreshFalse_WithRefreshToken",
457+
serverDetails: &ServerDetails{
458+
ServerId: "test-server",
459+
AccessToken: "access-token-123",
460+
RefreshToken: "refresh-token-456",
461+
User: "testuser",
462+
Password: "testpass",
463+
DisableTokenRefresh: false,
464+
},
465+
shouldCallAppendPreRequest: true,
466+
},
467+
{
468+
name: "DisableTokenRefreshDefault_WithRefreshToken",
469+
serverDetails: &ServerDetails{
470+
ServerId: "test-server",
471+
AccessToken: "access-token-123",
472+
RefreshToken: "refresh-token-456",
473+
User: "testuser",
474+
Password: "testpass",
475+
},
476+
shouldCallAppendPreRequest: true,
477+
},
478+
{
479+
name: "DisableTokenRefreshTrue_WithArtifactoryRefreshToken",
480+
serverDetails: &ServerDetails{
481+
ServerId: "test-server",
482+
AccessToken: "access-token-123",
483+
ArtifactoryRefreshToken: "artifactory-refresh-token-789",
484+
User: "testuser",
485+
Password: "testpass",
486+
DisableTokenRefresh: true,
487+
},
488+
shouldCallAppendPreRequest: true,
489+
},
490+
{
491+
name: "DisableTokenRefreshFalse_WithArtifactoryRefreshToken",
492+
serverDetails: &ServerDetails{
493+
ServerId: "test-server",
494+
AccessToken: "access-token-123",
495+
ArtifactoryRefreshToken: "artifactory-refresh-token-789",
496+
User: "testuser",
497+
Password: "testpass",
498+
DisableTokenRefresh: false,
499+
},
500+
shouldCallAppendPreRequest: true,
501+
},
502+
}
503+
504+
for _, tt := range test {
505+
t.Run(tt.name, func(t *testing.T) {
506+
artDetails := artifactoryAuth.NewArtifactoryDetails()
507+
artDetails.SetUrl("https://test.com/artifactory/")
508+
509+
result, err := tt.serverDetails.createAuthConfig(artDetails)
510+
511+
assert.NoError(t, err)
512+
assert.Equal(t, artDetails, result)
513+
514+
if tt.shouldCallAppendPreRequest {
515+
// AppendPreRequestFunction was called - should use token refresh, not basic auth
516+
assert.Equal(t, "", result.GetUser(), "User should be empty when AppendPreRequestFunction is called (token refresh enabled)")
517+
assert.Equal(t, "", result.GetPassword(), "Password should be empty when AppendPreRequestFunction is called (token refresh enabled)")
518+
} else {
519+
// AppendPreRequestFunction was NOT called - should use basic auth
520+
assert.Equal(t, tt.serverDetails.User, result.GetUser(), "User should be set when AppendPreRequestFunction is NOT called (basic auth)")
521+
assert.Equal(t, tt.serverDetails.Password, result.GetPassword(), "Password should be set when AppendPreRequestFunction is NOT called (basic auth)")
522+
}
523+
})
524+
}
525+
}

0 commit comments

Comments
 (0)