...

Source file src/github.com/sigstore/rekor/pkg/events/newentry/new_entry.go

Documentation: github.com/sigstore/rekor/pkg/events/newentry

     1  // Copyright 2023 The Sigstore Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package newentry
    16  
    17  import (
    18  	"strings"
    19  	"time"
    20  
    21  	"github.com/sigstore/rekor/pkg/events"
    22  	"golang.org/x/exp/slices"
    23  
    24  	rekor_pb "github.com/sigstore/protobuf-specs/gen/pb-go/rekor/v1"
    25  )
    26  
    27  const (
    28  	Name   = "dev.sigstore.rekor.events.v1.NewEntry"
    29  	Source = "/createLogEntry"
    30  )
    31  
    32  var ty *events.EventType
    33  
    34  func init() {
    35  	empty := &rekor_pb.TransparencyLogEntry{}
    36  	ty = events.RegisterType(Name, Source, empty.ProtoReflect().Descriptor())
    37  }
    38  
    39  func New(id string, entry *rekor_pb.TransparencyLogEntry, subjects []string) (*events.Event, error) {
    40  	slices.Sort(subjects) // Must be sorted for consistency.
    41  	attrs := map[string]any{
    42  		"time":                   time.Unix(entry.GetIntegratedTime(), 0),
    43  		"rekor_entry_kind":       entry.GetKindVersion().GetKind(),
    44  		"rekor_signing_subjects": strings.Join(subjects, ","),
    45  	}
    46  	return ty.New(id, entry, attrs)
    47  }
    48  

View as plain text