Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion generators/artifacthub/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ func (pkg AhPackage) GenerateComponents(group string) ([]_component.ComponentDef
comp.Model = &model.ModelDefinition{}
}
if comp.Model.Metadata == nil {
comp.Model.Metadata = &model.ModelDefinition_Metadata{}
now := time.Now()
comp.Model.Metadata = &model.ModelDefinition_Metadata{
CreatedAt: &now,
}
}

if comp.Model.Metadata.AdditionalProperties == nil {
Expand Down
6 changes: 5 additions & 1 deletion generators/github/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io"
"os"
"time"

"github.com/meshery/meshkit/utils"
"github.com/meshery/meshkit/utils/component"
Expand Down Expand Up @@ -96,7 +97,10 @@ func (gp GitHubPackage) GenerateComponents(group string) ([]_component.Component
comp.Model = &model.ModelDefinition{}
}
if comp.Model.Metadata == nil {
comp.Model.Metadata = &model.ModelDefinition_Metadata{}
now := time.Now()
comp.Model.Metadata = &model.ModelDefinition_Metadata{
CreatedAt: &now,
}
}
if comp.Model.Metadata.AdditionalProperties == nil {
comp.Model.Metadata.AdditionalProperties = make(map[string]interface{})
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,7 @@ require (
sigs.k8s.io/structured-merge-diff/v6 v6.3.1 // indirect
)

replace github.com/meshery/meshkit => ../meshkit
replace (
github.com/meshery/meshkit => ../meshkit
github.com/meshery/schemas => ../schemas
Comment on lines +309 to +310
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should never be pushed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove it and push the code ASAP

)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,6 @@ github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuE
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/meshery/meshery-operator v0.8.11 h1:eDo2Sw0jjVrXsvvhF8LenADM58pK+7Z68ROPVIejTPc=
github.com/meshery/meshery-operator v0.8.11/go.mod h1:hQEtFKKa5Fr/Mskk6bV5ip3bQ0+3F0u1voYS3XisBp4=
github.com/meshery/schemas v0.8.94 h1:Xmjc0+MKUbvFPO/LmS4/0ncVqPpHqID3tuThn4QltQ0=
github.com/meshery/schemas v0.8.94/go.mod h1:1GRdkWXLCzL6Y664T8JWpGMW9EtLaaBMxYD+u4GMG1M=
github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM=
github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
Expand Down
15 changes: 12 additions & 3 deletions registry/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ var modelMetadataValues = []string{
func (m *ModelCSV) UpdateModelDefinition(modelDef *_model.ModelDefinition) error {
metadata := modelDef.Metadata
if metadata == nil {
metadata = &_model.ModelDefinition_Metadata{}
now := time.Now()
metadata = &_model.ModelDefinition_Metadata{
CreatedAt: &now,
}
}
if metadata.AdditionalProperties == nil {
metadata.AdditionalProperties = make(map[string]interface{})
Expand Down Expand Up @@ -626,7 +629,10 @@ func GenerateComponentsFromPkg(pkg models.Package, compDirPath string, defVersio
for _, comp := range comps {
comp.Version = defVersion
if modelDef.Metadata == nil {
modelDef.Metadata = &_model.ModelDefinition_Metadata{}
now := time.Now()
modelDef.Metadata = &_model.ModelDefinition_Metadata{
CreatedAt: &now,
}
}
if modelDef.Metadata.AdditionalProperties == nil {
modelDef.Metadata.AdditionalProperties = make(map[string]interface{})
Expand Down Expand Up @@ -918,7 +924,10 @@ func InvokeGenerationFromSheet(wg *sync.WaitGroup, path string, modelsheetID, co
// i.e., If model is enabled, comps are also "enabled". Ultimately, all individual comps will have the ability to control their status.
// The status "enabled" indicates that the component will be registered inside the registry.
if modelDef.Metadata == nil {
modelDef.Metadata = &_model.ModelDefinition_Metadata{}
now := time.Now()
modelDef.Metadata = &_model.ModelDefinition_Metadata{
CreatedAt: &now,
}
}
if modelDef.Metadata.AdditionalProperties == nil {
modelDef.Metadata.AdditionalProperties = make(map[string]interface{})
Expand Down
15 changes: 10 additions & 5 deletions utils/component/openapi_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"strings"
"time"

"cuelang.org/go/cue"
"cuelang.org/go/cue/cuecontext"
Expand Down Expand Up @@ -121,6 +122,14 @@ func GenerateFromOpenAPI(resource string, pkg models.Package) ([]component.Compo
}
}

now := time.Now()
metadata := &model.ModelDefinition_Metadata{
CreatedAt: &now,
}
if metadata.AdditionalProperties == nil {
metadata.AdditionalProperties = make(map[string]interface{})
}
metadata.AdditionalProperties["source_uri"] = pkg.GetSourceURL()
c := component.ComponentDefinition{
SchemaVersion: v1beta1.ComponentSchemaVersion,
Format: component.JSON,
Expand All @@ -140,11 +149,7 @@ func GenerateFromOpenAPI(resource string, pkg models.Package) ([]component.Compo
},
Name: pkg.GetName(),
DisplayName: manifests.FormatToReadableString(pkg.GetName()),
Metadata: &model.ModelDefinition_Metadata{
AdditionalProperties: map[string]interface{}{
"source_uri": pkg.GetSourceURL(),
},
},
Metadata: metadata,
},
}

Expand Down