common

package
v0.0.0-...-636a2a8 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package common has utilities that are not context specific and can be used by all packages.

Package common has utilities that are not context specific and can be used by all packages.

Index

Constants

View Source
const (
	Day       = 24 * time.Hour
	Week      = 7 * Day
	Fortnight = 14 * Day

	DefaultHoursAhead = -1 * time.Hour
	DefaultInt64      = int64(-1)
	DefaultString     = ""

	Monday                     = 0
	Tuesday                    = 1
	Wednesday                  = 2
	Thursday                   = 3
	Friday                     = 4
	Saturday                   = 5
	Sunday                     = 6
	FortnightlySecondMonday    = 7
	FortnightlySecondTuesday   = 8
	FortnightlySecondWednesday = 9
	FortnightlySecondThursday  = 10
	FortnightlySecondFriday    = 11
	FortnightlySecondSaturday  = 12
	FortnightlySecondSunday    = 13

	SuiteSchedulerCfgURL = "" /* 146-byte string literal not displayed */
	LabCfgURL            = "" /* 141-byte string literal not displayed */
	SuiteSchedulerIniURL = "" /* 146-byte string literal not displayed */
	LabIniURL            = "" /* 141-byte string literal not displayed */

	TotFileURL = "" /* 138-byte string literal not displayed */

	StagingProjectID     = "google.com:suite-scheduler-staging"
	StagingProjectNumber = 118927920079
	ProdProjectID        = "google.com:suite-scheduler"
	ProdProjectNumber    = 542690066668

	BuildsSubscription          = "chromeos-builds-all"
	BuildsSubscriptionMultiDUT  = "chromeos-builds-all-multidut"
	BuildsSubscriptionTesting   = "chromeos-builds-all-testing"
	BuildsSubscription3d        = "chromeos-builds-all-3d"
	BuildsSubscription3dTesting = "chromeos-builds-all-3d-testing"

	BuildsPubSubTopic = "kron-builds"
	EventsPubSubTopic = "kron-events"
	RunsPubSubTopic   = "kron-runs"

	FirestoreDatabaseName         = "suite-scheduler-configs"
	FirestoreConfigCollectionName = "configs"

	// MultirequestSize is the maximum number of tests requests that we can
	// combine per CTP builder run.
	MultirequestSize = 25

	KronWriterUsernameSecret               = "kron-writer-username"
	KronWriterUsernameSecretVersionStaging = 2
	KronWriterUsernameSecretVersionProd    = 1

	KronWriterPasswordSecret               = "kron-writer-password"
	KronWriterPasswordSecretVersionStaging = 1
	KronWriterPasswordSecretVersionProd    = 2

	KronReaderUsernameSecret               = "kron-reader-username"
	KronReaderUsernameSecretVersionStaging = 1
	KronReaderUsernameSecretVersionProd    = 1

	KronReaderPasswordSecret               = "kron-reader-password"
	KronReaderPasswordSecretVersionStaging = 1
	KronReaderPasswordSecretVersionProd    = 1

	KronBuildsDBNameSecret               = "kron-builds-dbname"
	KronBuildsDBNameSecretVersionStaging = 1
	KronBuildsDBNameSecretVersionProd    = 1

	KronBuildsConnectionNameSecret               = "kron-builds-connection-name"
	KronBuildsConnectionNameSecretVersionStaging = 1
	KronBuildsConnectionNameSecretVersionProd    = 1

	// StagingConfigsPrefix is the prefix for all configs that we will allow to
	// execute in staging. This will ensure that we are testing specific CUJs in
	// staging.
	StagingConfigsPrefix = "TSEStaging"
)

Variables

View Source
var (
	Stdout = log.New(os.Stdout, "", log.Lshortfile|log.LstdFlags)
	Stderr = log.New(os.Stderr, "", log.Lshortfile|log.LstdFlags)

	ProtoJSONUnmarshaller = &protojson.UnmarshalOptions{
		DiscardUnknown: true,
	}
	ProtoUnmarshaller = &proto.UnmarshalOptions{
		DiscardUnknown: true,
	}
)

Create a common STDOUT/ERR type so that the full project can standardize logging. TODO(b/317243207): change these to handle both structured and unstructured logging.

KronDayToTimeDay provides a map to translate time weekday enums to Kron weekdays.

View Source
var (
	MaxStagingSeconds = int64(18 * time.Hour.Seconds())
)

Functions

func FetchFileFromInternalURL

func FetchFileFromInternalURL(url string, authOpts *auth.Options) ([]byte, error)

FetchFileFromInternalURL retrieves text from the given internal URL, LUCI auth must be provided. It assumes the text received will be base64 encoded.

func FetchFileFromURL

func FetchFileFromURL(url string) ([]byte, error)

FetchFileFromURL retrieves text from the given URL. It assumes the text received will be base64 encoded.

func FindFactors

func FindFactors(n int) []int

FindFactors returns the list of FindFactors for the provided number.

func HasString

func HasString(target string, strings []string) bool

HasString checks to see if the given string array has the target string in it.

func IsStagingConfig

func IsStagingConfig(config *suschpb.SchedulerConfig) bool

func IsTimedEvent

func IsTimedEvent(config *suschpb.SchedulerConfig) bool

IsTimedEvent returns if the given config is a timed event or a build event type.

func ReadLocalFile

func ReadLocalFile(path string) ([]byte, error)

ReadLocalFile reads a file at the given path into memory and returns it's contents.

func TimestamppbNowWithoutNanos

func TimestamppbNowWithoutNanos() *timestamppb.Timestamp

TimestamppbNowWithoutNanos returns the current time in timestamppb.Timestamp format but with a 0 value for nanoseconds. Nanos need to be set to 0 because PLX cannot support sub second precision when time format RFC 3339 is used.

func WriteToFile

func WriteToFile(path string, data []byte) error

WriteToFile copies the given data into a file with read/write permissions. If the directory structure given does not exist at the time of calling then this function will create it.

Types

type KronTime

type KronTime struct {
	// WeeklyDay will only use [0,6].
	WeeklyDay int
	// Fortnightly can use the full [0,13].
	FortnightDay int
	// KronHour is bounded to [0,23]
	Hour      int
	StartTime time.Time
}

func TimeToKronTime

func TimeToKronTime(time time.Time) KronTime

TimeToKronTime translates time's return values into Kron parsable time.

func (*KronTime) String

func (c *KronTime) String() string

Jump to

Keyboard shortcuts

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