Skip to content

Commit

Permalink
feat: save only k3d supported apps from the catalog into db
Browse files Browse the repository at this point in the history
Signed-off-by: tomekz <[email protected]>
  • Loading branch information
tomekz committed Oct 23, 2023
1 parent 19d95a0 commit 9953ca9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/db/gitopsCatalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ func (mdbcl *MongoDBClient) GetGitopsCatalogApps() (types.GitopsCatalogApps, err
return result, nil
}

func k3dCatalogApps(apps []types.GitopsCatalogApp) []types.GitopsCatalogApp {
var k3dApps []types.GitopsCatalogApp
for _, app := range apps {
worksOnK3D := app.K3D == nil
if worksOnK3D {
k3dApps = append(k3dApps, app)
}
}
return k3dApps
}

// UpdateGitopsCatalogApps
func (mdbcl *MongoDBClient) UpdateGitopsCatalogApps() error {
mpapps, err := gitopsCatalog.ReadActiveApplications()
Expand All @@ -36,7 +47,7 @@ func (mdbcl *MongoDBClient) UpdateGitopsCatalogApps() error {
}

filter := bson.D{{Key: "name", Value: "gitops_catalog_application_list"}}
update := bson.D{{Key: "$set", Value: bson.D{{Key: "apps", Value: mpapps.Apps}}}}
update := bson.D{{Key: "$set", Value: bson.D{{Key: "apps", Value: k3dCatalogApps(mpapps.Apps)}}}}
opts := options.Update().SetUpsert(true)

_, err = mdbcl.GitopsCatalogCollection.UpdateOne(mdbcl.Context, filter, update, opts)
Expand Down
1 change: 1 addition & 0 deletions internal/types/gitopsCatalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type GitopsCatalogApp struct {
ImageURL string `bson:"image_url" json:"image_url" yaml:"imageUrl"`
Description string `bson:"description" json:"description" yaml:"description"`
Categories []string `bson:"categories" json:"categories" yaml:"categories"`
K3D *bool `bson:"k3d" json:"k3d" yaml:"k3d"`
}

// GitopsCatalogAppSecretKey describes a required secret value when creating a
Expand Down

0 comments on commit 9953ca9

Please sign in to comment.