diff --git a/buildtools/cli.go b/buildtools/cli.go index 307e62e05..d75536098 100644 --- a/buildtools/cli.go +++ b/buildtools/cli.go @@ -23,10 +23,10 @@ import ( "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/gradle" "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/mvn" "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/npm" + containerutils "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/ocicontainer" "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/terraform" "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/yarn" commandsUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils" - containerutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container" "github.com/jfrog/jfrog-cli-core/v2/common/build" commonCliUtils "github.com/jfrog/jfrog-cli-core/v2/common/cliutils" "github.com/jfrog/jfrog-cli-core/v2/common/commands" diff --git a/docker_test.go b/docker_test.go index dcddf2acc..5271b3245 100644 --- a/docker_test.go +++ b/docker_test.go @@ -19,15 +19,15 @@ import ( "github.com/jfrog/gofrog/version" coreContainer "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/container" "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/generic" + container "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/ocicontainer" "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" - "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container" "github.com/jfrog/jfrog-cli-core/v2/common/build" "github.com/jfrog/jfrog-cli-core/v2/common/spec" - commonTests "github.com/jfrog/jfrog-cli-core/v2/common/tests" "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" coreTests "github.com/jfrog/jfrog-cli-core/v2/utils/tests" "github.com/jfrog/jfrog-cli/inttestutils" "github.com/jfrog/jfrog-cli/utils/tests" + commonTests "github.com/jfrog/jfrog-cli/utils/tests" "github.com/jfrog/jfrog-client-go/auth" clientUtils "github.com/jfrog/jfrog-client-go/utils" "github.com/jfrog/jfrog-client-go/utils/io/fileutils" diff --git a/go.mod b/go.mod index 4a85e7557..6b5bb6ec9 100644 --- a/go.mod +++ b/go.mod @@ -19,11 +19,11 @@ require ( github.com/jfrog/build-info-go v1.12.0 github.com/jfrog/gofrog v1.7.6 github.com/jfrog/jfrog-cli-application v1.0.1 - github.com/jfrog/jfrog-cli-artifactory v0.7.3-0.20251008063046-4bfcdeb54f16 - github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251008065215-ebd53b5439fa + github.com/jfrog/jfrog-cli-artifactory v0.7.3-0.20251015051724-72d111a3d107 + github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251015045218-1a38c9e47097 github.com/jfrog/jfrog-cli-platform-services v1.10.0 github.com/jfrog/jfrog-cli-security v1.21.8 - github.com/jfrog/jfrog-client-go v1.55.1-0.20251008045603-4ca43b3f3d45 + github.com/jfrog/jfrog-client-go v1.55.1-0.20251015041910-ef0fe832b111 github.com/jszwec/csvutil v1.10.0 github.com/manifoldco/promptui v0.9.0 github.com/stretchr/testify v1.11.1 @@ -220,14 +220,14 @@ require ( go.uber.org/zap v1.27.0 // indirect go.yaml.in/yaml/v2 v2.4.2 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/crypto v0.42.0 // indirect + golang.org/x/crypto v0.43.0 // indirect golang.org/x/mod v0.28.0 // indirect - golang.org/x/net v0.43.0 // indirect + golang.org/x/net v0.45.0 // indirect golang.org/x/oauth2 v0.31.0 // indirect golang.org/x/sync v0.17.0 // indirect - golang.org/x/sys v0.36.0 // indirect - golang.org/x/term v0.35.0 // indirect - golang.org/x/text v0.29.0 // indirect + golang.org/x/sys v0.37.0 // indirect + golang.org/x/term v0.36.0 // indirect + golang.org/x/text v0.30.0 // indirect golang.org/x/time v0.12.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect @@ -250,9 +250,9 @@ require ( //replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20251006061821-8b1be6a65215 -//replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory v0.0.0-20251007085159-3db123d4398b +//replace github.com/jfrog/jfrog-cli-artifactory => github.com/fluxxBot/jfrog-cli-artifactory v0.0.0-20251008152604-32538b00579c -//replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.0.0-20251007071921-a9564595b084 +//replace github.com/jfrog/jfrog-cli-core/v2 => github.com/fluxxBot/jfrog-cli-core/v2 v2.58.1-0.20251008152439-da488ef26725 //replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.54.2-0.20251007084958-5eeaa42c31a6 diff --git a/go.sum b/go.sum index 748713d91..c1c1d9ea6 100644 --- a/go.sum +++ b/go.sum @@ -365,16 +365,16 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w= github.com/jfrog/jfrog-cli-application v1.0.1 h1:PiiSVKFFs8VLAwjCe2JrIKlX7LmARFt+r8BLTupWIDc= github.com/jfrog/jfrog-cli-application v1.0.1/go.mod h1:gjV6Q2hhoMe3FF77GFiTyIRLSHokpDrkVj0GvYM+1Y4= -github.com/jfrog/jfrog-cli-artifactory v0.7.3-0.20251008063046-4bfcdeb54f16 h1:a3HT8zy/UQ0NzkxUVrTyL52hLlpMVtt3aNeewJJwX5A= -github.com/jfrog/jfrog-cli-artifactory v0.7.3-0.20251008063046-4bfcdeb54f16/go.mod h1:IakTDViEn67KzaQTyOyvqkfGsamryAnckO3VGs0cg2c= -github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251008065215-ebd53b5439fa h1:JfK0lvV1aCLkgbktdHkjRp61jlc1Llxq2QFK7sf52SE= -github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251008065215-ebd53b5439fa/go.mod h1:XnTbhDuUKPOe215lJ6mxRu/xKL2zdy6a9CU+e85bjME= +github.com/jfrog/jfrog-cli-artifactory v0.7.3-0.20251015051724-72d111a3d107 h1:0VVFI1AHzMKyr/Nwxmu/Jhg3U1Rq725AQPKpSTtk7XU= +github.com/jfrog/jfrog-cli-artifactory v0.7.3-0.20251015051724-72d111a3d107/go.mod h1:nT050Wb18tTlfcQHefyMENzFOz9Vdym6WP0Z3Nc2qHc= +github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251015045218-1a38c9e47097 h1:+W6BPxJ0nPtlQ6l6nmypW1eEANoVPiN8HDR4kQJA8uI= +github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251015045218-1a38c9e47097/go.mod h1:UOeOwEEmRIi57cRwghN5OBVoqkJieYQQfLpeqw8Yv38= github.com/jfrog/jfrog-cli-platform-services v1.10.0 h1:O+N/VAF+QjFvq9xkHpmzKLcdl9aJu3IP204Su0L14rw= github.com/jfrog/jfrog-cli-platform-services v1.10.0/go.mod h1:qbu4iqBST9x8LgD8HhzUm91iOB3vHqtoGmaxOnmw0ok= github.com/jfrog/jfrog-cli-security v1.21.8 h1:yRVOW4FqETd0tVeHxdC7l19aLi5gS3hai9XwkMQuVr8= github.com/jfrog/jfrog-cli-security v1.21.8/go.mod h1:AYckVBA3qNmCku1MrBLpQwbr9eAZ91U/3zMa88gckD8= -github.com/jfrog/jfrog-client-go v1.55.1-0.20251008045603-4ca43b3f3d45 h1:8NcEHGwal5iyVqpNoKsltTW6h1b9yyN/c49XA0OoBtc= -github.com/jfrog/jfrog-client-go v1.55.1-0.20251008045603-4ca43b3f3d45/go.mod h1:E2s23qRRDdyPdzSYG1irPOEpjJ6kXvhV1U4g/0rG93k= +github.com/jfrog/jfrog-client-go v1.55.1-0.20251015041910-ef0fe832b111 h1:IBkggQwQi7D4+vafA3f8aHSrgZ89bMdlMffmNQfjuLw= +github.com/jfrog/jfrog-client-go v1.55.1-0.20251015041910-ef0fe832b111/go.mod h1:jrODQbAbCt97F24d/0bYpqpdc0PFMuBxNJOTfTdW+Fk= github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94= github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8= github.com/jmespath/go-jmespath v0.4.1-0.20220621161143-b0104c826a24 h1:liMMTbpW34dhU4az1GN0pTPADwNmvoRSeoZ6PItiqnY= @@ -716,8 +716,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= -golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI= -golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8= +golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04= +golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0= golang.org/x/exp v0.0.0-20250911091902-df9299821621 h1:2id6c1/gto0kaHYyrixvknJ8tUK/Qs5IsmBtrc+FtgU= golang.org/x/exp v0.0.0-20250911091902-df9299821621/go.mod h1:TwQYMMnGpvZyc+JpB/UAuTNIsVJifOlSkrZkhcvpVUk= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -740,8 +740,8 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= -golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= -golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= +golang.org/x/net v0.45.0 h1:RLBg5JKixCy82FtLJpeNlVM0nrSqpCRYzVU1n8kj0tM= +golang.org/x/net v0.45.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/oauth2 v0.31.0 h1:8Fq0yVZLh4j4YA47vHKFTa9Ew5XIrCP8LC6UeNZnLxo= @@ -789,16 +789,16 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= -golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= +golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= -golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ= -golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA= +golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q= +golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -806,8 +806,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= -golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= +golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k= +golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM= golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE= golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/inttestutils/docker.go b/inttestutils/docker.go index 279c2c699..61f5be1aa 100644 --- a/inttestutils/docker.go +++ b/inttestutils/docker.go @@ -10,11 +10,11 @@ import ( gofrogcmd "github.com/jfrog/gofrog/io" "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/generic" + container "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/ocicontainer" "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" - "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container" - commonTests "github.com/jfrog/jfrog-cli-core/v2/common/tests" "github.com/jfrog/jfrog-cli-core/v2/utils/config" "github.com/jfrog/jfrog-cli/utils/tests" + commonTests "github.com/jfrog/jfrog-cli/utils/tests" "github.com/jfrog/jfrog-client-go/utils/io/httputils" "github.com/jfrog/jfrog-client-go/utils/log" "github.com/stretchr/testify/assert" diff --git a/npm_test.go b/npm_test.go index 0d9ef29aa..7757a183f 100644 --- a/npm_test.go +++ b/npm_test.go @@ -814,7 +814,7 @@ func TestNpmPublishWithWorkspaces(t *testing.T) { assert.NotEmpty(t, artifact.Sha1, "Artifact %d in module %d should have SHA1", j) assert.NotEmpty(t, artifact.Sha256, "Artifact %d in module %d should have SHA256", j) assert.NotEmpty(t, artifact.Md5, "Artifact %d in module %d should have MD5", j) - assert.Contains(t, artifact.Name, "nested"+strconv.Itoa(j+1)) + assert.True(t, containsTarName(artifact.Name, expectedTars)) } // Publish build info to Artifactory @@ -865,6 +865,7 @@ func TestNpmPublishWithWorkspacesRunNative(t *testing.T) { err = commands.Exec(npmpCmd) assert.NoError(t, err) + expectedTars := []string{"nested1", "nested2"} // Validate build info was created buildInfoService := build.CreateBuildInfoService() npmBuild, err := buildInfoService.GetOrCreateBuild(buildName, buildNumber) @@ -893,7 +894,7 @@ func TestNpmPublishWithWorkspacesRunNative(t *testing.T) { assert.NotEmpty(t, artifact.Sha1, "Artifact %d should have SHA1", j) assert.NotEmpty(t, artifact.Sha256, "Artifact %d should have SHA256", j) assert.NotEmpty(t, artifact.Md5, "Artifact %d should have MD5", j) - assert.Contains(t, artifact.Name, "nested"+strconv.Itoa(j+1), "Artifact %d should be named nested%d", j, j+1) + assert.True(t, containsTarName(artifact.Name, expectedTars)) } // Publish build info to Artifactory @@ -1259,3 +1260,13 @@ func TestSetupNpmCommand(t *testing.T) { assert.Equal(t, http.StatusOK, res.StatusCode) } } + +func containsTarName(tarName string, expectedTars []string) bool { + isTarPresent := false + for _, tar := range expectedTars { + strings.Contains(tarName, tar) + isTarPresent = true + break + } + return isTarPresent +} diff --git a/utils/tests/docker.go b/utils/tests/docker.go new file mode 100644 index 000000000..cf3af77f0 --- /dev/null +++ b/utils/tests/docker.go @@ -0,0 +1,192 @@ +package tests + +import ( + "io" + "os/exec" + "path" + "testing" + + gofrogcmd "github.com/jfrog/gofrog/io" + container "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/ocicontainer" + "github.com/stretchr/testify/assert" +) + +// Image get parent image id command +type BuildDockerImage struct { + // The build command builds images from a Dockerfile and a context. + // A build's context is the set of files located in the specified PATH. + // The build process can refer to any of the files in the context. + // For example, The build can use a COPY instruction to reference a file in the context. + buildContext string + dockerFileName string + imageName string + containerManager container.ContainerManagerType +} + +func NewBuildDockerImage(imageTag, dockerFilePath string, containerManager container.ContainerManagerType) *BuildDockerImage { + return &BuildDockerImage{imageName: imageTag, buildContext: dockerFilePath, containerManager: containerManager} +} + +func (image *BuildDockerImage) SetDockerFileName(name string) *BuildDockerImage { + image.dockerFileName = name + return image +} + +func (image *BuildDockerImage) GetCmd() *exec.Cmd { + var cmd []string + cmd = append(cmd, "build") + cmd = append(cmd, "--tag", image.imageName) + if image.dockerFileName != "" { + cmd = append(cmd, "--file", path.Join(image.buildContext, image.dockerFileName)) + + } + cmd = append(cmd, image.buildContext) + return exec.Command(image.containerManager.String(), cmd...) +} + +func (image *BuildDockerImage) GetEnv() map[string]string { + return map[string]string{} +} + +func (image *BuildDockerImage) GetStdWriter() io.WriteCloser { + return nil +} + +func (image *BuildDockerImage) GetErrWriter() io.WriteCloser { + return nil +} + +// The ExecDockerImage command runs a new command in a running container. +type ExecDockerImage struct { + Args []string + errCloser io.WriteCloser + stdWriter io.WriteCloser + containerManager container.ContainerManagerType +} + +func NewExecDockerImage(containerManager container.ContainerManagerType, args ...string) *ExecDockerImage { + return &ExecDockerImage{Args: args, containerManager: containerManager} +} + +func (e *ExecDockerImage) GetCmd() *exec.Cmd { + var cmd []string + cmd = append(cmd, "exec") + cmd = append(cmd, e.Args...) + return exec.Command(e.containerManager.String(), cmd...) +} + +func (e *ExecDockerImage) GetEnv() map[string]string { + return map[string]string{} +} + +func (e *ExecDockerImage) GetStdWriter() io.WriteCloser { + return e.stdWriter +} + +func (e *ExecDockerImage) SetStdWriter(writer io.WriteCloser) { + e.stdWriter = writer +} + +func (e *ExecDockerImage) GetErrWriter() io.WriteCloser { + return e.errCloser +} + +func (e *ExecDockerImage) SetErrWriter(writer io.WriteCloser) { + e.errCloser = writer +} + +type RunDockerImage struct { + Args []string + containerManager container.ContainerManagerType +} + +func NewRunDockerImage(containerManager container.ContainerManagerType, args ...string) *RunDockerImage { + return &RunDockerImage{Args: args, containerManager: containerManager} +} + +func (run *RunDockerImage) GetCmd() *exec.Cmd { + var cmd []string + cmd = append(cmd, "run") + cmd = append(cmd, run.Args...) + return exec.Command(run.containerManager.String(), cmd...) +} + +func (run *RunDockerImage) GetEnv() map[string]string { + return map[string]string{} +} + +func (run *RunDockerImage) GetStdWriter() io.WriteCloser { + return nil +} + +func (run *RunDockerImage) GetErrWriter() io.WriteCloser { + return nil +} + +type DeleteDockerImage struct { + imageTag string + containerManager container.ContainerManagerType +} + +func NewDeleteDockerImage(imageTag string, containerManager container.ContainerManagerType) *DeleteDockerImage { + return &DeleteDockerImage{imageTag: imageTag, containerManager: containerManager} +} + +func (image *DeleteDockerImage) GetCmd() *exec.Cmd { + var cmd []string + cmd = append(cmd, "image") + cmd = append(cmd, "rm") + cmd = append(cmd, image.imageTag) + return exec.Command(image.containerManager.String(), cmd...) +} + +func (image *DeleteDockerImage) GetEnv() map[string]string { + return map[string]string{} +} + +func (image *DeleteDockerImage) GetStdWriter() io.WriteCloser { + return nil +} + +func (image *DeleteDockerImage) GetErrWriter() io.WriteCloser { + return nil +} + +type DeleteContainer struct { + containerName string + containerManager container.ContainerManagerType +} + +func NewDeleteContainer(containerName string, containerManager container.ContainerManagerType) *DeleteContainer { + return &DeleteContainer{containerName: containerName, containerManager: containerManager} +} + +func (image *DeleteContainer) GetCmd() *exec.Cmd { + var cmd []string + cmd = append(cmd, "rm") + cmd = append(cmd, "--force") + cmd = append(cmd, image.containerName) + return exec.Command(image.containerManager.String(), cmd...) +} + +func (image *DeleteContainer) GetEnv() map[string]string { + return map[string]string{} +} + +func (image *DeleteContainer) GetStdWriter() io.WriteCloser { + return nil +} + +func (image *DeleteContainer) GetErrWriter() io.WriteCloser { + return nil +} + +func DeleteTestImage(t *testing.T, imageTag string, containerManagerType container.ContainerManagerType) { + imageBuilder := NewDeleteDockerImage(imageTag, containerManagerType) + assert.NoError(t, gofrogcmd.RunCmd(imageBuilder)) +} + +func DeleteTestContainer(t *testing.T, containerName string, containerManagerType container.ContainerManagerType) { + containerDelete := NewDeleteContainer(containerName, containerManagerType) + assert.NoError(t, gofrogcmd.RunCmd(containerDelete)) +}