Skip to content

Commit

Permalink
Remove CatalogSpec.SiteId (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
RemindD authored May 8, 2024
1 parent 17392d8 commit ed20922
Show file tree
Hide file tree
Showing 40 changed files with 74 additions and 189 deletions.
2 changes: 0 additions & 2 deletions agent/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ pub struct StagedProperties {
}
#[derive(Serialize, Deserialize)]
pub struct CatalogSpec {
#[serde(rename = "siteId")]
site_id: String,
#[serde(rename = "type")]
pub catalog_type: String,
pub properties: StagedProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ var catalogState = model.CatalogState{
Name: "name1",
},
Spec: &model.CatalogSpec{
SiteId: "site1",
Type: "catalog",
Type: "catalog",
Properties: map[string]interface{}{
"property1": "value1",
"property2": "value2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func InitializeMockSymphonyAPI() *httptest.Server {
Name: "catalog1",
},
Spec: &model.CatalogSpec{
SiteId: "fake",
Generation: "1",
ParentName: "fakeparent",
},
Expand Down
3 changes: 1 addition & 2 deletions api/pkg/apis/v1alpha1/managers/sync/sync-manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ func InitiazlizeMockSymphonyAPI(siteId string) *httptest.Server {
Name: "catalog1",
},
Spec: &model.CatalogSpec{
SiteId: "parent",
Type: "Instance",
Type: "Instance",
Properties: map[string]interface{}{
"foo": "bar",
},
Expand Down
5 changes: 0 additions & 5 deletions api/pkg/apis/v1alpha1/model/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type ObjectRef struct {
Metadata map[string]string `json:"metadata,omitempty"`
}
type CatalogSpec struct {
SiteId string `json:"siteId"`
Type string `json:"type"`
Metadata map[string]string `json:"metadata,omitempty"`
Properties map[string]interface{} `json:"properties"`
Expand All @@ -50,10 +49,6 @@ func (c CatalogSpec) DeepEquals(other IDeepEquals) (bool, error) {
return false, errors.New("parameter is not a CatalogSpec type")
}

if c.SiteId != otherC.SiteId {
return false, nil
}

if c.ParentName != otherC.ParentName {
return false, nil
}
Expand Down
20 changes: 3 additions & 17 deletions api/pkg/apis/v1alpha1/model/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ func TestIntefaceConvertion(t *testing.T) {
}
func TestCatalogMatch(t *testing.T) {
catalog1 := CatalogSpec{
SiteId: "siteId",
ParentName: "parentName",
Generation: "1",
Properties: map[string]interface{}{
"key": "value",
},
}
catalog2 := CatalogSpec{
SiteId: "siteId",
ParentName: "parentName",
Generation: "1",
Properties: map[string]interface{}{
Expand All @@ -63,25 +61,13 @@ func TestCatalogMatchOneEmpty(t *testing.T) {
}

func TestCatalogNotMatch(t *testing.T) {
catalog1 := CatalogSpec{
SiteId: "siteId",
}
catalog2 := CatalogSpec{
SiteId: "siteId2",
}

// siteId not match
catalog1.SiteId = "siteId"
catalog2.SiteId = "siteId2"
equal, err := catalog1.DeepEquals(catalog2)
assert.Nil(t, err)
assert.False(t, equal)
catalog1 := CatalogSpec{}
catalog2 := CatalogSpec{}

// parentName not match
catalog2.SiteId = "siteId"
catalog1.ParentName = "parentName"
catalog2.ParentName = "parentName2"
equal, err = catalog1.DeepEquals(catalog2)
equal, err := catalog1.DeepEquals(catalog2)
assert.Nil(t, err)
assert.False(t, equal)

Expand Down
1 change: 0 additions & 1 deletion api/pkg/apis/v1alpha1/providers/target/staging/staging.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func (i *StagingTargetProvider) Apply(ctx context.Context, deployment model.Depl
if catalog.Spec == nil {
catalog.ObjectMeta.Name = deployment.Instance.ObjectMeta.Name + "-" + i.Config.TargetName
catalog.Spec = &model.CatalogSpec{
SiteId: i.Context.SiteInfo.SiteId,
Type: "staged",
}
}
Expand Down
6 changes: 2 additions & 4 deletions api/pkg/apis/v1alpha1/vendors/catalogs-vendor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ var catalogState = model.CatalogState{
Name: "name1",
},
Spec: &model.CatalogSpec{
SiteId: "site1",
Type: "catalog",
Type: "catalog",
Properties: map[string]interface{}{
"property1": "value1",
"property2": "value2",
Expand Down Expand Up @@ -174,8 +173,7 @@ func TestCatalogOnCheck(t *testing.T) {

var catalogState = model.CatalogState{
Spec: &model.CatalogSpec{
SiteId: "site1",
Type: "catalog",
Type: "catalog",
Properties: map[string]interface{}{
"property1": "value1",
"property2": "value2",
Expand Down
6 changes: 2 additions & 4 deletions api/pkg/apis/v1alpha1/vendors/federation-vendor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,7 @@ func TestFederationOnSyncGet(t *testing.T) {
Name: "catalog1",
},
Spec: &model.CatalogSpec{
SiteId: vendor.Config.SiteInfo.SiteId,
Type: "catalog",
Type: "catalog",
Properties: map[string]interface{}{
"property1": "value1",
"property2": "value2",
Expand Down Expand Up @@ -470,8 +469,7 @@ func TestFederationOnK8SHook(t *testing.T) {
Name: "catalog1",
},
Spec: &model.CatalogSpec{
SiteId: vendor.Config.SiteInfo.SiteId,
Type: "catalog",
Type: "catalog",
Properties: map[string]interface{}{
"property1": "value1",
"property2": "value2",
Expand Down
3 changes: 1 addition & 2 deletions api/pkg/apis/v1alpha1/vendors/visualization-vendor.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ func mergeCatalogs(existingCatalog, newCatalog model.CatalogState) (model.Catalo
func convertVisualizationPacketToCatalog(site string, packet model.Packet) (model.CatalogState, error) {
catalog := model.CatalogState{
Spec: &model.CatalogSpec{
SiteId: site,
Type: "topology",
Type: "topology",
Properties: map[string]interface{}{
packet.From: map[string]model.Packet{
packet.To: packet,
Expand Down
6 changes: 0 additions & 6 deletions api/pkg/apis/v1alpha1/vendors/visualization-vendor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func TestConvertVisualizationPacketToCatalog(t *testing.T) {
DataType: "bytes",
})
assert.Nil(t, err)
assert.Equal(t, "fake-site", catalog.Spec.SiteId)
assert.Equal(t, "topology", catalog.Spec.Type)

v, ok := catalog.Spec.Properties["from-1"].(map[string]model.Packet)
Expand All @@ -131,7 +130,6 @@ func TestConvertVisualizationPacketToCatalogNoData(t *testing.T) {
To: "to-1",
})
assert.Nil(t, err)
assert.Equal(t, "fake-site", catalog.Spec.SiteId)
assert.Equal(t, "topology", catalog.Spec.Type)

v, ok := catalog.Spec.Properties["from-1"].(map[string]model.Packet)
Expand All @@ -150,7 +148,6 @@ func TestMergeCatalogsSameKey(t *testing.T) {
DataType: "bytes",
})
assert.Nil(t, err)
assert.Equal(t, "fake-site", catalog1.Spec.SiteId)
assert.Equal(t, "topology", catalog1.Spec.Type)
catalog2, err := convertVisualizationPacketToCatalog("fake-site", model.Packet{
Solution: "solution-1",
Expand All @@ -162,7 +159,6 @@ func TestMergeCatalogsSameKey(t *testing.T) {
DataType: "bytes",
})
assert.Nil(t, err)
assert.Equal(t, "fake-site", catalog2.Spec.SiteId)
assert.Equal(t, "topology", catalog2.Spec.Type)

mergedCatalog, err := mergeCatalogs(catalog1, catalog2)
Expand Down Expand Up @@ -190,7 +186,6 @@ func TestMergeCatalogsDifferentKey(t *testing.T) {
DataType: "bytes",
})
assert.Nil(t, err)
assert.Equal(t, "fake-site", catalog1.Spec.SiteId)
assert.Equal(t, "topology", catalog1.Spec.Type)
catalog2, err := convertVisualizationPacketToCatalog("fake-site", model.Packet{
Solution: "solution-1",
Expand All @@ -202,7 +197,6 @@ func TestMergeCatalogsDifferentKey(t *testing.T) {
DataType: "bytes",
})
assert.Nil(t, err)
assert.Equal(t, "fake-site", catalog2.Spec.SiteId)
assert.Equal(t, "topology", catalog2.Spec.Type)

mergedCatalog, err := mergeCatalogs(catalog1, catalog2)
Expand Down
3 changes: 1 addition & 2 deletions docs/samples/approval/logicapp/instance-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: gated-prometheus-instance
spec:
siteId: hq
spec:
type: instance
properties:
spec:
Expand Down
3 changes: 1 addition & 2 deletions docs/samples/approval/script/instance-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: gated-prometheus-instance
spec:
siteId: hq
spec:
type: instance
properties:
spec:
Expand Down
3 changes: 1 addition & 2 deletions docs/samples/multisite/catalog-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: site-catalog
spec:
siteId: hq
spec:
type: catalog
properties:
metadata:
Expand Down
3 changes: 1 addition & 2 deletions docs/samples/multisite/instance-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: site-instance
spec:
siteId: hq
spec:
type: instance
properties:
spec:
Expand Down
3 changes: 1 addition & 2 deletions docs/samples/multisite/solution-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: site-app
spec:
siteId: hq
spec:
type: solution
properties:
spec:
Expand Down
3 changes: 1 addition & 2 deletions docs/samples/multisite/target-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: site-k8s-target
spec:
siteId: hq
spec:
type: target
properties:
spec:
Expand Down
3 changes: 1 addition & 2 deletions docs/samples/opera/app/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export interface CampaignSpec {
}

export interface ObjectRef {
siteId: string;
siteId: string;
name: string;
group: string;
version: string;
Expand All @@ -58,7 +58,6 @@ export interface ObjectRef {
}

export interface CatalogSpec {
siteId: string;
name: string;
type: string;
properties: Record<string, any>;
Expand Down
1 change: 0 additions & 1 deletion docs/samples/opera/components/editors/CatalogEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function CatalogEditor(props: CatalogEditorProps) {
const formData = new FormData(event.currentTarget);
const data = Object.fromEntries(formData.entries());
const catalog = {
siteId : process.env.SYMPHONY_SITE,
name: data.name,
type: "config"
};
Expand Down
27 changes: 9 additions & 18 deletions docs/samples/universe-data/chemical-factory-2/catalogs/assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: hq
spec:
siteId: hq
spec:
type: asset
properties:
name: HQ
Expand All @@ -21,8 +20,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: infrastructure
spec:
siteId: hq
spec:
type: asset
properties:
name: "Infrastructure"
Expand All @@ -32,8 +30,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: l3
spec:
siteId: hq
spec:
type: asset
properties:
name: "Level 3"
Expand All @@ -43,8 +40,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: l4
spec:
siteId: hq
spec:
type: asset
properties:
name: "Level 4"
Expand All @@ -54,8 +50,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: use-cases
spec:
siteId: hq
spec:
type: asset
properties:
name: "Use Cases"
Expand All @@ -65,8 +60,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: csad
spec:
siteId: hq
spec:
type: asset
properties:
name: "CSAD"
Expand All @@ -76,8 +70,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: site
spec:
siteId: hq
spec:
type: asset
properties:
name: "Site"
Expand All @@ -87,8 +80,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: line-a
spec:
siteId: hq
spec:
type: asset
properties:
name: "Line A"
Expand All @@ -98,8 +90,7 @@ apiVersion: federation.symphony/v1
kind: Catalog
metadata:
name: line-b
spec:
siteId: hq
spec:
type: asset
properties:
name: "Line B"
Expand Down
Loading

0 comments on commit ed20922

Please sign in to comment.