Skip to content

Commit 5b35cb2

Browse files
authored
Merge branch 'LinuxSuRen:master' into history-api
2 parents 7ebe10e + 4aadd06 commit 5b35cb2

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed

cmd/extension.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type extensionOption struct {
3535
os string
3636
arch string
3737
timeout time.Duration
38+
imagePrefix string
3839
}
3940

4041
func createExtensionCommand(ociDownloader downloader.PlatformAwareOCIDownloader) (c *cobra.Command) {
@@ -55,13 +56,15 @@ func createExtensionCommand(ociDownloader downloader.PlatformAwareOCIDownloader)
5556
flags.StringVarP(&opt.os, "os", "", runtime.GOOS, "The OS")
5657
flags.StringVarP(&opt.arch, "arch", "", runtime.GOARCH, "The architecture")
5758
flags.DurationVarP(&opt.timeout, "timeout", "", time.Minute, "The timeout of downloading")
59+
flags.StringVarP(&opt.imagePrefix, "image-prefix", "", "linuxsuren", "The prefix for the image address")
5860
return
5961
}
6062

6163
func (o *extensionOption) runE(cmd *cobra.Command, args []string) (err error) {
6264
o.ociDownloader.WithOS(o.os)
6365
o.ociDownloader.WithArch(o.arch)
6466
o.ociDownloader.WithRegistry(o.registry)
67+
o.ociDownloader.WithImagePrefix(o.imagePrefix)
6568
o.ociDownloader.WithTimeout(o.timeout)
6669
o.ociDownloader.WithContext(cmd.Context())
6770

pkg/downloader/oci.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type PlatformAwareOCIDownloader interface {
4444
WithOS(string)
4545
WithArch(string)
4646
GetTargetFile() string
47+
WithImagePrefix(string)
4748
}
4849

4950
type defaultOCIDownloader struct {

pkg/downloader/store.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ import (
2727

2828
type storeDownloader struct {
2929
OCIDownloader
30-
os, arch string
31-
extFile string
30+
os, arch string
31+
extFile string
32+
imagePrefix string
3233
}
3334

3435
func NewStoreDownloader() PlatformAwareOCIDownloader {
@@ -37,6 +38,7 @@ func NewStoreDownloader() PlatformAwareOCIDownloader {
3738
}
3839
ociDownloader.WithOS(runtime.GOOS)
3940
ociDownloader.WithArch(runtime.GOARCH)
41+
ociDownloader.WithImagePrefix("linuxsuren")
4042
return ociDownloader
4143
}
4244

@@ -46,7 +48,7 @@ func (d *storeDownloader) Download(name, tag, _ string) (reader io.Reader, err e
4648
if d.os == "windows" {
4749
d.extFile = fmt.Sprintf("%s.exe", d.extFile)
4850
}
49-
image := fmt.Sprintf("linuxsuren/atest-ext-store-%s", name)
51+
image := fmt.Sprintf("%s/atest-ext-store-%s", d.imagePrefix, name)
5052
reader, err = d.OCIDownloader.Download(image, tag, d.extFile)
5153
return
5254
}
@@ -70,6 +72,10 @@ func (d *storeDownloader) WithOS(os string) {
7072
d.os = os
7173
}
7274

75+
func (d *storeDownloader) WithImagePrefix(imagePrefix string) {
76+
d.imagePrefix = imagePrefix
77+
}
78+
7379
func (d *storeDownloader) WithArch(arch string) {
7480
d.arch = arch
7581
if d.arch == "amd64" {

pkg/runner/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (r *simpleTestCaseRunner) RunTestCase(testcase *testing.TestCase, dataConte
188188
return
189189
}
190190

191-
r.log.Debug("test case %q, status code: %d\n", testcase.Name, resp.StatusCode)
191+
r.log.Debug("test case %q, test case info: %v, status code: %d\n", testcase.Name, testcase, resp.StatusCode)
192192

193193
if err = testcase.Expect.Render(dataContext); err != nil {
194194
return

pkg/server/remote_server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func TestRunTestCase(t *testing.T) {
148148
})
149149
assert.NoError(t, err)
150150
assert.Equal(t, sampleBody, result.Body)
151-
assert.Contains(t, result.Output, "start to run: 'get'\nstart to send request to http://foo\ntest case \"get\", status code: 200\n")
151+
assert.Contains(t, result.Output, "start to run: 'get'\nstart to send request to http://foo\ntest case \"get\", test case info: &{ get <nil> <nil> {http://foo GET map[] map[key:value] map[] map[] } {0 map[] map[] [] [] }}, status code: 200\n")
152152
})
153153

154154
t.Run("text response", func(t *testing.T) {

pkg/server/store_ext_manager.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ func (n *nonDownloader) WithRegistry(string) {
185185
// Do nothing because this is an empty implementation
186186
}
187187

188+
func (n *nonDownloader) WithImagePrefix(imagePrefix string) {
189+
// Do nothing because this is an empty implementation
190+
}
188191
func (d *nonDownloader) WithRoundTripper(rt http.RoundTripper) {
189192
// Do nothing because this is an empty implementation
190193
}

0 commit comments

Comments
 (0)