Skip to content

Commit

Permalink
Merge branch 'master' into missingNameSpace
Browse files Browse the repository at this point in the history
  • Loading branch information
Jougan-0 authored Oct 15, 2024
2 parents 4224be0 + 140d9a5 commit 4c91ba6
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 35 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/slack.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
name: Slack Notify on Star
on: watch
name: Slack Notify
on:
watch:
types: [started]
jobs:
star-notify:
if: github.event_name == 'watch'
name: Notify Slack on star
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Get current star count
run: |
echo "STARS=$(curl --silent 'https://api.github.com/repos/layer5io/meshkit' -H 'Accept: application/vnd.github.preview' | jq '.watchers_count')" >> $GITHUB_ENV
echo "STARS=$(curl --silent 'https://api.github.com/repos/${{github.repository}}' -H 'Accept: application/vnd.github.preview' | jq '.stargazers_count')" >> $GITHUB_ENV
- name: Notify slack
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: pullreminders/slack-action@master
with:
args: '{\"channel\":\"CSK7N9TGX\",\"text\":\"${{ github.actor }} just starred Meshkit! (https://github.com/layer5io/meshkit/stargazers) Total ⭐️: ${{env.STARS}}\"}'
args: '{\"channel\":\"CSK7N9TGX\",\"text\":\"${{ github.actor }} just starred ${{github.repository}}! (https://github.com/${{github.repository}}/stargazers) Total ⭐️: ${{env.STARS}}\"}'
good-first-issue-notify:
if: github.event_name == 'issues' && github.event.label.name == 'good first issue' || github.event.label.name == 'first-timers-only'
name: Notify Slack for new good-first-issue
runs-on: ubuntu-22.04
steps:
- name: Notify slack
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: pullreminders/slack-action@master
with:
args: '{\"channel\":\"C019426UBNY\",\"text\":\"A good first issue label was just added to ${{github.event.issue.html_url}}.\"}'
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/google/uuid v1.6.0
github.com/kubernetes/kompose v1.31.1
github.com/layer5io/meshery-operator v0.7.0
github.com/meshery/schemas v0.7.31
github.com/meshery/schemas v0.7.36
github.com/nats-io/nats.go v1.31.0
github.com/open-policy-agent/opa v0.67.1
github.com/opencontainers/image-spec v1.1.0
Expand All @@ -39,7 +39,7 @@ require (
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/postgres v1.5.3
gorm.io/driver/sqlite v1.5.4
gorm.io/gorm v1.25.11
gorm.io/gorm v1.25.12
helm.sh/helm/v3 v3.13.2
k8s.io/api v0.28.4
k8s.io/apimachinery v0.28.4
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@ github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/meshery/kompose v1.0.1 h1:lg8B/pkLh6762jeFsQATD8UJZZwXZf/aviC3/dzw78A=
github.com/meshery/kompose v1.0.1/go.mod h1:TWhWTEMbJBUzENf4JTEtBmZRFm/r8n0nS6v4/nSD2vA=
github.com/meshery/schemas v0.7.31 h1:FfVR+oErAiiEomt6sTZI5uKhoyU26QXawT6UDZHbthI=
github.com/meshery/schemas v0.7.31/go.mod h1:UfiO+zm92yLkaJP0aroNwVnjuozoh793AWDXrKDYmT0=
github.com/meshery/schemas v0.7.36 h1:KQOz/SODr+T6fDS2lDSrNo/Eu3LCaEUGIRauQtvXkjg=
github.com/meshery/schemas v0.7.36/go.mod h1:wOh519/EDxiYlC4aeGv74ru+t9h9VJ4P2JYIvSfdPWQ=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM=
github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk=
Expand Down Expand Up @@ -1198,8 +1198,8 @@ gorm.io/driver/postgres v1.5.3 h1:qKGY5CPHOuj47K/VxbCXJfFvIUeqMSXXadqdCY+MbBU=
gorm.io/driver/postgres v1.5.3/go.mod h1:F+LtvlFhZT7UBiA81mC9W6Su3D4WUhSboc/36QZU0gk=
gorm.io/driver/sqlite v1.5.4 h1:IqXwXi8M/ZlPzH/947tn5uik3aYQslP9BVveoax0nV0=
gorm.io/driver/sqlite v1.5.4/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4=
gorm.io/gorm v1.25.11 h1:/Wfyg1B/je1hnDx3sMkX+gAlxrlZpn6X0BXRlwXlvHg=
gorm.io/gorm v1.25.11/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o=
Expand Down
60 changes: 42 additions & 18 deletions models/meshmodel/registry/v1beta1/model_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ type ModelFilter struct {
Components bool
Relationships bool
Status string
// When Trim is true it will only send necessary models data
// like: component count, relationship count, id and name of model
Trim bool
}

// Create the filter from map[string]interface{}
Expand Down Expand Up @@ -182,27 +185,48 @@ func (mf *ModelFilter) Get(db *database.Handler) ([]entity.Entity, int64, int, e
for _, modelDB := range modelWithCategories {
// resolve for loop scope
_modelDB := modelDB
if includeComponents {
var components []component.ComponentDefinition
finder := db.Model(&component.ComponentDefinition{}).
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").
Where("component_definition_dbs.model_id = ?", _modelDB.Id)
if err := finder.Scan(&components).Error; err != nil {
return nil, 0, 0, err
var componentCount int64
db.Model(&component.ComponentDefinition{}).Where("component_definition_dbs.model_id = ?", _modelDB.Id).Count(&componentCount)
var relationshipCount int64
db.Model(&relationship.RelationshipDefinition{}).Where("relationship_definition_dbs.model_id = ?", _modelDB.Id).Count(&relationshipCount)
_modelDB.ComponentsCount = int(componentCount)
_modelDB.RelationshipsCount = int(relationshipCount)

// If Trim is true, only include the id, name, counts and metadata
if mf.Trim {
trimmedModel := &model.ModelDefinition{
Id: _modelDB.Id,
Name: _modelDB.Name,
DisplayName: _modelDB.DisplayName,
Metadata: _modelDB.Metadata,
ComponentsCount: int(componentCount),
RelationshipsCount: int(relationshipCount),
}
_modelDB.Components = components
}
if includeRelationships {
var relationships []relationship.RelationshipDefinition
finder := db.Model(&relationship.RelationshipDefinition{}).
Select("relationship_definition_dbs.*").
Where("relationship_definition_dbs.model_id = ?", _modelDB.Id)
if err := finder.Scan(&relationships).Error; err != nil {
return nil, 0, 0, err
defs = append(defs, trimmedModel)

} else {
if includeComponents {
var components []component.ComponentDefinition
finder := db.Model(&component.ComponentDefinition{}).
Select("component_definition_dbs.*").
Where("component_definition_dbs.model_id = ?", _modelDB.Id)
if err := finder.Scan(&components).Error; err != nil {
return nil, 0, 0, err
}
_modelDB.Components = components
}
if includeRelationships {
var relationships []relationship.RelationshipDefinition
finder := db.Model(&relationship.RelationshipDefinition{}).
Select("relationship_definition_dbs.*").
Where("relationship_definition_dbs.model_id = ?", _modelDB.Id)
if err := finder.Scan(&relationships).Error; err != nil {
return nil, 0, 0, err
}
_modelDB.Relationships = relationships
}
_modelDB.Relationships = relationships
defs = append(defs, &_modelDB)
}
defs = append(defs, &_modelDB)
}
return defs, count, countUniqueModels(modelWithCategories), nil
}
2 changes: 2 additions & 0 deletions models/registration/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (rh *RegistrationHelper) register(pkg PackagingUnit) {
rh.svgBaseDir,
model.Name,
model.Name,
true,
)
if svgCompletePath != "" {
model.Metadata.SvgComplete = &svgCompletePath
Expand Down Expand Up @@ -120,6 +121,7 @@ func (rh *RegistrationHelper) register(pkg PackagingUnit) {
rh.svgBaseDir,
comp.Model.Name,
comp.Component.Kind,
false,
)
}

Expand Down
10 changes: 4 additions & 6 deletions models/registration/svg_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func writeHashCheckSVG(key string, val string) {
mx.Unlock()
}

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

}
White:
if svgWhite != "" {
if svgWhite != "" && !isModel {
path := filepath.Join(baseDir, dirname, "white")
err := os.MkdirAll(path, 0777)
if err != nil {
Expand Down Expand Up @@ -90,7 +90,7 @@ White:

}
Complete:
if svgComplete != "" {
if svgComplete != "" && !isModel {
path := filepath.Join(baseDir, dirname, "complete")
err := os.MkdirAll(path, 0777)
if err != nil {
Expand Down Expand Up @@ -123,8 +123,6 @@ Complete:
return
}

// func WriteAndReplaceSVGWithFileSystemPath(metadata map[string]interface{}, baseDir, dirname, filename string) {

func getRelativePathForAPI(baseDir, path string) string {
ui := strings.TrimPrefix(baseDir, "../../")
return filepath.Join(ui, path)
Expand Down

0 comments on commit 4c91ba6

Please sign in to comment.