|
1 | 1 | package e2e |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "encoding/json" |
5 | 4 | "fmt" |
6 | | - "io/ioutil" |
7 | | - "net/http" |
8 | 5 | "path/filepath" |
9 | 6 | "strings" |
10 | 7 | "testing" |
11 | 8 |
|
12 | | - "github.com/docker/cnab-to-oci/converter" |
13 | | - "github.com/opencontainers/go-digest" |
14 | | - v1 "github.com/opencontainers/image-spec/specs-go/v1" |
15 | 9 | "gotest.tools/assert" |
16 | 10 | "gotest.tools/assert/cmp" |
17 | 11 | "gotest.tools/icmd" |
18 | 12 | ) |
19 | 13 |
|
20 | | -type dindSwarmAndRegistryInfo struct { |
21 | | - swarmAddress string |
22 | | - registryAddress string |
23 | | - configuredCmd icmd.Cmd |
24 | | - stopRegistry func() |
25 | | - registryLogs func() string |
26 | | -} |
27 | | - |
28 | 14 | func TestPushInsecureRegistry(t *testing.T) { |
29 | 15 | runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) { |
30 | 16 | ref := info.registryAddress + "/test/push-insecure" |
@@ -172,39 +158,3 @@ func TestPushInstallBundle(t *testing.T) { |
172 | 158 | }) |
173 | 159 | }) |
174 | 160 | } |
175 | | - |
176 | | -func httpGet(url string, headers map[string]string, obj interface{}) error { |
177 | | - client := &http.Client{} |
178 | | - req, err := http.NewRequest("GET", url, nil) |
179 | | - if err != nil { |
180 | | - return err |
181 | | - } |
182 | | - for k, v := range headers { |
183 | | - req.Header.Set(k, v) |
184 | | - } |
185 | | - r, err := client.Do(req) |
186 | | - if err != nil { |
187 | | - return err |
188 | | - } |
189 | | - defer r.Body.Close() |
190 | | - if r.StatusCode != http.StatusOK { |
191 | | - body, err := ioutil.ReadAll(r.Body) |
192 | | - if err != nil { |
193 | | - return err |
194 | | - } |
195 | | - return fmt.Errorf("unexpected http error code %d with message %s", r.StatusCode, string(body)) |
196 | | - } |
197 | | - if err := json.NewDecoder(r.Body).Decode(obj); err != nil { |
198 | | - return err |
199 | | - } |
200 | | - return nil |
201 | | -} |
202 | | - |
203 | | -func getManifestListDigest(index v1.Index) (digest.Digest, error) { |
204 | | - for _, m := range index.Manifests { |
205 | | - if m.Annotations[converter.CNABDescriptorTypeAnnotation] == "component" { |
206 | | - return m.Digest, nil |
207 | | - } |
208 | | - } |
209 | | - return "", fmt.Errorf("Service image not found") |
210 | | -} |
0 commit comments