MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / GetParams

Method GetParams

agent/app/service/app_install.go:722–832  ·  view source on GitHub ↗
(id uint)

Source from the content-addressed store, hash-verified

720}
721
722func (a *AppInstallService) GetParams(id uint) (*response.AppConfig, error) {
723 var (
724 params []response.AppParam
725 appForm dto.AppForm
726 envs = make(map[string]interface{})
727 res response.AppConfig
728 )
729 install, err := appInstallRepo.GetFirst(repo.WithByID(id))
730 if err != nil {
731 return nil, err
732 }
733 detail, err := appDetailRepo.GetFirst(repo.WithByID(install.AppDetailId))
734 if err != nil {
735 return nil, err
736 }
737 if err = json.Unmarshal([]byte(detail.Params), &appForm); err != nil {
738 return nil, err
739 }
740 if err = json.Unmarshal([]byte(install.Env), &envs); err != nil {
741 return nil, err
742 }
743 for _, form := range appForm.FormFields {
744 if v, ok := envs[form.EnvKey]; ok {
745 appParam := response.AppParam{
746 Edit: false,
747 Key: form.EnvKey,
748 Rule: form.Rule,
749 Type: form.Type,
750 Multiple: form.Multiple,
751 Required: form.Required,
752 }
753 if form.Edit {
754 appParam.Edit = true
755 }
756 appParam.LabelZh = form.LabelZh
757 appParam.LabelEn = form.LabelEn
758 appParam.Label = form.Label
759 appParam.Value = v
760 if form.Type == "service" {
761 appInstall, _ := appInstallRepo.GetFirst(appInstallRepo.WithServiceName(v.(string)))
762 appParam.ShowValue = appInstall.Name
763 } else if form.Type == "select" {
764 if form.Multiple {
765 if v == "" {
766 appParam.Value = []string{}
767 } else {
768 if str, ok := v.(string); ok {
769 appParam.Value = strings.Split(str, ",")
770 }
771 }
772 } else {
773 for _, fv := range form.Values {
774 if fv.Value == v {
775 appParam.ShowValue = fv.Label
776 break
777 }
778 }
779 }

Callers

nothing calls this directly

Calls 7

getAppCommonConfigFunction · 0.85
isHostModelFunction · 0.85
getRestartPolicyFunction · 0.85
getUpgradeComposeFunction · 0.85
GetFirstMethod · 0.65
WithByIDMethod · 0.65
WithServiceNameMethod · 0.65

Tested by

no test coverage detected