record

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package record provides utilities for manipulating and validating Records.

Index

Constants

This section is empty.

Variables

View Source
var (
	// NameRegex matches valid name specs for a Result.
	NameRegex = regexp.MustCompile("(^[a-z0-9_-]{1,63})/results/([a-z0-9_-]{1,63})/records/([a-z0-9_-]{1,63}$)")
)

Functions

func FormatName

func FormatName(parent, name string) string

FormatName takes in a parent ("a/results/b") and record name ("c") and returns the full resource name ("a/results/b/records/c").

func Match

func Match(r *pb.Record, prg cel.Program) (bool, error)

Match determines whether the given CEL filter matches the result.

func ParseName

func ParseName(raw string) (parent, result, name string, err error)

ParseName splits a full Result name into its individual (parent, result, name) components.

func ToAPI

func ToAPI(r *db.Record) *pb.Record

ToAPI converts a database storage Record into its corresponding API equivalent.

func ToStorage

func ToStorage(parent, resultName, resultID, name string, r *pb.Record, config *config.Config) (*db.Record, error)

ToStorage converts an API Record into its corresponding database storage equivalent. parent,result,name should be the name parts (e.g. not containing "/results/" or "/records/").

func UpdateEtag

func UpdateEtag(r *db.Record) error

UpdateEtag updates the etag field of a record according to its content. The record should at least have its `Id` and `UpdatedTime` fields set.

func ValidateType added in v0.5.0

func ValidateType(t string) error

ValidateType validates line t to ensure it can be stored in the database.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL