Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocph committed Oct 19, 2024
1 parent 675f07b commit 48240c1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions dependency-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ catalog:
# - url: https://github.com/gimlet-io/charts.git?path=rabbitmq
# - url: https://github.com/gimlet-io/charts.git?path=postgresql
- url: https://github.com/gimlet-io/charts.git?path=postgresql-database
requiredStackComponent: centralizedPostgresql
- url: https://github.com/gimlet-io/charts.git?path=containerized-redis
29 changes: 28 additions & 1 deletion pkg/dashboard/server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ func dependencyCatalog(w http.ResponseWriter, r *http.Request) {
cfg := ctx.Value("config").(*config.Config)
tokenManager := ctx.Value("tokenManager").(customScm.NonImpersonatedTokenManager)
installationToken, _, _ := tokenManager.Token()
db := r.Context().Value("store").(*store.Store)

owner := chi.URLParam(r, "owner")
repoName := chi.URLParam(r, "name")
Expand All @@ -352,6 +353,26 @@ func dependencyCatalog(w http.ResponseWriter, r *http.Request) {
return
}

environment, err := db.GetEnvironment(env)
if err != nil {
logrus.Errorf("cannot get env: %s", err)
w.WriteHeader(http.StatusInternalServerError)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}

stackYamlPath := "stack.yaml"
if !environment.RepoPerEnv {
stackYamlPath = filepath.Join(environment.Name, "stack.yaml")
}

stackConfig, err := StackConfig(gitRepoCache, stackYamlPath, environment.InfraRepo)
if err != nil {
logrus.Errorf("cannot get stack config: %s", err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}

catalogBytes, err := downloadFile(cfg.DependencyCatalogURL)
if err != nil {
logrus.Errorf("cannot get dependency catalog: %s", err)
Expand All @@ -369,7 +390,13 @@ func dependencyCatalog(w http.ResponseWriter, r *http.Request) {

components := []DeploymentTemplate{}
for _, component := range catalog["catalog"].([]interface{}) {
url := component.(map[string]interface{})["url"].(string)
c := component.(map[string]interface{})
url := c["url"].(string)
if requiredStackComponent, ok := stackConfig.Config["requiredStackComponent"]; ok {
if _, exists := c[requiredStackComponent.(string)]; !exists {
continue
}
}
schema, schemaUI, err := dx.ChartSchema(dx.Chart{Name: url}, installationToken)
if err != nil {
logrus.Warnf("could not get chart schema from %s: %s", url, err)
Expand Down
1 change: 0 additions & 1 deletion web/src/views/footer/capacitor/Describe.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function Describe(props) {
const [selected, setSelected] = useState("")
const [content, setContent] = useState()
store.subscribe(() => {
console.log(store.getState().detail)
setContent(store.getState().details[selected])
});

Expand Down

0 comments on commit 48240c1

Please sign in to comment.