From 1b2f80d4c528ca2121e27d4f9086e3b1f6d3674e Mon Sep 17 00:00:00 2001 From: mrjoelkamp Date: Mon, 22 Apr 2024 12:51:10 -0500 Subject: [PATCH] refactor: export oci --- internal/oci/types.go | 5 ----- internal/test/test.go | 2 +- {internal => pkg}/oci/http.go | 0 {internal => pkg}/oci/oci.go | 5 ++--- {internal => pkg}/oci/oci_test.go | 0 {internal => pkg}/oci/resolver.go | 0 pkg/oci/types.go | 8 ++++++++ pkg/policy/evaluator.go | 2 +- pkg/policy/policy.go | 2 +- pkg/policy/policy_test.go | 2 +- pkg/policy/rego.go | 2 +- 11 files changed, 15 insertions(+), 13 deletions(-) delete mode 100644 internal/oci/types.go rename {internal => pkg}/oci/http.go (100%) rename {internal => pkg}/oci/oci.go (98%) rename {internal => pkg}/oci/oci_test.go (100%) rename {internal => pkg}/oci/resolver.go (100%) create mode 100644 pkg/oci/types.go diff --git a/internal/oci/types.go b/internal/oci/types.go deleted file mode 100644 index 4f9367d..0000000 --- a/internal/oci/types.go +++ /dev/null @@ -1,5 +0,0 @@ -package oci - -const ( - InTotoPredicateType = "in-toto.io/predicate-type" -) diff --git a/internal/test/test.go b/internal/test/test.go index b149693..87533d7 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/docker/attest/internal/oci" + "github.com/docker/attest/pkg/oci" "github.com/docker/attest/pkg/policy" "github.com/docker/attest/pkg/signerverifier" "github.com/docker/attest/pkg/tlog" diff --git a/internal/oci/http.go b/pkg/oci/http.go similarity index 100% rename from internal/oci/http.go rename to pkg/oci/http.go diff --git a/internal/oci/oci.go b/pkg/oci/oci.go similarity index 98% rename from internal/oci/oci.go rename to pkg/oci/oci.go index 0f50222..89af78c 100644 --- a/internal/oci/oci.go +++ b/pkg/oci/oci.go @@ -9,7 +9,6 @@ import ( "github.com/containerd/containerd/platforms" "github.com/distribution/reference" att "github.com/docker/attest/pkg/attestation" - "github.com/docker/attest/pkg/types" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" @@ -72,11 +71,11 @@ func attestationManifestFromOCILayout(path string, platformStr string) (*Attesta } } for _, mf := range mfs2.Manifests { - if mf.Annotations[types.DockerReferenceType] != types.AttestationManifestType { + if mf.Annotations[DockerReferenceType] != AttestationManifestType { continue } - if mf.Annotations[types.DockerReferenceDigest] != imageDigest { + if mf.Annotations[DockerReferenceDigest] != imageDigest { continue } diff --git a/internal/oci/oci_test.go b/pkg/oci/oci_test.go similarity index 100% rename from internal/oci/oci_test.go rename to pkg/oci/oci_test.go diff --git a/internal/oci/resolver.go b/pkg/oci/resolver.go similarity index 100% rename from internal/oci/resolver.go rename to pkg/oci/resolver.go diff --git a/pkg/oci/types.go b/pkg/oci/types.go new file mode 100644 index 0000000..5af15eb --- /dev/null +++ b/pkg/oci/types.go @@ -0,0 +1,8 @@ +package oci + +const ( + DockerReferenceType = "vnd.docker.reference.type" + DockerReferenceDigest = "vnd.docker.reference.digest" + AttestationManifestType = "attestation-manifest" + InTotoPredicateType = "in-toto.io/predicate-type" +) diff --git a/pkg/policy/evaluator.go b/pkg/policy/evaluator.go index e4ada6b..42cce24 100644 --- a/pkg/policy/evaluator.go +++ b/pkg/policy/evaluator.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/docker/attest/internal/oci" + "github.com/docker/attest/pkg/oci" ) type policyEvaluatorCtxKeyType struct{} diff --git a/pkg/policy/policy.go b/pkg/policy/policy.go index c408aa6..ceb8de3 100644 --- a/pkg/policy/policy.go +++ b/pkg/policy/policy.go @@ -9,8 +9,8 @@ import ( "strings" "github.com/distribution/reference" - "github.com/docker/attest/internal/oci" "github.com/docker/attest/internal/util" + "github.com/docker/attest/pkg/oci" "github.com/docker/attest/pkg/tuf" goyaml "gopkg.in/yaml.v3" diff --git a/pkg/policy/policy_test.go b/pkg/policy/policy_test.go index 21205da..9e404b8 100644 --- a/pkg/policy/policy_test.go +++ b/pkg/policy/policy_test.go @@ -6,9 +6,9 @@ import ( "path/filepath" "testing" - "github.com/docker/attest/internal/oci" "github.com/docker/attest/internal/test" "github.com/docker/attest/pkg/attestation" + "github.com/docker/attest/pkg/oci" "github.com/docker/attest/pkg/policy" "github.com/docker/attest/pkg/tuf" "github.com/stretchr/testify/assert" diff --git a/pkg/policy/rego.go b/pkg/policy/rego.go index b6d5c8a..3dd42e2 100644 --- a/pkg/policy/rego.go +++ b/pkg/policy/rego.go @@ -7,8 +7,8 @@ import ( "os" "path/filepath" - "github.com/docker/attest/internal/oci" att "github.com/docker/attest/pkg/attestation" + "github.com/docker/attest/pkg/oci" intoto "github.com/in-toto/in-toto-golang/in_toto" "github.com/open-policy-agent/opa/ast" "github.com/open-policy-agent/opa/rego"