(ctx *cliContext.Context)
| 99 | } |
| 100 | |
| 101 | func (bi *BackendsInstall) Run(ctx *cliContext.Context) error { |
| 102 | var galleries []config.Gallery |
| 103 | if err := json.Unmarshal([]byte(bi.BackendGalleries), &galleries); err != nil { |
| 104 | xlog.Error("unable to load galleries", "error", err) |
| 105 | } |
| 106 | |
| 107 | systemState, err := system.GetSystemState( |
| 108 | system.WithBackendSystemPath(bi.BackendsSystemPath), |
| 109 | system.WithBackendPath(bi.BackendsPath), |
| 110 | ) |
| 111 | if err != nil { |
| 112 | return err |
| 113 | } |
| 114 | |
| 115 | progressBar := progressbar.NewOptions( |
| 116 | 1000, |
| 117 | progressbar.OptionSetDescription(fmt.Sprintf("downloading backend %s", bi.BackendArgs)), |
| 118 | progressbar.OptionShowBytes(false), |
| 119 | progressbar.OptionClearOnFinish(), |
| 120 | ) |
| 121 | progressCallback := func(fileName string, current string, total string, percentage float64) { |
| 122 | v := int(percentage * 10) |
| 123 | err := progressBar.Set(v) |
| 124 | if err != nil { |
| 125 | xlog.Error("error while updating progress bar", "error", err, "filename", fileName, "value", v) |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | modelLoader := model.NewModelLoader(systemState) |
| 130 | err = galleryop.InstallExternalBackend(context.Background(), galleries, systemState, modelLoader, progressCallback, bi.BackendArgs, bi.Name, bi.Alias, bi.RequireBackendIntegrity) |
| 131 | if err != nil { |
| 132 | return err |
| 133 | } |
| 134 | |
| 135 | return nil |
| 136 | } |
| 137 | |
| 138 | func (bu *BackendsUpgrade) Run(ctx *cliContext.Context) error { |
| 139 | var galleries []config.Gallery |
nothing calls this directly
no test coverage detected