diff --git a/cloudevents-server/configs/example-config-sqlite3.yaml b/cloudevents-server/configs/example-config-sqlite3.yaml index d84cceb..a553dd0 100644 --- a/cloudevents-server/configs/example-config-sqlite3.yaml +++ b/cloudevents-server/configs/example-config-sqlite3.yaml @@ -5,3 +5,6 @@ lark: app_id: cli_12345678 app_secret: s123456789 receiver: abc@test.com +tibuild: + result_sink_url: http://localhost:49244 # url of tibuild events listener. + trigger_sink_url: http://localhost:8080 # url of tekton event listener. diff --git a/cloudevents-server/ent/client.go b/cloudevents-server/ent/client.go index f585d37..9fdf6ef 100644 --- a/cloudevents-server/ent/client.go +++ b/cloudevents-server/ent/client.go @@ -28,9 +28,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -58,6 +56,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { diff --git a/cloudevents-server/ent/problemcaserun_update.go b/cloudevents-server/ent/problemcaserun_update.go index 412876e..55fd93b 100644 --- a/cloudevents-server/ent/problemcaserun_update.go +++ b/cloudevents-server/ent/problemcaserun_update.go @@ -34,24 +34,56 @@ func (pcru *ProblemCaseRunUpdate) SetRepo(s string) *ProblemCaseRunUpdate { return pcru } +// SetNillableRepo sets the "repo" field if the given value is not nil. +func (pcru *ProblemCaseRunUpdate) SetNillableRepo(s *string) *ProblemCaseRunUpdate { + if s != nil { + pcru.SetRepo(*s) + } + return pcru +} + // SetBranch sets the "branch" field. func (pcru *ProblemCaseRunUpdate) SetBranch(s string) *ProblemCaseRunUpdate { pcru.mutation.SetBranch(s) return pcru } +// SetNillableBranch sets the "branch" field if the given value is not nil. +func (pcru *ProblemCaseRunUpdate) SetNillableBranch(s *string) *ProblemCaseRunUpdate { + if s != nil { + pcru.SetBranch(*s) + } + return pcru +} + // SetSuiteName sets the "suite_name" field. func (pcru *ProblemCaseRunUpdate) SetSuiteName(s string) *ProblemCaseRunUpdate { pcru.mutation.SetSuiteName(s) return pcru } +// SetNillableSuiteName sets the "suite_name" field if the given value is not nil. +func (pcru *ProblemCaseRunUpdate) SetNillableSuiteName(s *string) *ProblemCaseRunUpdate { + if s != nil { + pcru.SetSuiteName(*s) + } + return pcru +} + // SetCaseName sets the "case_name" field. func (pcru *ProblemCaseRunUpdate) SetCaseName(s string) *ProblemCaseRunUpdate { pcru.mutation.SetCaseName(s) return pcru } +// SetNillableCaseName sets the "case_name" field if the given value is not nil. +func (pcru *ProblemCaseRunUpdate) SetNillableCaseName(s *string) *ProblemCaseRunUpdate { + if s != nil { + pcru.SetCaseName(*s) + } + return pcru +} + // SetFlaky sets the "flaky" field. func (pcru *ProblemCaseRunUpdate) SetFlaky(b bool) *ProblemCaseRunUpdate { pcru.mutation.SetFlaky(b) @@ -73,6 +105,14 @@ func (pcru *ProblemCaseRunUpdate) SetTimecostMs(i int) *ProblemCaseRunUpdate { return pcru } +// SetNillableTimecostMs sets the "timecost_ms" field if the given value is not nil. +func (pcru *ProblemCaseRunUpdate) SetNillableTimecostMs(i *int) *ProblemCaseRunUpdate { + if i != nil { + pcru.SetTimecostMs(*i) + } + return pcru +} + // AddTimecostMs adds i to the "timecost_ms" field. func (pcru *ProblemCaseRunUpdate) AddTimecostMs(i int) *ProblemCaseRunUpdate { pcru.mutation.AddTimecostMs(i) @@ -85,18 +125,42 @@ func (pcru *ProblemCaseRunUpdate) SetReportTime(t time.Time) *ProblemCaseRunUpda return pcru } +// SetNillableReportTime sets the "report_time" field if the given value is not nil. +func (pcru *ProblemCaseRunUpdate) SetNillableReportTime(t *time.Time) *ProblemCaseRunUpdate { + if t != nil { + pcru.SetReportTime(*t) + } + return pcru +} + // SetBuildURL sets the "build_url" field. func (pcru *ProblemCaseRunUpdate) SetBuildURL(s string) *ProblemCaseRunUpdate { pcru.mutation.SetBuildURL(s) return pcru } +// SetNillableBuildURL sets the "build_url" field if the given value is not nil. +func (pcru *ProblemCaseRunUpdate) SetNillableBuildURL(s *string) *ProblemCaseRunUpdate { + if s != nil { + pcru.SetBuildURL(*s) + } + return pcru +} + // SetReason sets the "reason" field. func (pcru *ProblemCaseRunUpdate) SetReason(s string) *ProblemCaseRunUpdate { pcru.mutation.SetReason(s) return pcru } +// SetNillableReason sets the "reason" field if the given value is not nil. +func (pcru *ProblemCaseRunUpdate) SetNillableReason(s *string) *ProblemCaseRunUpdate { + if s != nil { + pcru.SetReason(*s) + } + return pcru +} + // Mutation returns the ProblemCaseRunMutation object of the builder. func (pcru *ProblemCaseRunUpdate) Mutation() *ProblemCaseRunMutation { return pcru.mutation @@ -212,24 +276,56 @@ func (pcruo *ProblemCaseRunUpdateOne) SetRepo(s string) *ProblemCaseRunUpdateOne return pcruo } +// SetNillableRepo sets the "repo" field if the given value is not nil. +func (pcruo *ProblemCaseRunUpdateOne) SetNillableRepo(s *string) *ProblemCaseRunUpdateOne { + if s != nil { + pcruo.SetRepo(*s) + } + return pcruo +} + // SetBranch sets the "branch" field. func (pcruo *ProblemCaseRunUpdateOne) SetBranch(s string) *ProblemCaseRunUpdateOne { pcruo.mutation.SetBranch(s) return pcruo } +// SetNillableBranch sets the "branch" field if the given value is not nil. +func (pcruo *ProblemCaseRunUpdateOne) SetNillableBranch(s *string) *ProblemCaseRunUpdateOne { + if s != nil { + pcruo.SetBranch(*s) + } + return pcruo +} + // SetSuiteName sets the "suite_name" field. func (pcruo *ProblemCaseRunUpdateOne) SetSuiteName(s string) *ProblemCaseRunUpdateOne { pcruo.mutation.SetSuiteName(s) return pcruo } +// SetNillableSuiteName sets the "suite_name" field if the given value is not nil. +func (pcruo *ProblemCaseRunUpdateOne) SetNillableSuiteName(s *string) *ProblemCaseRunUpdateOne { + if s != nil { + pcruo.SetSuiteName(*s) + } + return pcruo +} + // SetCaseName sets the "case_name" field. func (pcruo *ProblemCaseRunUpdateOne) SetCaseName(s string) *ProblemCaseRunUpdateOne { pcruo.mutation.SetCaseName(s) return pcruo } +// SetNillableCaseName sets the "case_name" field if the given value is not nil. +func (pcruo *ProblemCaseRunUpdateOne) SetNillableCaseName(s *string) *ProblemCaseRunUpdateOne { + if s != nil { + pcruo.SetCaseName(*s) + } + return pcruo +} + // SetFlaky sets the "flaky" field. func (pcruo *ProblemCaseRunUpdateOne) SetFlaky(b bool) *ProblemCaseRunUpdateOne { pcruo.mutation.SetFlaky(b) @@ -251,6 +347,14 @@ func (pcruo *ProblemCaseRunUpdateOne) SetTimecostMs(i int) *ProblemCaseRunUpdate return pcruo } +// SetNillableTimecostMs sets the "timecost_ms" field if the given value is not nil. +func (pcruo *ProblemCaseRunUpdateOne) SetNillableTimecostMs(i *int) *ProblemCaseRunUpdateOne { + if i != nil { + pcruo.SetTimecostMs(*i) + } + return pcruo +} + // AddTimecostMs adds i to the "timecost_ms" field. func (pcruo *ProblemCaseRunUpdateOne) AddTimecostMs(i int) *ProblemCaseRunUpdateOne { pcruo.mutation.AddTimecostMs(i) @@ -263,18 +367,42 @@ func (pcruo *ProblemCaseRunUpdateOne) SetReportTime(t time.Time) *ProblemCaseRun return pcruo } +// SetNillableReportTime sets the "report_time" field if the given value is not nil. +func (pcruo *ProblemCaseRunUpdateOne) SetNillableReportTime(t *time.Time) *ProblemCaseRunUpdateOne { + if t != nil { + pcruo.SetReportTime(*t) + } + return pcruo +} + // SetBuildURL sets the "build_url" field. func (pcruo *ProblemCaseRunUpdateOne) SetBuildURL(s string) *ProblemCaseRunUpdateOne { pcruo.mutation.SetBuildURL(s) return pcruo } +// SetNillableBuildURL sets the "build_url" field if the given value is not nil. +func (pcruo *ProblemCaseRunUpdateOne) SetNillableBuildURL(s *string) *ProblemCaseRunUpdateOne { + if s != nil { + pcruo.SetBuildURL(*s) + } + return pcruo +} + // SetReason sets the "reason" field. func (pcruo *ProblemCaseRunUpdateOne) SetReason(s string) *ProblemCaseRunUpdateOne { pcruo.mutation.SetReason(s) return pcruo } +// SetNillableReason sets the "reason" field if the given value is not nil. +func (pcruo *ProblemCaseRunUpdateOne) SetNillableReason(s *string) *ProblemCaseRunUpdateOne { + if s != nil { + pcruo.SetReason(*s) + } + return pcruo +} + // Mutation returns the ProblemCaseRunMutation object of the builder. func (pcruo *ProblemCaseRunUpdateOne) Mutation() *ProblemCaseRunMutation { return pcruo.mutation diff --git a/cloudevents-server/ent/runtime/runtime.go b/cloudevents-server/ent/runtime/runtime.go index 29855c4..24647c4 100644 --- a/cloudevents-server/ent/runtime/runtime.go +++ b/cloudevents-server/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in github.com/PingCAP-QE/ee-apps/cloudevents-server/ent/runtime.go const ( - Version = "v0.12.4" // Version of ent codegen. - Sum = "h1:LddPnAyxls/O7DTXZvUGDj0NZIdGSu317+aoNLJWbD8=" // Sum of ent codegen. + Version = "v0.12.5" // Version of ent codegen. + Sum = "h1:KREM5E4CSoej4zeGa88Ou/gfturAnpUv0mzAjch1sj4=" // Sum of ent codegen. ) diff --git a/cloudevents-server/pkg/events/custom/testcaserun/handler.go b/cloudevents-server/pkg/events/custom/testcaserun/handler.go index 097f700..01d0044 100644 --- a/cloudevents-server/pkg/events/custom/testcaserun/handler.go +++ b/cloudevents-server/pkg/events/custom/testcaserun/handler.go @@ -77,6 +77,7 @@ func (h *Handler) addRecords(ctx context.Context, caseData map[string]ProblemCas SetBuildURL(buildURL). SetTimecostMs(int(timecost * 1000)). SetReportTime(reportTime). + SetReason(reasonNA). SetFlaky(false) if timecost < 0 { entry.SetReason(reasonNotFinished) diff --git a/cloudevents-server/pkg/events/custom/testcaserun/types.go b/cloudevents-server/pkg/events/custom/testcaserun/types.go index 8b6b5f4..269fa60 100644 --- a/cloudevents-server/pkg/events/custom/testcaserun/types.go +++ b/cloudevents-server/pkg/events/custom/testcaserun/types.go @@ -5,6 +5,7 @@ const ( reasonNotFinished = "not_finished" reasonUnknown = "unknown" + reasonNA = "N/A" ) // ProblemCasesFromBazel present case run records from bazel.