-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathconfig.go
More file actions
73 lines (64 loc) · 2.21 KB
/
Copy pathconfig.go
File metadata and controls
73 lines (64 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package build
import (
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
"strings"
"github.com/layer5io/meshery-adapter-library/adapter"
"github.com/layer5io/meshkit/utils"
"github.com/layer5io/meshkit/utils/manifests"
smp "github.com/layer5io/service-mesh-performance/spec"
)
var DefaultGenerationMethod string
var DefaultGenerationURL string
var LatestVersion string
var MeshModelPath string
var AllVersions []string
const Component = "NGINX Service Mesh"
var Meshmodelmetadata = make(map[string]interface{})
var MeshModelConfig = adapter.MeshModelConfig{ //Move to build/config.go
Category: "Cloud Native Network",
Metadata: map[string]interface{}{},
}
// NewConfig creates the configuration for creating components
func NewConfig(version string) manifests.Config {
return manifests.Config{
Name: smp.ServiceMesh_Type_name[int32(smp.ServiceMesh_NGINX_SERVICE_MESH)],
Type: Component,
MeshVersion: version,
CrdFilter: manifests.NewCueCrdFilter(manifests.ExtractorPaths{
NamePath: "spec.names.kind",
IdPath: "spec.names.kind",
VersionPath: "spec.versions[0].name",
GroupPath: "spec.group",
SpecPath: "spec.versions[0].schema.openAPIV3Schema.properties.spec"}, false),
ExtractCrds: func(manifest string) []string {
crds := strings.Split(manifest, "---")
return crds
},
}
}
func init() {
f, _ := os.Open("./build/meshmodel_metadata.json")
defer func() {
if err := f.Close(); err != nil {
fmt.Printf("Error closing file: %s\n", err)
}
}()
byt, _ := io.ReadAll(f)
_ = json.Unmarshal(byt, &MeshModelConfig.Metadata)
wd, _ := os.Getwd()
MeshModelPath = filepath.Join(wd, "templates", "meshmodel", "components")
AllVersions, _ = utils.GetLatestReleaseTagsSorted("nginxinc", "nginx-service-mesh")
if len(AllVersions) == 0 {
return
}
// @TODO need to update this, because NGINX changes how they relate the version of the NGINX
// Service Mesh to the official release/branch which is v1.7.0 -> v0.7.0
// LatestVersion = AllVersions[len(AllVersions)-1]
LatestVersion = "0.7.0"
DefaultGenerationMethod = adapter.HelmCHARTS
DefaultGenerationURL = "https://github.com/nginxinc/helm-charts/blob/master/stable/nginx-service-mesh-" + LatestVersion + ".tgz?raw=true"
}