Ejemplo n.º 1
0
func AnalyseManifestFile(jsonIn string) (*attr.ImgAttr, error) {
	imgData := attr.DockerImageData{}
	err := json.Unmarshal([]byte(jsonIn), &imgData)
	if nil != err {
		return nil, err
	}

	var attrs []attr.DockerImg_Attr

	parsedDockerURL := &attr.ParsedDockerURL{}

	imgLayerAttr, _ := attr.AnalyseDockerManifest(imgData, parsedDockerURL)

	attrs = append(attrs, *imgLayerAttr)

	imgAttr := &attr.ImgAttr{Type: "Docker Image", Layers: 1, Attrs: attrs}

	return imgAttr, nil
}
Ejemplo n.º 2
0
func analyseReal(backend AnalyseBackend, dockerURL string) (*attr.ImgAttr, error) {
	ancestry, parsedDockerURL, err := backend.GetImageInfo(dockerURL)
	if err != nil {
		return nil, err
	}

	var attrs []attr.DockerImg_Attr

	for i := len(ancestry) - 1; i >= 0; i-- {
		layerID := ancestry[i]

		layerData, _ := backend.GetLayerInfo(layerID, parsedDockerURL)

		imgLayerAttr, _ := attr.AnalyseDockerManifest(*layerData, parsedDockerURL)

		attrs = append(attrs, *imgLayerAttr)
	}

	imgAttr := &attr.ImgAttr{Type: "Docker Image", Layers: len(ancestry), Attrs: attrs}

	return imgAttr, nil
}