Skip to content

Commit b72bb08

Browse files
authored
Added Capability for docker sha based pull (#3273)
1 parent 6ef51dd commit b72bb08

File tree

5 files changed

+98
-9
lines changed

5 files changed

+98
-9
lines changed

buildtools/cli.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ func GetCommands() []cli.Command {
357357
},
358358
{
359359
Name: "conan",
360+
Hidden: true,
360361
Flags: cliutils.GetCommandFlags(cliutils.Conan),
361362
Usage: conan.GetDescription(),
362363
HelpName: corecommon.CreateUsage("conan", conan.GetDescription(), conan.Usage),

docker_test.go

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ func TestDockerLoginWithServer(t *testing.T) {
736736
} else {
737737
credentials = "--user=" + *tests.JfrogUser + " --password=" + *tests.JfrogPassword
738738
}
739-
err := coreTests.NewJfrogCli(execMain, "jfrog config", credentials).Exec("add", "artDocker", "--interactive=false", "--url="+"http://localhost:8082", "--enc-password="+strconv.FormatBool(true))
739+
err := coreTests.NewJfrogCli(execMain, "jfrog config", credentials).Exec("add", "artDocker", "--interactive=false", "--url="+"http://localhost:8082", "--enc-password="+strconv.FormatBool(true), "--overwrite")
740740
assert.NoError(t, err)
741741

742742
imageName := path.Join(*tests.ContainerRegistry, tests.DockerRemoteRepo, "alpine:latest")
@@ -1158,3 +1158,92 @@ CMD ["sh"]`, baseImage)
11581158

11591159
inttestutils.DeleteBuild(serverDetails.ArtifactoryUrl, buildName, artHttpDetails)
11601160
}
1161+
1162+
func TestContainerPullWithSha(t *testing.T) {
1163+
cleanup := initNativeDockerWithArtTest(t)
1164+
defer cleanup()
1165+
var credentials string
1166+
if *tests.JfrogAccessToken != "" {
1167+
credentials = "--access-token=" + *tests.JfrogAccessToken
1168+
} else {
1169+
credentials = "--user=" + *tests.JfrogUser + " --password=" + *tests.JfrogPassword
1170+
}
1171+
err := coreTests.NewJfrogCli(execMain, "jfrog config", credentials).Exec("add", "artDocker", "--interactive=false", "--url="+"http://localhost:8082", "--enc-password="+strconv.FormatBool(true), "--overwrite")
1172+
assert.NoError(t, err)
1173+
runJfrogCli(t, "config", "use", "artDocker")
1174+
imageName, err := inttestutils.BuildTestImage(tests.DockerImageName+":1", "", tests.DockerLocalRepo, container.DockerClient)
1175+
assert.NoError(t, err)
1176+
defer tests2.DeleteTestImage(t, imageName, container.DockerClient)
1177+
1178+
// Push container image
1179+
runCmdWithRetries(t, jfrogRtCliTask(container.DockerClient.String()+"-push", imageName, tests.DockerVirtualRepo))
1180+
buildNumber := "1"
1181+
1182+
dockerImage := container.DockerImage{
1183+
Image: imageName,
1184+
}
1185+
manifestSha, err := dockerImage.GetManifestDetails()
1186+
assert.NoError(t, err)
1187+
imageTag := strings.ReplaceAll(imageName, ":1", "@"+manifestSha)
1188+
1189+
// pull image with SHA
1190+
runJfrogCli(t, "docker", "pull", imageTag, "--build-name="+tests.DockerBuildName, "--build-number="+buildNumber)
1191+
runRt(t, "build-publish", tests.DockerBuildName, buildNumber)
1192+
1193+
imagePath := path.Join(tests.DockerVirtualRepo, tests.DockerImageName, "1") + "/"
1194+
module := tests.DockerImageName + "@" + manifestSha
1195+
validateContainerBuild(tests.DockerBuildName, buildNumber, imagePath, module, 0, 7, t)
1196+
1197+
inttestutils.ContainerTestCleanup(t, serverDetails, artHttpDetails, tests.DockerImageName, tests.DockerBuildName, tests.DockerVirtualRepo)
1198+
1199+
}
1200+
1201+
func TestContainerFatManifestPullWithSha(t *testing.T) {
1202+
cleanup := initNativeDockerWithArtTest(t)
1203+
defer cleanup()
1204+
var credentials string
1205+
if *tests.JfrogAccessToken != "" {
1206+
credentials = "--access-token=" + *tests.JfrogAccessToken
1207+
} else {
1208+
credentials = "--user=" + *tests.JfrogUser + " --password=" + *tests.JfrogPassword
1209+
}
1210+
err := coreTests.NewJfrogCli(execMain, "jfrog config", credentials).Exec("add", "artDocker", "--interactive=false", "--url="+"http://localhost:8082", "--enc-password="+strconv.FormatBool(true), "--overwrite")
1211+
assert.NoError(t, err)
1212+
runJfrogCli(t, "config", "use", "artDocker")
1213+
imageName := "traefik"
1214+
buildNumber := "1"
1215+
for _, dockerRepo := range [...]string{tests.DockerRemoteRepo, tests.DockerVirtualRepo} {
1216+
func() {
1217+
// calculate the sha of the image provided above
1218+
dockerImage := container.DockerImage{
1219+
Image: imageName,
1220+
}
1221+
manifestSha, err := dockerImage.GetManifestDetails()
1222+
assert.NoError(t, err)
1223+
1224+
imageTag := path.Join(*tests.ContainerRegistry, dockerRepo, imageName+"@"+manifestSha)
1225+
// Pull container image
1226+
defer tests2.DeleteTestImage(t, imageTag, container.DockerClient)
1227+
// pull image with SHA
1228+
runJfrogCli(t, "docker", "pull", imageTag, "--build-name="+tests.DockerBuildName, "--build-number="+buildNumber)
1229+
runRt(t, "build-publish", tests.DockerBuildName, buildNumber)
1230+
1231+
// Validate
1232+
publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, tests.DockerBuildName, buildNumber)
1233+
if err != nil {
1234+
assert.NoError(t, err)
1235+
return
1236+
}
1237+
if !found {
1238+
assert.True(t, found, "build info was expected to be found")
1239+
return
1240+
}
1241+
buildInfo := publishedBuildInfo.BuildInfo
1242+
module := imageName + "@" + manifestSha
1243+
validateBuildInfo(buildInfo, t, 6, 0, module, entities.Docker)
1244+
1245+
inttestutils.DeleteBuild(serverDetails.ArtifactoryUrl, tests.DockerBuildName, artHttpDetails)
1246+
}()
1247+
}
1248+
1249+
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ require (
1919
github.com/jfrog/build-info-go v1.12.5-0.20251209171349-eb030db986f9
2020
github.com/jfrog/gofrog v1.7.6
2121
github.com/jfrog/jfrog-cli-application v1.0.2-0.20251210075951-519050602a7f
22-
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20251218044417-5113b260e416
22+
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20251222102341-20b9565387e0
2323
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251219102726-2cbe70d57403
2424
github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20251204144808-73fa744851c0
2525
github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20251205121610-171eb9b0000e
2626
github.com/jfrog/jfrog-cli-security v1.24.1
27-
github.com/jfrog/jfrog-client-go v1.55.1-0.20251212095223-711b02c53736
27+
github.com/jfrog/jfrog-client-go v1.55.1-0.20251218135123-ebfdf494c72d
2828
github.com/jszwec/csvutil v1.10.0
2929
github.com/manifoldco/promptui v0.9.0
3030
github.com/spf13/viper v1.21.0

go.sum

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,10 +1216,8 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL
12161216
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
12171217
github.com/jfrog/jfrog-cli-application v1.0.2-0.20251210075951-519050602a7f h1:YHwPNF13Gmt65J618kEGn/4SGewXqyYuAdcyYWYdrBA=
12181218
github.com/jfrog/jfrog-cli-application v1.0.2-0.20251210075951-519050602a7f/go.mod h1:xum2HquWO5uExa/A7MQs3TgJJVEeoqTR+6Z4mfBr1Xw=
1219-
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20251218044417-5113b260e416 h1:bCCsZ/2oVgcxeWVgUG8K0bE1I7JFZ+O6CISzwwEfrV8=
1220-
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20251218044417-5113b260e416/go.mod h1:7cCaRhXorlbyXZgiW5bplCExFxlnROaG21K12d8inpQ=
1221-
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251210085744-f8481d179ac5 h1:GYE67ubwl+ZRw3CcXFUi49EwwQp6k+qS8sX0QuHDHO8=
1222-
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251210085744-f8481d179ac5/go.mod h1:BMoGi2rG0udCCeaghqlNgiW3fTmT+TNnfTnBoWFYgcg=
1219+
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20251222102341-20b9565387e0 h1:hQscFu/t9G5A/2PuL4G4t8K5VUIxBubcB9+iYenATDE=
1220+
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20251222102341-20b9565387e0/go.mod h1:oIq7MEnqzAjA9ZbamJPvdgTpHcmlPBMo05KBxZ3fykE=
12231221
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251219102726-2cbe70d57403 h1:Hnw9eOCdybMBAh1pUt9FCs74CTDOUh0M79ZCQ3VKPc4=
12241222
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251219102726-2cbe70d57403/go.mod h1:BMoGi2rG0udCCeaghqlNgiW3fTmT+TNnfTnBoWFYgcg=
12251223
github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20251204144808-73fa744851c0 h1:8S1vE1PeVtrzWkKL0N39cX6XLLNV0It+f6xjRKjw7Ug=
@@ -1228,8 +1226,8 @@ github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20251205121610-171eb9b000
12281226
github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20251205121610-171eb9b0000e/go.mod h1:qbu4iqBST9x8LgD8HhzUm91iOB3vHqtoGmaxOnmw0ok=
12291227
github.com/jfrog/jfrog-cli-security v1.24.1 h1:NF8SE9uzUgqvqYjuuqbduXBqj+fwE4CmkMeVKtcLkyI=
12301228
github.com/jfrog/jfrog-cli-security v1.24.1/go.mod h1:3FXD5IkKtdQOm9CZk6cR7q0iC6PaGMnjqzZqRcQp2r0=
1231-
github.com/jfrog/jfrog-client-go v1.55.1-0.20251212095223-711b02c53736 h1:sPAQHxVaV9QQ2TpfLM5y9VY+Fgva/5o7UZYlhNKouvw=
1232-
github.com/jfrog/jfrog-client-go v1.55.1-0.20251212095223-711b02c53736/go.mod h1:WQ5Y+oKYyHFAlCbHN925bWhnShTd2ruxZ6YTpb76fpU=
1229+
github.com/jfrog/jfrog-client-go v1.55.1-0.20251218135123-ebfdf494c72d h1:AUavZ6icGpYiUXpTeya+3QhoG1Ja74pO71CtPr2h8iI=
1230+
github.com/jfrog/jfrog-client-go v1.55.1-0.20251218135123-ebfdf494c72d/go.mod h1:WQ5Y+oKYyHFAlCbHN925bWhnShTd2ruxZ6YTpb76fpU=
12331231
github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94=
12341232
github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8=
12351233
github.com/jmespath/go-jmespath v0.4.1-0.20220621161143-b0104c826a24 h1:liMMTbpW34dhU4az1GN0pTPADwNmvoRSeoZ6PItiqnY=

nuget_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ func prepareSetupTest(t *testing.T, packageManager project.ProjectType) func() {
386386
// dep of NuGet.Core). This creates multiple RequestedBy paths that must be
387387
// consistently sorted across runs.
388388
func TestDotnetRequestedByDeterminism(t *testing.T) {
389+
t.Skip("Skipping test temporarily")
389390
initNugetTest(t)
390391
const numRuns = 5
391392
buildName := tests.DotnetBuildName + "-determinism"

0 commit comments

Comments
 (0)