feat: retrieve user-visible appchart customization data
@@ -104,6 +104,38 @@ func toChart(chart *unstructured.Unstructured) (*models.AppChart, error) {
return nil, errors.New("helm repo should be string")
}
+ theSettings, _, err := unstructured.NestedMap(chart.UnstructuredContent(), "spec", "settings")
+ if err != nil {
+ return nil, errors.New("helm repo should be string")
+ }
+
+ settings := make(map[string]models.AppChartSetting)
+ for key := range theSettings {
+ fieldType, _, err := unstructured.NestedString(theSettings, key, "type")
+ if err != nil {
+ return nil, errors.New("settings type should be string")
+ }
+ fieldMin, _, err := unstructured.NestedString(theSettings, key, "minimum")
+ if err != nil {
+ return nil, errors.New("settings minimum should be string")
+ }
+ fieldMax, _, err := unstructured.NestedString(theSettings, key, "maximum")
+ if err != nil {
+ return nil, errors.New("settings maximum should be string")
+ }
+ fieldEnum, _, err := unstructured.NestedStringSlice(theSettings, key, "enum")
+ if err != nil {
+ return nil, errors.New("settings enum should be string slice")
+ }
+
+ settings[key] = models.AppChartSetting{
+ Type: fieldType,
+ Minimum: fieldMin,
+ Maximum: fieldMax,
+ Enum: fieldEnum,
+ }
+ }
+
createdAt := chart.GetCreationTimestamp()
return &models.AppChart{
@@ -115,5 +147,6 @@ func toChart(chart *unstructured.Unstructured) (*models.AppChart, error) {
ShortDescription: short,
HelmChart: helmChart,
HelmRepo: helmRepo,
+ Settings: settings,
}, nil
}
