(state *InstallerState)
| 152 | } |
| 153 | |
| 154 | func loadConfig(state *InstallerState) error { |
| 155 | cwd, err := os.Getwd() |
| 156 | if err != nil { |
| 157 | return err |
| 158 | } |
| 159 | |
| 160 | parseConfig := func(content io.Reader) (*Config, error) { |
| 161 | // Create a new Config instance |
| 162 | var config Config |
| 163 | |
| 164 | // Decode the JSON data from the file into the Config struct |
| 165 | decoder := json.NewDecoder(content) |
| 166 | err = decoder.Decode(&config) |
| 167 | if err != nil { |
| 168 | return nil, err |
| 169 | } |
| 170 | |
| 171 | return &config, nil |
| 172 | } |
| 173 | |
| 174 | configPath := filepath.Join(cwd, "config.json") |
| 175 | _, err = os.Stat(configPath) |
| 176 | if err == nil { |
| 177 | // External found, use that |
| 178 | file, err := os.Open(configPath) |
| 179 | if err != nil { |
| 180 | return err |
| 181 | } |
| 182 | defer file.Close() |
| 183 | |
| 184 | config, err := parseConfig(file) |
| 185 | if err != nil { |
| 186 | return err |
| 187 | } |
| 188 | state.Config = config |
| 189 | } else if os.IsNotExist(err) { |
| 190 | // None found, Check internal config |
| 191 | reader := bytes.NewReader(resourceConfigJson.StaticContent) |
| 192 | config, err := parseConfig(reader) |
| 193 | if err != nil { |
| 194 | return err |
| 195 | } |
| 196 | state.Config = config |
| 197 | } else { |
| 198 | return err |
| 199 | } |
| 200 | |
| 201 | return nil |
| 202 | } |
| 203 | |
| 204 | func setupLayout(w fyne.Window, state *InstallerState) *fyne.Container { |
| 205 | buttonResume := widget.NewButton("Resume Install", func() { |
no test coverage detected