containsTask returns if the bundle contains a Tekton Task
(ctx context.Context, ref image.ImageReference)
| 26 | |
| 27 | // containsTask returns if the bundle contains a Tekton Task |
| 28 | func containsTask(ctx context.Context, ref image.ImageReference) (bool, error) { |
| 29 | client := NewClient(ctx) |
| 30 | img, err := client.GetImage(ctx, ref.Ref()) |
| 31 | if err != nil { |
| 32 | return false, err |
| 33 | } |
| 34 | |
| 35 | manifest, err := img.Manifest() |
| 36 | if err != nil { |
| 37 | return false, err |
| 38 | } |
| 39 | |
| 40 | for _, layer := range manifest.Layers { |
| 41 | if kind, ok := layer.Annotations[oci.KindAnnotation]; ok { |
| 42 | switch kind { |
| 43 | case "task": |
| 44 | return true, nil |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return false, nil |
| 50 | } |
no test coverage detected