diff --git a/pkg/extension/extension.go b/pkg/extension/extension.go index fb8044c7a2f4c76b775840c5628319196a0493ae..26d9b6d51171307161e68ceef0830857fbb569a8 100644 --- a/pkg/extension/extension.go +++ b/pkg/extension/extension.go @@ -21,8 +21,6 @@ const ( StateInstalled = pb.SpaceExtensions_INSTALLED StateInProgress = pb.SpaceExtensions_IN_PROGRESS StateFail = pb.SpaceExtensions_FAIL - - ExtensionMetadataKey = "extension" ) type ( diff --git a/pkg/schema/schema.go b/pkg/schema/schema.go index c468ee99f156b3acf09435474e23c5427702b2e7..e0eca6b6ffc02511acbe3712b2f2bf83fc5bc05e 100644 --- a/pkg/schema/schema.go +++ b/pkg/schema/schema.go @@ -12,8 +12,7 @@ import ( type Schema struct { field.Field - Loaded bool `json:"loaded"` - Metadata map[string]string `json:"metadata"` + Loaded bool `json:"loaded"` } func New(kv ...interface{}) *Schema { @@ -34,9 +33,8 @@ var ( func (s *Schema) Clone(reset bool) *Schema { return &Schema{ - Field: *s.Field.Clone(reset), - Loaded: s.Loaded, - Metadata: s.Metadata, + Field: *s.Field.Clone(reset), + Loaded: s.Loaded, } } @@ -45,21 +43,6 @@ func (s Schema) WithIncludes(includes ...interface{}) *Schema { return &s } -func (s *Schema) WithMetadata(kv ...string) *Schema { - if s.Metadata == nil { - s.Metadata = make(map[string]string) - } - for i := 0; i < len(kv); i += 2 { - s.Metadata[kv[i]] = kv[i+1] - } - return s -} - -func (s Schema) SetMetadata(md map[string]string) *Schema { - s.Metadata = md - return &s -} - func (s *Schema) Load(ctx context.Context) error { if s.Loaded { return nil diff --git a/pkg/schema/schema_json.go b/pkg/schema/schema_json.go index 72b4ac25bb78c6d8cb868bd7018e81acf2d2080c..906acb5d0d361611d01f43d10bd0f80377ccb4a7 100644 --- a/pkg/schema/schema_json.go +++ b/pkg/schema/schema_json.go @@ -6,8 +6,8 @@ import ( ) type jsonSchema struct { - Loaded bool `json:"loaded"` - Metadata map[string]string `json:"metadata"` + //Field json.RawMessage `json:"field,inline"` + Loaded bool `json:"loaded"` } func (s *Schema) UnmarshalJSON(b []byte) error { @@ -17,12 +17,20 @@ func (s *Schema) UnmarshalJSON(b []byte) error { return errors.Wrapf(err, "error unmarshal json into field") } s.Loaded = j.Loaded - s.Metadata = j.Metadata if err := s.Field.UnmarshalJSON(b); err != nil { return err } + //if len(j.Field) > 0 { + // if err := s.Field.UnmarshalJSON(j.Field); err != nil { + // return err + // } + // //if err := jsoniter.Unmarshal(j.Field, &s.Field); err != nil { + // // return err + // //} + //} + return nil } @@ -34,8 +42,8 @@ func (s *Schema) MarshalJSON() ([]byte, error) { } jsonSch, err := jsoniter.Marshal(jsonSchema{ - Loaded: s.Loaded, - Metadata: s.Metadata, + //Field: b, + Loaded: s.Loaded, }) if err != nil { return nil, err diff --git a/pkg/schema/test/object_test.go b/pkg/schema/test/object_test.go index 9ba618794f122ed8c5551324b02d6b8cf9e46829..e5af975cdb9ed8e86044e5d357530dd2420afee9 100644 --- a/pkg/schema/test/object_test.go +++ b/pkg/schema/test/object_test.go @@ -110,9 +110,6 @@ func TestSchema_JSON(t *testing.T) { "evaluatedField", field.String(modify.Value("stringField2 + '_' ")), ) sch.Loaded = true - sch.Metadata = map[string]string{ - "extension": "test-extension", - } b, err := json.MarshalIndent(sch, "", " ") require.NoError(t, err) diff --git a/pkg/setup/collection.go b/pkg/setup/collection.go index 9f0a41cdb8830ddb66557345153beea56e8e46e1..d61ba14d18f2d8bc93d2a535392b8b608ba6e2d0 100644 --- a/pkg/setup/collection.go +++ b/pkg/setup/collection.go @@ -12,10 +12,9 @@ import ( ) var ( - ErrCheckCollections = errors.New("collections check error") - ErrInstallCollections = errors.New("failed to install collections") - ErrUninstallCollections = errors.New("failed to uninstall collections") - ErrCollectionAlreadyExists = errors.New("failed to uninstall collections") + ErrCheckCollections = errors.New("collections check error") + ErrInstallCollections = errors.New("failed to install collections") + ErrUninstallCollections = errors.New("failed to uninstall collections") ) type CollectionsOption func(c *CollectionConfig) @@ -24,7 +23,6 @@ type DeleteCollectionFn func(s *Setup, col *collections.Collection) bool type CollectionConfig struct { collection *collections.Collection - metadata map[string]string UpdateFn UpdateCollectionFn DeleteFn DeleteCollectionFn } @@ -127,7 +125,7 @@ func (s *Setup) InstallCollection(ctx context.Context, c CollectionConfig) (setS collection.SpaceID, collection.EnvID = s.SpaceID, s.EnvironmentID var exist *collections.Collection - + // isForce - не удалять коллекцию, если она уже существует exist, err = s.content.Collections.Get(ctx, collection.SpaceID, collection.EnvID, collection.ID) if err != nil && !strings.Contains(err.Error(), collections.ErrNotFound.Error()) { return false, err @@ -135,7 +133,7 @@ func (s *Setup) InstallCollection(ctx context.Context, c CollectionConfig) (setS if exist == nil { setSchema = !collection.IsView() - _, err = s.content.Collections.Create(ctx, collection) + exist, err = s.content.Collections.Create(ctx, collection) if err != nil { return false, err } diff --git a/pkg/setup/collection_test.go b/pkg/setup/collection_test.go index bae2fc4b6b6d6cbec58fff882c2fc282f19ee2b4..3a033d29f51e8223222ad4b107254229fbbae865 100644 --- a/pkg/setup/collection_test.go +++ b/pkg/setup/collection_test.go @@ -23,7 +23,6 @@ func TestSetup_InstallCollections(t *testing.T) { collections []*collections.Collection collectionsCall func(svc *mockscollections.Collections) envsCall func(svc *envmocks.Environments) - force bool wantErr func(t *testing.T, err error) }{ { @@ -151,7 +150,6 @@ func TestSetup_InstallCollections(t *testing.T) { } s := NewSetup(&content.Content{Collections: c, Environments: e}, "sp", "env", nil) - s.force = tt.force s.AddCollections(tt.collections) tt.wantErr(t, s.InstallCollections(context.Background())) })