func NewDiamondDescriptor(opts ...DiamondDescriptorOption) *DiamondDescriptor {
	d := defaultDiamondDescriptor()
	for _, apply := range opts {
		apply(d)
	}
	return d
}
NewDiamondDescriptor builds a new DiamondDescriptor
package model
import (
	"fmt"
	"path"
	"time"
	"github.com/segmentio/ksuid"
)
type ConflictMode string
const (
	IgnoreConflicts ConflictMode = "ignored"
	EnableCheckpoints ConflictMode = "enable-checkpoints"
	EnableConflicts ConflictMode = "enable-conflicts"
	ForbidConflicts ConflictMode = "forbids-conflicts"
)
type DiamondState string
const (
	DiamondInitialized DiamondState = "initialized"
	DiamondDone DiamondState = "done"
	DiamondCanceled DiamondState = "canceled"
)
const (
	done                         = "done"
	running                      = "running"
	ext                          = ".yaml"
	diamondPrefix                = "diamond-"
	splitPrefix                  = "split-"
	diamondFinalDescriptorFile   = diamondPrefix + done + ext
	splitFinalDescriptorFile     = splitPrefix + done + ext
	diamondInitialDescriptorFile = diamondPrefix + running + ext
	splitInitialDescriptorFile   = splitPrefix + running + ext
)
func (s DiamondState) IsValid() bool {
	switch s {
	case DiamondInitialized, DiamondDone, DiamondCanceled:
		return true
	default:
		return false
	}
}
func (s DiamondState) String() string {
	return string(s)
}
type SplitState string
const (
	SplitDone SplitState = done
	SplitRunning SplitState = running
)
func (s SplitState) IsValid() bool {
	switch s {
	case SplitDone, SplitRunning:
		return true
	default:
		return false
	}
}
func (s SplitState) String() string {
	return string(s)
}
type DiamondDescriptor struct {
	DiamondID      string            `json:"diamondID" yaml:"diamondID"`
	StartTime      time.Time         `json:"startTime" yaml:"startTime"`                            
	EndTime        time.Time         `json:"endTime,omitempty" yaml:"endTime,omitempty"`            
	State          DiamondState      `json:"state" yaml:"state"`                                    
	Mode           ConflictMode      `json:"mode" yaml:"mode"`                                      
	HasConflicts   bool              `json:"hasConflicts,omitempty" yaml:"hasConflicts,omitempty"`  
	HasCheckpoints bool              `json:"hasCheckpoints,omitempty" yaml:"hasCheckpoints,omitempty"`
	Tag            string            `json:"tag,omitempty" yaml:"tag,omitempty"`            
	BundleID       string            `json:"bundleID,omitempty" yaml:"bundleID,omitempty"`  
	Splits         []SplitDescriptor `json:"splits,omitempty" yaml:"splits,omitempty"`      
	_              struct{}
}
type DiamondDescriptors []DiamondDescriptor
func (b DiamondDescriptors) Swap(i, j int) {
	b[i], b[j] = b[j], b[i]
}
func (b DiamondDescriptors) Len() int {
	return len(b)
}
func (b DiamondDescriptors) Less(i, j int) bool {
	if !b[i].StartTime.IsZero() && !b[j].StartTime.IsZero() {
		return b[i].StartTime.Before(b[j].StartTime)
	}
	return b[i].DiamondID < b[j].DiamondID
}
func (b DiamondDescriptors) Last() DiamondDescriptor {
	return b[len(b)-1]
}
func defaultDiamondDescriptor() *DiamondDescriptor {
	diamondID, err := ksuid.NewRandom()
	if err != nil {
		panic(fmt.Sprintf("cannot generate random ksuid: %v", err))
	}
	return &DiamondDescriptor{
		DiamondID: diamondID.String(),
		StartTime: GetBundleTimeStamp(),
		State:     DiamondInitialized,
		Mode:      EnableConflicts,
	}
}