Skip to content

Commit 4816893

Browse files
authored
Merge pull request #470 from meshery/expose-design-preferences
expose independent DesignPreferences struct
2 parents d4c4867 + 6a55411 commit 4816893

File tree

3 files changed

+16
-42
lines changed

3 files changed

+16
-42
lines changed

models/v1beta1/pattern/design_conversion.go

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package pattern
22

33
import (
4-
"crypto/rand"
54
"math/big"
65
"reflect"
76
"strings"
@@ -164,27 +163,6 @@ func (p *PatternFile) convertFromTraits(cmp *component.ComponentDefinition, serv
164163
cmp.Metadata = _compMetadata
165164
cmp.Metadata.IsNamespaced = isNamespaced
166165

167-
// Handle position properties: traits.meshmap.position
168-
randX, _ := rand.Int(rand.Reader, big.NewInt(100))
169-
170-
randY, _ := rand.Int(rand.Reader, big.NewInt(100))
171-
172-
positionX, _ := big.NewFloat(0).SetInt(randX).Float64()
173-
positionY, _ := big.NewFloat(0).SetInt(randY).Float64()
174-
175-
cmp.Styles = &component.ComponentDefinition_Styles{
176-
Position: &struct {
177-
// X The x-coordinate of the node.
178-
X float64 `json:"x" yaml:"x"`
179-
180-
// Y The y-coordinate of the node.
181-
Y float64 `json:"y" yaml:"y"`
182-
}{
183-
X: positionX,
184-
Y: positionY,
185-
},
186-
}
187-
188166
pos, err := utils.MarshalAndUnmarshal[interface{}, position](extensionsMetadata["position"])
189167
if err == nil {
190168
cmp.Styles.Position.X, _ = big.NewFloat(pos.X).Float64()
@@ -293,4 +271,4 @@ func (p *PatternFile) convertToSettings(service *v1alpha2.Service, component *co
293271
component.Configuration["metadata"] = _configurationMetadata // is this reassignment needed, map are references, check once.
294272
service.Settings = component.Configuration
295273
return nil
296-
}
274+
}

schemas/constructs/v1beta1/design/design.json

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"version": {
2222
"$ref": "../../core.json#/definitions/semverString",
23-
"default":"v0.0.1",
23+
"default": "v0.0.1",
2424
"x-order": 4,
2525
"description": "Revision of the design as expressed by an auto-incremented, SemVer-compliant version number. May be manually set by a user or third-party system, but will always be required to be of version number higher than the previously defined version number.",
2626
"minLength": 1,
@@ -58,16 +58,8 @@
5858
}
5959
},
6060
"preferences": {
61-
"type": "object",
62-
"description": "Design-level preferences",
63-
"x-order": 7,
64-
"properties": {
65-
"layers": {
66-
"type": "object",
67-
"description": "List of available layers"
68-
}
69-
},
70-
"required": ["layers"]
61+
"$ref": "./openapi.yml#/components/schemas/DesignPreferences",
62+
"x-go-type": "DesignPreferences"
7163
},
7264
"relationships": {
7365
"description": "List of relationships between components",
@@ -83,12 +75,5 @@
8375
}
8476
},
8577

86-
"required": [
87-
"id",
88-
"name",
89-
"schemaVersion",
90-
"version",
91-
"components",
92-
"relationships"
93-
]
78+
"required": ["id", "name", "schemaVersion", "version", "components", "relationships"]
9479
}

schemas/constructs/v1beta1/design/openapi.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,14 @@ components:
132132
type: string
133133
format: uri
134134
description: "Provide the URL of the file you want to import. This should be a direct URL to a single file, for example: https://raw.github.com/your-design-file.yaml. Also, ensure that design is in a supported format: Kubernetes Manifest, Helm Chart, Docker Compose, or Meshery Design. See [Import Designs Documentation](https://docs.meshery.io/guides/configuration-management/importing-designs#import-designs-using-meshery-ui) for details"
135+
136+
DesignPreferences:
137+
type: object
138+
description: Design-level preferences
139+
x-order: 7
140+
properties:
141+
layers:
142+
type: object
143+
description: Map of available layers, where keys are layer names.
144+
required:
145+
- layers

0 commit comments

Comments
 (0)