From 50893971ea8c6f1e1e18b8a886de9a4c890e1983 Mon Sep 17 00:00:00 2001 From: ChunHao <64747455+chuang8511@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:34:31 +0000 Subject: [PATCH] feat(vdp): skip google drive for cloud version (#899) Because - we want to hide google drive in cloud before we get drive.readonly scope from Google This commit - hide google drive in cloud version --- config/config.go | 7 +++++++ pkg/repository/repository.go | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index dc73bd68f..b87a28f4d 100644 --- a/config/config.go +++ b/config/config.go @@ -17,6 +17,13 @@ import ( miniox "github.com/instill-ai/x/minio" ) +const ( + EditionLocalCE = "local-ce:dev" + EditionCloudDev = "cloud:dev" + EditionCloudStaging = "cloud:staging" + EditionCloudProd = "cloud:prod" +) + // Config - Global variable to export var Config AppConfig diff --git a/pkg/repository/repository.go b/pkg/repository/repository.go index ddb279204..713691fa0 100644 --- a/pkg/repository/repository.go +++ b/pkg/repository/repository.go @@ -767,9 +767,14 @@ func (r *repository) ListComponentDefinitionUIDs(_ context.Context, p ListCompon Where(where, whereArgs...). Where("is_visible IS TRUE") - if config.Config.Server.Edition == "local-ce:dev" { + + // TODO: refactor it with store.go in ins-7031 + if config.Config.Server.Edition == config.EditionLocalCE { skipComponentsInCE := []string{"instill-app"} queryBuilder = queryBuilder.Where("id NOT IN (?)", skipComponentsInCE) + } else if config.Config.Server.Edition == config.EditionCloudStaging || config.Config.Server.Edition == config.EditionCloudProd { + skipComponentsInCloud := []string{"google-drive", "google-sheets"} + queryBuilder = queryBuilder.Where("id NOT IN (?)", skipComponentsInCloud) } queryBuilder.Count(&totalSize)