Skip to content

Commit 4c91ba6

Browse files
authored
Merge branch 'master' into missingNameSpace
2 parents 4224be0 + 140d9a5 commit 4c91ba6

File tree

6 files changed

+73
-35
lines changed

6 files changed

+73
-35
lines changed

.github/workflows/slack.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
1-
name: Slack Notify on Star
2-
on: watch
1+
name: Slack Notify
2+
on:
3+
watch:
4+
types: [started]
35
jobs:
46
star-notify:
7+
if: github.event_name == 'watch'
58
name: Notify Slack on star
6-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-22.04
710
steps:
811
- name: Get current star count
912
run: |
10-
echo "STARS=$(curl --silent 'https://api.github.com/repos/layer5io/meshkit' -H 'Accept: application/vnd.github.preview' | jq '.watchers_count')" >> $GITHUB_ENV
13+
echo "STARS=$(curl --silent 'https://api.github.com/repos/${{github.repository}}' -H 'Accept: application/vnd.github.preview' | jq '.stargazers_count')" >> $GITHUB_ENV
1114
- name: Notify slack
1215
env:
1316
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
1417
uses: pullreminders/slack-action@master
1518
with:
16-
args: '{\"channel\":\"CSK7N9TGX\",\"text\":\"${{ github.actor }} just starred Meshkit! (https://github.com/layer5io/meshkit/stargazers) Total ⭐️: ${{env.STARS}}\"}'
19+
args: '{\"channel\":\"CSK7N9TGX\",\"text\":\"${{ github.actor }} just starred ${{github.repository}}! (https://github.com/${{github.repository}}/stargazers) Total ⭐️: ${{env.STARS}}\"}'
20+
good-first-issue-notify:
21+
if: github.event_name == 'issues' && github.event.label.name == 'good first issue' || github.event.label.name == 'first-timers-only'
22+
name: Notify Slack for new good-first-issue
23+
runs-on: ubuntu-22.04
24+
steps:
25+
- name: Notify slack
26+
env:
27+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
28+
uses: pullreminders/slack-action@master
29+
with:
30+
args: '{\"channel\":\"C019426UBNY\",\"text\":\"A good first issue label was just added to ${{github.event.issue.html_url}}.\"}'

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/google/uuid v1.6.0
2525
github.com/kubernetes/kompose v1.31.1
2626
github.com/layer5io/meshery-operator v0.7.0
27-
github.com/meshery/schemas v0.7.31
27+
github.com/meshery/schemas v0.7.36
2828
github.com/nats-io/nats.go v1.31.0
2929
github.com/open-policy-agent/opa v0.67.1
3030
github.com/opencontainers/image-spec v1.1.0
@@ -39,7 +39,7 @@ require (
3939
gopkg.in/yaml.v3 v3.0.1
4040
gorm.io/driver/postgres v1.5.3
4141
gorm.io/driver/sqlite v1.5.4
42-
gorm.io/gorm v1.25.11
42+
gorm.io/gorm v1.25.12
4343
helm.sh/helm/v3 v3.13.2
4444
k8s.io/api v0.28.4
4545
k8s.io/apimachinery v0.28.4

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,8 @@ github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S
608608
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
609609
github.com/meshery/kompose v1.0.1 h1:lg8B/pkLh6762jeFsQATD8UJZZwXZf/aviC3/dzw78A=
610610
github.com/meshery/kompose v1.0.1/go.mod h1:TWhWTEMbJBUzENf4JTEtBmZRFm/r8n0nS6v4/nSD2vA=
611-
github.com/meshery/schemas v0.7.31 h1:FfVR+oErAiiEomt6sTZI5uKhoyU26QXawT6UDZHbthI=
612-
github.com/meshery/schemas v0.7.31/go.mod h1:UfiO+zm92yLkaJP0aroNwVnjuozoh793AWDXrKDYmT0=
611+
github.com/meshery/schemas v0.7.36 h1:KQOz/SODr+T6fDS2lDSrNo/Eu3LCaEUGIRauQtvXkjg=
612+
github.com/meshery/schemas v0.7.36/go.mod h1:wOh519/EDxiYlC4aeGv74ru+t9h9VJ4P2JYIvSfdPWQ=
613613
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
614614
github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM=
615615
github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk=
@@ -1198,8 +1198,8 @@ gorm.io/driver/postgres v1.5.3 h1:qKGY5CPHOuj47K/VxbCXJfFvIUeqMSXXadqdCY+MbBU=
11981198
gorm.io/driver/postgres v1.5.3/go.mod h1:F+LtvlFhZT7UBiA81mC9W6Su3D4WUhSboc/36QZU0gk=
11991199
gorm.io/driver/sqlite v1.5.4 h1:IqXwXi8M/ZlPzH/947tn5uik3aYQslP9BVveoax0nV0=
12001200
gorm.io/driver/sqlite v1.5.4/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4=
1201-
gorm.io/gorm v1.25.11 h1:/Wfyg1B/je1hnDx3sMkX+gAlxrlZpn6X0BXRlwXlvHg=
1202-
gorm.io/gorm v1.25.11/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
1201+
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
1202+
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
12031203
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
12041204
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
12051205
gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o=

models/meshmodel/registry/v1beta1/model_filter.go

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ type ModelFilter struct {
2929
Components bool
3030
Relationships bool
3131
Status string
32+
// When Trim is true it will only send necessary models data
33+
// like: component count, relationship count, id and name of model
34+
Trim bool
3235
}
3336

3437
// Create the filter from map[string]interface{}
@@ -182,27 +185,48 @@ func (mf *ModelFilter) Get(db *database.Handler) ([]entity.Entity, int64, int, e
182185
for _, modelDB := range modelWithCategories {
183186
// resolve for loop scope
184187
_modelDB := modelDB
185-
if includeComponents {
186-
var components []component.ComponentDefinition
187-
finder := db.Model(&component.ComponentDefinition{}).
188-
Select("component_definition_dbs.id, component_definition_dbs.component, component_definition_dbs.display_name, component_definition_dbs.metadata, component_definition_dbs.schema_version, component_definition_dbs.version,component_definition_dbs.styles,component_definition_dbs.capabilities").
189-
Where("component_definition_dbs.model_id = ?", _modelDB.Id)
190-
if err := finder.Scan(&components).Error; err != nil {
191-
return nil, 0, 0, err
188+
var componentCount int64
189+
db.Model(&component.ComponentDefinition{}).Where("component_definition_dbs.model_id = ?", _modelDB.Id).Count(&componentCount)
190+
var relationshipCount int64
191+
db.Model(&relationship.RelationshipDefinition{}).Where("relationship_definition_dbs.model_id = ?", _modelDB.Id).Count(&relationshipCount)
192+
_modelDB.ComponentsCount = int(componentCount)
193+
_modelDB.RelationshipsCount = int(relationshipCount)
194+
195+
// If Trim is true, only include the id, name, counts and metadata
196+
if mf.Trim {
197+
trimmedModel := &model.ModelDefinition{
198+
Id: _modelDB.Id,
199+
Name: _modelDB.Name,
200+
DisplayName: _modelDB.DisplayName,
201+
Metadata: _modelDB.Metadata,
202+
ComponentsCount: int(componentCount),
203+
RelationshipsCount: int(relationshipCount),
192204
}
193-
_modelDB.Components = components
194-
}
195-
if includeRelationships {
196-
var relationships []relationship.RelationshipDefinition
197-
finder := db.Model(&relationship.RelationshipDefinition{}).
198-
Select("relationship_definition_dbs.*").
199-
Where("relationship_definition_dbs.model_id = ?", _modelDB.Id)
200-
if err := finder.Scan(&relationships).Error; err != nil {
201-
return nil, 0, 0, err
205+
defs = append(defs, trimmedModel)
206+
207+
} else {
208+
if includeComponents {
209+
var components []component.ComponentDefinition
210+
finder := db.Model(&component.ComponentDefinition{}).
211+
Select("component_definition_dbs.*").
212+
Where("component_definition_dbs.model_id = ?", _modelDB.Id)
213+
if err := finder.Scan(&components).Error; err != nil {
214+
return nil, 0, 0, err
215+
}
216+
_modelDB.Components = components
217+
}
218+
if includeRelationships {
219+
var relationships []relationship.RelationshipDefinition
220+
finder := db.Model(&relationship.RelationshipDefinition{}).
221+
Select("relationship_definition_dbs.*").
222+
Where("relationship_definition_dbs.model_id = ?", _modelDB.Id)
223+
if err := finder.Scan(&relationships).Error; err != nil {
224+
return nil, 0, 0, err
225+
}
226+
_modelDB.Relationships = relationships
202227
}
203-
_modelDB.Relationships = relationships
228+
defs = append(defs, &_modelDB)
204229
}
205-
defs = append(defs, &_modelDB)
206230
}
207231
return defs, count, countUniqueModels(modelWithCategories), nil
208232
}

models/registration/register.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func (rh *RegistrationHelper) register(pkg PackagingUnit) {
8181
rh.svgBaseDir,
8282
model.Name,
8383
model.Name,
84+
true,
8485
)
8586
if svgCompletePath != "" {
8687
model.Metadata.SvgComplete = &svgCompletePath
@@ -120,6 +121,7 @@ func (rh *RegistrationHelper) register(pkg PackagingUnit) {
120121
rh.svgBaseDir,
121122
comp.Model.Name,
122123
comp.Component.Kind,
124+
false,
123125
)
124126
}
125127

models/registration/svg_helper.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func writeHashCheckSVG(key string, val string) {
2020
mx.Unlock()
2121
}
2222

23-
func WriteAndReplaceSVGWithFileSystemPath(svgColor, svgWhite, svgComplete string, baseDir, dirname, filename string) (svgColorPath, svgWhitePath, svgCompletePath string) {
23+
func WriteAndReplaceSVGWithFileSystemPath(svgColor, svgWhite, svgComplete string, baseDir, dirname, filename string, isModel bool) (svgColorPath, svgWhitePath, svgCompletePath string) {
2424
filename = strings.ToLower(filename)
2525
successCreatingDirectory := false
2626
defer func() {
@@ -40,7 +40,7 @@ func WriteAndReplaceSVGWithFileSystemPath(svgColor, svgWhite, svgComplete string
4040
hash := md5.Sum([]byte(svgColor))
4141
hashString := hex.EncodeToString(hash[:])
4242
pathsvg := hashCheckSVG[hashString]
43-
if pathsvg != "" { // the image has already been loaded, point the component to that path
43+
if pathsvg != "" && !isModel { // the image has already been loaded, point the component to that path
4444
svgColorPath = pathsvg
4545
goto White
4646
}
@@ -59,7 +59,7 @@ func WriteAndReplaceSVGWithFileSystemPath(svgColor, svgWhite, svgComplete string
5959

6060
}
6161
White:
62-
if svgWhite != "" {
62+
if svgWhite != "" && !isModel {
6363
path := filepath.Join(baseDir, dirname, "white")
6464
err := os.MkdirAll(path, 0777)
6565
if err != nil {
@@ -90,7 +90,7 @@ White:
9090

9191
}
9292
Complete:
93-
if svgComplete != "" {
93+
if svgComplete != "" && !isModel {
9494
path := filepath.Join(baseDir, dirname, "complete")
9595
err := os.MkdirAll(path, 0777)
9696
if err != nil {
@@ -123,8 +123,6 @@ Complete:
123123
return
124124
}
125125

126-
// func WriteAndReplaceSVGWithFileSystemPath(metadata map[string]interface{}, baseDir, dirname, filename string) {
127-
128126
func getRelativePathForAPI(baseDir, path string) string {
129127
ui := strings.TrimPrefix(baseDir, "../../")
130128
return filepath.Join(ui, path)

0 commit comments

Comments
 (0)