From 3be7edc4da9c39180f95b29418ba40eb0534ceab Mon Sep 17 00:00:00 2001 From: clyang82 Date: Thu, 23 May 2024 16:57:07 +0800 Subject: [PATCH] Set maestro as source Signed-off-by: clyang82 --- pkg/api/presenters/resource.go | 10 +++++++--- pkg/constants/constants.go | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 pkg/constants/constants.go diff --git a/pkg/api/presenters/resource.go b/pkg/api/presenters/resource.go index 929efec5..5a18703b 100755 --- a/pkg/api/presenters/resource.go +++ b/pkg/api/presenters/resource.go @@ -1,10 +1,12 @@ package presenters import ( + "gorm.io/datatypes" + "github.com/openshift-online/maestro/pkg/api" "github.com/openshift-online/maestro/pkg/api/openapi" + "github.com/openshift-online/maestro/pkg/constants" "github.com/openshift-online/maestro/pkg/util" - "gorm.io/datatypes" ) // ConvertResource converts a resource from the API to the openapi representation. @@ -20,8 +22,10 @@ func ConvertResource(resource openapi.Resource) (*api.Resource, error) { }, ConsumerName: util.NilToEmptyString(resource.ConsumerName), Version: util.NilToEmptyInt32(resource.Version), - Type: api.ResourceTypeSingle, - Manifest: manifest, + // Set the default source ID for RESTful API calls and do not allow modification + Source: constants.DefaultSourceID, + Type: api.ResourceTypeSingle, + Manifest: manifest, }, nil } diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go new file mode 100644 index 00000000..6467883b --- /dev/null +++ b/pkg/constants/constants.go @@ -0,0 +1,5 @@ +package constants + +const ( + DefaultSourceID = "maestro" +)