Exemple #1
0
func downloadManifest(artifact *ct.Artifact) error {
	verifier, err := verify.NewVerifier(artifact.Hashes, artifact.Size)
	if err != nil {
		return err
	}

	res, err := hh.RetryClient.Get(artifact.URI)
	if err != nil {
		return err
	}
	defer res.Body.Close()

	if res.StatusCode != http.StatusOK {
		return fmt.Errorf("unexpected HTTP status: %s", res.Status)
	}

	r := verifier.Reader(res.Body)
	data, err := ioutil.ReadAll(r)
	if err != nil {
		return err
	}

	if err := verifier.Verify(); err != nil {
		return err
	}

	artifact.RawManifest = data
	return nil
}
Exemple #2
0
func (s *S) createTestArtifact(c *C, in *ct.Artifact) *ct.Artifact {
	if in.Type == "" {
		in.Type = ct.ArtifactTypeFlynn
		in.RawManifest = ct.ImageManifest{
			Type: ct.ImageManifestTypeV1,
		}.RawManifest()
	}
	if in.URI == "" {
		in.URI = fmt.Sprintf("https://example.com/%s", random.String(8))
	}
	c.Assert(s.c.CreateArtifact(in), IsNil)
	return in
}