From 7f5ba6df657a5ad69cc21ba6e30b483aa569a8a1 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Wed, 7 Aug 2024 03:02:01 +0100 Subject: [PATCH] feat: upgrade proto to v0.4.20 --- .../internal/biz/biztiphereth/porter.go | 32 +- .../internal/biz/biztiphereth/tiphereth.go | 26 +- .../internal/biz/bizyesod/builtin_action.go | 16 +- app/sephirah/internal/biz/bizyesod/yesod.go | 5 +- .../data/internal/converter/biz_to_ent.go | 12 +- .../data/internal/converter/ent_to_biz.go | 20 +- .../data/internal/converter/generated.go | 220 +++++++------- .../data/internal/ent/feedactionset.go | 4 +- .../data/internal/ent/feedactionset_create.go | 10 +- .../data/internal/ent/feedactionset_update.go | 10 +- .../internal/data/internal/ent/feedconfig.go | 4 +- .../data/internal/ent/feedconfig_create.go | 10 +- .../data/internal/ent/feedconfig_update.go | 6 +- .../data/internal/ent/migrate/schema.go | 11 +- .../internal/data/internal/ent/mutation.go | 266 +++++++++++++++-- .../data/internal/ent/notifytarget.go | 4 +- .../data/internal/ent/notifytarget_create.go | 10 +- .../data/internal/ent/notifytarget_update.go | 6 +- .../data/internal/ent/porterinstance.go | 50 +++- .../ent/porterinstance/porterinstance.go | 32 ++ .../data/internal/ent/porterinstance/where.go | 280 ++++++++++++++++++ .../internal/ent/porterinstance_create.go | 222 +++++++++++++- .../internal/ent/porterinstance_update.go | 142 ++++++++- .../internal/data/internal/ent/runtime.go | 4 +- .../internal/ent/schema/feed_action_set.go | 4 +- .../data/internal/ent/schema/feed_config.go | 4 +- .../data/internal/ent/schema/notify_target.go | 4 +- .../internal/ent/schema/porter_instance.go | 9 +- app/sephirah/internal/data/tiphereth.go | 70 ++++- .../internal/model/converter/biz_to_pb.go | 38 +-- .../internal/model/converter/generated.go | 247 +++++++++------ .../internal/model/converter/pb_to_biz.go | 28 +- .../model/modelnetzach/modelnetzach.go | 4 +- .../modelsupervisor.go | 32 +- .../internal/model/modelyesod/modelyesod.go | 8 +- app/sephirah/internal/service/tiphereth.go | 29 +- app/sephirah/internal/supervisor/feature.go | 14 +- app/sephirah/internal/supervisor/summary.go | 19 +- .../internal/supervisor/supervisor.go | 68 ++--- go.mod | 2 +- go.sum | 4 +- 41 files changed, 1542 insertions(+), 444 deletions(-) rename app/sephirah/internal/model/{modeltiphereth => modelsupervisor}/modelsupervisor.go (87%) diff --git a/app/sephirah/internal/biz/biztiphereth/porter.go b/app/sephirah/internal/biz/biztiphereth/porter.go index 348d2ba..d8cb486 100644 --- a/app/sephirah/internal/biz/biztiphereth/porter.go +++ b/app/sephirah/internal/biz/biztiphereth/porter.go @@ -4,6 +4,7 @@ import ( "context" "github.com/tuihub/librarian/app/sephirah/internal/biz/bizutils" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/lib/logger" @@ -29,7 +30,7 @@ func (t *Tiphereth) updatePorters(ctx context.Context) error { } for i, porter := range newPorters { porter.ID = ids[i] - porter.Status = modeltiphereth.PorterInstanceStatusBlocked + porter.Status = modeltiphereth.UserStatusBlocked } err = t.repo.UpsertPorters(ctx, newPorters) if err != nil { @@ -42,7 +43,7 @@ func (t *Tiphereth) updatePorters(ctx context.Context) error { func (t *Tiphereth) ListPorters( ctx context.Context, paging model.Paging, -) ([]*modeltiphereth.PorterInstance, int64, *errors.Error) { +) ([]*modelsupervisor.PorterInstance, int64, *errors.Error) { if libauth.FromContextAssertUserType(ctx, libauth.UserTypeAdmin) == nil { return nil, 0, bizutils.NoPermissionError() } @@ -56,7 +57,7 @@ func (t *Tiphereth) ListPorters( func (t *Tiphereth) UpdatePorterStatus( ctx context.Context, id model.InternalID, - status modeltiphereth.PorterInstanceStatus, + status modeltiphereth.UserStatus, ) *errors.Error { if libauth.FromContextAssertUserType(ctx, libauth.UserTypeAdmin) == nil { return bizutils.NoPermissionError() @@ -69,7 +70,7 @@ func (t *Tiphereth) UpdatePorterStatus( return nil } -func (t *Tiphereth) CreatePorterContext(ctx context.Context, context *modeltiphereth.PorterContext) (model.InternalID, *errors.Error) { +func (t *Tiphereth) CreatePorterContext(ctx context.Context, context *modelsupervisor.PorterContext) (model.InternalID, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return 0, bizutils.NoPermissionError() @@ -86,7 +87,7 @@ func (t *Tiphereth) CreatePorterContext(ctx context.Context, context *modeltiphe return id, nil } -func (t *Tiphereth) ListPorterContexts(ctx context.Context, paging model.Paging) ([]*modeltiphereth.PorterContext, int64, *errors.Error) { +func (t *Tiphereth) ListPorterContexts(ctx context.Context, paging model.Paging) ([]*modelsupervisor.PorterContext, int64, *errors.Error) { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { return nil, 0, bizutils.NoPermissionError() @@ -100,7 +101,7 @@ func (t *Tiphereth) ListPorterContexts(ctx context.Context, paging model.Paging) func (t *Tiphereth) UpdatePorterContext( ctx context.Context, - context *modeltiphereth.PorterContext, + context *modelsupervisor.PorterContext, ) *errors.Error { claims := libauth.FromContextAssertUserType(ctx) if claims == nil { @@ -112,3 +113,22 @@ func (t *Tiphereth) UpdatePorterContext( } return nil } + +func (t *Tiphereth) ListPorterGroups( + ctx context.Context, + paging model.Paging, + status []modeltiphereth.UserStatus, +) ([]*modelsupervisor.PorterGroup, int64, *errors.Error) { + claims := libauth.FromContextAssertUserType(ctx) + if claims == nil { + return nil, 0, bizutils.NoPermissionError() + } + if claims.UserType != libauth.UserTypeAdmin { + status = []modeltiphereth.UserStatus{modeltiphereth.UserStatusActive} + } + groups, err := t.repo.ListPorterGroups(ctx, status) + if err != nil { + return nil, 0, pb.ErrorErrorReasonUnspecified("%s", err.Error()) + } + return groups, int64(len(groups)), nil +} diff --git a/app/sephirah/internal/biz/biztiphereth/tiphereth.go b/app/sephirah/internal/biz/biztiphereth/tiphereth.go index aca8d44..e311399 100644 --- a/app/sephirah/internal/biz/biztiphereth/tiphereth.go +++ b/app/sephirah/internal/biz/biztiphereth/tiphereth.go @@ -4,6 +4,7 @@ import ( "context" "github.com/tuihub/librarian/app/sephirah/internal/client" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/app/sephirah/internal/supervisor" "github.com/tuihub/librarian/internal/lib/libapp" @@ -36,14 +37,14 @@ type TipherethRepo interface { UnLinkAccount(context.Context, modeltiphereth.Account, model.InternalID) error ListLinkAccounts(context.Context, model.InternalID) ([]*modeltiphereth.Account, error) GetUser(context.Context, model.InternalID) (*modeltiphereth.User, error) - UpsertPorters(context.Context, []*modeltiphereth.PorterInstance) error - ListPorters(context.Context, model.Paging) ([]*modeltiphereth.PorterInstance, int64, error) - FetchPorterByAddress(context.Context, string) (*modeltiphereth.PorterInstance, error) + UpsertPorters(context.Context, []*modelsupervisor.PorterInstance) error + ListPorters(context.Context, model.Paging) ([]*modelsupervisor.PorterInstance, int64, error) + FetchPorterByAddress(context.Context, string) (*modelsupervisor.PorterInstance, error) UpdatePorterStatus(context.Context, model.InternalID, - modeltiphereth.PorterInstanceStatus) (*modeltiphereth.PorterInstance, error) - CreatePorterContext(context.Context, model.InternalID, *modeltiphereth.PorterContext) error - ListPorterContexts(context.Context, model.InternalID, model.Paging) ([]*modeltiphereth.PorterContext, int64, error) - UpdatePorterContext(context.Context, model.InternalID, *modeltiphereth.PorterContext) error + modeltiphereth.UserStatus) (*modelsupervisor.PorterInstance, error) + CreatePorterContext(context.Context, model.InternalID, *modelsupervisor.PorterContext) error + ListPorterContexts(context.Context, model.InternalID, model.Paging) ([]*modelsupervisor.PorterContext, int64, error) + UpdatePorterContext(context.Context, model.InternalID, *modelsupervisor.PorterContext) error CreateDevice(context.Context, *modeltiphereth.DeviceInfo) error ListUserSessions(context.Context, model.InternalID) ([]*modeltiphereth.UserSession, error) DeleteUserSession(context.Context, model.InternalID, model.InternalID) error @@ -52,6 +53,7 @@ type TipherethRepo interface { FetchUserSession(context.Context, model.InternalID, string) (*modeltiphereth.UserSession, error) UpdateUserSession(context.Context, *modeltiphereth.UserSession) error ListDevices(context.Context, model.InternalID) ([]*modeltiphereth.DeviceInfo, error) + ListPorterGroups(context.Context, []modeltiphereth.UserStatus) ([]*modelsupervisor.PorterGroup, error) } type Tiphereth struct { @@ -63,7 +65,7 @@ type Tiphereth struct { searcher *client.Searcher pullAccount *libmq.Topic[modeltiphereth.PullAccountInfo] userCountCache *libcache.Key[modeltiphereth.UserCount] - porterInstanceCache *libcache.Map[string, modeltiphereth.PorterInstance] + porterInstanceCache *libcache.Map[string, modelsupervisor.PorterInstance] } func NewTiphereth( @@ -76,7 +78,7 @@ func NewTiphereth( pullAccount *libmq.Topic[modeltiphereth.PullAccountInfo], cron *libcron.Cron, userCountCache *libcache.Key[modeltiphereth.UserCount], - porterInstanceCache *libcache.Map[string, modeltiphereth.PorterInstance], + porterInstanceCache *libcache.Map[string, modelsupervisor.PorterInstance], ) (*Tiphereth, error) { t := &Tiphereth{ app: app, @@ -170,14 +172,14 @@ func NewUserCountCache( func NewPorterInstanceCache( t TipherethRepo, store libcache.Store, -) *libcache.Map[string, modeltiphereth.PorterInstance] { - return libcache.NewMap[string, modeltiphereth.PorterInstance]( +) *libcache.Map[string, modelsupervisor.PorterInstance] { + return libcache.NewMap[string, modelsupervisor.PorterInstance]( store, "PorterInstanceCache", func(s string) string { return s }, - func(ctx context.Context, s string) (*modeltiphereth.PorterInstance, error) { + func(ctx context.Context, s string) (*modelsupervisor.PorterInstance, error) { return t.FetchPorterByAddress(ctx, s) }, libcache.WithExpiration(libtime.SevenDays), diff --git a/app/sephirah/internal/biz/bizyesod/builtin_action.go b/app/sephirah/internal/biz/bizyesod/builtin_action.go index e508ab7..e1f336b 100644 --- a/app/sephirah/internal/biz/bizyesod/builtin_action.go +++ b/app/sephirah/internal/biz/bizyesod/builtin_action.go @@ -5,7 +5,7 @@ import ( "net/url" "strings" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" "github.com/tuihub/librarian/internal/lib/libcodec" "github.com/tuihub/librarian/internal/model/modelfeed" @@ -25,15 +25,15 @@ func RequiredStartAction(ctx context.Context, item *modelfeed.Item) (*modelfeed. func GetBuiltinActionMap( ctx context.Context, -) map[string]func(context.Context, *modeltiphereth.FeatureRequest, *modelfeed.Item) (*modelfeed.Item, error) { - return map[string]func(context.Context, *modeltiphereth.FeatureRequest, *modelfeed.Item) (*modelfeed.Item, error){ +) map[string]func(context.Context, *modelsupervisor.FeatureRequest, *modelfeed.Item) (*modelfeed.Item, error) { + return map[string]func(context.Context, *modelsupervisor.FeatureRequest, *modelfeed.Item) (*modelfeed.Item, error){ simpleKeywordFilterActionID: simpleKeywordFilterAction, keywordFilterActionID: keywordFilterAction, descriptionGeneratorActionID: descriptionGeneratorAction, } } -func getBuiltinActionFeatureFlags() ([]*modeltiphereth.FeatureFlag, error) { +func getBuiltinActionFeatureFlags() ([]*modelsupervisor.FeatureFlag, error) { simple, err := modelyesod.GetSimpleKeywordFilterActionConfigSchema() if err != nil { return nil, err @@ -46,7 +46,7 @@ func getBuiltinActionFeatureFlags() ([]*modeltiphereth.FeatureFlag, error) { if err != nil { return nil, err } - return []*modeltiphereth.FeatureFlag{ + return []*modelsupervisor.FeatureFlag{ { ID: simpleKeywordFilterActionID, Name: "Simple Keyword Filter", @@ -121,7 +121,7 @@ func parseDigestAction(_ context.Context, item *modelfeed.Item) (*modelfeed.Item func simpleKeywordFilterAction( _ context.Context, - request *modeltiphereth.FeatureRequest, + request *modelsupervisor.FeatureRequest, item *modelfeed.Item, ) (*modelfeed.Item, error) { config := new(modelyesod.SimpleKeywordFilterActionConfig) @@ -151,12 +151,12 @@ func simpleKeywordFilterAction( return item, nil } -func keywordFilterAction(ctx context.Context, _ *modeltiphereth.FeatureRequest, item *modelfeed.Item) (*modelfeed.Item, error) { +func keywordFilterAction(ctx context.Context, _ *modelsupervisor.FeatureRequest, item *modelfeed.Item) (*modelfeed.Item, error) { // TODO: impl return item, nil } -func descriptionGeneratorAction(_ context.Context, _ *modeltiphereth.FeatureRequest, item *modelfeed.Item) (*modelfeed.Item, error) { +func descriptionGeneratorAction(_ context.Context, _ *modelsupervisor.FeatureRequest, item *modelfeed.Item) (*modelfeed.Item, error) { if len(item.Description) > 0 { return item, nil } diff --git a/app/sephirah/internal/biz/bizyesod/yesod.go b/app/sephirah/internal/biz/bizyesod/yesod.go index 532c5bc..c8ca42b 100644 --- a/app/sephirah/internal/biz/bizyesod/yesod.go +++ b/app/sephirah/internal/biz/bizyesod/yesod.go @@ -8,6 +8,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/client" "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" "github.com/tuihub/librarian/app/sephirah/internal/supervisor" @@ -66,7 +67,7 @@ type Yesod struct { pullFeed *libmq.Topic[modelyesod.PullFeed] systemNotify *libmq.Topic[modelnetzach.SystemNotify] feedOwner *libcache.Map[modelyesod.FeedConfig, modeltiphereth.User] - builtinFeedActions []*modeltiphereth.FeatureFlag + builtinFeedActions []*modelsupervisor.FeatureFlag } func NewYesod( @@ -100,7 +101,7 @@ func NewYesod( return y, nil } -func (y *Yesod) GetBuiltInFeedActions() []*modeltiphereth.FeatureFlag { +func (y *Yesod) GetBuiltInFeedActions() []*modelsupervisor.FeatureFlag { return y.builtinFeedActions } diff --git a/app/sephirah/internal/data/internal/converter/biz_to_ent.go b/app/sephirah/internal/data/internal/converter/biz_to_ent.go index 177bbf7..403b73f 100644 --- a/app/sephirah/internal/data/internal/converter/biz_to_ent.go +++ b/app/sephirah/internal/data/internal/converter/biz_to_ent.go @@ -15,6 +15,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/model/modelchesed" "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" "github.com/tuihub/librarian/internal/lib/libauth" @@ -53,16 +54,17 @@ type toEntConverter interface { //nolint:unused // used by generator ToEntSystemType(modeltiphereth.SystemType) deviceinfo.SystemType // goverter:enum:unknown @ignore - // goverter:enum:map PorterInstanceStatusUnspecified @ignore - // goverter:enum:map PorterInstanceStatusActive StatusActive - // goverter:enum:map PorterInstanceStatusBlocked StatusBlocked - ToEntPorterInstanceStatus(modeltiphereth.PorterInstanceStatus) porterinstance.Status + // goverter:enum:map UserStatusUnspecified @ignore + // goverter:enum:map UserStatusActive StatusActive + // goverter:enum:map UserStatusBlocked StatusBlocked + ToEntPorterInstanceStatus(modeltiphereth.UserStatus) porterinstance.Status + ToEntPorterInstanceStatusList([]modeltiphereth.UserStatus) []porterinstance.Status // goverter:enum:unknown @ignore // goverter:enum:map PorterContextStatusUnspecified @ignore // goverter:enum:map PorterContextStatusActive StatusActive // goverter:enum:map PorterContextStatusDisabled StatusDisabled - ToEntPorterContextStatus(modeltiphereth.PorterContextStatus) portercontext.Status + ToEntPorterContextStatus(modelsupervisor.PorterContextStatus) portercontext.Status // goverter:autoMap Details // goverter:useZeroValueOnPointerInconsistency diff --git a/app/sephirah/internal/data/internal/converter/ent_to_biz.go b/app/sephirah/internal/data/internal/converter/ent_to_biz.go index f011f97..40d51b4 100644 --- a/app/sephirah/internal/data/internal/converter/ent_to_biz.go +++ b/app/sephirah/internal/data/internal/converter/ent_to_biz.go @@ -17,6 +17,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/model/modelchesed" "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" "github.com/tuihub/librarian/internal/lib/libauth" @@ -67,21 +68,22 @@ type toBizConverter interface { //nolint:unused // used by generator ToBizAccount(*ent.Account) *modeltiphereth.Account ToBizAccountList([]*ent.Account) []*modeltiphereth.Account - ToBizPorter(*ent.PorterInstance) *modeltiphereth.PorterInstance - ToBizPorterList([]*ent.PorterInstance) []*modeltiphereth.PorterInstance - // goverter:enum:unknown PorterInstanceStatusUnspecified - // goverter:enum:map StatusActive PorterInstanceStatusActive - // goverter:enum:map StatusBlocked PorterInstanceStatusBlocked - ToBizPorterStatus(porterinstance.Status) modeltiphereth.PorterInstanceStatus + // goverter:map . BinarySummary + ToBizPorter(*ent.PorterInstance) *modelsupervisor.PorterInstance + ToBizPorterList([]*ent.PorterInstance) []*modelsupervisor.PorterInstance + // goverter:enum:unknown UserStatusUnspecified + // goverter:enum:map StatusActive UserStatusActive + // goverter:enum:map StatusBlocked UserStatusBlocked + ToBizPorterStatus(porterinstance.Status) modeltiphereth.UserStatus // goverter:ignore HandleStatus // goverter:ignore HandleStatusMessage - ToBizPorterContext(*ent.PorterContext) *modeltiphereth.PorterContext - ToBizPorterContextList([]*ent.PorterContext) []*modeltiphereth.PorterContext + ToBizPorterContext(*ent.PorterContext) *modelsupervisor.PorterContext + ToBizPorterContextList([]*ent.PorterContext) []*modelsupervisor.PorterContext // goverter:enum:unknown PorterContextStatusUnspecified // goverter:enum:map StatusActive PorterContextStatusActive // goverter:enum:map StatusDisabled PorterContextStatusDisabled - ToBizPorterContextStatus(portercontext.Status) modeltiphereth.PorterContextStatus + ToBizPorterContextStatus(portercontext.Status) modelsupervisor.PorterContextStatus // goverter:map . Details // goverter:map UpdatedAt LatestUpdateTime diff --git a/app/sephirah/internal/data/internal/converter/generated.go b/app/sephirah/internal/data/internal/converter/generated.go index 5020afd..b2650a0 100644 --- a/app/sephirah/internal/data/internal/converter/generated.go +++ b/app/sephirah/internal/data/internal/converter/generated.go @@ -18,6 +18,7 @@ import ( modelchesed "github.com/tuihub/librarian/app/sephirah/internal/model/modelchesed" modelgebura "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" modelnetzach "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" + modelsupervisor "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" modeltiphereth "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" modelyesod "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" libauth "github.com/tuihub/librarian/internal/lib/libauth" @@ -203,9 +204,9 @@ func ToBizFeedActionSet(source *ent.FeedActionSet) *modelyesod.FeedActionSet { modelyesodFeedActionSet.Name = (*source).Name modelyesodFeedActionSet.Description = (*source).Description if (*source).Actions != nil { - modelyesodFeedActionSet.Actions = make([]*modeltiphereth.FeatureRequest, len((*source).Actions)) + modelyesodFeedActionSet.Actions = make([]*modelsupervisor.FeatureRequest, len((*source).Actions)) for i := 0; i < len((*source).Actions); i++ { - modelyesodFeedActionSet.Actions[i] = pModeltipherethFeatureRequestToPModeltipherethFeatureRequest((*source).Actions[i]) + modelyesodFeedActionSet.Actions[i] = pModelsupervisorFeatureRequestToPModelsupervisorFeatureRequest((*source).Actions[i]) } } pModelyesodFeedActionSet = &modelyesodFeedActionSet @@ -229,7 +230,7 @@ func ToBizFeedConfig(source *ent.FeedConfig) *modelyesod.FeedConfig { modelyesodFeedConfig.ID = modelInternalIDToModelInternalID((*source).ID) modelyesodFeedConfig.Name = (*source).Name modelyesodFeedConfig.Description = (*source).Description - modelyesodFeedConfig.Source = pModeltipherethFeatureRequestToPModeltipherethFeatureRequest((*source).Source) + modelyesodFeedConfig.Source = pModelsupervisorFeatureRequestToPModelsupervisorFeatureRequest((*source).Source) modelyesodFeedConfig.Category = (*source).Category modelyesodFeedConfig.Status = ToBizFeedConfigStatus((*source).Status) modelyesodFeedConfig.PullInterval = time.Duration((*source).PullInterval) @@ -414,7 +415,7 @@ func ToBizNotifyTarget(source *ent.NotifyTarget) *modelnetzach.NotifyTarget { modelnetzachNotifyTarget.ID = modelInternalIDToModelInternalID((*source).ID) modelnetzachNotifyTarget.Name = (*source).Name modelnetzachNotifyTarget.Description = (*source).Description - modelnetzachNotifyTarget.Destination = pModeltipherethFeatureRequestToPModeltipherethFeatureRequest((*source).Destination) + modelnetzachNotifyTarget.Destination = pModelsupervisorFeatureRequestToPModelsupervisorFeatureRequest((*source).Destination) modelnetzachNotifyTarget.Status = ToBizNotifyTargetStatus((*source).Status) pModelnetzachNotifyTarget = &modelnetzachNotifyTarget } @@ -442,81 +443,80 @@ func ToBizNotifyTargetStatus(source notifytarget.Status) modelnetzach.NotifyTarg } return modelnetzachNotifyTargetStatus } -func ToBizPorter(source *ent.PorterInstance) *modeltiphereth.PorterInstance { - var pModeltipherethPorterInstance *modeltiphereth.PorterInstance +func ToBizPorter(source *ent.PorterInstance) *modelsupervisor.PorterInstance { + var pModelsupervisorPorterInstance *modelsupervisor.PorterInstance if source != nil { - var modeltipherethPorterInstance modeltiphereth.PorterInstance - modeltipherethPorterInstance.ID = modelInternalIDToModelInternalID((*source).ID) - modeltipherethPorterInstance.Name = (*source).Name - modeltipherethPorterInstance.Version = (*source).Version - modeltipherethPorterInstance.GlobalName = (*source).GlobalName - modeltipherethPorterInstance.Address = (*source).Address - modeltipherethPorterInstance.Region = (*source).Region - modeltipherethPorterInstance.FeatureSummary = pModeltipherethPorterFeatureSummaryToPModeltipherethPorterFeatureSummary((*source).FeatureSummary) - modeltipherethPorterInstance.Status = ToBizPorterStatus((*source).Status) - modeltipherethPorterInstance.ContextJSONSchema = (*source).ContextJSONSchema - pModeltipherethPorterInstance = &modeltipherethPorterInstance - } - return pModeltipherethPorterInstance -} -func ToBizPorterContext(source *ent.PorterContext) *modeltiphereth.PorterContext { - var pModeltipherethPorterContext *modeltiphereth.PorterContext + var modelsupervisorPorterInstance modelsupervisor.PorterInstance + modelsupervisorPorterInstance.ID = modelInternalIDToModelInternalID((*source).ID) + modelsupervisorPorterInstance.BinarySummary = entPorterInstanceToPModelsupervisorPorterBinarySummary((*source)) + modelsupervisorPorterInstance.GlobalName = (*source).GlobalName + modelsupervisorPorterInstance.Address = (*source).Address + modelsupervisorPorterInstance.Region = (*source).Region + modelsupervisorPorterInstance.FeatureSummary = pModelsupervisorPorterFeatureSummaryToPModelsupervisorPorterFeatureSummary((*source).FeatureSummary) + modelsupervisorPorterInstance.Status = ToBizPorterStatus((*source).Status) + modelsupervisorPorterInstance.ContextJSONSchema = (*source).ContextJSONSchema + pModelsupervisorPorterInstance = &modelsupervisorPorterInstance + } + return pModelsupervisorPorterInstance +} +func ToBizPorterContext(source *ent.PorterContext) *modelsupervisor.PorterContext { + var pModelsupervisorPorterContext *modelsupervisor.PorterContext if source != nil { - var modeltipherethPorterContext modeltiphereth.PorterContext - modeltipherethPorterContext.ID = modelInternalIDToModelInternalID((*source).ID) - modeltipherethPorterContext.GlobalName = (*source).GlobalName - modeltipherethPorterContext.Region = (*source).Region - modeltipherethPorterContext.ContextJSON = (*source).ContextJSON - modeltipherethPorterContext.Name = (*source).Name - modeltipherethPorterContext.Description = (*source).Description - modeltipherethPorterContext.Status = ToBizPorterContextStatus((*source).Status) - pModeltipherethPorterContext = &modeltipherethPorterContext - } - return pModeltipherethPorterContext -} -func ToBizPorterContextList(source []*ent.PorterContext) []*modeltiphereth.PorterContext { - var pModeltipherethPorterContextList []*modeltiphereth.PorterContext + var modelsupervisorPorterContext modelsupervisor.PorterContext + modelsupervisorPorterContext.ID = modelInternalIDToModelInternalID((*source).ID) + modelsupervisorPorterContext.GlobalName = (*source).GlobalName + modelsupervisorPorterContext.Region = (*source).Region + modelsupervisorPorterContext.ContextJSON = (*source).ContextJSON + modelsupervisorPorterContext.Name = (*source).Name + modelsupervisorPorterContext.Description = (*source).Description + modelsupervisorPorterContext.Status = ToBizPorterContextStatus((*source).Status) + pModelsupervisorPorterContext = &modelsupervisorPorterContext + } + return pModelsupervisorPorterContext +} +func ToBizPorterContextList(source []*ent.PorterContext) []*modelsupervisor.PorterContext { + var pModelsupervisorPorterContextList []*modelsupervisor.PorterContext if source != nil { - pModeltipherethPorterContextList = make([]*modeltiphereth.PorterContext, len(source)) + pModelsupervisorPorterContextList = make([]*modelsupervisor.PorterContext, len(source)) for i := 0; i < len(source); i++ { - pModeltipherethPorterContextList[i] = ToBizPorterContext(source[i]) + pModelsupervisorPorterContextList[i] = ToBizPorterContext(source[i]) } } - return pModeltipherethPorterContextList + return pModelsupervisorPorterContextList } -func ToBizPorterContextStatus(source portercontext.Status) modeltiphereth.PorterContextStatus { - var modeltipherethPorterContextStatus modeltiphereth.PorterContextStatus +func ToBizPorterContextStatus(source portercontext.Status) modelsupervisor.PorterContextStatus { + var modelsupervisorPorterContextStatus modelsupervisor.PorterContextStatus switch source { case portercontext.StatusActive: - modeltipherethPorterContextStatus = modeltiphereth.PorterContextStatusActive + modelsupervisorPorterContextStatus = modelsupervisor.PorterContextStatusActive case portercontext.StatusDisabled: - modeltipherethPorterContextStatus = modeltiphereth.PorterContextStatusDisabled + modelsupervisorPorterContextStatus = modelsupervisor.PorterContextStatusDisabled default: - modeltipherethPorterContextStatus = modeltiphereth.PorterContextStatusUnspecified + modelsupervisorPorterContextStatus = modelsupervisor.PorterContextStatusUnspecified } - return modeltipherethPorterContextStatus + return modelsupervisorPorterContextStatus } -func ToBizPorterList(source []*ent.PorterInstance) []*modeltiphereth.PorterInstance { - var pModeltipherethPorterInstanceList []*modeltiphereth.PorterInstance +func ToBizPorterList(source []*ent.PorterInstance) []*modelsupervisor.PorterInstance { + var pModelsupervisorPorterInstanceList []*modelsupervisor.PorterInstance if source != nil { - pModeltipherethPorterInstanceList = make([]*modeltiphereth.PorterInstance, len(source)) + pModelsupervisorPorterInstanceList = make([]*modelsupervisor.PorterInstance, len(source)) for i := 0; i < len(source); i++ { - pModeltipherethPorterInstanceList[i] = ToBizPorter(source[i]) + pModelsupervisorPorterInstanceList[i] = ToBizPorter(source[i]) } } - return pModeltipherethPorterInstanceList + return pModelsupervisorPorterInstanceList } -func ToBizPorterStatus(source porterinstance.Status) modeltiphereth.PorterInstanceStatus { - var modeltipherethPorterInstanceStatus modeltiphereth.PorterInstanceStatus +func ToBizPorterStatus(source porterinstance.Status) modeltiphereth.UserStatus { + var modeltipherethUserStatus modeltiphereth.UserStatus switch source { case porterinstance.StatusActive: - modeltipherethPorterInstanceStatus = modeltiphereth.PorterInstanceStatusActive + modeltipherethUserStatus = modeltiphereth.UserStatusActive case porterinstance.StatusBlocked: - modeltipherethPorterInstanceStatus = modeltiphereth.PorterInstanceStatusBlocked + modeltipherethUserStatus = modeltiphereth.UserStatusBlocked default: - modeltipherethPorterInstanceStatus = modeltiphereth.PorterInstanceStatusUnspecified + modeltipherethUserStatus = modeltiphereth.UserStatusUnspecified } - return modeltipherethPorterInstanceStatus + return modeltipherethUserStatus } func ToBizSystemNotification(source *ent.SystemNotification) *modelnetzach.SystemNotification { var pModelnetzachSystemNotification *modelnetzach.SystemNotification @@ -688,6 +688,16 @@ func entAppInfoToPModelgeburaAppInfoDetails(source ent.AppInfo) *modelgebura.App modelgeburaAppInfoDetails.Version = source.Version return &modelgeburaAppInfoDetails } +func entPorterInstanceToPModelsupervisorPorterBinarySummary(source ent.PorterInstance) *modelsupervisor.PorterBinarySummary { + var modelsupervisorPorterBinarySummary modelsupervisor.PorterBinarySummary + modelsupervisorPorterBinarySummary.Name = source.Name + modelsupervisorPorterBinarySummary.Version = source.Version + modelsupervisorPorterBinarySummary.Description = source.Description + modelsupervisorPorterBinarySummary.SourceCodeAddress = source.SourceCodeAddress + modelsupervisorPorterBinarySummary.BuildVersion = source.BuildVersion + modelsupervisorPorterBinarySummary.BuildDate = source.BuildDate + return &modelsupervisorPorterBinarySummary +} func modelInternalIDToModelInternalID(source model.InternalID) model.InternalID { return model.InternalID(source) } @@ -722,68 +732,68 @@ func pModelfeedPersonToPModelfeedPerson(source *modelfeed.Person) *modelfeed.Per } return pModelfeedPerson } -func pModeltipherethFeatureFlagToPModeltipherethFeatureFlag(source *modeltiphereth.FeatureFlag) *modeltiphereth.FeatureFlag { - var pModeltipherethFeatureFlag *modeltiphereth.FeatureFlag +func pModelsupervisorFeatureFlagToPModelsupervisorFeatureFlag(source *modelsupervisor.FeatureFlag) *modelsupervisor.FeatureFlag { + var pModelsupervisorFeatureFlag *modelsupervisor.FeatureFlag if source != nil { - var modeltipherethFeatureFlag modeltiphereth.FeatureFlag - modeltipherethFeatureFlag.ID = (*source).ID - modeltipherethFeatureFlag.Name = (*source).Name - modeltipherethFeatureFlag.Description = (*source).Description - modeltipherethFeatureFlag.ConfigJSONSchema = (*source).ConfigJSONSchema - modeltipherethFeatureFlag.RequireContext = (*source).RequireContext - pModeltipherethFeatureFlag = &modeltipherethFeatureFlag - } - return pModeltipherethFeatureFlag -} -func pModeltipherethFeatureRequestToPModeltipherethFeatureRequest(source *modeltiphereth.FeatureRequest) *modeltiphereth.FeatureRequest { - var pModeltipherethFeatureRequest *modeltiphereth.FeatureRequest + var modelsupervisorFeatureFlag modelsupervisor.FeatureFlag + modelsupervisorFeatureFlag.ID = (*source).ID + modelsupervisorFeatureFlag.Name = (*source).Name + modelsupervisorFeatureFlag.Description = (*source).Description + modelsupervisorFeatureFlag.ConfigJSONSchema = (*source).ConfigJSONSchema + modelsupervisorFeatureFlag.RequireContext = (*source).RequireContext + pModelsupervisorFeatureFlag = &modelsupervisorFeatureFlag + } + return pModelsupervisorFeatureFlag +} +func pModelsupervisorFeatureRequestToPModelsupervisorFeatureRequest(source *modelsupervisor.FeatureRequest) *modelsupervisor.FeatureRequest { + var pModelsupervisorFeatureRequest *modelsupervisor.FeatureRequest if source != nil { - var modeltipherethFeatureRequest modeltiphereth.FeatureRequest - modeltipherethFeatureRequest.ID = (*source).ID - modeltipherethFeatureRequest.Region = (*source).Region - modeltipherethFeatureRequest.ConfigJSON = (*source).ConfigJSON - modeltipherethFeatureRequest.ContextID = modelInternalIDToModelInternalID((*source).ContextID) - pModeltipherethFeatureRequest = &modeltipherethFeatureRequest + var modelsupervisorFeatureRequest modelsupervisor.FeatureRequest + modelsupervisorFeatureRequest.ID = (*source).ID + modelsupervisorFeatureRequest.Region = (*source).Region + modelsupervisorFeatureRequest.ConfigJSON = (*source).ConfigJSON + modelsupervisorFeatureRequest.ContextID = modelInternalIDToModelInternalID((*source).ContextID) + pModelsupervisorFeatureRequest = &modelsupervisorFeatureRequest } - return pModeltipherethFeatureRequest + return pModelsupervisorFeatureRequest } -func pModeltipherethPorterFeatureSummaryToPModeltipherethPorterFeatureSummary(source *modeltiphereth.PorterFeatureSummary) *modeltiphereth.PorterFeatureSummary { - var pModeltipherethPorterFeatureSummary *modeltiphereth.PorterFeatureSummary +func pModelsupervisorPorterFeatureSummaryToPModelsupervisorPorterFeatureSummary(source *modelsupervisor.PorterFeatureSummary) *modelsupervisor.PorterFeatureSummary { + var pModelsupervisorPorterFeatureSummary *modelsupervisor.PorterFeatureSummary if source != nil { - var modeltipherethPorterFeatureSummary modeltiphereth.PorterFeatureSummary + var modelsupervisorPorterFeatureSummary modelsupervisor.PorterFeatureSummary if (*source).AccountPlatforms != nil { - modeltipherethPorterFeatureSummary.AccountPlatforms = make([]*modeltiphereth.FeatureFlag, len((*source).AccountPlatforms)) + modelsupervisorPorterFeatureSummary.AccountPlatforms = make([]*modelsupervisor.FeatureFlag, len((*source).AccountPlatforms)) for i := 0; i < len((*source).AccountPlatforms); i++ { - modeltipherethPorterFeatureSummary.AccountPlatforms[i] = pModeltipherethFeatureFlagToPModeltipherethFeatureFlag((*source).AccountPlatforms[i]) + modelsupervisorPorterFeatureSummary.AccountPlatforms[i] = pModelsupervisorFeatureFlagToPModelsupervisorFeatureFlag((*source).AccountPlatforms[i]) } } if (*source).AppInfoSources != nil { - modeltipherethPorterFeatureSummary.AppInfoSources = make([]*modeltiphereth.FeatureFlag, len((*source).AppInfoSources)) + modelsupervisorPorterFeatureSummary.AppInfoSources = make([]*modelsupervisor.FeatureFlag, len((*source).AppInfoSources)) for j := 0; j < len((*source).AppInfoSources); j++ { - modeltipherethPorterFeatureSummary.AppInfoSources[j] = pModeltipherethFeatureFlagToPModeltipherethFeatureFlag((*source).AppInfoSources[j]) + modelsupervisorPorterFeatureSummary.AppInfoSources[j] = pModelsupervisorFeatureFlagToPModelsupervisorFeatureFlag((*source).AppInfoSources[j]) } } if (*source).FeedSources != nil { - modeltipherethPorterFeatureSummary.FeedSources = make([]*modeltiphereth.FeatureFlag, len((*source).FeedSources)) + modelsupervisorPorterFeatureSummary.FeedSources = make([]*modelsupervisor.FeatureFlag, len((*source).FeedSources)) for k := 0; k < len((*source).FeedSources); k++ { - modeltipherethPorterFeatureSummary.FeedSources[k] = pModeltipherethFeatureFlagToPModeltipherethFeatureFlag((*source).FeedSources[k]) + modelsupervisorPorterFeatureSummary.FeedSources[k] = pModelsupervisorFeatureFlagToPModelsupervisorFeatureFlag((*source).FeedSources[k]) } } if (*source).NotifyDestinations != nil { - modeltipherethPorterFeatureSummary.NotifyDestinations = make([]*modeltiphereth.FeatureFlag, len((*source).NotifyDestinations)) + modelsupervisorPorterFeatureSummary.NotifyDestinations = make([]*modelsupervisor.FeatureFlag, len((*source).NotifyDestinations)) for l := 0; l < len((*source).NotifyDestinations); l++ { - modeltipherethPorterFeatureSummary.NotifyDestinations[l] = pModeltipherethFeatureFlagToPModeltipherethFeatureFlag((*source).NotifyDestinations[l]) + modelsupervisorPorterFeatureSummary.NotifyDestinations[l] = pModelsupervisorFeatureFlagToPModelsupervisorFeatureFlag((*source).NotifyDestinations[l]) } } if (*source).FeedItemActions != nil { - modeltipherethPorterFeatureSummary.FeedItemActions = make([]*modeltiphereth.FeatureFlag, len((*source).FeedItemActions)) + modelsupervisorPorterFeatureSummary.FeedItemActions = make([]*modelsupervisor.FeatureFlag, len((*source).FeedItemActions)) for m := 0; m < len((*source).FeedItemActions); m++ { - modeltipherethPorterFeatureSummary.FeedItemActions[m] = pModeltipherethFeatureFlagToPModeltipherethFeatureFlag((*source).FeedItemActions[m]) + modelsupervisorPorterFeatureSummary.FeedItemActions[m] = pModelsupervisorFeatureFlagToPModelsupervisorFeatureFlag((*source).FeedItemActions[m]) } } - pModeltipherethPorterFeatureSummary = &modeltipherethPorterFeatureSummary + pModelsupervisorPorterFeatureSummary = &modelsupervisorPorterFeatureSummary } - return pModeltipherethPorterFeatureSummary + return pModelsupervisorPorterFeatureSummary } func timeTimeToPTimeTime(source time.Time) *time.Time { timeTime := TimeToTime(source) @@ -931,30 +941,40 @@ func ToEntNotifyTargetStatusList(source []modelnetzach.NotifyTargetStatus) []not } return notifytargetStatusList } -func ToEntPorterContextStatus(source modeltiphereth.PorterContextStatus) portercontext.Status { +func ToEntPorterContextStatus(source modelsupervisor.PorterContextStatus) portercontext.Status { var portercontextStatus portercontext.Status switch source { - case modeltiphereth.PorterContextStatusActive: + case modelsupervisor.PorterContextStatusActive: portercontextStatus = portercontext.StatusActive - case modeltiphereth.PorterContextStatusDisabled: + case modelsupervisor.PorterContextStatusDisabled: portercontextStatus = portercontext.StatusDisabled - case modeltiphereth.PorterContextStatusUnspecified: // ignored + case modelsupervisor.PorterContextStatusUnspecified: // ignored default: // ignored } return portercontextStatus } -func ToEntPorterInstanceStatus(source modeltiphereth.PorterInstanceStatus) porterinstance.Status { +func ToEntPorterInstanceStatus(source modeltiphereth.UserStatus) porterinstance.Status { var porterinstanceStatus porterinstance.Status switch source { - case modeltiphereth.PorterInstanceStatusActive: + case modeltiphereth.UserStatusActive: porterinstanceStatus = porterinstance.StatusActive - case modeltiphereth.PorterInstanceStatusBlocked: + case modeltiphereth.UserStatusBlocked: porterinstanceStatus = porterinstance.StatusBlocked - case modeltiphereth.PorterInstanceStatusUnspecified: // ignored + case modeltiphereth.UserStatusUnspecified: // ignored default: // ignored } return porterinstanceStatus } +func ToEntPorterInstanceStatusList(source []modeltiphereth.UserStatus) []porterinstance.Status { + var porterinstanceStatusList []porterinstance.Status + if source != nil { + porterinstanceStatusList = make([]porterinstance.Status, len(source)) + for i := 0; i < len(source); i++ { + porterinstanceStatusList[i] = ToEntPorterInstanceStatus(source[i]) + } + } + return porterinstanceStatusList +} func ToEntSystemNotificationLevel(source modelnetzach.SystemNotificationLevel) systemnotification.Level { var systemnotificationLevel systemnotification.Level switch source { diff --git a/app/sephirah/internal/data/internal/ent/feedactionset.go b/app/sephirah/internal/data/internal/ent/feedactionset.go index 68e8284..e495e33 100644 --- a/app/sephirah/internal/data/internal/ent/feedactionset.go +++ b/app/sephirah/internal/data/internal/ent/feedactionset.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) @@ -26,7 +26,7 @@ type FeedActionSet struct { // Description holds the value of the "description" field. Description string `json:"description,omitempty"` // Actions holds the value of the "actions" field. - Actions []*modeltiphereth.FeatureRequest `json:"actions,omitempty"` + Actions []*modelsupervisor.FeatureRequest `json:"actions,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at,omitempty"` // CreatedAt holds the value of the "created_at" field. diff --git a/app/sephirah/internal/data/internal/ent/feedactionset_create.go b/app/sephirah/internal/data/internal/ent/feedactionset_create.go index 0330d6c..fff9bb4 100644 --- a/app/sephirah/internal/data/internal/ent/feedactionset_create.go +++ b/app/sephirah/internal/data/internal/ent/feedactionset_create.go @@ -14,7 +14,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedactionset" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) @@ -39,7 +39,7 @@ func (fasc *FeedActionSetCreate) SetDescription(s string) *FeedActionSetCreate { } // SetActions sets the "actions" field. -func (fasc *FeedActionSetCreate) SetActions(mr []*modeltiphereth.FeatureRequest) *FeedActionSetCreate { +func (fasc *FeedActionSetCreate) SetActions(mr []*modelsupervisor.FeatureRequest) *FeedActionSetCreate { fasc.mutation.SetActions(mr) return fasc } @@ -332,7 +332,7 @@ func (u *FeedActionSetUpsert) UpdateDescription() *FeedActionSetUpsert { } // SetActions sets the "actions" field. -func (u *FeedActionSetUpsert) SetActions(v []*modeltiphereth.FeatureRequest) *FeedActionSetUpsert { +func (u *FeedActionSetUpsert) SetActions(v []*modelsupervisor.FeatureRequest) *FeedActionSetUpsert { u.Set(feedactionset.FieldActions, v) return u } @@ -444,7 +444,7 @@ func (u *FeedActionSetUpsertOne) UpdateDescription() *FeedActionSetUpsertOne { } // SetActions sets the "actions" field. -func (u *FeedActionSetUpsertOne) SetActions(v []*modeltiphereth.FeatureRequest) *FeedActionSetUpsertOne { +func (u *FeedActionSetUpsertOne) SetActions(v []*modelsupervisor.FeatureRequest) *FeedActionSetUpsertOne { return u.Update(func(s *FeedActionSetUpsert) { s.SetActions(v) }) @@ -728,7 +728,7 @@ func (u *FeedActionSetUpsertBulk) UpdateDescription() *FeedActionSetUpsertBulk { } // SetActions sets the "actions" field. -func (u *FeedActionSetUpsertBulk) SetActions(v []*modeltiphereth.FeatureRequest) *FeedActionSetUpsertBulk { +func (u *FeedActionSetUpsertBulk) SetActions(v []*modelsupervisor.FeatureRequest) *FeedActionSetUpsertBulk { return u.Update(func(s *FeedActionSetUpsert) { s.SetActions(v) }) diff --git a/app/sephirah/internal/data/internal/ent/feedactionset_update.go b/app/sephirah/internal/data/internal/ent/feedactionset_update.go index cdf8492..aa7ad53 100644 --- a/app/sephirah/internal/data/internal/ent/feedactionset_update.go +++ b/app/sephirah/internal/data/internal/ent/feedactionset_update.go @@ -16,7 +16,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) @@ -62,13 +62,13 @@ func (fasu *FeedActionSetUpdate) SetNillableDescription(s *string) *FeedActionSe } // SetActions sets the "actions" field. -func (fasu *FeedActionSetUpdate) SetActions(mr []*modeltiphereth.FeatureRequest) *FeedActionSetUpdate { +func (fasu *FeedActionSetUpdate) SetActions(mr []*modelsupervisor.FeatureRequest) *FeedActionSetUpdate { fasu.mutation.SetActions(mr) return fasu } // AppendActions appends mr to the "actions" field. -func (fasu *FeedActionSetUpdate) AppendActions(mr []*modeltiphereth.FeatureRequest) *FeedActionSetUpdate { +func (fasu *FeedActionSetUpdate) AppendActions(mr []*modelsupervisor.FeatureRequest) *FeedActionSetUpdate { fasu.mutation.AppendActions(mr) return fasu } @@ -350,13 +350,13 @@ func (fasuo *FeedActionSetUpdateOne) SetNillableDescription(s *string) *FeedActi } // SetActions sets the "actions" field. -func (fasuo *FeedActionSetUpdateOne) SetActions(mr []*modeltiphereth.FeatureRequest) *FeedActionSetUpdateOne { +func (fasuo *FeedActionSetUpdateOne) SetActions(mr []*modelsupervisor.FeatureRequest) *FeedActionSetUpdateOne { fasuo.mutation.SetActions(mr) return fasuo } // AppendActions appends mr to the "actions" field. -func (fasuo *FeedActionSetUpdateOne) AppendActions(mr []*modeltiphereth.FeatureRequest) *FeedActionSetUpdateOne { +func (fasuo *FeedActionSetUpdateOne) AppendActions(mr []*modelsupervisor.FeatureRequest) *FeedActionSetUpdateOne { fasuo.mutation.AppendActions(mr) return fasuo } diff --git a/app/sephirah/internal/data/internal/ent/feedconfig.go b/app/sephirah/internal/data/internal/ent/feedconfig.go index 841dba4..23b04ab 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig.go +++ b/app/sephirah/internal/data/internal/ent/feedconfig.go @@ -13,7 +13,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feed" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfig" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) @@ -29,7 +29,7 @@ type FeedConfig struct { // Description holds the value of the "description" field. Description string `json:"description,omitempty"` // Source holds the value of the "source" field. - Source *modeltiphereth.FeatureRequest `json:"source,omitempty"` + Source *modelsupervisor.FeatureRequest `json:"source,omitempty"` // Status holds the value of the "status" field. Status feedconfig.Status `json:"status,omitempty"` // Category holds the value of the "category" field. diff --git a/app/sephirah/internal/data/internal/ent/feedconfig_create.go b/app/sephirah/internal/data/internal/ent/feedconfig_create.go index e5e5317..536533b 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig_create.go +++ b/app/sephirah/internal/data/internal/ent/feedconfig_create.go @@ -17,7 +17,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/feedconfigaction" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) @@ -48,7 +48,7 @@ func (fcc *FeedConfigCreate) SetDescription(s string) *FeedConfigCreate { } // SetSource sets the "source" field. -func (fcc *FeedConfigCreate) SetSource(mr *modeltiphereth.FeatureRequest) *FeedConfigCreate { +func (fcc *FeedConfigCreate) SetSource(mr *modelsupervisor.FeatureRequest) *FeedConfigCreate { fcc.mutation.SetSource(mr) return fcc } @@ -607,7 +607,7 @@ func (u *FeedConfigUpsert) UpdateDescription() *FeedConfigUpsert { } // SetSource sets the "source" field. -func (u *FeedConfigUpsert) SetSource(v *modeltiphereth.FeatureRequest) *FeedConfigUpsert { +func (u *FeedConfigUpsert) SetSource(v *modelsupervisor.FeatureRequest) *FeedConfigUpsert { u.Set(feedconfig.FieldSource, v) return u } @@ -835,7 +835,7 @@ func (u *FeedConfigUpsertOne) UpdateDescription() *FeedConfigUpsertOne { } // SetSource sets the "source" field. -func (u *FeedConfigUpsertOne) SetSource(v *modeltiphereth.FeatureRequest) *FeedConfigUpsertOne { +func (u *FeedConfigUpsertOne) SetSource(v *modelsupervisor.FeatureRequest) *FeedConfigUpsertOne { return u.Update(func(s *FeedConfigUpsert) { s.SetSource(v) }) @@ -1252,7 +1252,7 @@ func (u *FeedConfigUpsertBulk) UpdateDescription() *FeedConfigUpsertBulk { } // SetSource sets the "source" field. -func (u *FeedConfigUpsertBulk) SetSource(v *modeltiphereth.FeatureRequest) *FeedConfigUpsertBulk { +func (u *FeedConfigUpsertBulk) SetSource(v *modelsupervisor.FeatureRequest) *FeedConfigUpsertBulk { return u.Update(func(s *FeedConfigUpsert) { s.SetSource(v) }) diff --git a/app/sephirah/internal/data/internal/ent/feedconfig_update.go b/app/sephirah/internal/data/internal/ent/feedconfig_update.go index c5e5b31..de0d798 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig_update.go +++ b/app/sephirah/internal/data/internal/ent/feedconfig_update.go @@ -18,7 +18,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifysource" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) @@ -78,7 +78,7 @@ func (fcu *FeedConfigUpdate) SetNillableDescription(s *string) *FeedConfigUpdate } // SetSource sets the "source" field. -func (fcu *FeedConfigUpdate) SetSource(mr *modeltiphereth.FeatureRequest) *FeedConfigUpdate { +func (fcu *FeedConfigUpdate) SetSource(mr *modelsupervisor.FeatureRequest) *FeedConfigUpdate { fcu.mutation.SetSource(mr) return fcu } @@ -753,7 +753,7 @@ func (fcuo *FeedConfigUpdateOne) SetNillableDescription(s *string) *FeedConfigUp } // SetSource sets the "source" field. -func (fcuo *FeedConfigUpdateOne) SetSource(mr *modeltiphereth.FeatureRequest) *FeedConfigUpdateOne { +func (fcuo *FeedConfigUpdateOne) SetSource(mr *modelsupervisor.FeatureRequest) *FeedConfigUpdateOne { fcuo.mutation.SetSource(mr) return fcuo } diff --git a/app/sephirah/internal/data/internal/ent/migrate/schema.go b/app/sephirah/internal/data/internal/ent/migrate/schema.go index 4858c01..0703bf5 100644 --- a/app/sephirah/internal/data/internal/ent/migrate/schema.go +++ b/app/sephirah/internal/data/internal/ent/migrate/schema.go @@ -670,6 +670,10 @@ var ( {Name: "id", Type: field.TypeInt64}, {Name: "name", Type: field.TypeString}, {Name: "version", Type: field.TypeString}, + {Name: "description", Type: field.TypeString}, + {Name: "source_code_address", Type: field.TypeString}, + {Name: "build_version", Type: field.TypeString}, + {Name: "build_date", Type: field.TypeString}, {Name: "global_name", Type: field.TypeString}, {Name: "address", Type: field.TypeString}, {Name: "region", Type: field.TypeString}, @@ -688,7 +692,12 @@ var ( { Name: "porterinstance_address", Unique: true, - Columns: []*schema.Column{PorterInstancesColumns[4]}, + Columns: []*schema.Column{PorterInstancesColumns[8]}, + }, + { + Name: "porterinstance_global_name_region", + Unique: false, + Columns: []*schema.Column{PorterInstancesColumns[7], PorterInstancesColumns[9]}, }, }, } diff --git a/app/sephirah/internal/data/internal/ent/mutation.go b/app/sephirah/internal/data/internal/ent/mutation.go index c08afec..18de03d 100644 --- a/app/sephirah/internal/data/internal/ent/mutation.go +++ b/app/sephirah/internal/data/internal/ent/mutation.go @@ -39,7 +39,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" ) @@ -7523,8 +7523,8 @@ type FeedActionSetMutation struct { id *model.InternalID name *string description *string - actions *[]*modeltiphereth.FeatureRequest - appendactions []*modeltiphereth.FeatureRequest + actions *[]*modelsupervisor.FeatureRequest + appendactions []*modelsupervisor.FeatureRequest updated_at *time.Time created_at *time.Time clearedFields map[string]struct{} @@ -7715,13 +7715,13 @@ func (m *FeedActionSetMutation) ResetDescription() { } // SetActions sets the "actions" field. -func (m *FeedActionSetMutation) SetActions(mr []*modeltiphereth.FeatureRequest) { +func (m *FeedActionSetMutation) SetActions(mr []*modelsupervisor.FeatureRequest) { m.actions = &mr m.appendactions = nil } // Actions returns the value of the "actions" field in the mutation. -func (m *FeedActionSetMutation) Actions() (r []*modeltiphereth.FeatureRequest, exists bool) { +func (m *FeedActionSetMutation) Actions() (r []*modelsupervisor.FeatureRequest, exists bool) { v := m.actions if v == nil { return @@ -7732,7 +7732,7 @@ func (m *FeedActionSetMutation) Actions() (r []*modeltiphereth.FeatureRequest, e // OldActions returns the old "actions" field's value of the FeedActionSet entity. // If the FeedActionSet object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *FeedActionSetMutation) OldActions(ctx context.Context) (v []*modeltiphereth.FeatureRequest, err error) { +func (m *FeedActionSetMutation) OldActions(ctx context.Context) (v []*modelsupervisor.FeatureRequest, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldActions is only allowed on UpdateOne operations") } @@ -7747,12 +7747,12 @@ func (m *FeedActionSetMutation) OldActions(ctx context.Context) (v []*modeltiphe } // AppendActions adds mr to the "actions" field. -func (m *FeedActionSetMutation) AppendActions(mr []*modeltiphereth.FeatureRequest) { +func (m *FeedActionSetMutation) AppendActions(mr []*modelsupervisor.FeatureRequest) { m.appendactions = append(m.appendactions, mr...) } // AppendedActions returns the list of values that were appended to the "actions" field in this mutation. -func (m *FeedActionSetMutation) AppendedActions() ([]*modeltiphereth.FeatureRequest, bool) { +func (m *FeedActionSetMutation) AppendedActions() ([]*modelsupervisor.FeatureRequest, bool) { if len(m.appendactions) == 0 { return nil, false } @@ -8041,7 +8041,7 @@ func (m *FeedActionSetMutation) SetField(name string, value ent.Value) error { m.SetDescription(v) return nil case feedactionset.FieldActions: - v, ok := value.([]*modeltiphereth.FeatureRequest) + v, ok := value.([]*modelsupervisor.FeatureRequest) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -8239,7 +8239,7 @@ type FeedConfigMutation struct { id *model.InternalID name *string description *string - source **modeltiphereth.FeatureRequest + source **modelsupervisor.FeatureRequest status *feedconfig.Status category *string pull_interval *time.Duration @@ -8483,12 +8483,12 @@ func (m *FeedConfigMutation) ResetDescription() { } // SetSource sets the "source" field. -func (m *FeedConfigMutation) SetSource(mr *modeltiphereth.FeatureRequest) { +func (m *FeedConfigMutation) SetSource(mr *modelsupervisor.FeatureRequest) { m.source = &mr } // Source returns the value of the "source" field in the mutation. -func (m *FeedConfigMutation) Source() (r *modeltiphereth.FeatureRequest, exists bool) { +func (m *FeedConfigMutation) Source() (r *modelsupervisor.FeatureRequest, exists bool) { v := m.source if v == nil { return @@ -8499,7 +8499,7 @@ func (m *FeedConfigMutation) Source() (r *modeltiphereth.FeatureRequest, exists // OldSource returns the old "source" field's value of the FeedConfig entity. // If the FeedConfig object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *FeedConfigMutation) OldSource(ctx context.Context) (v *modeltiphereth.FeatureRequest, err error) { +func (m *FeedConfigMutation) OldSource(ctx context.Context) (v *modelsupervisor.FeatureRequest, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldSource is only allowed on UpdateOne operations") } @@ -9320,7 +9320,7 @@ func (m *FeedConfigMutation) SetField(name string, value ent.Value) error { m.SetDescription(v) return nil case feedconfig.FieldSource: - v, ok := value.(*modeltiphereth.FeatureRequest) + v, ok := value.(*modelsupervisor.FeatureRequest) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -17641,7 +17641,7 @@ type NotifyTargetMutation struct { id *model.InternalID name *string description *string - destination **modeltiphereth.FeatureRequest + destination **modelsupervisor.FeatureRequest status *notifytarget.Status updated_at *time.Time created_at *time.Time @@ -17836,12 +17836,12 @@ func (m *NotifyTargetMutation) ResetDescription() { } // SetDestination sets the "destination" field. -func (m *NotifyTargetMutation) SetDestination(mr *modeltiphereth.FeatureRequest) { +func (m *NotifyTargetMutation) SetDestination(mr *modelsupervisor.FeatureRequest) { m.destination = &mr } // Destination returns the value of the "destination" field in the mutation. -func (m *NotifyTargetMutation) Destination() (r *modeltiphereth.FeatureRequest, exists bool) { +func (m *NotifyTargetMutation) Destination() (r *modelsupervisor.FeatureRequest, exists bool) { v := m.destination if v == nil { return @@ -17852,7 +17852,7 @@ func (m *NotifyTargetMutation) Destination() (r *modeltiphereth.FeatureRequest, // OldDestination returns the old "destination" field's value of the NotifyTarget entity. // If the NotifyTarget object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyTargetMutation) OldDestination(ctx context.Context) (v *modeltiphereth.FeatureRequest, err error) { +func (m *NotifyTargetMutation) OldDestination(ctx context.Context) (v *modelsupervisor.FeatureRequest, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDestination is only allowed on UpdateOne operations") } @@ -18244,7 +18244,7 @@ func (m *NotifyTargetMutation) SetField(name string, value ent.Value) error { m.SetDescription(v) return nil case notifytarget.FieldDestination: - v, ok := value.(*modeltiphereth.FeatureRequest) + v, ok := value.(*modelsupervisor.FeatureRequest) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -19255,10 +19255,14 @@ type PorterInstanceMutation struct { id *model.InternalID name *string version *string + description *string + source_code_address *string + build_version *string + build_date *string global_name *string address *string region *string - feature_summary **modeltiphereth.PorterFeatureSummary + feature_summary **modelsupervisor.PorterFeatureSummary context_json_schema *string status *porterinstance.Status updated_at *time.Time @@ -19445,6 +19449,150 @@ func (m *PorterInstanceMutation) ResetVersion() { m.version = nil } +// SetDescription sets the "description" field. +func (m *PorterInstanceMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *PorterInstanceMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the PorterInstance entity. +// If the PorterInstance object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PorterInstanceMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ResetDescription resets all changes to the "description" field. +func (m *PorterInstanceMutation) ResetDescription() { + m.description = nil +} + +// SetSourceCodeAddress sets the "source_code_address" field. +func (m *PorterInstanceMutation) SetSourceCodeAddress(s string) { + m.source_code_address = &s +} + +// SourceCodeAddress returns the value of the "source_code_address" field in the mutation. +func (m *PorterInstanceMutation) SourceCodeAddress() (r string, exists bool) { + v := m.source_code_address + if v == nil { + return + } + return *v, true +} + +// OldSourceCodeAddress returns the old "source_code_address" field's value of the PorterInstance entity. +// If the PorterInstance object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PorterInstanceMutation) OldSourceCodeAddress(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSourceCodeAddress is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSourceCodeAddress requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSourceCodeAddress: %w", err) + } + return oldValue.SourceCodeAddress, nil +} + +// ResetSourceCodeAddress resets all changes to the "source_code_address" field. +func (m *PorterInstanceMutation) ResetSourceCodeAddress() { + m.source_code_address = nil +} + +// SetBuildVersion sets the "build_version" field. +func (m *PorterInstanceMutation) SetBuildVersion(s string) { + m.build_version = &s +} + +// BuildVersion returns the value of the "build_version" field in the mutation. +func (m *PorterInstanceMutation) BuildVersion() (r string, exists bool) { + v := m.build_version + if v == nil { + return + } + return *v, true +} + +// OldBuildVersion returns the old "build_version" field's value of the PorterInstance entity. +// If the PorterInstance object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PorterInstanceMutation) OldBuildVersion(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBuildVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBuildVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBuildVersion: %w", err) + } + return oldValue.BuildVersion, nil +} + +// ResetBuildVersion resets all changes to the "build_version" field. +func (m *PorterInstanceMutation) ResetBuildVersion() { + m.build_version = nil +} + +// SetBuildDate sets the "build_date" field. +func (m *PorterInstanceMutation) SetBuildDate(s string) { + m.build_date = &s +} + +// BuildDate returns the value of the "build_date" field in the mutation. +func (m *PorterInstanceMutation) BuildDate() (r string, exists bool) { + v := m.build_date + if v == nil { + return + } + return *v, true +} + +// OldBuildDate returns the old "build_date" field's value of the PorterInstance entity. +// If the PorterInstance object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PorterInstanceMutation) OldBuildDate(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBuildDate is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBuildDate requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBuildDate: %w", err) + } + return oldValue.BuildDate, nil +} + +// ResetBuildDate resets all changes to the "build_date" field. +func (m *PorterInstanceMutation) ResetBuildDate() { + m.build_date = nil +} + // SetGlobalName sets the "global_name" field. func (m *PorterInstanceMutation) SetGlobalName(s string) { m.global_name = &s @@ -19554,12 +19702,12 @@ func (m *PorterInstanceMutation) ResetRegion() { } // SetFeatureSummary sets the "feature_summary" field. -func (m *PorterInstanceMutation) SetFeatureSummary(mfs *modeltiphereth.PorterFeatureSummary) { +func (m *PorterInstanceMutation) SetFeatureSummary(mfs *modelsupervisor.PorterFeatureSummary) { m.feature_summary = &mfs } // FeatureSummary returns the value of the "feature_summary" field in the mutation. -func (m *PorterInstanceMutation) FeatureSummary() (r *modeltiphereth.PorterFeatureSummary, exists bool) { +func (m *PorterInstanceMutation) FeatureSummary() (r *modelsupervisor.PorterFeatureSummary, exists bool) { v := m.feature_summary if v == nil { return @@ -19570,7 +19718,7 @@ func (m *PorterInstanceMutation) FeatureSummary() (r *modeltiphereth.PorterFeatu // OldFeatureSummary returns the old "feature_summary" field's value of the PorterInstance entity. // If the PorterInstance object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PorterInstanceMutation) OldFeatureSummary(ctx context.Context) (v *modeltiphereth.PorterFeatureSummary, err error) { +func (m *PorterInstanceMutation) OldFeatureSummary(ctx context.Context) (v *modelsupervisor.PorterFeatureSummary, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldFeatureSummary is only allowed on UpdateOne operations") } @@ -19767,13 +19915,25 @@ func (m *PorterInstanceMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *PorterInstanceMutation) Fields() []string { - fields := make([]string, 0, 10) + fields := make([]string, 0, 14) if m.name != nil { fields = append(fields, porterinstance.FieldName) } if m.version != nil { fields = append(fields, porterinstance.FieldVersion) } + if m.description != nil { + fields = append(fields, porterinstance.FieldDescription) + } + if m.source_code_address != nil { + fields = append(fields, porterinstance.FieldSourceCodeAddress) + } + if m.build_version != nil { + fields = append(fields, porterinstance.FieldBuildVersion) + } + if m.build_date != nil { + fields = append(fields, porterinstance.FieldBuildDate) + } if m.global_name != nil { fields = append(fields, porterinstance.FieldGlobalName) } @@ -19810,6 +19970,14 @@ func (m *PorterInstanceMutation) Field(name string) (ent.Value, bool) { return m.Name() case porterinstance.FieldVersion: return m.Version() + case porterinstance.FieldDescription: + return m.Description() + case porterinstance.FieldSourceCodeAddress: + return m.SourceCodeAddress() + case porterinstance.FieldBuildVersion: + return m.BuildVersion() + case porterinstance.FieldBuildDate: + return m.BuildDate() case porterinstance.FieldGlobalName: return m.GlobalName() case porterinstance.FieldAddress: @@ -19839,6 +20007,14 @@ func (m *PorterInstanceMutation) OldField(ctx context.Context, name string) (ent return m.OldName(ctx) case porterinstance.FieldVersion: return m.OldVersion(ctx) + case porterinstance.FieldDescription: + return m.OldDescription(ctx) + case porterinstance.FieldSourceCodeAddress: + return m.OldSourceCodeAddress(ctx) + case porterinstance.FieldBuildVersion: + return m.OldBuildVersion(ctx) + case porterinstance.FieldBuildDate: + return m.OldBuildDate(ctx) case porterinstance.FieldGlobalName: return m.OldGlobalName(ctx) case porterinstance.FieldAddress: @@ -19878,6 +20054,34 @@ func (m *PorterInstanceMutation) SetField(name string, value ent.Value) error { } m.SetVersion(v) return nil + case porterinstance.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case porterinstance.FieldSourceCodeAddress: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSourceCodeAddress(v) + return nil + case porterinstance.FieldBuildVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBuildVersion(v) + return nil + case porterinstance.FieldBuildDate: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBuildDate(v) + return nil case porterinstance.FieldGlobalName: v, ok := value.(string) if !ok { @@ -19900,7 +20104,7 @@ func (m *PorterInstanceMutation) SetField(name string, value ent.Value) error { m.SetRegion(v) return nil case porterinstance.FieldFeatureSummary: - v, ok := value.(*modeltiphereth.PorterFeatureSummary) + v, ok := value.(*modelsupervisor.PorterFeatureSummary) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -19989,6 +20193,18 @@ func (m *PorterInstanceMutation) ResetField(name string) error { case porterinstance.FieldVersion: m.ResetVersion() return nil + case porterinstance.FieldDescription: + m.ResetDescription() + return nil + case porterinstance.FieldSourceCodeAddress: + m.ResetSourceCodeAddress() + return nil + case porterinstance.FieldBuildVersion: + m.ResetBuildVersion() + return nil + case porterinstance.FieldBuildDate: + m.ResetBuildDate() + return nil case porterinstance.FieldGlobalName: m.ResetGlobalName() return nil diff --git a/app/sephirah/internal/data/internal/ent/notifytarget.go b/app/sephirah/internal/data/internal/ent/notifytarget.go index abc1aae..53a3035 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget.go +++ b/app/sephirah/internal/data/internal/ent/notifytarget.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) @@ -26,7 +26,7 @@ type NotifyTarget struct { // Description holds the value of the "description" field. Description string `json:"description,omitempty"` // Destination holds the value of the "destination" field. - Destination *modeltiphereth.FeatureRequest `json:"destination,omitempty"` + Destination *modelsupervisor.FeatureRequest `json:"destination,omitempty"` // Status holds the value of the "status" field. Status notifytarget.Status `json:"status,omitempty"` // UpdatedAt holds the value of the "updated_at" field. diff --git a/app/sephirah/internal/data/internal/ent/notifytarget_create.go b/app/sephirah/internal/data/internal/ent/notifytarget_create.go index 577833f..018b906 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget_create.go +++ b/app/sephirah/internal/data/internal/ent/notifytarget_create.go @@ -15,7 +15,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifyflowtarget" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) @@ -40,7 +40,7 @@ func (ntc *NotifyTargetCreate) SetDescription(s string) *NotifyTargetCreate { } // SetDestination sets the "destination" field. -func (ntc *NotifyTargetCreate) SetDestination(mr *modeltiphereth.FeatureRequest) *NotifyTargetCreate { +func (ntc *NotifyTargetCreate) SetDestination(mr *modelsupervisor.FeatureRequest) *NotifyTargetCreate { ntc.mutation.SetDestination(mr) return ntc } @@ -386,7 +386,7 @@ func (u *NotifyTargetUpsert) UpdateDescription() *NotifyTargetUpsert { } // SetDestination sets the "destination" field. -func (u *NotifyTargetUpsert) SetDestination(v *modeltiphereth.FeatureRequest) *NotifyTargetUpsert { +func (u *NotifyTargetUpsert) SetDestination(v *modelsupervisor.FeatureRequest) *NotifyTargetUpsert { u.Set(notifytarget.FieldDestination, v) return u } @@ -510,7 +510,7 @@ func (u *NotifyTargetUpsertOne) UpdateDescription() *NotifyTargetUpsertOne { } // SetDestination sets the "destination" field. -func (u *NotifyTargetUpsertOne) SetDestination(v *modeltiphereth.FeatureRequest) *NotifyTargetUpsertOne { +func (u *NotifyTargetUpsertOne) SetDestination(v *modelsupervisor.FeatureRequest) *NotifyTargetUpsertOne { return u.Update(func(s *NotifyTargetUpsert) { s.SetDestination(v) }) @@ -808,7 +808,7 @@ func (u *NotifyTargetUpsertBulk) UpdateDescription() *NotifyTargetUpsertBulk { } // SetDestination sets the "destination" field. -func (u *NotifyTargetUpsertBulk) SetDestination(v *modeltiphereth.FeatureRequest) *NotifyTargetUpsertBulk { +func (u *NotifyTargetUpsertBulk) SetDestination(v *modelsupervisor.FeatureRequest) *NotifyTargetUpsertBulk { return u.Update(func(s *NotifyTargetUpsert) { s.SetDestination(v) }) diff --git a/app/sephirah/internal/data/internal/ent/notifytarget_update.go b/app/sephirah/internal/data/internal/ent/notifytarget_update.go index 18ee091..703dd62 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget_update.go +++ b/app/sephirah/internal/data/internal/ent/notifytarget_update.go @@ -16,7 +16,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/notifytarget" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) @@ -62,7 +62,7 @@ func (ntu *NotifyTargetUpdate) SetNillableDescription(s *string) *NotifyTargetUp } // SetDestination sets the "destination" field. -func (ntu *NotifyTargetUpdate) SetDestination(mr *modeltiphereth.FeatureRequest) *NotifyTargetUpdate { +func (ntu *NotifyTargetUpdate) SetDestination(mr *modelsupervisor.FeatureRequest) *NotifyTargetUpdate { ntu.mutation.SetDestination(mr) return ntu } @@ -454,7 +454,7 @@ func (ntuo *NotifyTargetUpdateOne) SetNillableDescription(s *string) *NotifyTarg } // SetDestination sets the "destination" field. -func (ntuo *NotifyTargetUpdateOne) SetDestination(mr *modeltiphereth.FeatureRequest) *NotifyTargetUpdateOne { +func (ntuo *NotifyTargetUpdateOne) SetDestination(mr *modelsupervisor.FeatureRequest) *NotifyTargetUpdateOne { ntuo.mutation.SetDestination(mr) return ntuo } diff --git a/app/sephirah/internal/data/internal/ent/porterinstance.go b/app/sephirah/internal/data/internal/ent/porterinstance.go index c1295ac..9d5d3b5 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance.go +++ b/app/sephirah/internal/data/internal/ent/porterinstance.go @@ -11,7 +11,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) @@ -24,6 +24,14 @@ type PorterInstance struct { Name string `json:"name,omitempty"` // Version holds the value of the "version" field. Version string `json:"version,omitempty"` + // Description holds the value of the "description" field. + Description string `json:"description,omitempty"` + // SourceCodeAddress holds the value of the "source_code_address" field. + SourceCodeAddress string `json:"source_code_address,omitempty"` + // BuildVersion holds the value of the "build_version" field. + BuildVersion string `json:"build_version,omitempty"` + // BuildDate holds the value of the "build_date" field. + BuildDate string `json:"build_date,omitempty"` // GlobalName holds the value of the "global_name" field. GlobalName string `json:"global_name,omitempty"` // Address holds the value of the "address" field. @@ -31,7 +39,7 @@ type PorterInstance struct { // Region holds the value of the "region" field. Region string `json:"region,omitempty"` // FeatureSummary holds the value of the "feature_summary" field. - FeatureSummary *modeltiphereth.PorterFeatureSummary `json:"feature_summary,omitempty"` + FeatureSummary *modelsupervisor.PorterFeatureSummary `json:"feature_summary,omitempty"` // ContextJSONSchema holds the value of the "context_json_schema" field. ContextJSONSchema string `json:"context_json_schema,omitempty"` // Status holds the value of the "status" field. @@ -52,7 +60,7 @@ func (*PorterInstance) scanValues(columns []string) ([]any, error) { values[i] = new([]byte) case porterinstance.FieldID: values[i] = new(sql.NullInt64) - case porterinstance.FieldName, porterinstance.FieldVersion, porterinstance.FieldGlobalName, porterinstance.FieldAddress, porterinstance.FieldRegion, porterinstance.FieldContextJSONSchema, porterinstance.FieldStatus: + case porterinstance.FieldName, porterinstance.FieldVersion, porterinstance.FieldDescription, porterinstance.FieldSourceCodeAddress, porterinstance.FieldBuildVersion, porterinstance.FieldBuildDate, porterinstance.FieldGlobalName, porterinstance.FieldAddress, porterinstance.FieldRegion, porterinstance.FieldContextJSONSchema, porterinstance.FieldStatus: values[i] = new(sql.NullString) case porterinstance.FieldUpdatedAt, porterinstance.FieldCreatedAt: values[i] = new(sql.NullTime) @@ -89,6 +97,30 @@ func (pi *PorterInstance) assignValues(columns []string, values []any) error { } else if value.Valid { pi.Version = value.String } + case porterinstance.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + pi.Description = value.String + } + case porterinstance.FieldSourceCodeAddress: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field source_code_address", values[i]) + } else if value.Valid { + pi.SourceCodeAddress = value.String + } + case porterinstance.FieldBuildVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field build_version", values[i]) + } else if value.Valid { + pi.BuildVersion = value.String + } + case porterinstance.FieldBuildDate: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field build_date", values[i]) + } else if value.Valid { + pi.BuildDate = value.String + } case porterinstance.FieldGlobalName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field global_name", values[i]) @@ -181,6 +213,18 @@ func (pi *PorterInstance) String() string { builder.WriteString("version=") builder.WriteString(pi.Version) builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(pi.Description) + builder.WriteString(", ") + builder.WriteString("source_code_address=") + builder.WriteString(pi.SourceCodeAddress) + builder.WriteString(", ") + builder.WriteString("build_version=") + builder.WriteString(pi.BuildVersion) + builder.WriteString(", ") + builder.WriteString("build_date=") + builder.WriteString(pi.BuildDate) + builder.WriteString(", ") builder.WriteString("global_name=") builder.WriteString(pi.GlobalName) builder.WriteString(", ") diff --git a/app/sephirah/internal/data/internal/ent/porterinstance/porterinstance.go b/app/sephirah/internal/data/internal/ent/porterinstance/porterinstance.go index 6e36201..abe37b5 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance/porterinstance.go +++ b/app/sephirah/internal/data/internal/ent/porterinstance/porterinstance.go @@ -18,6 +18,14 @@ const ( FieldName = "name" // FieldVersion holds the string denoting the version field in the database. FieldVersion = "version" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldSourceCodeAddress holds the string denoting the source_code_address field in the database. + FieldSourceCodeAddress = "source_code_address" + // FieldBuildVersion holds the string denoting the build_version field in the database. + FieldBuildVersion = "build_version" + // FieldBuildDate holds the string denoting the build_date field in the database. + FieldBuildDate = "build_date" // FieldGlobalName holds the string denoting the global_name field in the database. FieldGlobalName = "global_name" // FieldAddress holds the string denoting the address field in the database. @@ -43,6 +51,10 @@ var Columns = []string{ FieldID, FieldName, FieldVersion, + FieldDescription, + FieldSourceCodeAddress, + FieldBuildVersion, + FieldBuildDate, FieldGlobalName, FieldAddress, FieldRegion, @@ -113,6 +125,26 @@ func ByVersion(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldVersion, opts...).ToFunc() } +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// BySourceCodeAddress orders the results by the source_code_address field. +func BySourceCodeAddress(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSourceCodeAddress, opts...).ToFunc() +} + +// ByBuildVersion orders the results by the build_version field. +func ByBuildVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBuildVersion, opts...).ToFunc() +} + +// ByBuildDate orders the results by the build_date field. +func ByBuildDate(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBuildDate, opts...).ToFunc() +} + // ByGlobalName orders the results by the global_name field. func ByGlobalName(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldGlobalName, opts...).ToFunc() diff --git a/app/sephirah/internal/data/internal/ent/porterinstance/where.go b/app/sephirah/internal/data/internal/ent/porterinstance/where.go index b9c2fe4..03fa7bf 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance/where.go +++ b/app/sephirah/internal/data/internal/ent/porterinstance/where.go @@ -65,6 +65,26 @@ func Version(v string) predicate.PorterInstance { return predicate.PorterInstance(sql.FieldEQ(FieldVersion, v)) } +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldEQ(FieldDescription, v)) +} + +// SourceCodeAddress applies equality check predicate on the "source_code_address" field. It's identical to SourceCodeAddressEQ. +func SourceCodeAddress(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldEQ(FieldSourceCodeAddress, v)) +} + +// BuildVersion applies equality check predicate on the "build_version" field. It's identical to BuildVersionEQ. +func BuildVersion(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldEQ(FieldBuildVersion, v)) +} + +// BuildDate applies equality check predicate on the "build_date" field. It's identical to BuildDateEQ. +func BuildDate(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldEQ(FieldBuildDate, v)) +} + // GlobalName applies equality check predicate on the "global_name" field. It's identical to GlobalNameEQ. func GlobalName(v string) predicate.PorterInstance { return predicate.PorterInstance(sql.FieldEQ(FieldGlobalName, v)) @@ -225,6 +245,266 @@ func VersionContainsFold(v string) predicate.PorterInstance { return predicate.PorterInstance(sql.FieldContainsFold(FieldVersion, v)) } +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldContainsFold(FieldDescription, v)) +} + +// SourceCodeAddressEQ applies the EQ predicate on the "source_code_address" field. +func SourceCodeAddressEQ(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldEQ(FieldSourceCodeAddress, v)) +} + +// SourceCodeAddressNEQ applies the NEQ predicate on the "source_code_address" field. +func SourceCodeAddressNEQ(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldNEQ(FieldSourceCodeAddress, v)) +} + +// SourceCodeAddressIn applies the In predicate on the "source_code_address" field. +func SourceCodeAddressIn(vs ...string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldIn(FieldSourceCodeAddress, vs...)) +} + +// SourceCodeAddressNotIn applies the NotIn predicate on the "source_code_address" field. +func SourceCodeAddressNotIn(vs ...string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldNotIn(FieldSourceCodeAddress, vs...)) +} + +// SourceCodeAddressGT applies the GT predicate on the "source_code_address" field. +func SourceCodeAddressGT(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldGT(FieldSourceCodeAddress, v)) +} + +// SourceCodeAddressGTE applies the GTE predicate on the "source_code_address" field. +func SourceCodeAddressGTE(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldGTE(FieldSourceCodeAddress, v)) +} + +// SourceCodeAddressLT applies the LT predicate on the "source_code_address" field. +func SourceCodeAddressLT(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldLT(FieldSourceCodeAddress, v)) +} + +// SourceCodeAddressLTE applies the LTE predicate on the "source_code_address" field. +func SourceCodeAddressLTE(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldLTE(FieldSourceCodeAddress, v)) +} + +// SourceCodeAddressContains applies the Contains predicate on the "source_code_address" field. +func SourceCodeAddressContains(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldContains(FieldSourceCodeAddress, v)) +} + +// SourceCodeAddressHasPrefix applies the HasPrefix predicate on the "source_code_address" field. +func SourceCodeAddressHasPrefix(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldHasPrefix(FieldSourceCodeAddress, v)) +} + +// SourceCodeAddressHasSuffix applies the HasSuffix predicate on the "source_code_address" field. +func SourceCodeAddressHasSuffix(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldHasSuffix(FieldSourceCodeAddress, v)) +} + +// SourceCodeAddressEqualFold applies the EqualFold predicate on the "source_code_address" field. +func SourceCodeAddressEqualFold(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldEqualFold(FieldSourceCodeAddress, v)) +} + +// SourceCodeAddressContainsFold applies the ContainsFold predicate on the "source_code_address" field. +func SourceCodeAddressContainsFold(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldContainsFold(FieldSourceCodeAddress, v)) +} + +// BuildVersionEQ applies the EQ predicate on the "build_version" field. +func BuildVersionEQ(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldEQ(FieldBuildVersion, v)) +} + +// BuildVersionNEQ applies the NEQ predicate on the "build_version" field. +func BuildVersionNEQ(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldNEQ(FieldBuildVersion, v)) +} + +// BuildVersionIn applies the In predicate on the "build_version" field. +func BuildVersionIn(vs ...string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldIn(FieldBuildVersion, vs...)) +} + +// BuildVersionNotIn applies the NotIn predicate on the "build_version" field. +func BuildVersionNotIn(vs ...string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldNotIn(FieldBuildVersion, vs...)) +} + +// BuildVersionGT applies the GT predicate on the "build_version" field. +func BuildVersionGT(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldGT(FieldBuildVersion, v)) +} + +// BuildVersionGTE applies the GTE predicate on the "build_version" field. +func BuildVersionGTE(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldGTE(FieldBuildVersion, v)) +} + +// BuildVersionLT applies the LT predicate on the "build_version" field. +func BuildVersionLT(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldLT(FieldBuildVersion, v)) +} + +// BuildVersionLTE applies the LTE predicate on the "build_version" field. +func BuildVersionLTE(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldLTE(FieldBuildVersion, v)) +} + +// BuildVersionContains applies the Contains predicate on the "build_version" field. +func BuildVersionContains(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldContains(FieldBuildVersion, v)) +} + +// BuildVersionHasPrefix applies the HasPrefix predicate on the "build_version" field. +func BuildVersionHasPrefix(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldHasPrefix(FieldBuildVersion, v)) +} + +// BuildVersionHasSuffix applies the HasSuffix predicate on the "build_version" field. +func BuildVersionHasSuffix(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldHasSuffix(FieldBuildVersion, v)) +} + +// BuildVersionEqualFold applies the EqualFold predicate on the "build_version" field. +func BuildVersionEqualFold(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldEqualFold(FieldBuildVersion, v)) +} + +// BuildVersionContainsFold applies the ContainsFold predicate on the "build_version" field. +func BuildVersionContainsFold(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldContainsFold(FieldBuildVersion, v)) +} + +// BuildDateEQ applies the EQ predicate on the "build_date" field. +func BuildDateEQ(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldEQ(FieldBuildDate, v)) +} + +// BuildDateNEQ applies the NEQ predicate on the "build_date" field. +func BuildDateNEQ(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldNEQ(FieldBuildDate, v)) +} + +// BuildDateIn applies the In predicate on the "build_date" field. +func BuildDateIn(vs ...string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldIn(FieldBuildDate, vs...)) +} + +// BuildDateNotIn applies the NotIn predicate on the "build_date" field. +func BuildDateNotIn(vs ...string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldNotIn(FieldBuildDate, vs...)) +} + +// BuildDateGT applies the GT predicate on the "build_date" field. +func BuildDateGT(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldGT(FieldBuildDate, v)) +} + +// BuildDateGTE applies the GTE predicate on the "build_date" field. +func BuildDateGTE(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldGTE(FieldBuildDate, v)) +} + +// BuildDateLT applies the LT predicate on the "build_date" field. +func BuildDateLT(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldLT(FieldBuildDate, v)) +} + +// BuildDateLTE applies the LTE predicate on the "build_date" field. +func BuildDateLTE(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldLTE(FieldBuildDate, v)) +} + +// BuildDateContains applies the Contains predicate on the "build_date" field. +func BuildDateContains(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldContains(FieldBuildDate, v)) +} + +// BuildDateHasPrefix applies the HasPrefix predicate on the "build_date" field. +func BuildDateHasPrefix(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldHasPrefix(FieldBuildDate, v)) +} + +// BuildDateHasSuffix applies the HasSuffix predicate on the "build_date" field. +func BuildDateHasSuffix(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldHasSuffix(FieldBuildDate, v)) +} + +// BuildDateEqualFold applies the EqualFold predicate on the "build_date" field. +func BuildDateEqualFold(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldEqualFold(FieldBuildDate, v)) +} + +// BuildDateContainsFold applies the ContainsFold predicate on the "build_date" field. +func BuildDateContainsFold(v string) predicate.PorterInstance { + return predicate.PorterInstance(sql.FieldContainsFold(FieldBuildDate, v)) +} + // GlobalNameEQ applies the EQ predicate on the "global_name" field. func GlobalNameEQ(v string) predicate.PorterInstance { return predicate.PorterInstance(sql.FieldEQ(FieldGlobalName, v)) diff --git a/app/sephirah/internal/data/internal/ent/porterinstance_create.go b/app/sephirah/internal/data/internal/ent/porterinstance_create.go index ad792af..0cd7442 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance_create.go +++ b/app/sephirah/internal/data/internal/ent/porterinstance_create.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) @@ -36,6 +36,30 @@ func (pic *PorterInstanceCreate) SetVersion(s string) *PorterInstanceCreate { return pic } +// SetDescription sets the "description" field. +func (pic *PorterInstanceCreate) SetDescription(s string) *PorterInstanceCreate { + pic.mutation.SetDescription(s) + return pic +} + +// SetSourceCodeAddress sets the "source_code_address" field. +func (pic *PorterInstanceCreate) SetSourceCodeAddress(s string) *PorterInstanceCreate { + pic.mutation.SetSourceCodeAddress(s) + return pic +} + +// SetBuildVersion sets the "build_version" field. +func (pic *PorterInstanceCreate) SetBuildVersion(s string) *PorterInstanceCreate { + pic.mutation.SetBuildVersion(s) + return pic +} + +// SetBuildDate sets the "build_date" field. +func (pic *PorterInstanceCreate) SetBuildDate(s string) *PorterInstanceCreate { + pic.mutation.SetBuildDate(s) + return pic +} + // SetGlobalName sets the "global_name" field. func (pic *PorterInstanceCreate) SetGlobalName(s string) *PorterInstanceCreate { pic.mutation.SetGlobalName(s) @@ -55,7 +79,7 @@ func (pic *PorterInstanceCreate) SetRegion(s string) *PorterInstanceCreate { } // SetFeatureSummary sets the "feature_summary" field. -func (pic *PorterInstanceCreate) SetFeatureSummary(mfs *modeltiphereth.PorterFeatureSummary) *PorterInstanceCreate { +func (pic *PorterInstanceCreate) SetFeatureSummary(mfs *modelsupervisor.PorterFeatureSummary) *PorterInstanceCreate { pic.mutation.SetFeatureSummary(mfs) return pic } @@ -159,6 +183,18 @@ func (pic *PorterInstanceCreate) check() error { if _, ok := pic.mutation.Version(); !ok { return &ValidationError{Name: "version", err: errors.New(`ent: missing required field "PorterInstance.version"`)} } + if _, ok := pic.mutation.Description(); !ok { + return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "PorterInstance.description"`)} + } + if _, ok := pic.mutation.SourceCodeAddress(); !ok { + return &ValidationError{Name: "source_code_address", err: errors.New(`ent: missing required field "PorterInstance.source_code_address"`)} + } + if _, ok := pic.mutation.BuildVersion(); !ok { + return &ValidationError{Name: "build_version", err: errors.New(`ent: missing required field "PorterInstance.build_version"`)} + } + if _, ok := pic.mutation.BuildDate(); !ok { + return &ValidationError{Name: "build_date", err: errors.New(`ent: missing required field "PorterInstance.build_date"`)} + } if _, ok := pic.mutation.GlobalName(); !ok { return &ValidationError{Name: "global_name", err: errors.New(`ent: missing required field "PorterInstance.global_name"`)} } @@ -229,6 +265,22 @@ func (pic *PorterInstanceCreate) createSpec() (*PorterInstance, *sqlgraph.Create _spec.SetField(porterinstance.FieldVersion, field.TypeString, value) _node.Version = value } + if value, ok := pic.mutation.Description(); ok { + _spec.SetField(porterinstance.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := pic.mutation.SourceCodeAddress(); ok { + _spec.SetField(porterinstance.FieldSourceCodeAddress, field.TypeString, value) + _node.SourceCodeAddress = value + } + if value, ok := pic.mutation.BuildVersion(); ok { + _spec.SetField(porterinstance.FieldBuildVersion, field.TypeString, value) + _node.BuildVersion = value + } + if value, ok := pic.mutation.BuildDate(); ok { + _spec.SetField(porterinstance.FieldBuildDate, field.TypeString, value) + _node.BuildDate = value + } if value, ok := pic.mutation.GlobalName(); ok { _spec.SetField(porterinstance.FieldGlobalName, field.TypeString, value) _node.GlobalName = value @@ -337,6 +389,54 @@ func (u *PorterInstanceUpsert) UpdateVersion() *PorterInstanceUpsert { return u } +// SetDescription sets the "description" field. +func (u *PorterInstanceUpsert) SetDescription(v string) *PorterInstanceUpsert { + u.Set(porterinstance.FieldDescription, v) + return u +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *PorterInstanceUpsert) UpdateDescription() *PorterInstanceUpsert { + u.SetExcluded(porterinstance.FieldDescription) + return u +} + +// SetSourceCodeAddress sets the "source_code_address" field. +func (u *PorterInstanceUpsert) SetSourceCodeAddress(v string) *PorterInstanceUpsert { + u.Set(porterinstance.FieldSourceCodeAddress, v) + return u +} + +// UpdateSourceCodeAddress sets the "source_code_address" field to the value that was provided on create. +func (u *PorterInstanceUpsert) UpdateSourceCodeAddress() *PorterInstanceUpsert { + u.SetExcluded(porterinstance.FieldSourceCodeAddress) + return u +} + +// SetBuildVersion sets the "build_version" field. +func (u *PorterInstanceUpsert) SetBuildVersion(v string) *PorterInstanceUpsert { + u.Set(porterinstance.FieldBuildVersion, v) + return u +} + +// UpdateBuildVersion sets the "build_version" field to the value that was provided on create. +func (u *PorterInstanceUpsert) UpdateBuildVersion() *PorterInstanceUpsert { + u.SetExcluded(porterinstance.FieldBuildVersion) + return u +} + +// SetBuildDate sets the "build_date" field. +func (u *PorterInstanceUpsert) SetBuildDate(v string) *PorterInstanceUpsert { + u.Set(porterinstance.FieldBuildDate, v) + return u +} + +// UpdateBuildDate sets the "build_date" field to the value that was provided on create. +func (u *PorterInstanceUpsert) UpdateBuildDate() *PorterInstanceUpsert { + u.SetExcluded(porterinstance.FieldBuildDate) + return u +} + // SetGlobalName sets the "global_name" field. func (u *PorterInstanceUpsert) SetGlobalName(v string) *PorterInstanceUpsert { u.Set(porterinstance.FieldGlobalName, v) @@ -374,7 +474,7 @@ func (u *PorterInstanceUpsert) UpdateRegion() *PorterInstanceUpsert { } // SetFeatureSummary sets the "feature_summary" field. -func (u *PorterInstanceUpsert) SetFeatureSummary(v *modeltiphereth.PorterFeatureSummary) *PorterInstanceUpsert { +func (u *PorterInstanceUpsert) SetFeatureSummary(v *modelsupervisor.PorterFeatureSummary) *PorterInstanceUpsert { u.Set(porterinstance.FieldFeatureSummary, v) return u } @@ -509,6 +609,62 @@ func (u *PorterInstanceUpsertOne) UpdateVersion() *PorterInstanceUpsertOne { }) } +// SetDescription sets the "description" field. +func (u *PorterInstanceUpsertOne) SetDescription(v string) *PorterInstanceUpsertOne { + return u.Update(func(s *PorterInstanceUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *PorterInstanceUpsertOne) UpdateDescription() *PorterInstanceUpsertOne { + return u.Update(func(s *PorterInstanceUpsert) { + s.UpdateDescription() + }) +} + +// SetSourceCodeAddress sets the "source_code_address" field. +func (u *PorterInstanceUpsertOne) SetSourceCodeAddress(v string) *PorterInstanceUpsertOne { + return u.Update(func(s *PorterInstanceUpsert) { + s.SetSourceCodeAddress(v) + }) +} + +// UpdateSourceCodeAddress sets the "source_code_address" field to the value that was provided on create. +func (u *PorterInstanceUpsertOne) UpdateSourceCodeAddress() *PorterInstanceUpsertOne { + return u.Update(func(s *PorterInstanceUpsert) { + s.UpdateSourceCodeAddress() + }) +} + +// SetBuildVersion sets the "build_version" field. +func (u *PorterInstanceUpsertOne) SetBuildVersion(v string) *PorterInstanceUpsertOne { + return u.Update(func(s *PorterInstanceUpsert) { + s.SetBuildVersion(v) + }) +} + +// UpdateBuildVersion sets the "build_version" field to the value that was provided on create. +func (u *PorterInstanceUpsertOne) UpdateBuildVersion() *PorterInstanceUpsertOne { + return u.Update(func(s *PorterInstanceUpsert) { + s.UpdateBuildVersion() + }) +} + +// SetBuildDate sets the "build_date" field. +func (u *PorterInstanceUpsertOne) SetBuildDate(v string) *PorterInstanceUpsertOne { + return u.Update(func(s *PorterInstanceUpsert) { + s.SetBuildDate(v) + }) +} + +// UpdateBuildDate sets the "build_date" field to the value that was provided on create. +func (u *PorterInstanceUpsertOne) UpdateBuildDate() *PorterInstanceUpsertOne { + return u.Update(func(s *PorterInstanceUpsert) { + s.UpdateBuildDate() + }) +} + // SetGlobalName sets the "global_name" field. func (u *PorterInstanceUpsertOne) SetGlobalName(v string) *PorterInstanceUpsertOne { return u.Update(func(s *PorterInstanceUpsert) { @@ -552,7 +708,7 @@ func (u *PorterInstanceUpsertOne) UpdateRegion() *PorterInstanceUpsertOne { } // SetFeatureSummary sets the "feature_summary" field. -func (u *PorterInstanceUpsertOne) SetFeatureSummary(v *modeltiphereth.PorterFeatureSummary) *PorterInstanceUpsertOne { +func (u *PorterInstanceUpsertOne) SetFeatureSummary(v *modelsupervisor.PorterFeatureSummary) *PorterInstanceUpsertOne { return u.Update(func(s *PorterInstanceUpsert) { s.SetFeatureSummary(v) }) @@ -863,6 +1019,62 @@ func (u *PorterInstanceUpsertBulk) UpdateVersion() *PorterInstanceUpsertBulk { }) } +// SetDescription sets the "description" field. +func (u *PorterInstanceUpsertBulk) SetDescription(v string) *PorterInstanceUpsertBulk { + return u.Update(func(s *PorterInstanceUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *PorterInstanceUpsertBulk) UpdateDescription() *PorterInstanceUpsertBulk { + return u.Update(func(s *PorterInstanceUpsert) { + s.UpdateDescription() + }) +} + +// SetSourceCodeAddress sets the "source_code_address" field. +func (u *PorterInstanceUpsertBulk) SetSourceCodeAddress(v string) *PorterInstanceUpsertBulk { + return u.Update(func(s *PorterInstanceUpsert) { + s.SetSourceCodeAddress(v) + }) +} + +// UpdateSourceCodeAddress sets the "source_code_address" field to the value that was provided on create. +func (u *PorterInstanceUpsertBulk) UpdateSourceCodeAddress() *PorterInstanceUpsertBulk { + return u.Update(func(s *PorterInstanceUpsert) { + s.UpdateSourceCodeAddress() + }) +} + +// SetBuildVersion sets the "build_version" field. +func (u *PorterInstanceUpsertBulk) SetBuildVersion(v string) *PorterInstanceUpsertBulk { + return u.Update(func(s *PorterInstanceUpsert) { + s.SetBuildVersion(v) + }) +} + +// UpdateBuildVersion sets the "build_version" field to the value that was provided on create. +func (u *PorterInstanceUpsertBulk) UpdateBuildVersion() *PorterInstanceUpsertBulk { + return u.Update(func(s *PorterInstanceUpsert) { + s.UpdateBuildVersion() + }) +} + +// SetBuildDate sets the "build_date" field. +func (u *PorterInstanceUpsertBulk) SetBuildDate(v string) *PorterInstanceUpsertBulk { + return u.Update(func(s *PorterInstanceUpsert) { + s.SetBuildDate(v) + }) +} + +// UpdateBuildDate sets the "build_date" field to the value that was provided on create. +func (u *PorterInstanceUpsertBulk) UpdateBuildDate() *PorterInstanceUpsertBulk { + return u.Update(func(s *PorterInstanceUpsert) { + s.UpdateBuildDate() + }) +} + // SetGlobalName sets the "global_name" field. func (u *PorterInstanceUpsertBulk) SetGlobalName(v string) *PorterInstanceUpsertBulk { return u.Update(func(s *PorterInstanceUpsert) { @@ -906,7 +1118,7 @@ func (u *PorterInstanceUpsertBulk) UpdateRegion() *PorterInstanceUpsertBulk { } // SetFeatureSummary sets the "feature_summary" field. -func (u *PorterInstanceUpsertBulk) SetFeatureSummary(v *modeltiphereth.PorterFeatureSummary) *PorterInstanceUpsertBulk { +func (u *PorterInstanceUpsertBulk) SetFeatureSummary(v *modelsupervisor.PorterFeatureSummary) *PorterInstanceUpsertBulk { return u.Update(func(s *PorterInstanceUpsert) { s.SetFeatureSummary(v) }) diff --git a/app/sephirah/internal/data/internal/ent/porterinstance_update.go b/app/sephirah/internal/data/internal/ent/porterinstance_update.go index 5a13bdb..e94cd40 100644 --- a/app/sephirah/internal/data/internal/ent/porterinstance_update.go +++ b/app/sephirah/internal/data/internal/ent/porterinstance_update.go @@ -13,7 +13,7 @@ import ( "entgo.io/ent/schema/field" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/porterinstance" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/predicate" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" ) // PorterInstanceUpdate is the builder for updating PorterInstance entities. @@ -57,6 +57,62 @@ func (piu *PorterInstanceUpdate) SetNillableVersion(s *string) *PorterInstanceUp return piu } +// SetDescription sets the "description" field. +func (piu *PorterInstanceUpdate) SetDescription(s string) *PorterInstanceUpdate { + piu.mutation.SetDescription(s) + return piu +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (piu *PorterInstanceUpdate) SetNillableDescription(s *string) *PorterInstanceUpdate { + if s != nil { + piu.SetDescription(*s) + } + return piu +} + +// SetSourceCodeAddress sets the "source_code_address" field. +func (piu *PorterInstanceUpdate) SetSourceCodeAddress(s string) *PorterInstanceUpdate { + piu.mutation.SetSourceCodeAddress(s) + return piu +} + +// SetNillableSourceCodeAddress sets the "source_code_address" field if the given value is not nil. +func (piu *PorterInstanceUpdate) SetNillableSourceCodeAddress(s *string) *PorterInstanceUpdate { + if s != nil { + piu.SetSourceCodeAddress(*s) + } + return piu +} + +// SetBuildVersion sets the "build_version" field. +func (piu *PorterInstanceUpdate) SetBuildVersion(s string) *PorterInstanceUpdate { + piu.mutation.SetBuildVersion(s) + return piu +} + +// SetNillableBuildVersion sets the "build_version" field if the given value is not nil. +func (piu *PorterInstanceUpdate) SetNillableBuildVersion(s *string) *PorterInstanceUpdate { + if s != nil { + piu.SetBuildVersion(*s) + } + return piu +} + +// SetBuildDate sets the "build_date" field. +func (piu *PorterInstanceUpdate) SetBuildDate(s string) *PorterInstanceUpdate { + piu.mutation.SetBuildDate(s) + return piu +} + +// SetNillableBuildDate sets the "build_date" field if the given value is not nil. +func (piu *PorterInstanceUpdate) SetNillableBuildDate(s *string) *PorterInstanceUpdate { + if s != nil { + piu.SetBuildDate(*s) + } + return piu +} + // SetGlobalName sets the "global_name" field. func (piu *PorterInstanceUpdate) SetGlobalName(s string) *PorterInstanceUpdate { piu.mutation.SetGlobalName(s) @@ -100,7 +156,7 @@ func (piu *PorterInstanceUpdate) SetNillableRegion(s *string) *PorterInstanceUpd } // SetFeatureSummary sets the "feature_summary" field. -func (piu *PorterInstanceUpdate) SetFeatureSummary(mfs *modeltiphereth.PorterFeatureSummary) *PorterInstanceUpdate { +func (piu *PorterInstanceUpdate) SetFeatureSummary(mfs *modelsupervisor.PorterFeatureSummary) *PorterInstanceUpdate { piu.mutation.SetFeatureSummary(mfs) return piu } @@ -222,6 +278,18 @@ func (piu *PorterInstanceUpdate) sqlSave(ctx context.Context) (n int, err error) if value, ok := piu.mutation.Version(); ok { _spec.SetField(porterinstance.FieldVersion, field.TypeString, value) } + if value, ok := piu.mutation.Description(); ok { + _spec.SetField(porterinstance.FieldDescription, field.TypeString, value) + } + if value, ok := piu.mutation.SourceCodeAddress(); ok { + _spec.SetField(porterinstance.FieldSourceCodeAddress, field.TypeString, value) + } + if value, ok := piu.mutation.BuildVersion(); ok { + _spec.SetField(porterinstance.FieldBuildVersion, field.TypeString, value) + } + if value, ok := piu.mutation.BuildDate(); ok { + _spec.SetField(porterinstance.FieldBuildDate, field.TypeString, value) + } if value, ok := piu.mutation.GlobalName(); ok { _spec.SetField(porterinstance.FieldGlobalName, field.TypeString, value) } @@ -294,6 +362,62 @@ func (piuo *PorterInstanceUpdateOne) SetNillableVersion(s *string) *PorterInstan return piuo } +// SetDescription sets the "description" field. +func (piuo *PorterInstanceUpdateOne) SetDescription(s string) *PorterInstanceUpdateOne { + piuo.mutation.SetDescription(s) + return piuo +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (piuo *PorterInstanceUpdateOne) SetNillableDescription(s *string) *PorterInstanceUpdateOne { + if s != nil { + piuo.SetDescription(*s) + } + return piuo +} + +// SetSourceCodeAddress sets the "source_code_address" field. +func (piuo *PorterInstanceUpdateOne) SetSourceCodeAddress(s string) *PorterInstanceUpdateOne { + piuo.mutation.SetSourceCodeAddress(s) + return piuo +} + +// SetNillableSourceCodeAddress sets the "source_code_address" field if the given value is not nil. +func (piuo *PorterInstanceUpdateOne) SetNillableSourceCodeAddress(s *string) *PorterInstanceUpdateOne { + if s != nil { + piuo.SetSourceCodeAddress(*s) + } + return piuo +} + +// SetBuildVersion sets the "build_version" field. +func (piuo *PorterInstanceUpdateOne) SetBuildVersion(s string) *PorterInstanceUpdateOne { + piuo.mutation.SetBuildVersion(s) + return piuo +} + +// SetNillableBuildVersion sets the "build_version" field if the given value is not nil. +func (piuo *PorterInstanceUpdateOne) SetNillableBuildVersion(s *string) *PorterInstanceUpdateOne { + if s != nil { + piuo.SetBuildVersion(*s) + } + return piuo +} + +// SetBuildDate sets the "build_date" field. +func (piuo *PorterInstanceUpdateOne) SetBuildDate(s string) *PorterInstanceUpdateOne { + piuo.mutation.SetBuildDate(s) + return piuo +} + +// SetNillableBuildDate sets the "build_date" field if the given value is not nil. +func (piuo *PorterInstanceUpdateOne) SetNillableBuildDate(s *string) *PorterInstanceUpdateOne { + if s != nil { + piuo.SetBuildDate(*s) + } + return piuo +} + // SetGlobalName sets the "global_name" field. func (piuo *PorterInstanceUpdateOne) SetGlobalName(s string) *PorterInstanceUpdateOne { piuo.mutation.SetGlobalName(s) @@ -337,7 +461,7 @@ func (piuo *PorterInstanceUpdateOne) SetNillableRegion(s *string) *PorterInstanc } // SetFeatureSummary sets the "feature_summary" field. -func (piuo *PorterInstanceUpdateOne) SetFeatureSummary(mfs *modeltiphereth.PorterFeatureSummary) *PorterInstanceUpdateOne { +func (piuo *PorterInstanceUpdateOne) SetFeatureSummary(mfs *modelsupervisor.PorterFeatureSummary) *PorterInstanceUpdateOne { piuo.mutation.SetFeatureSummary(mfs) return piuo } @@ -489,6 +613,18 @@ func (piuo *PorterInstanceUpdateOne) sqlSave(ctx context.Context) (_node *Porter if value, ok := piuo.mutation.Version(); ok { _spec.SetField(porterinstance.FieldVersion, field.TypeString, value) } + if value, ok := piuo.mutation.Description(); ok { + _spec.SetField(porterinstance.FieldDescription, field.TypeString, value) + } + if value, ok := piuo.mutation.SourceCodeAddress(); ok { + _spec.SetField(porterinstance.FieldSourceCodeAddress, field.TypeString, value) + } + if value, ok := piuo.mutation.BuildVersion(); ok { + _spec.SetField(porterinstance.FieldBuildVersion, field.TypeString, value) + } + if value, ok := piuo.mutation.BuildDate(); ok { + _spec.SetField(porterinstance.FieldBuildDate, field.TypeString, value) + } if value, ok := piuo.mutation.GlobalName(); ok { _spec.SetField(porterinstance.FieldGlobalName, field.TypeString, value) } diff --git a/app/sephirah/internal/data/internal/ent/runtime.go b/app/sephirah/internal/data/internal/ent/runtime.go index 098dd39..4c991b3 100644 --- a/app/sephirah/internal/data/internal/ent/runtime.go +++ b/app/sephirah/internal/data/internal/ent/runtime.go @@ -310,13 +310,13 @@ func init() { porterinstanceFields := schema.PorterInstance{}.Fields() _ = porterinstanceFields // porterinstanceDescUpdatedAt is the schema descriptor for updated_at field. - porterinstanceDescUpdatedAt := porterinstanceFields[9].Descriptor() + porterinstanceDescUpdatedAt := porterinstanceFields[13].Descriptor() // porterinstance.DefaultUpdatedAt holds the default value on creation for the updated_at field. porterinstance.DefaultUpdatedAt = porterinstanceDescUpdatedAt.Default.(func() time.Time) // porterinstance.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. porterinstance.UpdateDefaultUpdatedAt = porterinstanceDescUpdatedAt.UpdateDefault.(func() time.Time) // porterinstanceDescCreatedAt is the schema descriptor for created_at field. - porterinstanceDescCreatedAt := porterinstanceFields[10].Descriptor() + porterinstanceDescCreatedAt := porterinstanceFields[14].Descriptor() // porterinstance.DefaultCreatedAt holds the default value on creation for the created_at field. porterinstance.DefaultCreatedAt = porterinstanceDescCreatedAt.Default.(func() time.Time) systemnotificationFields := schema.SystemNotification{}.Fields() diff --git a/app/sephirah/internal/data/internal/ent/schema/feed_action_set.go b/app/sephirah/internal/data/internal/ent/schema/feed_action_set.go index 553231e..8648e0d 100644 --- a/app/sephirah/internal/data/internal/ent/schema/feed_action_set.go +++ b/app/sephirah/internal/data/internal/ent/schema/feed_action_set.go @@ -3,7 +3,7 @@ package schema import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "entgo.io/ent" "entgo.io/ent/schema/edge" @@ -19,7 +19,7 @@ func (FeedActionSet) Fields() []ent.Field { defaultPrimaryKey(), field.String("name"), field.String("description"), - field.JSON("actions", []*modeltiphereth.FeatureRequest{}), + field.JSON("actions", []*modelsupervisor.FeatureRequest{}), field.Time("updated_at"). Default(time.Now).UpdateDefault(time.Now), field.Time("created_at"). diff --git a/app/sephirah/internal/data/internal/ent/schema/feed_config.go b/app/sephirah/internal/data/internal/ent/schema/feed_config.go index a06fe86..5eefe32 100644 --- a/app/sephirah/internal/data/internal/ent/schema/feed_config.go +++ b/app/sephirah/internal/data/internal/ent/schema/feed_config.go @@ -3,7 +3,7 @@ package schema import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" "entgo.io/ent" @@ -25,7 +25,7 @@ func (FeedConfig) Fields() []ent.Field { GoType(model.InternalID(0)), field.String("name"), field.String("description"), - field.JSON("source", new(modeltiphereth.FeatureRequest)), + field.JSON("source", new(modelsupervisor.FeatureRequest)), field.Enum("status"). Values("active", "suspend"), field.String("category"), diff --git a/app/sephirah/internal/data/internal/ent/schema/notify_target.go b/app/sephirah/internal/data/internal/ent/schema/notify_target.go index 01576ee..0b4c713 100644 --- a/app/sephirah/internal/data/internal/ent/schema/notify_target.go +++ b/app/sephirah/internal/data/internal/ent/schema/notify_target.go @@ -3,7 +3,7 @@ package schema import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "entgo.io/ent" "entgo.io/ent/schema/edge" @@ -21,7 +21,7 @@ func (NotifyTarget) Fields() []ent.Field { defaultPrimaryKey(), field.String("name"), field.String("description"), - field.JSON("destination", new(modeltiphereth.FeatureRequest)), + field.JSON("destination", new(modelsupervisor.FeatureRequest)), field.Enum("status"). Values("active", "suspend"), field.Time("updated_at"). diff --git a/app/sephirah/internal/data/internal/ent/schema/porter_instance.go b/app/sephirah/internal/data/internal/ent/schema/porter_instance.go index 328100d..66b8051 100644 --- a/app/sephirah/internal/data/internal/ent/schema/porter_instance.go +++ b/app/sephirah/internal/data/internal/ent/schema/porter_instance.go @@ -3,7 +3,7 @@ package schema import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "entgo.io/ent" "entgo.io/ent/schema/field" @@ -19,10 +19,14 @@ func (PorterInstance) Fields() []ent.Field { defaultPrimaryKey(), field.String("name"), field.String("version"), + field.String("description"), + field.String("source_code_address"), + field.String("build_version"), + field.String("build_date"), field.String("global_name"), field.String("address"), field.String("region"), - field.JSON("feature_summary", new(modeltiphereth.PorterFeatureSummary)), + field.JSON("feature_summary", new(modelsupervisor.PorterFeatureSummary)), field.String("context_json_schema"), field.Enum("status"). Values("active", "blocked"), @@ -37,5 +41,6 @@ func (PorterInstance) Indexes() []ent.Index { return []ent.Index{ index.Fields("address"). Unique(), + index.Fields("global_name", "region"), } } diff --git a/app/sephirah/internal/data/tiphereth.go b/app/sephirah/internal/data/tiphereth.go index 10a766d..7c887e6 100644 --- a/app/sephirah/internal/data/tiphereth.go +++ b/app/sephirah/internal/data/tiphereth.go @@ -14,6 +14,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/user" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/userdevice" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/usersession" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/lib/libauth" "github.com/tuihub/librarian/internal/model" @@ -346,13 +347,20 @@ func (t tipherethRepo) ListLinkAccounts( return converter.ToBizAccountList(a), nil } -func (t tipherethRepo) UpsertPorters(ctx context.Context, il []*modeltiphereth.PorterInstance) error { +func (t tipherethRepo) UpsertPorters(ctx context.Context, il []*modelsupervisor.PorterInstance) error { instances := make([]*ent.PorterInstanceCreate, len(il)) for i, instance := range il { + if instance.BinarySummary == nil { + instance.BinarySummary = new(modelsupervisor.PorterBinarySummary) + } instances[i] = t.data.db.PorterInstance.Create(). SetID(instance.ID). - SetName(instance.Name). - SetVersion(instance.Version). + SetName(instance.BinarySummary.Name). + SetVersion(instance.BinarySummary.Version). + SetDescription(instance.BinarySummary.Description). + SetSourceCodeAddress(instance.BinarySummary.SourceCodeAddress). + SetBuildVersion(instance.BinarySummary.BuildVersion). + SetBuildDate(instance.BinarySummary.BuildDate). SetGlobalName(instance.GlobalName). SetAddress(instance.Address). SetStatus(converter.ToEntPorterInstanceStatus(instance.Status)). @@ -374,7 +382,7 @@ func (t tipherethRepo) UpsertPorters(ctx context.Context, il []*modeltiphereth.P func (t tipherethRepo) ListPorters( ctx context.Context, paging model.Paging, -) ([]*modeltiphereth.PorterInstance, int64, error) { +) ([]*modelsupervisor.PorterInstance, int64, error) { q := t.data.db.PorterInstance.Query() count, err := q.Count(ctx) if err != nil { @@ -393,8 +401,8 @@ func (t tipherethRepo) ListPorters( func (t tipherethRepo) UpdatePorterStatus( ctx context.Context, id model.InternalID, - status modeltiphereth.PorterInstanceStatus, -) (*modeltiphereth.PorterInstance, error) { + status modeltiphereth.UserStatus, +) (*modelsupervisor.PorterInstance, error) { pi, err := t.data.db.PorterInstance.Get(ctx, id) if err != nil { return nil, err @@ -406,7 +414,7 @@ func (t tipherethRepo) UpdatePorterStatus( return converter.ToBizPorter(pi), nil } -func (t tipherethRepo) FetchPorterByAddress(ctx context.Context, address string) (*modeltiphereth.PorterInstance, error) { +func (t tipherethRepo) FetchPorterByAddress(ctx context.Context, address string) (*modelsupervisor.PorterInstance, error) { p, err := t.data.db.PorterInstance.Query().Where( porterinstance.AddressEQ(address), ).Only(ctx) @@ -419,7 +427,7 @@ func (t tipherethRepo) FetchPorterByAddress(ctx context.Context, address string) func (t tipherethRepo) CreatePorterContext( ctx context.Context, userID model.InternalID, - context *modeltiphereth.PorterContext, + context *modelsupervisor.PorterContext, ) error { return t.data.db.PorterContext.Create(). SetOwnerID(userID). @@ -436,7 +444,7 @@ func (t tipherethRepo) ListPorterContexts( ctx context.Context, userID model.InternalID, paging model.Paging, -) ([]*modeltiphereth.PorterContext, int64, error) { +) ([]*modelsupervisor.PorterContext, int64, error) { q := t.data.db.PorterContext.Query().Where( portercontext.HasOwnerWith(user.IDEQ(userID)), ) @@ -457,7 +465,7 @@ func (t tipherethRepo) ListPorterContexts( func (t tipherethRepo) UpdatePorterContext( ctx context.Context, userID model.InternalID, - context *modeltiphereth.PorterContext, + context *modelsupervisor.PorterContext, ) error { return t.data.db.PorterContext.Update().Where( portercontext.IDEQ(context.ID), @@ -469,3 +477,45 @@ func (t tipherethRepo) UpdatePorterContext( SetStatus(converter.ToEntPorterContextStatus(context.Status)). Exec(ctx) } + +func (t tipherethRepo) ListPorterGroups( + ctx context.Context, + status []modeltiphereth.UserStatus, +) ([]*modelsupervisor.PorterGroup, error) { + var pi []*ent.PorterInstance + var pg []*modelsupervisor.PorterGroup + pgm := make(map[string]*modelsupervisor.PorterGroup) + q := t.data.db.PorterInstance.Query() + if len(status) > 0 { + q.Where(porterinstance.StatusIn(converter.ToEntPorterInstanceStatusList(status)...)) + } + err := q.GroupBy( + porterinstance.FieldGlobalName, + porterinstance.FieldRegion, + ).Scan(ctx, &pi) + if err != nil { + return nil, err + } + for _, p := range pi { + if pgm[p.GlobalName] == nil { + pgm[p.GlobalName] = &modelsupervisor.PorterGroup{ + BinarySummary: &modelsupervisor.PorterBinarySummary{ + Name: p.Name, + Version: p.Version, + Description: p.Description, + SourceCodeAddress: p.SourceCodeAddress, + BuildVersion: p.BuildVersion, + BuildDate: p.BuildDate, + }, + GlobalName: p.GlobalName, + Regions: []string{p.Region}, + ContextJSONSchema: p.ContextJSONSchema, + } + } + pgm[p.GlobalName].Regions = append(pgm[p.GlobalName].Regions, p.Region) + } + for _, v := range pgm { + pg = append(pg, v) + } + return pg, nil +} diff --git a/app/sephirah/internal/model/converter/biz_to_pb.go b/app/sephirah/internal/model/converter/biz_to_pb.go index b2711fc..6dcf4cb 100644 --- a/app/sephirah/internal/model/converter/biz_to_pb.go +++ b/app/sephirah/internal/model/converter/biz_to_pb.go @@ -5,6 +5,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" "github.com/tuihub/librarian/internal/lib/libauth" @@ -30,9 +31,9 @@ import ( type toPBConverter interface { //nolint:unused // used by generator ToPBTimeRange(*model.TimeRange) *librarian.TimeRange ToPBInternalIDList([]model.InternalID) []*librarian.InternalID - ToPBServerFeatureSummary(*modeltiphereth.ServerFeatureSummary) *pb.ServerFeatureSummary - ToPBFeatureFlag(*modeltiphereth.FeatureFlag) *librarian.FeatureFlag - ToPBFeatureRequest(*modeltiphereth.FeatureRequest) *librarian.FeatureRequest + ToPBServerFeatureSummary(*modelsupervisor.ServerFeatureSummary) *pb.ServerFeatureSummary + ToPBFeatureFlag(*modelsupervisor.FeatureFlag) *librarian.FeatureFlag + ToPBFeatureRequest(*modelsupervisor.FeatureRequest) *librarian.FeatureRequest // goverter:map ID DeviceId ToPBDeviceInfo(*modeltiphereth.DeviceInfo) *pb.DeviceInfo @@ -71,11 +72,10 @@ type toPBConverter interface { //nolint:unused // used by generator ToPBAccount(*modeltiphereth.Account) *librarian.Account ToPBAccountList([]*modeltiphereth.Account) []*librarian.Account - // goverter:map Status | ToPBPorterStatus // goverter:ignore FeatureSummary // goverter:autoMap PorterInstance - ToPBPorter(*modeltiphereth.PorterInstanceController) *pb.Porter - ToPBPorterList([]*modeltiphereth.PorterInstanceController) []*pb.Porter + ToPBPorter(*modelsupervisor.PorterInstanceController) *pb.Porter + ToPBPorterList([]*modelsupervisor.PorterInstanceController) []*pb.Porter // goverter:enum:unknown PorterConnectionStatus_PORTER_CONNECTION_STATUS_UNSPECIFIED // goverter:enum:map PorterConnectionStatusUnspecified PorterConnectionStatus_PORTER_CONNECTION_STATUS_UNSPECIFIED // goverter:enum:map PorterConnectionStatusConnected PorterConnectionStatus_PORTER_CONNECTION_STATUS_CONNECTED @@ -83,22 +83,25 @@ type toPBConverter interface { //nolint:unused // used by generator // goverter:enum:map PorterConnectionStatusActive PorterConnectionStatus_PORTER_CONNECTION_STATUS_ACTIVE // goverter:enum:map PorterConnectionStatusActivationFailed PorterConnectionStatus_PORTER_CONNECTION_STATUS_ACTIVATION_FAILED // goverter:enum:map PorterConnectionStatusDowngraded PorterConnectionStatus_PORTER_CONNECTION_STATUS_DOWNGRADED - ToPBPorterConnectionStatus(modeltiphereth.PorterConnectionStatus) pb.PorterConnectionStatus + ToPBPorterConnectionStatus(modelsupervisor.PorterConnectionStatus) pb.PorterConnectionStatus - ToPBPorterContext(*modeltiphereth.PorterContext) *pb.PorterContext - ToPBPorterContextList([]*modeltiphereth.PorterContext) []*pb.PorterContext + ToPBPorterContext(*modelsupervisor.PorterContext) *pb.PorterContext + ToPBPorterContextList([]*modelsupervisor.PorterContext) []*pb.PorterContext // goverter:enum:unknown PorterContextStatus_PORTER_CONTEXT_STATUS_UNSPECIFIED // goverter:enum:map PorterContextStatusUnspecified PorterContextStatus_PORTER_CONTEXT_STATUS_UNSPECIFIED // goverter:enum:map PorterContextStatusActive PorterContextStatus_PORTER_CONTEXT_STATUS_ACTIVE // goverter:enum:map PorterContextStatusDisabled PorterContextStatus_PORTER_CONTEXT_STATUS_DISABLED - ToPBPorterContextStatus(modeltiphereth.PorterContextStatus) pb.PorterContextStatus + ToPBPorterContextStatus(modelsupervisor.PorterContextStatus) pb.PorterContextStatus // goverter:enum:unknown PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_UNSPECIFIED // goverter:enum:map PorterContextHandleStatusUnspecified PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_UNSPECIFIED // goverter:enum:map PorterContextHandleStatusActive PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_ACTIVE // goverter:enum:map PorterContextHandleStatusDowngraded PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_DOWNGRADED // goverter:enum:map PorterContextHandleStatusQueueing PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_QUEUEING // goverter:enum:map PorterContextHandleStatusBlocked PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_BLOCKED - ToPBPorterContextHandleStatus(modeltiphereth.PorterContextHandleStatus) pb.PorterContextHandleStatus + ToPBPorterContextHandleStatus(modelsupervisor.PorterContextHandleStatus) pb.PorterContextHandleStatus + + ToPBPorterGroup(*modelsupervisor.PorterGroup) *pb.PorterGroup + ToPBPorterGroupList([]*modelsupervisor.PorterGroup) []*pb.PorterGroup // goverter:ignore AltNames ToPBAppInfo(*modelgebura.AppInfo) *librarian.AppInfo @@ -213,19 +216,6 @@ func ToPBDuration(d time.Duration) *durationpb.Duration { return durationpb.New(d) } -func ToPBPorterStatus(s modeltiphereth.PorterInstanceStatus) pb.UserStatus { - switch s { - case modeltiphereth.PorterInstanceStatusUnspecified: - return pb.UserStatus_USER_STATUS_UNSPECIFIED - case modeltiphereth.PorterInstanceStatusActive: - return pb.UserStatus_USER_STATUS_ACTIVE - case modeltiphereth.PorterInstanceStatusBlocked: - return pb.UserStatus_USER_STATUS_BLOCKED - default: - return pb.UserStatus_USER_STATUS_UNSPECIFIED - } -} - func ToPBFeedConfigPullStatus(s modelyesod.FeedConfigPullStatus) *pb.FeedConfigPullStatus { var status pb.FeedConfigPullStatus switch s { diff --git a/app/sephirah/internal/model/converter/generated.go b/app/sephirah/internal/model/converter/generated.go index c87d94f..b6738ef 100755 --- a/app/sephirah/internal/model/converter/generated.go +++ b/app/sephirah/internal/model/converter/generated.go @@ -7,6 +7,7 @@ import ( modelbinah "github.com/tuihub/librarian/app/sephirah/internal/model/modelbinah" modelgebura "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" modelnetzach "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" + modelsupervisor "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" modeltiphereth "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" modelyesod "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" libauth "github.com/tuihub/librarian/internal/lib/libauth" @@ -189,30 +190,30 @@ func ToBizDeviceInfo(source *v11.DeviceInfo) *modeltiphereth.DeviceInfo { } return pModeltipherethDeviceInfo } -func ToBizFeatureFlag(source *v1.FeatureFlag) *modeltiphereth.FeatureFlag { - var pModeltipherethFeatureFlag *modeltiphereth.FeatureFlag +func ToBizFeatureFlag(source *v1.FeatureFlag) *modelsupervisor.FeatureFlag { + var pModelsupervisorFeatureFlag *modelsupervisor.FeatureFlag if source != nil { - var modeltipherethFeatureFlag modeltiphereth.FeatureFlag - modeltipherethFeatureFlag.ID = (*source).Id - modeltipherethFeatureFlag.Name = (*source).Name - modeltipherethFeatureFlag.Description = (*source).Description - modeltipherethFeatureFlag.ConfigJSONSchema = (*source).ConfigJsonSchema - modeltipherethFeatureFlag.RequireContext = (*source).RequireContext - pModeltipherethFeatureFlag = &modeltipherethFeatureFlag + var modelsupervisorFeatureFlag modelsupervisor.FeatureFlag + modelsupervisorFeatureFlag.ID = (*source).Id + modelsupervisorFeatureFlag.Name = (*source).Name + modelsupervisorFeatureFlag.Description = (*source).Description + modelsupervisorFeatureFlag.ConfigJSONSchema = (*source).ConfigJsonSchema + modelsupervisorFeatureFlag.RequireContext = (*source).RequireContext + pModelsupervisorFeatureFlag = &modelsupervisorFeatureFlag } - return pModeltipherethFeatureFlag + return pModelsupervisorFeatureFlag } -func ToBizFeatureRequest(source *v1.FeatureRequest) *modeltiphereth.FeatureRequest { - var pModeltipherethFeatureRequest *modeltiphereth.FeatureRequest +func ToBizFeatureRequest(source *v1.FeatureRequest) *modelsupervisor.FeatureRequest { + var pModelsupervisorFeatureRequest *modelsupervisor.FeatureRequest if source != nil { - var modeltipherethFeatureRequest modeltiphereth.FeatureRequest - modeltipherethFeatureRequest.ID = (*source).Id - modeltipherethFeatureRequest.Region = (*source).Region - modeltipherethFeatureRequest.ConfigJSON = (*source).ConfigJson - modeltipherethFeatureRequest.ContextID = ToBizInternalID((*source).ContextId) - pModeltipherethFeatureRequest = &modeltipherethFeatureRequest + var modelsupervisorFeatureRequest modelsupervisor.FeatureRequest + modelsupervisorFeatureRequest.ID = (*source).Id + modelsupervisorFeatureRequest.Region = (*source).Region + modelsupervisorFeatureRequest.ConfigJSON = (*source).ConfigJson + modelsupervisorFeatureRequest.ContextID = ToBizInternalID((*source).ContextId) + pModelsupervisorFeatureRequest = &modelsupervisorFeatureRequest } - return pModeltipherethFeatureRequest + return pModelsupervisorFeatureRequest } func ToBizFeedActionSet(source *v11.FeedActionSet) *modelyesod.FeedActionSet { var pModelyesodFeedActionSet *modelyesod.FeedActionSet @@ -222,7 +223,7 @@ func ToBizFeedActionSet(source *v11.FeedActionSet) *modelyesod.FeedActionSet { modelyesodFeedActionSet.Name = (*source).Name modelyesodFeedActionSet.Description = (*source).Description if (*source).Actions != nil { - modelyesodFeedActionSet.Actions = make([]*modeltiphereth.FeatureRequest, len((*source).Actions)) + modelyesodFeedActionSet.Actions = make([]*modelsupervisor.FeatureRequest, len((*source).Actions)) for i := 0; i < len((*source).Actions); i++ { modelyesodFeedActionSet.Actions[i] = ToBizFeatureRequest((*source).Actions[i]) } @@ -494,92 +495,106 @@ func ToBizNotifyTargetStatusList(source []v11.NotifyTargetStatus) []modelnetzach } return modelnetzachNotifyTargetStatusList } -func ToBizPorterContext(source *v11.PorterContext) *modeltiphereth.PorterContext { - var pModeltipherethPorterContext *modeltiphereth.PorterContext - if source != nil { - var modeltipherethPorterContext modeltiphereth.PorterContext - modeltipherethPorterContext.ID = ToBizInternalID((*source).Id) - modeltipherethPorterContext.GlobalName = (*source).GlobalName - modeltipherethPorterContext.Region = (*source).Region - modeltipherethPorterContext.ContextJSON = (*source).ContextJson - modeltipherethPorterContext.Name = (*source).Name - modeltipherethPorterContext.Description = (*source).Description - modeltipherethPorterContext.Status = ToBizPorterContextStatus((*source).Status) - modeltipherethPorterContext.HandleStatus = ToBizPorterContextHandleStatus((*source).HandleStatus) - modeltipherethPorterContext.HandleStatusMessage = (*source).HandleStatusMessage - pModeltipherethPorterContext = &modeltipherethPorterContext - } - return pModeltipherethPorterContext -} -func ToBizPorterContextHandleStatus(source v11.PorterContextHandleStatus) modeltiphereth.PorterContextHandleStatus { - var modeltipherethPorterContextHandleStatus modeltiphereth.PorterContextHandleStatus +func ToBizPorterBinarySummary(source *v1.PorterBinarySummary) *modelsupervisor.PorterBinarySummary { + var pModelsupervisorPorterBinarySummary *modelsupervisor.PorterBinarySummary + if source != nil { + var modelsupervisorPorterBinarySummary modelsupervisor.PorterBinarySummary + modelsupervisorPorterBinarySummary.Name = (*source).Name + modelsupervisorPorterBinarySummary.Version = (*source).Version + modelsupervisorPorterBinarySummary.Description = (*source).Description + modelsupervisorPorterBinarySummary.SourceCodeAddress = (*source).SourceCodeAddress + modelsupervisorPorterBinarySummary.BuildVersion = (*source).BuildVersion + modelsupervisorPorterBinarySummary.BuildDate = (*source).BuildDate + pModelsupervisorPorterBinarySummary = &modelsupervisorPorterBinarySummary + } + return pModelsupervisorPorterBinarySummary +} +func ToBizPorterContext(source *v11.PorterContext) *modelsupervisor.PorterContext { + var pModelsupervisorPorterContext *modelsupervisor.PorterContext + if source != nil { + var modelsupervisorPorterContext modelsupervisor.PorterContext + modelsupervisorPorterContext.ID = ToBizInternalID((*source).Id) + modelsupervisorPorterContext.GlobalName = (*source).GlobalName + modelsupervisorPorterContext.Region = (*source).Region + modelsupervisorPorterContext.ContextJSON = (*source).ContextJson + modelsupervisorPorterContext.Name = (*source).Name + modelsupervisorPorterContext.Description = (*source).Description + modelsupervisorPorterContext.Status = ToBizPorterContextStatus((*source).Status) + modelsupervisorPorterContext.HandleStatus = ToBizPorterContextHandleStatus((*source).HandleStatus) + modelsupervisorPorterContext.HandleStatusMessage = (*source).HandleStatusMessage + pModelsupervisorPorterContext = &modelsupervisorPorterContext + } + return pModelsupervisorPorterContext +} +func ToBizPorterContextHandleStatus(source v11.PorterContextHandleStatus) modelsupervisor.PorterContextHandleStatus { + var modelsupervisorPorterContextHandleStatus modelsupervisor.PorterContextHandleStatus switch source { case v11.PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_ACTIVE: - modeltipherethPorterContextHandleStatus = modeltiphereth.PorterContextHandleStatusActive + modelsupervisorPorterContextHandleStatus = modelsupervisor.PorterContextHandleStatusActive case v11.PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_BLOCKED: - modeltipherethPorterContextHandleStatus = modeltiphereth.PorterContextHandleStatusBlocked + modelsupervisorPorterContextHandleStatus = modelsupervisor.PorterContextHandleStatusBlocked case v11.PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_DOWNGRADED: - modeltipherethPorterContextHandleStatus = modeltiphereth.PorterContextHandleStatusDowngraded + modelsupervisorPorterContextHandleStatus = modelsupervisor.PorterContextHandleStatusDowngraded case v11.PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_QUEUEING: - modeltipherethPorterContextHandleStatus = modeltiphereth.PorterContextHandleStatusQueueing + modelsupervisorPorterContextHandleStatus = modelsupervisor.PorterContextHandleStatusQueueing case v11.PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_UNSPECIFIED: - modeltipherethPorterContextHandleStatus = modeltiphereth.PorterContextHandleStatusUnspecified + modelsupervisorPorterContextHandleStatus = modelsupervisor.PorterContextHandleStatusUnspecified default: - modeltipherethPorterContextHandleStatus = modeltiphereth.PorterContextHandleStatusUnspecified + modelsupervisorPorterContextHandleStatus = modelsupervisor.PorterContextHandleStatusUnspecified } - return modeltipherethPorterContextHandleStatus + return modelsupervisorPorterContextHandleStatus } -func ToBizPorterContextStatus(source v11.PorterContextStatus) modeltiphereth.PorterContextStatus { - var modeltipherethPorterContextStatus modeltiphereth.PorterContextStatus +func ToBizPorterContextStatus(source v11.PorterContextStatus) modelsupervisor.PorterContextStatus { + var modelsupervisorPorterContextStatus modelsupervisor.PorterContextStatus switch source { case v11.PorterContextStatus_PORTER_CONTEXT_STATUS_ACTIVE: - modeltipherethPorterContextStatus = modeltiphereth.PorterContextStatusActive + modelsupervisorPorterContextStatus = modelsupervisor.PorterContextStatusActive case v11.PorterContextStatus_PORTER_CONTEXT_STATUS_DISABLED: - modeltipherethPorterContextStatus = modeltiphereth.PorterContextStatusDisabled + modelsupervisorPorterContextStatus = modelsupervisor.PorterContextStatusDisabled case v11.PorterContextStatus_PORTER_CONTEXT_STATUS_UNSPECIFIED: - modeltipherethPorterContextStatus = modeltiphereth.PorterContextStatusUnspecified + modelsupervisorPorterContextStatus = modelsupervisor.PorterContextStatusUnspecified default: - modeltipherethPorterContextStatus = modeltiphereth.PorterContextStatusUnspecified + modelsupervisorPorterContextStatus = modelsupervisor.PorterContextStatusUnspecified } - return modeltipherethPorterContextStatus + return modelsupervisorPorterContextStatus } -func ToBizPorterFeatureSummary(source *v12.PorterFeatureSummary) *modeltiphereth.PorterFeatureSummary { - var pModeltipherethPorterFeatureSummary *modeltiphereth.PorterFeatureSummary +func ToBizPorterFeatureSummary(source *v12.PorterFeatureSummary) *modelsupervisor.PorterFeatureSummary { + var pModelsupervisorPorterFeatureSummary *modelsupervisor.PorterFeatureSummary if source != nil { - var modeltipherethPorterFeatureSummary modeltiphereth.PorterFeatureSummary + var modelsupervisorPorterFeatureSummary modelsupervisor.PorterFeatureSummary if (*source).AccountPlatforms != nil { - modeltipherethPorterFeatureSummary.AccountPlatforms = make([]*modeltiphereth.FeatureFlag, len((*source).AccountPlatforms)) + modelsupervisorPorterFeatureSummary.AccountPlatforms = make([]*modelsupervisor.FeatureFlag, len((*source).AccountPlatforms)) for i := 0; i < len((*source).AccountPlatforms); i++ { - modeltipherethPorterFeatureSummary.AccountPlatforms[i] = ToBizFeatureFlag((*source).AccountPlatforms[i]) + modelsupervisorPorterFeatureSummary.AccountPlatforms[i] = ToBizFeatureFlag((*source).AccountPlatforms[i]) } } if (*source).AppInfoSources != nil { - modeltipherethPorterFeatureSummary.AppInfoSources = make([]*modeltiphereth.FeatureFlag, len((*source).AppInfoSources)) + modelsupervisorPorterFeatureSummary.AppInfoSources = make([]*modelsupervisor.FeatureFlag, len((*source).AppInfoSources)) for j := 0; j < len((*source).AppInfoSources); j++ { - modeltipherethPorterFeatureSummary.AppInfoSources[j] = ToBizFeatureFlag((*source).AppInfoSources[j]) + modelsupervisorPorterFeatureSummary.AppInfoSources[j] = ToBizFeatureFlag((*source).AppInfoSources[j]) } } if (*source).FeedSources != nil { - modeltipherethPorterFeatureSummary.FeedSources = make([]*modeltiphereth.FeatureFlag, len((*source).FeedSources)) + modelsupervisorPorterFeatureSummary.FeedSources = make([]*modelsupervisor.FeatureFlag, len((*source).FeedSources)) for k := 0; k < len((*source).FeedSources); k++ { - modeltipherethPorterFeatureSummary.FeedSources[k] = ToBizFeatureFlag((*source).FeedSources[k]) + modelsupervisorPorterFeatureSummary.FeedSources[k] = ToBizFeatureFlag((*source).FeedSources[k]) } } if (*source).NotifyDestinations != nil { - modeltipherethPorterFeatureSummary.NotifyDestinations = make([]*modeltiphereth.FeatureFlag, len((*source).NotifyDestinations)) + modelsupervisorPorterFeatureSummary.NotifyDestinations = make([]*modelsupervisor.FeatureFlag, len((*source).NotifyDestinations)) for l := 0; l < len((*source).NotifyDestinations); l++ { - modeltipherethPorterFeatureSummary.NotifyDestinations[l] = ToBizFeatureFlag((*source).NotifyDestinations[l]) + modelsupervisorPorterFeatureSummary.NotifyDestinations[l] = ToBizFeatureFlag((*source).NotifyDestinations[l]) } } if (*source).FeedItemActions != nil { - modeltipherethPorterFeatureSummary.FeedItemActions = make([]*modeltiphereth.FeatureFlag, len((*source).FeedItemActions)) + modelsupervisorPorterFeatureSummary.FeedItemActions = make([]*modelsupervisor.FeatureFlag, len((*source).FeedItemActions)) for m := 0; m < len((*source).FeedItemActions); m++ { - modeltipherethPorterFeatureSummary.FeedItemActions[m] = ToBizFeatureFlag((*source).FeedItemActions[m]) + modelsupervisorPorterFeatureSummary.FeedItemActions[m] = ToBizFeatureFlag((*source).FeedItemActions[m]) } } - pModeltipherethPorterFeatureSummary = &modeltipherethPorterFeatureSummary + pModelsupervisorPorterFeatureSummary = &modelsupervisorPorterFeatureSummary } - return pModeltipherethPorterFeatureSummary + return pModelsupervisorPorterFeatureSummary } func ToBizSystemNotificationLevel(source v11.SystemNotificationLevel) modelnetzach.SystemNotificationLevel { var modelnetzachSystemNotificationLevel modelnetzach.SystemNotificationLevel @@ -1012,7 +1027,7 @@ func ToPBEnclosure(source *modelfeed.Enclosure) *v1.FeedEnclosure { } return pV1FeedEnclosure } -func ToPBFeatureFlag(source *modeltiphereth.FeatureFlag) *v1.FeatureFlag { +func ToPBFeatureFlag(source *modelsupervisor.FeatureFlag) *v1.FeatureFlag { var pV1FeatureFlag *v1.FeatureFlag if source != nil { var v1FeatureFlag v1.FeatureFlag @@ -1025,7 +1040,7 @@ func ToPBFeatureFlag(source *modeltiphereth.FeatureFlag) *v1.FeatureFlag { } return pV1FeatureFlag } -func ToPBFeatureRequest(source *modeltiphereth.FeatureRequest) *v1.FeatureRequest { +func ToPBFeatureRequest(source *modelsupervisor.FeatureRequest) *v1.FeatureRequest { var pV1FeatureRequest *v1.FeatureRequest if source != nil { var v1FeatureRequest v1.FeatureRequest @@ -1365,15 +1380,15 @@ func ToPBNotifyTargetStatus(source modelnetzach.NotifyTargetStatus) v11.NotifyTa } return v1NotifyTargetStatus } -func ToPBPorter(source *modeltiphereth.PorterInstanceController) *v11.Porter { +func ToPBPorter(source *modelsupervisor.PorterInstanceController) *v11.Porter { var pV1Porter *v11.Porter if source != nil { var v1Porter v11.Porter v1Porter.Id = ToPBInternalID((*source).PorterInstance.ID) - v1Porter.Name = (*source).PorterInstance.Name - v1Porter.Version = (*source).PorterInstance.Version + v1Porter.BinarySummary = pModelsupervisorPorterBinarySummaryToPV1PorterBinarySummary((*source).PorterInstance.BinarySummary) v1Porter.GlobalName = (*source).PorterInstance.GlobalName - v1Porter.Status = ToPBPorterStatus((*source).PorterInstance.Status) + v1Porter.Region = (*source).PorterInstance.Region + v1Porter.Status = ToPBUserStatus((*source).PorterInstance.Status) v1Porter.ConnectionStatus = ToPBPorterConnectionStatus((*source).ConnectionStatus) pString := (*source).PorterInstance.ContextJSONSchema v1Porter.ContextJsonSchema = &pString @@ -1382,27 +1397,27 @@ func ToPBPorter(source *modeltiphereth.PorterInstanceController) *v11.Porter { } return pV1Porter } -func ToPBPorterConnectionStatus(source modeltiphereth.PorterConnectionStatus) v11.PorterConnectionStatus { +func ToPBPorterConnectionStatus(source modelsupervisor.PorterConnectionStatus) v11.PorterConnectionStatus { var v1PorterConnectionStatus v11.PorterConnectionStatus switch source { - case modeltiphereth.PorterConnectionStatusActivationFailed: + case modelsupervisor.PorterConnectionStatusActivationFailed: v1PorterConnectionStatus = v11.PorterConnectionStatus_PORTER_CONNECTION_STATUS_ACTIVATION_FAILED - case modeltiphereth.PorterConnectionStatusActive: + case modelsupervisor.PorterConnectionStatusActive: v1PorterConnectionStatus = v11.PorterConnectionStatus_PORTER_CONNECTION_STATUS_ACTIVE - case modeltiphereth.PorterConnectionStatusConnected: + case modelsupervisor.PorterConnectionStatusConnected: v1PorterConnectionStatus = v11.PorterConnectionStatus_PORTER_CONNECTION_STATUS_CONNECTED - case modeltiphereth.PorterConnectionStatusDisconnected: + case modelsupervisor.PorterConnectionStatusDisconnected: v1PorterConnectionStatus = v11.PorterConnectionStatus_PORTER_CONNECTION_STATUS_DISCONNECTED - case modeltiphereth.PorterConnectionStatusDowngraded: + case modelsupervisor.PorterConnectionStatusDowngraded: v1PorterConnectionStatus = v11.PorterConnectionStatus_PORTER_CONNECTION_STATUS_DOWNGRADED - case modeltiphereth.PorterConnectionStatusUnspecified: + case modelsupervisor.PorterConnectionStatusUnspecified: v1PorterConnectionStatus = v11.PorterConnectionStatus_PORTER_CONNECTION_STATUS_UNSPECIFIED default: v1PorterConnectionStatus = v11.PorterConnectionStatus_PORTER_CONNECTION_STATUS_UNSPECIFIED } return v1PorterConnectionStatus } -func ToPBPorterContext(source *modeltiphereth.PorterContext) *v11.PorterContext { +func ToPBPorterContext(source *modelsupervisor.PorterContext) *v11.PorterContext { var pV1PorterContext *v11.PorterContext if source != nil { var v1PorterContext v11.PorterContext @@ -1419,25 +1434,25 @@ func ToPBPorterContext(source *modeltiphereth.PorterContext) *v11.PorterContext } return pV1PorterContext } -func ToPBPorterContextHandleStatus(source modeltiphereth.PorterContextHandleStatus) v11.PorterContextHandleStatus { +func ToPBPorterContextHandleStatus(source modelsupervisor.PorterContextHandleStatus) v11.PorterContextHandleStatus { var v1PorterContextHandleStatus v11.PorterContextHandleStatus switch source { - case modeltiphereth.PorterContextHandleStatusActive: + case modelsupervisor.PorterContextHandleStatusActive: v1PorterContextHandleStatus = v11.PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_ACTIVE - case modeltiphereth.PorterContextHandleStatusBlocked: + case modelsupervisor.PorterContextHandleStatusBlocked: v1PorterContextHandleStatus = v11.PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_BLOCKED - case modeltiphereth.PorterContextHandleStatusDowngraded: + case modelsupervisor.PorterContextHandleStatusDowngraded: v1PorterContextHandleStatus = v11.PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_DOWNGRADED - case modeltiphereth.PorterContextHandleStatusQueueing: + case modelsupervisor.PorterContextHandleStatusQueueing: v1PorterContextHandleStatus = v11.PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_QUEUEING - case modeltiphereth.PorterContextHandleStatusUnspecified: + case modelsupervisor.PorterContextHandleStatusUnspecified: v1PorterContextHandleStatus = v11.PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_UNSPECIFIED default: v1PorterContextHandleStatus = v11.PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_UNSPECIFIED } return v1PorterContextHandleStatus } -func ToPBPorterContextList(source []*modeltiphereth.PorterContext) []*v11.PorterContext { +func ToPBPorterContextList(source []*modelsupervisor.PorterContext) []*v11.PorterContext { var pV1PorterContextList []*v11.PorterContext if source != nil { pV1PorterContextList = make([]*v11.PorterContext, len(source)) @@ -1447,21 +1462,49 @@ func ToPBPorterContextList(source []*modeltiphereth.PorterContext) []*v11.Porter } return pV1PorterContextList } -func ToPBPorterContextStatus(source modeltiphereth.PorterContextStatus) v11.PorterContextStatus { +func ToPBPorterContextStatus(source modelsupervisor.PorterContextStatus) v11.PorterContextStatus { var v1PorterContextStatus v11.PorterContextStatus switch source { - case modeltiphereth.PorterContextStatusActive: + case modelsupervisor.PorterContextStatusActive: v1PorterContextStatus = v11.PorterContextStatus_PORTER_CONTEXT_STATUS_ACTIVE - case modeltiphereth.PorterContextStatusDisabled: + case modelsupervisor.PorterContextStatusDisabled: v1PorterContextStatus = v11.PorterContextStatus_PORTER_CONTEXT_STATUS_DISABLED - case modeltiphereth.PorterContextStatusUnspecified: + case modelsupervisor.PorterContextStatusUnspecified: v1PorterContextStatus = v11.PorterContextStatus_PORTER_CONTEXT_STATUS_UNSPECIFIED default: v1PorterContextStatus = v11.PorterContextStatus_PORTER_CONTEXT_STATUS_UNSPECIFIED } return v1PorterContextStatus } -func ToPBPorterList(source []*modeltiphereth.PorterInstanceController) []*v11.Porter { +func ToPBPorterGroup(source *modelsupervisor.PorterGroup) *v11.PorterGroup { + var pV1PorterGroup *v11.PorterGroup + if source != nil { + var v1PorterGroup v11.PorterGroup + v1PorterGroup.BinarySummary = pModelsupervisorPorterBinarySummaryToPV1PorterBinarySummary((*source).BinarySummary) + v1PorterGroup.GlobalName = (*source).GlobalName + if (*source).Regions != nil { + v1PorterGroup.Regions = make([]string, len((*source).Regions)) + for i := 0; i < len((*source).Regions); i++ { + v1PorterGroup.Regions[i] = (*source).Regions[i] + } + } + pString := (*source).ContextJSONSchema + v1PorterGroup.ContextJsonSchema = &pString + pV1PorterGroup = &v1PorterGroup + } + return pV1PorterGroup +} +func ToPBPorterGroupList(source []*modelsupervisor.PorterGroup) []*v11.PorterGroup { + var pV1PorterGroupList []*v11.PorterGroup + if source != nil { + pV1PorterGroupList = make([]*v11.PorterGroup, len(source)) + for i := 0; i < len(source); i++ { + pV1PorterGroupList[i] = ToPBPorterGroup(source[i]) + } + } + return pV1PorterGroupList +} +func ToPBPorterList(source []*modelsupervisor.PorterInstanceController) []*v11.Porter { var pV1PorterList []*v11.Porter if source != nil { pV1PorterList = make([]*v11.Porter, len(source)) @@ -1471,7 +1514,7 @@ func ToPBPorterList(source []*modeltiphereth.PorterInstanceController) []*v11.Po } return pV1PorterList } -func ToPBServerFeatureSummary(source *modeltiphereth.ServerFeatureSummary) *v11.ServerFeatureSummary { +func ToPBServerFeatureSummary(source *modelsupervisor.ServerFeatureSummary) *v11.ServerFeatureSummary { var pV1ServerFeatureSummary *v11.ServerFeatureSummary if source != nil { var v1ServerFeatureSummary v11.ServerFeatureSummary @@ -1722,3 +1765,17 @@ func pModelnetzachNotifyFilterToPV1NotifyFilter(source *modelnetzach.NotifyFilte } return pV1NotifyFilter } +func pModelsupervisorPorterBinarySummaryToPV1PorterBinarySummary(source *modelsupervisor.PorterBinarySummary) *v1.PorterBinarySummary { + var pV1PorterBinarySummary *v1.PorterBinarySummary + if source != nil { + var v1PorterBinarySummary v1.PorterBinarySummary + v1PorterBinarySummary.SourceCodeAddress = (*source).SourceCodeAddress + v1PorterBinarySummary.BuildVersion = (*source).BuildVersion + v1PorterBinarySummary.BuildDate = (*source).BuildDate + v1PorterBinarySummary.Name = (*source).Name + v1PorterBinarySummary.Version = (*source).Version + v1PorterBinarySummary.Description = (*source).Description + pV1PorterBinarySummary = &v1PorterBinarySummary + } + return pV1PorterBinarySummary +} diff --git a/app/sephirah/internal/model/converter/pb_to_biz.go b/app/sephirah/internal/model/converter/pb_to_biz.go index 7e7d6af..e0c3506 100644 --- a/app/sephirah/internal/model/converter/pb_to_biz.go +++ b/app/sephirah/internal/model/converter/pb_to_biz.go @@ -6,6 +6,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/model/modelbinah" "github.com/tuihub/librarian/app/sephirah/internal/model/modelgebura" "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/app/sephirah/internal/model/modelyesod" "github.com/tuihub/librarian/internal/lib/libauth" @@ -32,9 +33,9 @@ import ( // goverter:extend DurationPBToDuration type toBizConverter interface { //nolint:unused // used by generator ToBizTimeRange(*librarian.TimeRange) *model.TimeRange - ToBizPorterFeatureSummary(*porter.PorterFeatureSummary) *modeltiphereth.PorterFeatureSummary - ToBizFeatureFlag(*librarian.FeatureFlag) *modeltiphereth.FeatureFlag - ToBizFeatureRequest(*librarian.FeatureRequest) *modeltiphereth.FeatureRequest + ToBizPorterFeatureSummary(*porter.PorterFeatureSummary) *modelsupervisor.PorterFeatureSummary + ToBizFeatureFlag(*librarian.FeatureFlag) *modelsupervisor.FeatureFlag + ToBizFeatureRequest(*librarian.FeatureRequest) *modelsupervisor.FeatureRequest // goverter:enum:unknown AccountAppRelationTypeUnspecified // goverter:enum:map AccountAppRelationType_ACCOUNT_APP_RELATION_TYPE_UNSPECIFIED AccountAppRelationTypeUnspecified // goverter:enum:map AccountAppRelationType_ACCOUNT_APP_RELATION_TYPE_OWN AccountAppRelationTypeOwner @@ -69,19 +70,21 @@ type toBizConverter interface { //nolint:unused // used by generator // goverter:enum:map UserStatus_USER_STATUS_BLOCKED UserStatusBlocked ToBizUserStatus(pb.UserStatus) modeltiphereth.UserStatus - ToBizPorterContext(*pb.PorterContext) *modeltiphereth.PorterContext + ToBizPorterContext(*pb.PorterContext) *modelsupervisor.PorterContext // goverter:enum:unknown PorterContextStatusUnspecified // goverter:enum:map PorterContextStatus_PORTER_CONTEXT_STATUS_UNSPECIFIED PorterContextStatusUnspecified // goverter:enum:map PorterContextStatus_PORTER_CONTEXT_STATUS_ACTIVE PorterContextStatusActive // goverter:enum:map PorterContextStatus_PORTER_CONTEXT_STATUS_DISABLED PorterContextStatusDisabled - ToBizPorterContextStatus(pb.PorterContextStatus) modeltiphereth.PorterContextStatus + ToBizPorterContextStatus(pb.PorterContextStatus) modelsupervisor.PorterContextStatus // goverter:enum:unknown PorterContextHandleStatusUnspecified // goverter:enum:map PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_UNSPECIFIED PorterContextHandleStatusUnspecified // goverter:enum:map PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_ACTIVE PorterContextHandleStatusActive // goverter:enum:map PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_DOWNGRADED PorterContextHandleStatusDowngraded // goverter:enum:map PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_QUEUEING PorterContextHandleStatusQueueing // goverter:enum:map PorterContextHandleStatus_PORTER_CONTEXT_HANDLE_STATUS_BLOCKED PorterContextHandleStatusBlocked - ToBizPorterContextHandleStatus(pb.PorterContextHandleStatus) modeltiphereth.PorterContextHandleStatus + ToBizPorterContextHandleStatus(pb.PorterContextHandleStatus) modelsupervisor.PorterContextHandleStatus + + ToBizPorterBinarySummary(*librarian.PorterBinarySummary) *modelsupervisor.PorterBinarySummary // goverter:ignore BoundInternal // goverter:ignore LatestUpdateTime @@ -203,19 +206,6 @@ func ToBizDuration(d *durationpb.Duration) time.Duration { return d.AsDuration() } -func ToBizPorterStatus(s pb.UserStatus) modeltiphereth.PorterInstanceStatus { - switch s { - case pb.UserStatus_USER_STATUS_UNSPECIFIED: - return modeltiphereth.PorterInstanceStatusUnspecified - case pb.UserStatus_USER_STATUS_ACTIVE: - return modeltiphereth.PorterInstanceStatusActive - case pb.UserStatus_USER_STATUS_BLOCKED: - return modeltiphereth.PorterInstanceStatusBlocked - default: - return modeltiphereth.PorterInstanceStatusUnspecified - } -} - func ToBizGroupFeedItemsBy(by librarian.TimeAggregation_AggregationType) modelyesod.GroupFeedItemsBy { switch by { case librarian.TimeAggregation_AGGREGATION_TYPE_UNSPECIFIED: diff --git a/app/sephirah/internal/model/modelnetzach/modelnetzach.go b/app/sephirah/internal/model/modelnetzach/modelnetzach.go index 1486b13..89ef10b 100644 --- a/app/sephirah/internal/model/modelnetzach/modelnetzach.go +++ b/app/sephirah/internal/model/modelnetzach/modelnetzach.go @@ -3,7 +3,7 @@ package modelnetzach import ( "time" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" ) @@ -38,7 +38,7 @@ type NotifyTarget struct { ID model.InternalID Name string Description string - Destination *modeltiphereth.FeatureRequest + Destination *modelsupervisor.FeatureRequest Status NotifyTargetStatus } diff --git a/app/sephirah/internal/model/modeltiphereth/modelsupervisor.go b/app/sephirah/internal/model/modelsupervisor/modelsupervisor.go similarity index 87% rename from app/sephirah/internal/model/modeltiphereth/modelsupervisor.go rename to app/sephirah/internal/model/modelsupervisor/modelsupervisor.go index 67b3f5a..dffbdf1 100644 --- a/app/sephirah/internal/model/modeltiphereth/modelsupervisor.go +++ b/app/sephirah/internal/model/modelsupervisor/modelsupervisor.go @@ -1,8 +1,9 @@ -package modeltiphereth +package modelsupervisor import ( "time" + "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/lib/libtype" "github.com/tuihub/librarian/internal/model" ) @@ -16,16 +17,24 @@ type PorterInstanceController struct { type PorterInstance struct { ID model.InternalID - Name string - Version string + BinarySummary *PorterBinarySummary GlobalName string Address string Region string FeatureSummary *PorterFeatureSummary - Status PorterInstanceStatus + Status modeltiphereth.UserStatus ContextJSONSchema string } +type PorterBinarySummary struct { + Name string + Version string + Description string + SourceCodeAddress string + BuildVersion string + BuildDate string +} + type PorterFeatureSummary struct { AccountPlatforms []*FeatureFlag `json:"account_platforms"` AppInfoSources []*FeatureFlag `json:"app_info_sources"` @@ -53,14 +62,6 @@ type FeatureRequest struct { ContextID model.InternalID `json:"context_id"` } -type PorterInstanceStatus int - -const ( - PorterInstanceStatusUnspecified PorterInstanceStatus = iota - PorterInstanceStatusActive - PorterInstanceStatusBlocked -) - type ServerFeatureSummary struct { AccountPlatforms []*FeatureFlag AppInfoSources []*FeatureFlag @@ -110,6 +111,13 @@ const ( PorterContextHandleStatusBlocked ) +type PorterGroup struct { + BinarySummary *PorterBinarySummary + GlobalName string + Regions []string + ContextJSONSchema string +} + type ServerFeatureSummaryMap struct { AccountPlatforms *libtype.SyncMap[[]string] AppInfoSources *libtype.SyncMap[[]string] diff --git a/app/sephirah/internal/model/modelyesod/modelyesod.go b/app/sephirah/internal/model/modelyesod/modelyesod.go index 4f060c9..cfa5ea6 100644 --- a/app/sephirah/internal/model/modelyesod/modelyesod.go +++ b/app/sephirah/internal/model/modelyesod/modelyesod.go @@ -4,7 +4,7 @@ import ( "time" "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/internal/model" "github.com/tuihub/librarian/internal/model/modelfeed" ) @@ -33,7 +33,7 @@ type FeedConfig struct { ID model.InternalID Name string Description string - Source *modeltiphereth.FeatureRequest + Source *modelsupervisor.FeatureRequest ActionSets []model.InternalID Category string Status FeedConfigStatus @@ -70,7 +70,7 @@ const ( type PullFeed struct { InternalID model.InternalID - Source *modeltiphereth.FeatureRequest + Source *modelsupervisor.FeatureRequest SystemNotify *modelnetzach.SystemNotify } @@ -95,5 +95,5 @@ type FeedActionSet struct { ID model.InternalID Name string Description string - Actions []*modeltiphereth.FeatureRequest + Actions []*modelsupervisor.FeatureRequest } diff --git a/app/sephirah/internal/service/tiphereth.go b/app/sephirah/internal/service/tiphereth.go index ea072dc..7e6d498 100644 --- a/app/sephirah/internal/service/tiphereth.go +++ b/app/sephirah/internal/service/tiphereth.go @@ -5,6 +5,7 @@ import ( "time" "github.com/tuihub/librarian/app/sephirah/internal/model/converter" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/lib/logger" "github.com/tuihub/librarian/internal/model" @@ -262,13 +263,13 @@ func (s *LibrarianSephirahServiceService) ListPorters(ctx context.Context, req * if err != nil { return nil, err } - res := make([]*modeltiphereth.PorterInstanceController, len(porters)) + res := make([]*modelsupervisor.PorterInstanceController, len(porters)) for i := range res { res[i] = s.s.GetInstanceController(ctx, porters[i].Address) if res[i] == nil { - res[i] = new(modeltiphereth.PorterInstanceController) + res[i] = new(modelsupervisor.PorterInstanceController) res[i].PorterInstance = *porters[i] - res[i].ConnectionStatus = modeltiphereth.PorterConnectionStatusDisconnected + res[i].ConnectionStatus = modelsupervisor.PorterConnectionStatusDisconnected } } return &pb.ListPortersResponse{ @@ -285,7 +286,7 @@ func (s *LibrarianSephirahServiceService) UpdatePorterStatus(ctx context.Context } if err := s.t.UpdatePorterStatus(ctx, converter.ToBizInternalID(req.GetPorterId()), - converter.ToBizPorterStatus(req.GetStatus()), + converter.ToBizUserStatus(req.GetStatus()), ); err != nil { return nil, err } @@ -343,3 +344,23 @@ func (s *LibrarianSephirahServiceService) UpdatePorterContext( } return &pb.UpdatePorterContextResponse{}, nil } + +func (s *LibrarianSephirahServiceService) ListPorterGroups( + ctx context.Context, + req *pb.ListPorterGroupsRequest, +) (*pb.ListPorterGroupsResponse, error) { + if req.GetPaging() == nil { + return nil, pb.ErrorErrorReasonBadRequest("") + } + groups, total, err := s.t.ListPorterGroups(ctx, + model.ToBizPaging(req.GetPaging()), + converter.ToBizUserStatusList(req.GetStatusFilter()), + ) + if err != nil { + return nil, err + } + return &pb.ListPorterGroupsResponse{ + Paging: &librarian.PagingResponse{TotalSize: total}, + PorterGroups: converter.ToPBPorterGroupList(groups), + }, nil +} diff --git a/app/sephirah/internal/supervisor/feature.go b/app/sephirah/internal/supervisor/feature.go index 331a612..a0c1261 100644 --- a/app/sephirah/internal/supervisor/feature.go +++ b/app/sephirah/internal/supervisor/feature.go @@ -4,7 +4,7 @@ import ( "context" "github.com/tuihub/librarian/app/sephirah/internal/client" - "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" ) func (s *Supervisor) HasAccountPlatform(platform string) bool { @@ -47,7 +47,7 @@ func (s *Supervisor) WithAppInfoSource(ctx context.Context, source string) conte return client.WithPorterFastFail(ctx) } -func (s *Supervisor) HasFeedSource(source *modeltiphereth.FeatureRequest) bool { +func (s *Supervisor) HasFeedSource(source *modelsupervisor.FeatureRequest) bool { s.featureSummaryRWMu.RLock() defer s.featureSummaryRWMu.RUnlock() if source == nil { @@ -61,7 +61,7 @@ func (s *Supervisor) HasFeedSource(source *modeltiphereth.FeatureRequest) bool { return false } -func (s *Supervisor) WithFeedSource(ctx context.Context, source *modeltiphereth.FeatureRequest) context.Context { +func (s *Supervisor) WithFeedSource(ctx context.Context, source *modelsupervisor.FeatureRequest) context.Context { s.featureSummaryRWMu.RLock() defer s.featureSummaryRWMu.RUnlock() if sources := s.featureSummaryMap.FeedSources.Load(source.ID); sources != nil { @@ -70,7 +70,7 @@ func (s *Supervisor) WithFeedSource(ctx context.Context, source *modeltiphereth. return client.WithPorterFastFail(ctx) } -func (s *Supervisor) HasNotifyDestination(destination *modeltiphereth.FeatureRequest) bool { +func (s *Supervisor) HasNotifyDestination(destination *modelsupervisor.FeatureRequest) bool { s.featureSummaryRWMu.RLock() defer s.featureSummaryRWMu.RUnlock() if destination == nil { @@ -84,7 +84,7 @@ func (s *Supervisor) HasNotifyDestination(destination *modeltiphereth.FeatureReq return false } -func (s *Supervisor) WithNotifyDestination(ctx context.Context, destination *modeltiphereth.FeatureRequest) context.Context { +func (s *Supervisor) WithNotifyDestination(ctx context.Context, destination *modelsupervisor.FeatureRequest) context.Context { s.featureSummaryRWMu.RLock() defer s.featureSummaryRWMu.RUnlock() if destinations := s.featureSummaryMap.NotifyDestinations.Load(destination.ID); destinations != nil { @@ -93,7 +93,7 @@ func (s *Supervisor) WithNotifyDestination(ctx context.Context, destination *mod return client.WithPorterFastFail(ctx) } -func (s *Supervisor) HasFeedItemAction(request *modeltiphereth.FeatureRequest) bool { +func (s *Supervisor) HasFeedItemAction(request *modelsupervisor.FeatureRequest) bool { s.featureSummaryRWMu.RLock() defer s.featureSummaryRWMu.RUnlock() for _, p := range s.featureSummary.FeedItemActions { @@ -104,7 +104,7 @@ func (s *Supervisor) HasFeedItemAction(request *modeltiphereth.FeatureRequest) b return false } -func (s *Supervisor) WithFeedItemAction(ctx context.Context, request *modeltiphereth.FeatureRequest) context.Context { +func (s *Supervisor) WithFeedItemAction(ctx context.Context, request *modelsupervisor.FeatureRequest) context.Context { s.featureSummaryRWMu.RLock() defer s.featureSummaryRWMu.RUnlock() if actions := s.featureSummaryMap.FeedItemActions.Load(request.ID); actions != nil { diff --git a/app/sephirah/internal/supervisor/summary.go b/app/sephirah/internal/supervisor/summary.go index 3239c65..1e965a0 100644 --- a/app/sephirah/internal/supervisor/summary.go +++ b/app/sephirah/internal/supervisor/summary.go @@ -3,14 +3,15 @@ package supervisor import ( "context" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/lib/libtype" ) -func (s *Supervisor) GetFeatureSummary() *modeltiphereth.ServerFeatureSummary { +func (s *Supervisor) GetFeatureSummary() *modelsupervisor.ServerFeatureSummary { s.featureSummaryRWMu.RLock() defer s.featureSummaryRWMu.RUnlock() - featureSummary := new(modeltiphereth.ServerFeatureSummary) + featureSummary := new(modelsupervisor.ServerFeatureSummary) if s.featureSummary != nil { _ = libtype.DeepCopyStruct(s.featureSummary, &featureSummary) } @@ -18,10 +19,10 @@ func (s *Supervisor) GetFeatureSummary() *modeltiphereth.ServerFeatureSummary { } func (s *Supervisor) updateFeatureSummary(ctx context.Context) { - var instances []*modeltiphereth.PorterInstance - s.instanceController.Range(func(key string, controller modeltiphereth.PorterInstanceController) bool { + var instances []*modelsupervisor.PorterInstance + s.instanceController.Range(func(key string, controller modelsupervisor.PorterInstanceController) bool { ins, err := s.instanceCache.Get(ctx, key) - if err == nil && ins != nil && ins.Status == modeltiphereth.PorterInstanceStatusActive { + if err == nil && ins != nil && ins.Status == modeltiphereth.UserStatusActive { instances = append(instances, ins) } return true @@ -36,10 +37,10 @@ func (s *Supervisor) updateFeatureSummary(ctx context.Context) { } func summarize( //nolint:gocognit // how? - instances []*modeltiphereth.PorterInstance, -) (*modeltiphereth.ServerFeatureSummary, *modeltiphereth.ServerFeatureSummaryMap) { - res := new(modeltiphereth.ServerFeatureSummary) - resMap := modeltiphereth.NewServerFeatureSummaryMap() + instances []*modelsupervisor.PorterInstance, +) (*modelsupervisor.ServerFeatureSummary, *modelsupervisor.ServerFeatureSummaryMap) { + res := new(modelsupervisor.ServerFeatureSummary) + resMap := modelsupervisor.NewServerFeatureSummaryMap() supportedAccountPlatforms := make(map[string]bool) supportedAppSources := make(map[string]bool) diff --git a/app/sephirah/internal/supervisor/supervisor.go b/app/sephirah/internal/supervisor/supervisor.go index 77be007..6253cf6 100644 --- a/app/sephirah/internal/supervisor/supervisor.go +++ b/app/sephirah/internal/supervisor/supervisor.go @@ -10,6 +10,7 @@ import ( "github.com/tuihub/librarian/app/sephirah/internal/client" "github.com/tuihub/librarian/app/sephirah/internal/model/converter" "github.com/tuihub/librarian/app/sephirah/internal/model/modelnetzach" + "github.com/tuihub/librarian/app/sephirah/internal/model/modelsupervisor" "github.com/tuihub/librarian/app/sephirah/internal/model/modeltiphereth" "github.com/tuihub/librarian/internal/conf" "github.com/tuihub/librarian/internal/lib/libauth" @@ -40,11 +41,11 @@ type Supervisor struct { refreshMu sync.Mutex trustedAddresses []string - instanceController *libtype.SyncMap[modeltiphereth.PorterInstanceController] - instanceCache *libcache.Map[string, modeltiphereth.PorterInstance] + instanceController *libtype.SyncMap[modelsupervisor.PorterInstanceController] + instanceCache *libcache.Map[string, modelsupervisor.PorterInstance] - featureSummary *modeltiphereth.ServerFeatureSummary - featureSummaryMap *modeltiphereth.ServerFeatureSummaryMap + featureSummary *modelsupervisor.ServerFeatureSummary + featureSummaryMap *modelsupervisor.ServerFeatureSummaryMap featureSummaryRWMu sync.RWMutex } @@ -53,7 +54,7 @@ func NewSupervisor( auth *libauth.Auth, porter *client.Porter, systemNotify *libmq.Topic[modelnetzach.SystemNotify], - instanceCache *libcache.Map[string, modeltiphereth.PorterInstance], + instanceCache *libcache.Map[string, modelsupervisor.PorterInstance], ) (*Supervisor, error) { if c == nil { c = new(conf.Porter) @@ -62,11 +63,11 @@ func NewSupervisor( UUID: int64(uuid.New().ID()), porter: porter, auth: auth, - instanceController: libtype.NewSyncMap[modeltiphereth.PorterInstanceController](), + instanceController: libtype.NewSyncMap[modelsupervisor.PorterInstanceController](), instanceCache: instanceCache, refreshMu: sync.Mutex{}, - featureSummary: new(modeltiphereth.ServerFeatureSummary), - featureSummaryMap: modeltiphereth.NewServerFeatureSummaryMap(), + featureSummary: new(modelsupervisor.ServerFeatureSummary), + featureSummaryMap: modelsupervisor.NewServerFeatureSummaryMap(), featureSummaryRWMu: sync.RWMutex{}, trustedAddresses: c.GetTrusted(), systemNotify: systemNotify, @@ -80,13 +81,13 @@ func (s *Supervisor) GetHeartbeatInterval() time.Duration { func (s *Supervisor) GetInstanceController( ctx context.Context, address string, -) *modeltiphereth.PorterInstanceController { +) *modelsupervisor.PorterInstanceController { return s.instanceController.Load(address) } func (s *Supervisor) RefreshAliveInstances( //nolint:gocognit,funlen // TODO ctx context.Context, -) ([]*modeltiphereth.PorterInstance, error) { +) ([]*modelsupervisor.PorterInstance, error) { if !s.refreshMu.TryLock() { return nil, errors.New("refresh in progress") } @@ -97,7 +98,7 @@ func (s *Supervisor) RefreshAliveInstances( //nolint:gocognit,funlen // TODO logger.Errorf("%s", err.Error()) return nil, err } - newInstances := make([]*modeltiphereth.PorterInstance, 0, len(discoveredAddresses)) + newInstances := make([]*modelsupervisor.PorterInstance, 0, len(discoveredAddresses)) newInstancesMu := sync.Mutex{} hasError := false notification := modelnetzach.NewSystemNotify( @@ -114,14 +115,14 @@ func (s *Supervisor) RefreshAliveInstances( //nolint:gocognit,funlen // TODO // Discover new instances and Refresh disconnected instances for _, address := range discoveredAddresses { if ic := s.instanceController.Load(address); ic != nil && - ic.ConnectionStatus != modeltiphereth.PorterConnectionStatusDisconnected { + ic.ConnectionStatus != modelsupervisor.PorterConnectionStatusDisconnected { continue } wg.Add(1) go func(ctx context.Context, address string) { defer wg.Done() - var ins *modeltiphereth.PorterInstance + var ins *modelsupervisor.PorterInstance ins, err = s.evaluatePorterInstance(ctx, address) if err != nil { logger.Errorf("%s", err.Error()) @@ -131,14 +132,14 @@ func (s *Supervisor) RefreshAliveInstances( //nolint:gocognit,funlen // TODO } if ic := s.instanceController.Load(address); ic == nil || - (ic.GlobalName != ins.GlobalName || ic.Version != ins.Version) { + (ic.GlobalName != ins.GlobalName || ic.BinarySummary.BuildVersion != ins.BinarySummary.Version) { newInstancesMu.Lock() newInstances = append(newInstances, ins) newInstancesMu.Unlock() } - s.instanceController.Store(address, modeltiphereth.PorterInstanceController{ + s.instanceController.Store(address, modelsupervisor.PorterInstanceController{ PorterInstance: *ins, - ConnectionStatus: modeltiphereth.PorterConnectionStatusConnected, + ConnectionStatus: modelsupervisor.PorterConnectionStatusConnected, ConnectionStatusMessage: "", LastHeartbeat: time.Now(), }) @@ -146,15 +147,15 @@ func (s *Supervisor) RefreshAliveInstances( //nolint:gocognit,funlen // TODO } // Heartbeat - s.instanceController.Range(func(address string, ctl modeltiphereth.PorterInstanceController) bool { - var ins *modeltiphereth.PorterInstance + s.instanceController.Range(func(address string, ctl modelsupervisor.PorterInstanceController) bool { + var ins *modelsupervisor.PorterInstance if ins, err = s.instanceCache.Get(ctx, address); err != nil || - ins.Status != modeltiphereth.PorterInstanceStatusActive { + ins.Status != modeltiphereth.UserStatusActive { return true } wg.Add(1) - go func(ctx context.Context, ins *modeltiphereth.PorterInstance) { + go func(ctx context.Context, ins *modelsupervisor.PorterInstance) { defer wg.Done() var resp *porter.EnablePorterResponse resp, err = s.enablePorterInstance(ctx, ins) @@ -173,20 +174,20 @@ func (s *Supervisor) RefreshAliveInstances( //nolint:gocognit,funlen // TODO } if err != nil { //nolint:nestif // TODO if ctl.LastHeartbeat.Add(defaultHeartbeatTimeout).Before(now) { - ctl.ConnectionStatus = modeltiphereth.PorterConnectionStatusDisconnected + ctl.ConnectionStatus = modelsupervisor.PorterConnectionStatusDisconnected } else if ctl.LastHeartbeat.Add(defaultHeartbeatDowngrade).Before(now) { - ctl.ConnectionStatus = modeltiphereth.PorterConnectionStatusDowngraded - } else if ctl.ConnectionStatus == modeltiphereth.PorterConnectionStatusActive { - ctl.ConnectionStatus = modeltiphereth.PorterConnectionStatusActive + ctl.ConnectionStatus = modelsupervisor.PorterConnectionStatusDowngraded + } else if ctl.ConnectionStatus == modelsupervisor.PorterConnectionStatusActive { + ctl.ConnectionStatus = modelsupervisor.PorterConnectionStatusActive } else { - ctl.ConnectionStatus = modeltiphereth.PorterConnectionStatusActivationFailed + ctl.ConnectionStatus = modelsupervisor.PorterConnectionStatusActivationFailed } if ctl.ConnectionStatusMessage != "" { ctl.ConnectionStatusMessage += "\n" } ctl.ConnectionStatusMessage += fmt.Sprintf("Error: %s", err.Error()) } else { - ctl.ConnectionStatus = modeltiphereth.PorterConnectionStatusActive + ctl.ConnectionStatus = modelsupervisor.PorterConnectionStatusActive ctl.LastHeartbeat = now } @@ -235,7 +236,7 @@ func (s *Supervisor) RefreshAliveInstances( //nolint:gocognit,funlen // TODO func (s *Supervisor) evaluatePorterInstance( ctx context.Context, address string, -) (*modeltiphereth.PorterInstance, error) { +) (*modelsupervisor.PorterInstance, error) { if address == "" { // bad address return nil, errors.New("address is empty") @@ -249,20 +250,19 @@ func (s *Supervisor) evaluatePorterInstance( logger.Infof("%s", err.Error()) return nil, err } - if info == nil { + if info == nil || info.GetBinarySummary() == nil { // bad instance - return nil, errors.New("info is nil") + return nil, errors.New("bad instance info") } feature := converter.ToBizPorterFeatureSummary(info.GetFeatureSummary()) - return &modeltiphereth.PorterInstance{ + return &modelsupervisor.PorterInstance{ ID: 0, - Name: info.GetName(), - Version: info.GetVersion(), + BinarySummary: converter.ToBizPorterBinarySummary(info.GetBinarySummary()), GlobalName: info.GetGlobalName(), Address: address, Region: info.GetRegion(), FeatureSummary: feature, - Status: modeltiphereth.PorterInstanceStatusUnspecified, + Status: modeltiphereth.UserStatusUnspecified, ContextJSONSchema: info.GetContextJsonSchema(), }, nil } @@ -270,7 +270,7 @@ func (s *Supervisor) evaluatePorterInstance( // enablePorterInstance enable porter instance, can be called multiple times. func (s *Supervisor) enablePorterInstance( ctx context.Context, - instance *modeltiphereth.PorterInstance, + instance *modelsupervisor.PorterInstance, ) (*porter.EnablePorterResponse, error) { if instance == nil { return nil, errors.New("instance is nil") diff --git a/go.mod b/go.mod index 88371e6..988d074 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,7 @@ require ( github.com/redis/go-redis/v9 v9.5.3 github.com/sony/sonyflake v1.2.0 github.com/stretchr/testify v1.9.0 - github.com/tuihub/protos v0.4.18 + github.com/tuihub/protos v0.4.20 github.com/zhihu/norm v0.1.11 go.opentelemetry.io/otel v1.27.0 go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240606163659-6a0fa3c911a0 diff --git a/go.sum b/go.sum index 68af349..d47fd94 100644 --- a/go.sum +++ b/go.sum @@ -972,8 +972,8 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tuihub/protos v0.4.18 h1:dsTyhF+j+dvGCcwNhEzxZTv7WEY41dcsxpBAOMOQklc= -github.com/tuihub/protos v0.4.18/go.mod h1:btbip/Tx2/xwrCuD/+pk7F/ElXhUYhjm8Dv2+uhd58o= +github.com/tuihub/protos v0.4.20 h1:fozd8I6uRS1250YqmX7a26mFR/xUQPp4YAB0pqJoFZU= +github.com/tuihub/protos v0.4.20/go.mod h1:btbip/Tx2/xwrCuD/+pk7F/ElXhUYhjm8Dv2+uhd58o= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/tylertreat/BoomFilters v0.0.0-20181028192813-611b3dbe80e8/go.mod h1:OYRfF6eb5wY9VRFkXJH8FFBi3plw2v+giaIu7P054pM= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=