Skip to content

Commit

Permalink
schema reference
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiQL committed Jul 30, 2024
1 parent 1b779a4 commit 642a5e3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions k8s/apis/federation/v1/catalog_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import (
"gopls-workspace/apis/metrics/v1"
commoncontainer "gopls-workspace/apis/model/v1"
"gopls-workspace/configutils"
"gopls-workspace/utils"
"time"

"github.com/eclipse-symphony/symphony/api/pkg/apis/v1alpha1/utils"
api_utils "github.com/eclipse-symphony/symphony/api/pkg/apis/v1alpha1/utils"
"github.com/eclipse-symphony/symphony/k8s/constants"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -170,6 +172,7 @@ func (r *Catalog) validateCreateCatalog() error {
func (r *Catalog) checkSchema() *field.Error {
if r.Spec.Metadata != nil {
if schemaName, ok := r.Spec.Metadata["schema"]; ok {
schemaName = utils.ReplaceLastSeperator(schemaName, ":", constants.ResourceSeperator)
cataloglog.Info("Find schema name", "name", schemaName)
var catalogs CatalogList
err := myCatalogReaderClient.List(context.Background(), &catalogs, client.InNamespace(r.ObjectMeta.Namespace), client.MatchingFields{"metadata.name": schemaName}, client.Limit(1))
Expand All @@ -186,7 +189,7 @@ func (r *Catalog) checkSchema() *field.Error {
return field.Invalid(field.NewPath("spec").Child("properties"), schemaName, "invalid catalog properties")
}
if spec, ok := properties["spec"]; ok {
var schemaObj utils.Schema
var schemaObj api_utils.Schema
jData, _ := json.Marshal(spec)
err := json.Unmarshal(jData, &schemaObj)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/scenarios/05.catalog/catalogs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ spec:
rootResource: config
catalogType: config
metadata:
schema: schema-v-v1
schema: schema:v1
properties:
email: "sample@sample.com"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ metadata:
spec:
catalogType: config
metadata:
schema: schema-v-v1
schema: schema:v1
properties:
email: "this is an invalid email"

0 comments on commit 642a5e3

Please sign in to comment.