Skip to content

Commit

Permalink
Address PR Feedback. Add URI to CustomMetadata
Browse files Browse the repository at this point in the history
Signed-off-by: Ville Aikas <vaikas@chainguard.dev>
  • Loading branch information
vaikas committed Oct 31, 2022
1 parent d3c6639 commit 03415a7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type TargetWithMetadata struct {
type CustomMetadata struct {
Usage string `json:"usage"`
Status string `json:"status"`
URI string `json:"uri"`
}

type sigstoreCustomMetadata struct {
Expand Down Expand Up @@ -108,7 +109,7 @@ func CreateRepoWithMetadata(ctx context.Context, targets []TargetWithMetadata) (
return local, dir, nil
}

// CreateRepo creates and initializes a Tuf repo for Sigstore by adding
// CreateRepo creates and initializes a TUF repo for Sigstore by adding
// keys to bytes. keys are typically for a basic setup like:
// "fulcio_v1.crt.pem" - Fulcio root cert in PEM format
// "ctfe.pub" - CTLog public key in PEM format
Expand All @@ -119,7 +120,8 @@ func CreateRepoWithMetadata(ctx context.Context, targets []TargetWithMetadata) (
// if the filename contains:
// - `fulcio` = it will get Usage set to `Fulcio`
// - `ctfe` = it will get Usage set to `CTFE`
// - Anything else will get set to `Rekor`
// - `rekor` = it will get Usage set to `Rekor`
// - Anything else will get set to `Unknown`
func CreateRepo(ctx context.Context, files map[string][]byte) (tuf.LocalStore, string, error) {
targets := make([]TargetWithMetadata, 0, len(files))
for name, bytes := range files {
Expand All @@ -128,8 +130,10 @@ func CreateRepo(ctx context.Context, files map[string][]byte) (tuf.LocalStore, s
usage = "Fulcio"
} else if strings.Contains(name, "ctfe") {
usage = "CTFE"
} else {
} else if strings.Contains(name, "rekor") {
usage = "Rekor"
} else {
usage = "Unknown"
}
scmActive, err := json.Marshal(&sigstoreCustomMetadata{Sigstore: CustomMetadata{Usage: usage, Status: "Active"}})
if err != nil {
Expand Down

0 comments on commit 03415a7

Please sign in to comment.