Skip to content

Commit b75cfc7

Browse files
authored
Merge pull request #4087 from dmytrovoytko/dmytrovoytko-patch-1
Make missing plugin repo errors more informative
2 parents 0b551d8 + 147f2c1 commit b75cfc7

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

internal/config/plugin_installer.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ func (pc PluginChannel) Fetch(out io.Writer) PluginPackages {
132132
resp, err := http.Get(string(pc))
133133
if err != nil {
134134
fmt.Fprintln(out, "Failed to query plugin channel:\n", err)
135-
return PluginPackages{}
135+
return nil
136136
}
137137
defer resp.Body.Close()
138138
decoder := json5.NewDecoder(resp.Body)
139139

140140
var repositories []PluginRepository
141141
if err := decoder.Decode(&repositories); err != nil {
142142
fmt.Fprintln(out, "Failed to decode channel data:\n", err)
143-
return PluginPackages{}
143+
return nil
144144
}
145145
return fetchAllSources(len(repositories), func(i int) PluginPackages {
146146
return repositories[i].Fetch(out)
@@ -152,15 +152,25 @@ func (pr PluginRepository) Fetch(out io.Writer) PluginPackages {
152152
resp, err := http.Get(string(pr))
153153
if err != nil {
154154
fmt.Fprintln(out, "Failed to query plugin repository:\n", err)
155-
return PluginPackages{}
155+
return nil
156156
}
157157
defer resp.Body.Close()
158+
159+
if resp.StatusCode != http.StatusOK {
160+
fmt.Fprintf(out, "Skipped: %s\n", pr)
161+
fmt.Fprintf(out, " Reason: Server error %d (%s)\n", resp.StatusCode,
162+
http.StatusText(resp.StatusCode))
163+
return nil
164+
}
165+
158166
decoder := json5.NewDecoder(resp.Body)
159167

160168
var plugins PluginPackages
161169
if err := decoder.Decode(&plugins); err != nil {
162-
fmt.Fprintln(out, "Failed to decode repository data:\n", err)
163-
return PluginPackages{}
170+
fmt.Fprintf(out, "Skipped: %s\n", pr)
171+
fmt.Fprintf(out, " Reason: Failed to decode repository data:\n")
172+
fmt.Fprintf(out, " %s\n", err)
173+
return nil
164174
}
165175
if len(plugins) > 0 {
166176
return PluginPackages{plugins[0]}

0 commit comments

Comments
 (0)