MCPcopy Create free account
hub / github.com/OpenCSGs/csghub-server / SetRuntimeFrameworkModes

Method SetRuntimeFrameworkModes

component/model.go:788–818  ·  view source on GitHub ↗
(ctx context.Context, currentUser string, deployType int, id int64, paths []string)

Source from the content-addressed store, hash-verified

786}
787
788func (c *ModelComponent) SetRuntimeFrameworkModes(ctx context.Context, currentUser string, deployType int, id int64, paths []string) ([]string, error) {
789 runtimeRepos, err := c.rtfm.FindByID(ctx, id)
790 if err != nil {
791 return nil, err
792 }
793
794 if runtimeRepos == nil {
795 return nil, fmt.Errorf("failed to get runtime framework")
796 }
797
798 models, err := c.ms.ListByPath(ctx, paths)
799 if err != nil {
800 return nil, err
801 }
802
803 var failedModels []string
804 for _, model := range models {
805 relations, err := c.rrtfms.GetByIDsAndType(ctx, id, model.Repository.ID, deployType)
806 if err != nil {
807 return nil, err
808 }
809 if relations == nil || len(relations) < 1 {
810 err = c.rrtfms.Add(ctx, id, model.Repository.ID, deployType)
811 if err != nil {
812 failedModels = append(failedModels, model.Repository.Path)
813 }
814 }
815 }
816
817 return failedModels, nil
818}
819
820func (c *ModelComponent) DeleteRuntimeFrameworkModes(ctx context.Context, currentUser string, deployType int, id int64, paths []string) ([]string, error) {
821 models, err := c.ms.ListByPath(ctx, paths)

Callers 1

Calls 4

GetByIDsAndTypeMethod · 0.80
FindByIDMethod · 0.45
ListByPathMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected