Skip to content

Commit

Permalink
fixs some minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaqiluo committed Apr 5, 2022
1 parent 16b9165 commit 9304e9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion main.go
Expand Up @@ -59,7 +59,7 @@ func main() {
},
&cli.StringFlag{
Name: "app-name",
Usage: "the app for which the app default versions are for",
Usage: "the app for which to retrieve the app default versions",
EnvVars: []string{"APP_NAME"},
Destination: &AppName,
},
Expand Down
10 changes: 7 additions & 3 deletions pkg/config/get.go
Expand Up @@ -45,10 +45,11 @@ func get(ctx context.Context, url Source) ([]byte, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("status %v", resp.Status)
}
defer resp.Body.Close()

return ioutil.ReadAll(resp.Body)
}
Expand Down Expand Up @@ -165,8 +166,11 @@ func GetAppDefaultsConfig(content []byte, subKey, appName string) (*model.AppDef
if err := yaml.Unmarshal(content, &data); err != nil {
return nil, err
}
data, _ = data[subKey].(map[string]interface{})
if err := convert.ToObj(data, &allConfigs); err != nil {
subData, ok := data[subKey].(map[string]interface{})
if !ok {
return nil, fmt.Errorf("content at key %s expected to be map[string]interface{}, found %T instead", subKey, data[subKey])
}
if err := convert.ToObj(subData, &allConfigs); err != nil {
return nil, err
}
}
Expand Down

0 comments on commit 9304e9b

Please sign in to comment.