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
- Variables
- func FetchFileFromInternalURL(url string, authOpts *auth.Options) ([]byte, error)
- func FetchFileFromURL(url string) ([]byte, error)
- func FindFactors(n int) []int
- func HasString(target string, strings []string) bool
- func IsStagingConfig(config *suschpb.SchedulerConfig) bool
- func IsTimedEvent(config *suschpb.SchedulerConfig) bool
- func ReadLocalFile(path string) ([]byte, error)
- func TimestamppbNowWithoutNanos() *timestamppb.Timestamp
- func WriteToFile(path string, data []byte) error
- type KronTime
Constants ¶
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 ¶
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.
var KronDayToTimeDay = map[time.Weekday]int{ time.Sunday: Sunday, time.Monday: Monday, time.Tuesday: Tuesday, time.Wednesday: Wednesday, time.Thursday: Thursday, time.Friday: Friday, time.Saturday: Saturday, }
KronDayToTimeDay provides a map to translate time weekday enums to Kron weekdays.
var (
MaxStagingSeconds = int64(18 * time.Hour.Seconds())
)
Functions ¶
func FetchFileFromInternalURL ¶
FetchFileFromInternalURL retrieves text from the given internal URL, LUCI auth must be provided. It assumes the text received will be base64 encoded.
func FetchFileFromURL ¶
FetchFileFromURL retrieves text from the given URL. It assumes the text received will be base64 encoded.
func FindFactors ¶
FindFactors returns the list of FindFactors for the provided number.
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 ¶
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 ¶
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 ¶
TimeToKronTime translates time's return values into Kron parsable time.