diff --git a/api/v1/project.proto b/api/v1/project.proto index 92d623a44..50bafff1c 100644 --- a/api/v1/project.proto +++ b/api/v1/project.proto @@ -9,14 +9,14 @@ service ProjectService { } message GenerateCodeRequest { - string projectVersion = 1; + string compageCoreVersion = 1; string projectName = 2; string projectJSON = 3; - string gitRepositoryName = 4; - string gitPlatformName = 5; - string gitPlatformURL = 6; - string gitPlatformUserName = 7; - string projectMetadata = 8; + string projectMetadata = 4; + string gitRepositoryName = 5; + string gitPlatformName = 6; + string gitPlatformURL = 7; + string gitPlatformUserName = 8; } message GenerateCodeResponse{ diff --git a/cmd/dotnet-config.yaml.tmpl b/cmd/dotnet-config.yaml.tmpl index b26342eda..3b2cfc22a 100644 --- a/cmd/dotnet-config.yaml.tmpl +++ b/cmd/dotnet-config.yaml.tmpl @@ -1,5 +1,5 @@ name: {{.ProjectName}} -version: v1.0.0 +compageCoreVersion: v1.0.0 git: repository: name: {{.GitRepositoryName}} diff --git a/cmd/generate.go b/cmd/generate.go index 3ce8d18a8..29ebe226a 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -1,6 +1,7 @@ package cmd import ( + "encoding/json" ociregistry "github.com/intelops/compage/cmd/artifacts" "github.com/intelops/compage/cmd/models" "github.com/intelops/compage/internal/converter/cmd" @@ -62,38 +63,79 @@ func GenerateCode() error { return err } - if len(coreProject.License.Path) > 0 { - // assign absolute path to the license file Path if it's not - absPath, err := filepath.Abs(coreProject.License.Path) - if err != nil { - log.Errorf("error while getting absolute path [" + err.Error() + "]") - return err + if project.Metadata != nil { + license := &models.License{} + l, ok := project.Metadata["license"] + if ok { + // convert the license data to byte array + licenseData, err1 := json.Marshal(l) + if err1 != nil { + log.Errorf("error while marshalling license data [" + err1.Error() + "]") + return err1 + } + // convert the license data to license struct + err1 = json.Unmarshal(licenseData, license) + if err1 != nil { + log.Errorf("error while unmarshalling license data [" + err1.Error() + "]") + return err1 + } + // assign absolute path to the license file Path if it's not set + if len(license.Path) > 0 { + // assign absolute path to the license file Path if it's not + absPath, err2 := filepath.Abs(license.Path) + if err2 != nil { + log.Errorf("error while getting absolute path [" + err2.Error() + "]") + return err2 + } + license.Path = absPath + } + project.Metadata["license"] = license + } else { + log.Warn("license data not found in project metadata") } - coreProject.License.Path = absPath } // assign absolute path to the license file path if it's not (if supplied for the nodes) for _, node := range coreProject.CompageJSON.Nodes { - if len(node.License.Path) > 0 { - absPath, err := filepath.Abs(node.License.Path) - if err != nil { - log.Errorf("error while getting absolute path [" + err.Error() + "]") - return err + license := &models.License{} + l, ok := node.Metadata["license"] + if ok { + // convert the license data to byte array + licenseData, err1 := json.Marshal(l) + if err1 != nil { + log.Errorf("error while marshalling license data [" + err1.Error() + "]") + return err1 + } + // convert the license data to license struct + err1 = json.Unmarshal(licenseData, license) + if err1 != nil { + log.Errorf("error while unmarshalling license data [" + err1.Error() + "]") + return err1 + } + // assign absolute path to the license file Path if it's not set + if len(license.Path) > 0 { + // assign absolute path to the license file Path if it's not + absPath, err2 := filepath.Abs(license.Path) + if err2 != nil { + log.Errorf("error while getting absolute path [" + err2.Error() + "]") + return err2 + } + license.Path = absPath } - node.License.Path = absPath + node.Metadata["license"] = license } } // pull all required templates // pull the common templates - err = ociregistry.PullOCIArtifact("common", project.Version) + err = ociregistry.PullOCIArtifact("common", project.CompageCoreVersion) if err != nil { log.Errorf("error while pulling the common templates [" + err.Error() + "]") return err } for _, node := range coreProject.CompageJSON.Nodes { // make sure that the latest template is pulled - err = ociregistry.PullOCIArtifact(node.Language, project.Version) + err = ociregistry.PullOCIArtifact(node.Language, project.CompageCoreVersion) if err != nil { log.Errorf("error while pulling the template [" + err.Error() + "]") return err diff --git a/cmd/go-config.yaml.tmpl b/cmd/go-config.yaml.tmpl index dd8b1d448..1da1d6de5 100644 --- a/cmd/go-config.yaml.tmpl +++ b/cmd/go-config.yaml.tmpl @@ -1,5 +1,5 @@ name: {{.ProjectName}} -version: v1.0.0 +compageCoreVersion: v1.0.0 git: repository: name: {{.GitRepositoryName}} diff --git a/cmd/models/config.go b/cmd/models/config.go index 7835e88d7..d3b6e09e7 100644 --- a/cmd/models/config.go +++ b/cmd/models/config.go @@ -23,18 +23,17 @@ type GitDetails struct { } type License struct { - Name string `yaml:"name,omitempty"` - URL string `yaml:"url,omitempty"` - Path string `yaml:"path,omitempty"` + Name string `yaml:"name,omitempty" json:"name,omitempty"` + URL string `yaml:"url,omitempty" json:"url,omitempty"` + Path string `yaml:"path,omitempty" json:"path,omitempty"` } type Project struct { - Name string `yaml:"name"` - Version string `yaml:"version"` - License License `yaml:"license"` - GitDetails GitDetails `yaml:"git"` - CompageJSON map[string]interface{} `yaml:"compageJSON"` - ProjectMetadata string `yaml:"projectMetadata"` + Name string `yaml:"name"` + CompageCoreVersion string `yaml:"compageCoreVersion"` + GitDetails GitDetails `yaml:"git"` + CompageJSON map[string]interface{} `yaml:"compageJSON"` + Metadata map[string]interface{} `yaml:"metadata"` } func ReadConfigYAMLFile(configFile string) (*Project, error) { diff --git a/cmd/start.go b/cmd/start.go index 50e419470..45468ad27 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -52,28 +52,33 @@ This command will start thr gRPC server and allow the gRPC clients to get connec // this will be the version same as release (as the version is not configurable from the ui) // for local development, you can set the version in the environment variable - version := os.Getenv("COMPAGE_CORE_VERSION") - if version == "" { + compageCoreVersion := os.Getenv("COMPAGE_CORE_VERSION") + if compageCoreVersion == "" { // default version - version = "v1.0.0" + compageCoreVersion = "v1.0.0" + err := os.Setenv("COMPAGE_CORE_VERSION", compageCoreVersion) + if err != nil { + log.Errorf("error while setting environment variable COMPAGE_CORE_VERSION [%v]", err) + return + } } - err := ociregistry.PullOCIArtifact("common", version) + err := ociregistry.PullOCIArtifact("common", compageCoreVersion) cobra.CheckErr(err) - err = ociregistry.PullOCIArtifact("go", version) + err = ociregistry.PullOCIArtifact("go", compageCoreVersion) cobra.CheckErr(err) - err = ociregistry.PullOCIArtifact("python", version) + err = ociregistry.PullOCIArtifact("python", compageCoreVersion) cobra.CheckErr(err) - err = ociregistry.PullOCIArtifact("java", version) + err = ociregistry.PullOCIArtifact("java", compageCoreVersion) cobra.CheckErr(err) - err = ociregistry.PullOCIArtifact("javascript", version) + err = ociregistry.PullOCIArtifact("javascript", compageCoreVersion) cobra.CheckErr(err) - err = ociregistry.PullOCIArtifact("ruby", version) + err = ociregistry.PullOCIArtifact("ruby", compageCoreVersion) cobra.CheckErr(err) - err = ociregistry.PullOCIArtifact("rust", version) + err = ociregistry.PullOCIArtifact("rust", compageCoreVersion) cobra.CheckErr(err) - err = ociregistry.PullOCIArtifact("typescript", version) + err = ociregistry.PullOCIArtifact("typescript", compageCoreVersion) cobra.CheckErr(err) - err = ociregistry.PullOCIArtifact("dotnet", version) + err = ociregistry.PullOCIArtifact("dotnet", compageCoreVersion) cobra.CheckErr(err) // check if the language templates have been pulled (mainly need to check this on developer's machine) diff --git a/gen/api/v1/project.pb.go b/gen/api/v1/project.pb.go index eb540ae0f..943e99625 100644 --- a/gen/api/v1/project.pb.go +++ b/gen/api/v1/project.pb.go @@ -25,14 +25,14 @@ type GenerateCodeRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ProjectVersion string `protobuf:"bytes,1,opt,name=projectVersion,proto3" json:"projectVersion,omitempty"` + CompageCoreVersion string `protobuf:"bytes,1,opt,name=compageCoreVersion,proto3" json:"compageCoreVersion,omitempty"` ProjectName string `protobuf:"bytes,2,opt,name=projectName,proto3" json:"projectName,omitempty"` ProjectJSON string `protobuf:"bytes,3,opt,name=projectJSON,proto3" json:"projectJSON,omitempty"` - GitRepositoryName string `protobuf:"bytes,4,opt,name=gitRepositoryName,proto3" json:"gitRepositoryName,omitempty"` - GitPlatformName string `protobuf:"bytes,5,opt,name=gitPlatformName,proto3" json:"gitPlatformName,omitempty"` - GitPlatformURL string `protobuf:"bytes,6,opt,name=gitPlatformURL,proto3" json:"gitPlatformURL,omitempty"` - GitPlatformUserName string `protobuf:"bytes,7,opt,name=gitPlatformUserName,proto3" json:"gitPlatformUserName,omitempty"` - ProjectMetadata string `protobuf:"bytes,8,opt,name=projectMetadata,proto3" json:"projectMetadata,omitempty"` + ProjectMetadata string `protobuf:"bytes,4,opt,name=projectMetadata,proto3" json:"projectMetadata,omitempty"` + GitRepositoryName string `protobuf:"bytes,5,opt,name=gitRepositoryName,proto3" json:"gitRepositoryName,omitempty"` + GitPlatformName string `protobuf:"bytes,6,opt,name=gitPlatformName,proto3" json:"gitPlatformName,omitempty"` + GitPlatformURL string `protobuf:"bytes,7,opt,name=gitPlatformURL,proto3" json:"gitPlatformURL,omitempty"` + GitPlatformUserName string `protobuf:"bytes,8,opt,name=gitPlatformUserName,proto3" json:"gitPlatformUserName,omitempty"` } func (x *GenerateCodeRequest) Reset() { @@ -67,9 +67,9 @@ func (*GenerateCodeRequest) Descriptor() ([]byte, []int) { return file_api_v1_project_proto_rawDescGZIP(), []int{0} } -func (x *GenerateCodeRequest) GetProjectVersion() string { +func (x *GenerateCodeRequest) GetCompageCoreVersion() string { if x != nil { - return x.ProjectVersion + return x.CompageCoreVersion } return "" } @@ -88,6 +88,13 @@ func (x *GenerateCodeRequest) GetProjectJSON() string { return "" } +func (x *GenerateCodeRequest) GetProjectMetadata() string { + if x != nil { + return x.ProjectMetadata + } + return "" +} + func (x *GenerateCodeRequest) GetGitRepositoryName() string { if x != nil { return x.GitRepositoryName @@ -116,13 +123,6 @@ func (x *GenerateCodeRequest) GetGitPlatformUserName() string { return "" } -func (x *GenerateCodeRequest) GetProjectMetadata() string { - if x != nil { - return x.ProjectMetadata - } - return "" -} - type GenerateCodeResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -174,48 +174,48 @@ var File_api_v1_project_proto protoreflect.FileDescriptor var file_api_v1_project_proto_rawDesc = []byte{ 0x0a, 0x14, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x22, 0xdd, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x22, 0xe5, 0x02, 0x0a, 0x13, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, - 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, - 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x20, - 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, - 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4a, 0x53, 0x4f, 0x4e, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4a, 0x53, - 0x4f, 0x4e, 0x12, 0x2c, 0x0a, 0x11, 0x67, 0x69, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x67, - 0x69, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x4e, 0x61, 0x6d, 0x65, - 0x12, 0x28, 0x0a, 0x0f, 0x67, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x4e, - 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x67, 0x69, 0x74, 0x50, 0x6c, - 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x67, 0x69, - 0x74, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x55, 0x52, 0x4c, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0e, 0x67, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x55, - 0x52, 0x4c, 0x12, 0x30, 0x0a, 0x13, 0x67, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, - 0x6d, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x13, 0x67, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x55, 0x73, 0x65, 0x72, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x70, - 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x34, - 0x0a, 0x14, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x68, - 0x75, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x43, - 0x68, 0x75, 0x6e, 0x6b, 0x32, 0xb0, 0x01, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4d, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x72, - 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, - 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x4f, 0x0a, 0x0e, 0x52, 0x65, 0x67, 0x65, 0x6e, 0x65, - 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, - 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x6c, 0x6f, 0x70, 0x73, 0x2f, 0x63, - 0x6f, 0x6d, 0x70, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, - 0x31, 0x3b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x67, + 0x65, 0x43, 0x6f, 0x72, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x12, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x72, 0x65, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x28, 0x0a, 0x0f, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x12, 0x2c, 0x0a, 0x11, 0x67, 0x69, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x11, 0x67, 0x69, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x67, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, + 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x67, 0x69, 0x74, + 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e, + 0x67, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x55, 0x52, 0x4c, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x67, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, + 0x6d, 0x55, 0x52, 0x4c, 0x12, 0x30, 0x0a, 0x13, 0x67, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x74, 0x66, + 0x6f, 0x72, 0x6d, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x13, 0x67, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x55, 0x73, + 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x34, 0x0a, 0x14, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, + 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, + 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x32, 0xb0, 0x01, 0x0a, + 0x0e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x4d, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, + 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, + 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x4f, + 0x0a, 0x0e, 0x52, 0x65, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, + 0x12, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, + 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, + 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x42, + 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x6c, 0x6f, 0x70, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x67, 0x65, 0x2f, 0x67, + 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/internal/converter/cmd/converter.go b/internal/converter/cmd/converter.go index 726ecd57d..494bc5f7e 100644 --- a/internal/converter/cmd/converter.go +++ b/internal/converter/cmd/converter.go @@ -1,11 +1,11 @@ package cmd import ( + "github.com/intelops/compage/internal/converter" log "github.com/sirupsen/logrus" "time" "github.com/intelops/compage/cmd/models" - "github.com/intelops/compage/internal/converter" "github.com/intelops/compage/internal/core" ) @@ -20,14 +20,13 @@ func GetProject(input *models.Project) (*core.Project, error) { return &core.Project{ CompageJSON: compageJSON, Name: input.Name, - Version: input.Version, - License: &input.License, + CompageCoreVersion: input.CompageCoreVersion, GitPlatformName: input.GitDetails.Platform.Name, GitPlatformURL: input.GitDetails.Platform.URL, GitPlatformUserName: input.GitDetails.Platform.UserName, GitRepositoryName: input.GitDetails.Repository.Name, GitRepositoryURL: input.GitDetails.Repository.URL, - Metadata: converter.GetMetadata(input.ProjectMetadata), + Metadata: input.Metadata, ModificationDetails: core.ModificationDetails{ CreatedBy: input.GitDetails.Platform.UserName, UpdatedBy: input.GitDetails.Platform.UserName, diff --git a/internal/converter/grpc/converter.go b/internal/converter/grpc/converter.go index bab496f04..fe31ebe44 100644 --- a/internal/converter/grpc/converter.go +++ b/internal/converter/grpc/converter.go @@ -5,6 +5,7 @@ import ( "github.com/intelops/compage/internal/converter" "github.com/intelops/compage/internal/core" log "github.com/sirupsen/logrus" + "os" "time" ) @@ -15,12 +16,21 @@ func GetProject(input *project.GenerateCodeRequest) (*core.Project, error) { log.Errorf("error getting compageJSON: %v", err) return nil, err } + if len(input.CompageCoreVersion) == 0 { + compageCoreVersion := os.Getenv("COMPAGE_CORE_VERSION") + if compageCoreVersion != "" { + input.CompageCoreVersion = compageCoreVersion + } else { + log.Errorf("COMPAGE_CORE_VERSION is not set in the environment variables") + return nil, err + } + } return &core.Project{ CompageJSON: compageJSON, Name: input.ProjectName, // latest is the tag for every ui based request - Version: input.ProjectVersion, + CompageCoreVersion: input.CompageCoreVersion, GitRepositoryName: input.GitRepositoryName, GitPlatformUserName: input.GitPlatformUserName, GitPlatformURL: input.GitPlatformURL, diff --git a/internal/core/models.go b/internal/core/models.go index 8efe82af5..fc37c23f2 100644 --- a/internal/core/models.go +++ b/internal/core/models.go @@ -1,7 +1,6 @@ package core import ( - "github.com/intelops/compage/cmd/models" coreedge "github.com/intelops/compage/internal/core/edge" corenode "github.com/intelops/compage/internal/core/node" "time" @@ -19,8 +18,7 @@ type ModificationDetails struct { // It has a single compage.json and can have multiple nodes and edges (projects and connections) internally. type Project struct { Name string `json:"name"` - Version string `json:"version"` - License *models.License `json:"license"` + CompageCoreVersion string `json:"compageCoreVersion"` CompageJSON *CompageJSON `json:"compageJSON"` GitRepositoryName string `json:"gitRepositoryName"` GitRepositoryURL string `json:"gitRepositoryURL"` diff --git a/internal/core/node/node.go b/internal/core/node/node.go index 6233d6835..c01e108f9 100644 --- a/internal/core/node/node.go +++ b/internal/core/node/node.go @@ -7,8 +7,6 @@ type Node struct { Language string `json:"language"` // Name of a component (required, this will be service and deployment name). Name string `json:"name"` - // License of the component. - License *License `json:"license"` // RestConfig holds all config related to REST. If nil, it means that the node is not REST server or has REST clients. RestConfig *RestConfig `json:"restConfig,omitempty"` // GrpcConfig holds all config related to gRPC. If nil, it means that the node is not gRPC server or has gRPC clients. diff --git a/internal/integrations/deepsource/copier.go b/internal/integrations/deepsource/copier.go index f7338325f..7c7bf0fa9 100644 --- a/internal/integrations/deepsource/copier.go +++ b/internal/integrations/deepsource/copier.go @@ -24,7 +24,7 @@ func NewCopier(project *core.Project) (*Copier, error) { "GitPlatformUserName": project.GitPlatformUserName, } - templatesRootPath, err := utils.GetTemplatesRootPath("common-templates/", project.Version) + templatesRootPath, err := utils.GetTemplatesRootPath("common-templates/", project.CompageCoreVersion) if err != nil { log.Errorf("error while getting the project root path [" + err.Error() + "]") return nil, err diff --git a/internal/integrations/license/copier.go b/internal/integrations/license/copier.go index b1ad12897..d78a3602b 100644 --- a/internal/integrations/license/copier.go +++ b/internal/integrations/license/copier.go @@ -1,6 +1,7 @@ package license import ( + "encoding/json" "github.com/intelops/compage/cmd/models" "github.com/intelops/compage/internal/core" "github.com/intelops/compage/internal/languages/executor" @@ -26,18 +27,41 @@ func NewCopier(project *core.Project) (*Copier, error) { "GitPlatformUserName": project.GitPlatformUserName, } - templatesRootPath, err := utils.GetTemplatesRootPath("common-templates/", project.Version) + templatesRootPath, err := utils.GetTemplatesRootPath("common-templates/", project.CompageCoreVersion) if err != nil { log.Errorf("error while getting the project root path [" + err.Error() + "]") return nil, err } + // extract license from metadata + license := &models.License{} + if project.Metadata != nil { + l, ok := project.Metadata["license"] + if ok { + licenseData, err1 := json.Marshal(l) + if err1 != nil { + log.Errorf("error while marshalling license data [" + err1.Error() + "]") + return nil, err1 + } + // for license data + err1 = json.Unmarshal(licenseData, license) + if err1 != nil { + log.Errorf("error while unmarshalling license data [" + err1.Error() + "]") + return nil, err1 + } + // this is not required to be set back as we are not modifying the license data + //project.Metadata["license"] = license + } else { + log.Warn("license data not found in project metadata") + } + } + return &Copier{ // TODO change this path to constant. Add language specific analysers in a generic way later. TemplatesRootPath: templatesRootPath, ProjectDirectoryName: utils.GetProjectDirectoryName(project.Name), GitRepositoryName: project.GitRepositoryName, Data: data, - License: project.License, + License: license, }, nil } diff --git a/internal/integrations/readme/copier.go b/internal/integrations/readme/copier.go index f16de79e7..8da730256 100644 --- a/internal/integrations/readme/copier.go +++ b/internal/integrations/readme/copier.go @@ -24,7 +24,7 @@ func NewCopier(project *core.Project) (*Copier, error) { "GitPlatformUserName": project.GitPlatformUserName, } - templatesRootPath, err := utils.GetTemplatesRootPath("common-templates/", project.Version) + templatesRootPath, err := utils.GetTemplatesRootPath("common-templates/", project.CompageCoreVersion) if err != nil { log.Errorf("error while getting the project root path [" + err.Error() + "]") return nil, err diff --git a/internal/languages/context.go b/internal/languages/context.go index fabd2867c..9084b003b 100644 --- a/internal/languages/context.go +++ b/internal/languages/context.go @@ -27,11 +27,11 @@ const ( ) type Values struct { - TemplateVars map[TemplateVarKey]string - ProjectName string - Version string - NodeDirectoryName string - LanguageNode *LanguageNode + TemplateVars map[TemplateVarKey]string + ProjectName string + CompageCoreVersion string + NodeDirectoryName string + LanguageNode *LanguageNode } func (v Values) Get(key TemplateVarKey) string { @@ -54,10 +54,10 @@ func AddValuesToContext(ctx context.Context, project *core.Project, languageNode GitPlatformURL: project.GitPlatformURL, GitPlatformUserName: project.GitPlatformUserName, }, - NodeDirectoryName: nodeDirectoryName, - ProjectName: project.Name, - Version: project.Version, - LanguageNode: languageNode, + NodeDirectoryName: nodeDirectoryName, + ProjectName: project.Name, + CompageCoreVersion: project.CompageCoreVersion, + LanguageNode: languageNode, } return context.WithValue(ctx, ContextKeyLanguageContextVars, v) diff --git a/internal/languages/dotnet/generator.go b/internal/languages/dotnet/generator.go index 1ce29aa81..23a2f85be 100644 --- a/internal/languages/dotnet/generator.go +++ b/internal/languages/dotnet/generator.go @@ -66,7 +66,7 @@ func generateRESTConfig(_ context.Context, dotNetValues *DotNetValues) error { } func getDotNetCleanArchitectureCopier(dotNetValues *DotNetValues) (*dotnetcleanarchitecture.Copier, error) { - dotNetTemplatesRootPath := GetDotNetTemplatesRootPath(dotNetValues.Values.Version) + dotNetTemplatesRootPath := GetDotNetTemplatesRootPath(dotNetValues.Values.CompageCoreVersion) if dotNetTemplatesRootPath == "" { return nil, errors.New("dotnet templates root path is empty") } @@ -147,7 +147,7 @@ func generateIntegrationConfig(dotNetValues *DotNetValues) error { } func getIntegrationsCopier(dotNetValues *DotNetValues) (map[string]interface{}, error) { - dotNetTemplatesRootPath := GetDotNetTemplatesRootPath(dotNetValues.Values.Version) + dotNetTemplatesRootPath := GetDotNetTemplatesRootPath(dotNetValues.Values.CompageCoreVersion) if dotNetTemplatesRootPath == "" { return nil, errors.New("dotnet templates root path is empty") } @@ -169,7 +169,7 @@ func getIntegrationsCopier(dotNetValues *DotNetValues) (map[string]interface{}, } // create dotnet specific licenseCopier - licenseCopier := license.NewCopier(gitPlatformUserName, gitRepositoryName, nodeName, nodeDirectoryName, dotNetTemplatesRootPath, dotNetValues.LDotNetLangNode.License) + licenseCopier := license.NewCopier(gitPlatformUserName, gitRepositoryName, nodeName, nodeDirectoryName, dotNetTemplatesRootPath, dotNetValues.LDotNetLangNode.Metadata) // create dotnet specific dockerCopier dockerCopier := docker.NewCopier(gitPlatformUserName, gitRepositoryName, nodeName, nodeDirectoryName, dotNetTemplatesRootPath, isRestServer, restServerPort) diff --git a/internal/languages/dotnet/integrations/license/copier.go b/internal/languages/dotnet/integrations/license/copier.go index 84352cff0..18b0d2654 100644 --- a/internal/languages/dotnet/integrations/license/copier.go +++ b/internal/languages/dotnet/integrations/license/copier.go @@ -1,6 +1,7 @@ package license import ( + "encoding/json" corenode "github.com/intelops/compage/internal/core/node" "github.com/intelops/compage/internal/utils" log "github.com/sirupsen/logrus" @@ -15,13 +16,34 @@ type Copier struct { Data map[string]interface{} } -func NewCopier(gitRepositoryName, gitPlatformUserName, nodeName, nodeDirectoryName, templatesRootPath string, license *corenode.License) *Copier { +func NewCopier(gitRepositoryName, gitPlatformUserName, nodeName, nodeDirectoryName, templatesRootPath string, metadata map[string]interface{}) *Copier { // populate map to replace templates data := map[string]interface{}{ "GitRepositoryName": gitRepositoryName, "GitPlatformUserName": gitPlatformUserName, } - + // extract license from metadata + license := &corenode.License{} + if metadata != nil { + l, ok := metadata["license"] + if ok { + licenseData, err1 := json.Marshal(l) + if err1 != nil { + log.Errorf("error while marshalling node license data [" + err1.Error() + "]") + return nil + } + // for license data + err1 = json.Unmarshal(licenseData, license) + if err1 != nil { + log.Errorf("error while unmarshalling node license data [" + err1.Error() + "]") + return nil + } + // this is not required to be set back as we are not modifying the license data + //project.Metadata["license"] = license + } else { + log.Warn("license data not found in node metadata") + } + } return &Copier{ TemplatesRootPath: templatesRootPath, NodeDirectoryName: nodeDirectoryName, diff --git a/internal/languages/golang/generator.go b/internal/languages/golang/generator.go index 857250b28..4e90be1cc 100644 --- a/internal/languages/golang/generator.go +++ b/internal/languages/golang/generator.go @@ -214,7 +214,7 @@ func generateRESTConfig(ctx context.Context, goValues *GoValues) error { } func getCommonFilesCopier(goValues GoValues) (*commonfiles.Copier, error) { - goTemplatesRootPath := GetGoTemplatesRootPath(goValues.Values.Version) + goTemplatesRootPath := GetGoTemplatesRootPath(goValues.Values.CompageCoreVersion) if goTemplatesRootPath == "" { return nil, errors.New("go templates root path is empty") } @@ -284,7 +284,7 @@ func getCommonFilesCopier(goValues GoValues) (*commonfiles.Copier, error) { } func getGoGrpcServerCopier(goValues *GoValues) (*gogrpcserver.Copier, error) { - goTemplatesRootPath := GetGoTemplatesRootPath(goValues.Values.Version) + goTemplatesRootPath := GetGoTemplatesRootPath(goValues.Values.CompageCoreVersion) if goTemplatesRootPath == "" { return nil, errors.New("go templates root path is empty") } @@ -326,7 +326,7 @@ func getGoGrpcServerCopier(goValues *GoValues) (*gogrpcserver.Copier, error) { } func getGoGinServerCopier(goValues *GoValues) (*goginserver.Copier, error) { - goTemplatesRootPath := GetGoTemplatesRootPath(goValues.Values.Version) + goTemplatesRootPath := GetGoTemplatesRootPath(goValues.Values.CompageCoreVersion) if goTemplatesRootPath == "" { return nil, errors.New("go templates root path is empty") } @@ -368,7 +368,7 @@ func getGoGinServerCopier(goValues *GoValues) (*goginserver.Copier, error) { } func getIntegrationsCopier(goValues *GoValues) (map[string]interface{}, error) { - goTemplatesRootPath := GetGoTemplatesRootPath(goValues.Values.Version) + goTemplatesRootPath := GetGoTemplatesRootPath(goValues.Values.CompageCoreVersion) if goTemplatesRootPath == "" { return nil, errors.New("go templates root path is empty") } @@ -399,7 +399,7 @@ func getIntegrationsCopier(goValues *GoValues) (map[string]interface{}, error) { projectName := goValues.Values.ProjectName // create dotnet specific licenseCopier - licenseCopier := license.NewCopier(gitPlatformUserName, gitRepositoryName, nodeName, nodeDirectoryName, goTemplatesRootPath, goValues.LGoLangNode.License) + licenseCopier := license.NewCopier(gitPlatformUserName, gitRepositoryName, nodeName, nodeDirectoryName, goTemplatesRootPath, goValues.LGoLangNode.Metadata) // create golang specific dockerCopier dockerCopier := docker.NewCopier(gitPlatformUserName, gitRepositoryName, nodeName, nodeDirectoryName, goTemplatesRootPath, isRestServer, restServerPort, isGrpcServer, grpcServerPort) diff --git a/internal/languages/golang/integrations/license/copier.go b/internal/languages/golang/integrations/license/copier.go index 84352cff0..92f203655 100644 --- a/internal/languages/golang/integrations/license/copier.go +++ b/internal/languages/golang/integrations/license/copier.go @@ -1,6 +1,7 @@ package license import ( + "encoding/json" corenode "github.com/intelops/compage/internal/core/node" "github.com/intelops/compage/internal/utils" log "github.com/sirupsen/logrus" @@ -15,13 +16,35 @@ type Copier struct { Data map[string]interface{} } -func NewCopier(gitRepositoryName, gitPlatformUserName, nodeName, nodeDirectoryName, templatesRootPath string, license *corenode.License) *Copier { +func NewCopier(gitRepositoryName, gitPlatformUserName, nodeName, nodeDirectoryName, templatesRootPath string, metadata map[string]interface{}) *Copier { // populate map to replace templates data := map[string]interface{}{ "GitRepositoryName": gitRepositoryName, "GitPlatformUserName": gitPlatformUserName, } + // extract license from metadata + license := &corenode.License{} + if metadata != nil { + l, ok := metadata["license"] + if ok { + licenseData, err1 := json.Marshal(l) + if err1 != nil { + log.Errorf("error while marshalling node license data [" + err1.Error() + "]") + return nil + } + // for license data + err1 = json.Unmarshal(licenseData, license) + if err1 != nil { + log.Errorf("error while unmarshalling node license data [" + err1.Error() + "]") + return nil + } + // this is not required to be set back as we are not modifying the license data + //project.Metadata["license"] = license + } else { + log.Warn("license data not found in node metadata") + } + } return &Copier{ TemplatesRootPath: templatesRootPath, NodeDirectoryName: nodeDirectoryName, diff --git a/internal/languages/java/generator.go b/internal/languages/java/generator.go index fbb90dfb5..7da4d0694 100644 --- a/internal/languages/java/generator.go +++ b/internal/languages/java/generator.go @@ -73,7 +73,7 @@ func Generate(ctx context.Context) error { } func getIntegrationsCopier(javaValues Values) (map[string]interface{}, error) { - javaTemplatesRootPath := GetJavaTemplatesRootPath(javaValues.Values.Version) + javaTemplatesRootPath := GetJavaTemplatesRootPath(javaValues.Values.CompageCoreVersion) if javaTemplatesRootPath == "" { return nil, errors.New("java templates root path is empty") } diff --git a/internal/languages/javascript/generator.go b/internal/languages/javascript/generator.go index 119bc1dff..6a8bc75bc 100644 --- a/internal/languages/javascript/generator.go +++ b/internal/languages/javascript/generator.go @@ -81,7 +81,7 @@ func Generate(ctx context.Context) error { } func getIntegrationsCopier(javascriptValues Values) (map[string]interface{}, error) { - javaScriptTemplatesRootPath := GetJavaScriptTemplatesRootPath(javascriptValues.Values.Version) + javaScriptTemplatesRootPath := GetJavaScriptTemplatesRootPath(javascriptValues.Values.CompageCoreVersion) if javaScriptTemplatesRootPath == "" { return nil, errors.New("javascript templates root path is empty") } diff --git a/internal/languages/languages.go b/internal/languages/languages.go index 64285c029..fef6c41bc 100644 --- a/internal/languages/languages.go +++ b/internal/languages/languages.go @@ -39,7 +39,6 @@ func NewLanguageNode(compageJSON *core.CompageJSON, node *corenode.Node) (*Langu Metadata: node.Metadata, Annotations: node.Annotations, Language: node.Language, - License: node.License, } addRestConfig(node, languageNode) diff --git a/internal/languages/python/generator.go b/internal/languages/python/generator.go index 4be89daf6..f9f78e716 100644 --- a/internal/languages/python/generator.go +++ b/internal/languages/python/generator.go @@ -66,7 +66,7 @@ func Generate(ctx context.Context) error { } func getIntegrationsCopier(pythonValues Values) (map[string]interface{}, error) { - pythonTemplatesRootPath := GetPythonTemplatesRootPath(pythonValues.Values.Version) + pythonTemplatesRootPath := GetPythonTemplatesRootPath(pythonValues.Values.CompageCoreVersion) if pythonTemplatesRootPath == "" { return nil, errors.New("python templates root path is empty") } diff --git a/internal/languages/ruby/generator.go b/internal/languages/ruby/generator.go index 41b7f0b36..d4f1aabec 100644 --- a/internal/languages/ruby/generator.go +++ b/internal/languages/ruby/generator.go @@ -66,7 +66,7 @@ func Generate(ctx context.Context) error { } func getIntegrationsCopier(rubyValues Values) (map[string]interface{}, error) { - rubyTemplatesRootPath := GetRubyTemplatesRootPath(rubyValues.Values.Version) + rubyTemplatesRootPath := GetRubyTemplatesRootPath(rubyValues.Values.CompageCoreVersion) if rubyTemplatesRootPath == "" { return nil, errors.New("ruby templates root path is empty") } diff --git a/internal/languages/rust/generator.go b/internal/languages/rust/generator.go index 88a680f1b..567c98f44 100644 --- a/internal/languages/rust/generator.go +++ b/internal/languages/rust/generator.go @@ -58,7 +58,7 @@ func Generate(ctx context.Context) error { } func getIntegrationsCopier(rustValues Values) (map[string]interface{}, error) { - rustTemplatesRootPath := GetRustTemplatesRootPath(rustValues.Values.Version) + rustTemplatesRootPath := GetRustTemplatesRootPath(rustValues.Values.CompageCoreVersion) if rustTemplatesRootPath == "" { return nil, errors.New("rust templates root path is empty") } diff --git a/internal/languages/typescript/generator.go b/internal/languages/typescript/generator.go index 952023ad2..786f17dce 100644 --- a/internal/languages/typescript/generator.go +++ b/internal/languages/typescript/generator.go @@ -56,7 +56,7 @@ func Generate(ctx context.Context) error { } func getIntegrationsCopier(typescriptValues Values) (map[string]interface{}, error) { - typeScriptTemplatesRootPath := GetTypeScriptTemplatesRootPath(typescriptValues.Values.Version) + typeScriptTemplatesRootPath := GetTypeScriptTemplatesRootPath(typescriptValues.Values.CompageCoreVersion) if typeScriptTemplatesRootPath == "" { return nil, errors.New("typescript templates root path is empty") } diff --git a/test/generator_test.go b/test/generator_test.go index 733591c12..b109fd18a 100644 --- a/test/generator_test.go +++ b/test/generator_test.go @@ -69,7 +69,7 @@ func TestRestServerGeneratorNoSql(t *testing.T) { GitRepositoryName: "first-rest-server-project-nosql", ProjectName: "first-rest-server-project-nosql", ProjectJSON: restServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-rest-server-project-nosql")) @@ -145,7 +145,7 @@ func TestRestServerGeneratorSqlMap(t *testing.T) { GitRepositoryName: "first-rest-server-project-map", ProjectName: "first-rest-server-project-map", ProjectJSON: restServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-rest-server-project-map")) @@ -225,7 +225,7 @@ func TestRestServerGeneratorSqlSQLite(t *testing.T) { GitRepositoryName: "first-rest-server-project-sqlite", ProjectName: "first-rest-server-project-sqlite", ProjectJSON: restServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-rest-server-project-sqlite")) @@ -301,7 +301,7 @@ func TestRestServerGeneratorSqlMySQL(t *testing.T) { GitRepositoryName: "first-rest-server-project-mysql", ProjectName: "first-rest-server-project-mysql", ProjectJSON: restServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-rest-server-project-mysql")) @@ -377,7 +377,7 @@ func TestRestServerGeneratorSqlSQLiteGORM(t *testing.T) { GitRepositoryName: "first-rest-server-project-sqlite-gorm", ProjectName: "first-rest-server-project-sqlite-gorm", ProjectJSON: restServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-rest-server-project-sqlite-gorm")) @@ -453,7 +453,7 @@ func TestRestServerGeneratorSqlMySQLGORM(t *testing.T) { GitRepositoryName: "first-rest-server-project-mysql-gorm", ProjectName: "first-rest-server-project-mysql-gorm", ProjectJSON: restServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-rest-server-project-mysql-gorm")) @@ -519,7 +519,7 @@ func TestRestServerWithOpenApiGenerator(t *testing.T) { GitRepositoryName: "first-project-github", ProjectName: "first-openapi-based-project-" + tt.language, ProjectJSON: replacedConfig, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-openapi-based-project-" + tt.language)) @@ -593,7 +593,7 @@ func TestGrpcServerGeneratorNoSql(t *testing.T) { GitRepositoryName: "first-grpc-server-project-nosql", ProjectName: "first-grpc-server-project-nosql", ProjectJSON: grpcServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-grpc-server-project-nosql")) @@ -663,7 +663,7 @@ func TestGrpcServerGeneratorSqlMap(t *testing.T) { GitRepositoryName: "first-grpc-server-project-map", ProjectName: "first-grpc-server-project-map", ProjectJSON: grpcServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-grpc-server-project-map")) @@ -737,7 +737,7 @@ func TestGrpcServerGeneratorSqlSQLite(t *testing.T) { GitRepositoryName: "first-grpc-server-project-sqlite", ProjectName: "first-grpc-server-project-sqlite", ProjectJSON: grpcServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-grpc-server-project-sqlite")) @@ -807,7 +807,7 @@ func TestGrpcServerGeneratorSqlMySQL(t *testing.T) { GitRepositoryName: "first-grpc-server-project-mysql", ProjectName: "first-grpc-server-project-mysql", ProjectJSON: grpcServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-grpc-server-project-mysql")) @@ -877,7 +877,7 @@ func TestGrpcServerGeneratorSqlSQLiteGORM(t *testing.T) { GitRepositoryName: "first-grpc-server-project-sqlite-gorm", ProjectName: "first-grpc-server-project-sqlite-gorm", ProjectJSON: grpcServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-grpc-server-project-sqlite-gorm")) @@ -947,7 +947,7 @@ func TestGrpcServerGeneratorSqlMySQLGORM(t *testing.T) { GitRepositoryName: "first-grpc-server-project-mysql-gorm", ProjectName: "first-grpc-server-project-mysql-gorm", ProjectJSON: grpcServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-grpc-server-project-mysql-gorm")) @@ -1122,7 +1122,7 @@ func TestRestServerClientsAndGrpcServerClientsCrossConfigGenerator(t *testing.T) GitRepositoryName: "first-rest-server-clients-and-grpc-server-clients-cross-config-project", ProjectName: "first-rest-server-clients-and-grpc-server-clients-cross-config-project", ProjectJSON: restGrpcServerClientsCrossConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-rest-server-clients-and-grpc-server-clients-cross-config-project")) @@ -1232,7 +1232,7 @@ func TestRestClientAndGrpcClientCrossConfigGenerator(t *testing.T) { GitRepositoryName: "first-rest-client-and-grpc-client-cross-config-project", ProjectName: "first-rest-client-and-grpc-client-cross-config-project", ProjectJSON: restGrpcClientCrossConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-rest-client-and-grpc-client-cross-config-project")) @@ -1308,7 +1308,7 @@ func TestRestAndGrpcServerGenerator(t *testing.T) { GitRepositoryName: "first-rest-and-grpc-server-project", ProjectName: "first-rest-and-grpc-server-project", ProjectJSON: restAndGrpcServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-rest-and-grpc-server-project")) @@ -1366,7 +1366,7 @@ func TestWsServerGenerator(t *testing.T) { GitRepositoryName: "first-ws-server-project", ProjectName: "first-ws-server-project", ProjectJSON: wsServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-ws-server-project")) @@ -1439,7 +1439,7 @@ func TestDotNetCleanArchitectureGenerator(t *testing.T) { GitRepositoryName: "first-rest-server-project-dotnet", ProjectName: "first-rest-server-project-dotnet", ProjectJSON: restServerConfigJSON, - ProjectVersion: "v1.0.0", + CompageCoreVersion: "v1.0.0", } defer func() { _ = os.RemoveAll(utils.GetProjectDirectoryName("first-rest-server-project-dotnet"))