From de2802a98f2f161de397c965e4bfa6e08ef951f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Fern=C3=A1ndez?= Date: Thu, 15 Feb 2024 18:43:18 -0500 Subject: [PATCH] feat: move service types to pkg (#299) --- internal/db/services.go | 5 ++--- internal/environments/defaultEnvironments.go | 3 +-- internal/services/services.go | 7 +++---- {internal => pkg}/types/services.go | 0 4 files changed, 6 insertions(+), 9 deletions(-) rename {internal => pkg}/types/services.go (100%) diff --git a/internal/db/services.go b/internal/db/services.go index 9e17e0ec..7fd4a6ec 100644 --- a/internal/db/services.go +++ b/internal/db/services.go @@ -9,8 +9,7 @@ package db import ( "fmt" - "github.com/kubefirst/kubefirst-api/internal/types" - pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" + "github.com/kubefirst/kubefirst-api/pkg/types" log "github.com/rs/zerolog/log" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" @@ -19,7 +18,7 @@ import ( // CreateClusterServiceList adds an entry for a cluster to the service list func (mdbcl *MongoDBClient) CreateClusterServiceList(clusterName string) error { filter := bson.D{{Key: "cluster_name", Value: clusterName}} - var result pkgtypes.Cluster + var result types.Cluster err := mdbcl.ServicesCollection.FindOne(mdbcl.Context, filter).Decode(&result) if err != nil { // This error means your query did not match any documents. diff --git a/internal/environments/defaultEnvironments.go b/internal/environments/defaultEnvironments.go index 651330e2..617e280f 100644 --- a/internal/environments/defaultEnvironments.go +++ b/internal/environments/defaultEnvironments.go @@ -19,7 +19,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/constants" "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/env" - internalTypes "github.com/kubefirst/kubefirst-api/internal/types" "github.com/kubefirst/kubefirst-api/pkg/types" log "github.com/rs/zerolog/log" @@ -101,7 +100,7 @@ func CreateDefaultEnvironments(mgmtCluster types.Cluster) error { } // Update list - err = db.Client.InsertClusterServiceListEntry(clusterName, &internalTypes.Service{ + err = db.Client.InsertClusterServiceListEntry(clusterName, &types.Service{ Name: "Metaphor", Default: true, Description: "A multi-environment demonstration space for frontend application best practices that's easy to apply to other projects.", diff --git a/internal/services/services.go b/internal/services/services.go index 44c59e96..f60790a7 100644 --- a/internal/services/services.go +++ b/internal/services/services.go @@ -26,7 +26,6 @@ import ( "github.com/kubefirst/kubefirst-api/internal/db" "github.com/kubefirst/kubefirst-api/internal/env" "github.com/kubefirst/kubefirst-api/internal/gitShim" - "github.com/kubefirst/kubefirst-api/internal/types" "github.com/kubefirst/kubefirst-api/pkg/providerConfigs" pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types" utils "github.com/kubefirst/kubefirst-api/pkg/utils" @@ -211,7 +210,7 @@ func CreateService(cl *pkgtypes.Cluster, serviceName string, appDef *pkgtypes.Gi } // Update list - err = db.Client.InsertClusterServiceListEntry(clusterName, &types.Service{ + err = db.Client.InsertClusterServiceListEntry(clusterName, &pkgtypes.Service{ Name: serviceName, Default: false, Description: appDef.Description, @@ -400,7 +399,7 @@ func AddDefaultServices(cl *pkgtypes.Cluster) error { fullDomainName = cl.DomainName } - defaults := []types.Service{ + defaults := []pkgtypes.Service{ { Name: cl.GitProvider, Default: true, @@ -450,7 +449,7 @@ func AddDefaultServices(cl *pkgtypes.Cluster) error { } if cl.CloudProvider == "k3d" { - defaults = append(defaults, types.Service{ + defaults = append(defaults, pkgtypes.Service{ Name: "Metaphor", Default: true, Description: "A multi-environment demonstration space for frontend application best practices that's easy to apply to other projects.", diff --git a/internal/types/services.go b/pkg/types/services.go similarity index 100% rename from internal/types/services.go rename to pkg/types/services.go