Skip to content

Commit

Permalink
Merge pull request #558 from MUzairS15/MUzairS15/feat/v1beta1
Browse files Browse the repository at this point in the history
[Models] Migrating to `v1beta1` constructs.
  • Loading branch information
Mohd Uzair authored Aug 13, 2024
2 parents ca535ba + a7afe56 commit 9846521
Show file tree
Hide file tree
Showing 38 changed files with 597 additions and 1,068 deletions.
2 changes: 1 addition & 1 deletion cmd/syncmodutil/internal/modsync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func getRequiredVersionsFromString(s string) (p []Package) {
if pkg == "" {
continue
}

pkgName, pkgVersion := getPackageAndVersionFromPackageVersion(pkg)
if strings.HasPrefix(pkgName, "//") { //Has been commented out
continue
Expand Down
5 changes: 5 additions & 0 deletions generators/artifacthub/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package artifacthub

const (
ArtifactHub = "artifacthub"
)
19 changes: 9 additions & 10 deletions generators/artifacthub/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"strings"
"time"

"github.com/layer5io/meshkit/models/meshmodel/core/v1beta1"
"github.com/layer5io/meshkit/utils"
"github.com/layer5io/meshkit/utils/component"
"github.com/layer5io/meshkit/utils/manifests"
_component "github.com/meshery/schemas/models/v1beta1/component"
"github.com/meshery/schemas/models/v1beta1/category"
"gopkg.in/yaml.v2"
)

Expand All @@ -36,8 +37,8 @@ func (pkg AhPackage) GetVersion() string {
return pkg.Version
}

func (pkg AhPackage) GenerateComponents() ([]v1beta1.ComponentDefinition, error) {
components := make([]v1beta1.ComponentDefinition, 0)
func (pkg AhPackage) GenerateComponents() ([]_component.ComponentDefinition, error) {
components := make([]_component.ComponentDefinition, 0)
// TODO: Move this to the configuration

if pkg.ChartUrl == "" {
Expand All @@ -52,16 +53,14 @@ func (pkg AhPackage) GenerateComponents() ([]v1beta1.ComponentDefinition, error)
if err != nil {
continue
}
if comp.Metadata == nil {
comp.Metadata = make(map[string]interface{})

if comp.Model.Metadata.AdditionalProperties == nil {
comp.Model.Metadata.AdditionalProperties = make(map[string]interface{})
}
if comp.Model.Metadata == nil {
comp.Model.Metadata = make(map[string]interface{})
}
comp.Model.Metadata["source_uri"] = pkg.ChartUrl
comp.Model.Metadata.AdditionalProperties["source_uri"] = pkg.ChartUrl
comp.Model.Version = pkg.Version
comp.Model.Name = pkg.Name
comp.Model.Category = v1beta1.Category{
comp.Model.Category = category.CategoryDefinition{
Name: "",
}
comp.Model.DisplayName = manifests.FormatToReadableString(comp.Model.Name)
Expand Down
5 changes: 5 additions & 0 deletions generators/github/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package github

const (
GitHub = "github"
)
18 changes: 8 additions & 10 deletions generators/github/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"bytes"
"os"

"github.com/layer5io/meshkit/models/meshmodel/core/v1beta1"
"github.com/layer5io/meshkit/utils"
"github.com/layer5io/meshkit/utils/component"
"github.com/layer5io/meshkit/utils/manifests"
"github.com/meshery/schemas/models/v1beta1/category"
_component "github.com/meshery/schemas/models/v1beta1/component"
)

type GitHubPackage struct {
Expand All @@ -23,8 +24,8 @@ func (gp GitHubPackage) GetVersion() string {
return gp.version
}

func (gp GitHubPackage) GenerateComponents() ([]v1beta1.ComponentDefinition, error) {
components := make([]v1beta1.ComponentDefinition, 0)
func (gp GitHubPackage) GenerateComponents() ([]_component.ComponentDefinition, error) {
components := make([]_component.ComponentDefinition, 0)

data, err := os.ReadFile(gp.filePath)
if err != nil {
Expand All @@ -39,17 +40,14 @@ func (gp GitHubPackage) GenerateComponents() ([]v1beta1.ComponentDefinition, err
if err != nil {
continue
}
if comp.Metadata == nil {
comp.Metadata = make(map[string]interface{})
}
if comp.Model.Metadata == nil {
comp.Model.Metadata = make(map[string]interface{})
if comp.Model.Metadata.AdditionalProperties == nil {
comp.Model.Metadata.AdditionalProperties = make(map[string]interface{})
}

comp.Model.Metadata["source_uri"] = gp.SourceURL
comp.Model.Metadata.AdditionalProperties["source_uri"] = gp.SourceURL
comp.Model.Version = gp.version
comp.Model.Name = gp.Name
comp.Model.Category = v1beta1.Category{
comp.Model.Category = category.CategoryDefinition{
Name: "",
}
comp.Model.DisplayName = manifests.FormatToReadableString(comp.Model.Name)
Expand Down
4 changes: 2 additions & 2 deletions generators/models/interfaces.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package models

import "github.com/layer5io/meshkit/models/meshmodel/core/v1beta1"
import "github.com/meshery/schemas/models/v1beta1/component"

// anything that can be validated is a Validator
type Validator interface {
Expand All @@ -11,7 +11,7 @@ type Validator interface {
// system's capabilities in Meshery
// A Package should have all the information that we need to generate the components
type Package interface {
GenerateComponents() ([]v1beta1.ComponentDefinition, error)
GenerateComponents() ([]component.ComponentDefinition, error)
GetVersion() string
}

Expand Down
73 changes: 35 additions & 38 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ require (
github.com/fluxcd/pkg/oci v0.34.0
github.com/fluxcd/pkg/tar v0.4.0
github.com/go-git/go-git/v5 v5.11.0
github.com/go-logr/logr v1.3.0
github.com/go-logr/logr v1.4.2
github.com/gofrs/uuid v4.4.0+incompatible
github.com/google/go-containerregistry v0.17.0
github.com/google/uuid v1.5.0
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.9
github.com/meshery/schemas v0.7.17
github.com/nats-io/nats.go v1.31.0
github.com/open-policy-agent/opa v0.57.1
github.com/opencontainers/image-spec v1.1.0-rc6
github.com/open-policy-agent/opa v0.67.1
github.com/opencontainers/image-spec v1.1.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.17.0
golang.org/x/oauth2 v0.15.0
golang.org/x/text v0.14.0
google.golang.org/api v0.152.0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.18.2
golang.org/x/oauth2 v0.20.0
golang.org/x/text v0.16.0
google.golang.org/api v0.153.0
gopkg.in/yaml.v2 v2.4.0
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.5
gorm.io/gorm v1.25.11
helm.sh/helm/v3 v3.13.2
k8s.io/api v0.28.4
k8s.io/apimachinery v0.28.4
Expand All @@ -50,8 +50,7 @@ require (
)

require (
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 // indirect
Expand All @@ -64,8 +63,7 @@ require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/OneOfOne/xxhash v1.2.8 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/agnivade/levenshtein v1.1.1 // indirect
Expand All @@ -85,12 +83,14 @@ require (
github.com/aws/aws-sdk-go-v2/service/sts v1.26.5 // indirect
github.com/aws/smithy-go v1.19.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/containerd/containerd v1.7.11 // indirect
github.com/containerd/containerd v1.7.20 // indirect
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
Expand Down Expand Up @@ -129,7 +129,7 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
Expand Down Expand Up @@ -172,7 +172,6 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
Expand Down Expand Up @@ -200,9 +199,9 @@ require (
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/rubenv/sql-migrate v1.5.2 // indirect
Expand All @@ -226,26 +225,24 @@ require (
github.com/xlab/treeprint v1.2.0 // indirect
github.com/yashtewari/glob-intersection v0.2.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.16.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/grpc v1.60.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
Loading

0 comments on commit 9846521

Please sign in to comment.