diff --git a/tibuild/docs/docs.go b/tibuild/docs/docs.go index 5c723fea..5913ec71 100644 --- a/tibuild/docs/docs.go +++ b/tibuild/docs/docs.go @@ -337,8 +337,8 @@ const docTemplate = `{ "component": { "type": "string" }, - "oras": { - "$ref": "#/definitions/service.OrasFile" + "ociFile": { + "$ref": "#/definitions/service.OciFile" }, "platform": { "type": "string" @@ -570,7 +570,7 @@ const docTemplate = `{ } } }, - "service.OrasFile": { + "service.OciFile": { "type": "object", "properties": { "file": { @@ -684,7 +684,7 @@ const docTemplate = `{ "name": { "type": "string" }, - "orasArtifacts": { + "ociArtifacts": { "type": "array", "items": { "$ref": "#/definitions/service.OciArtifact" diff --git a/tibuild/docs/swagger.json b/tibuild/docs/swagger.json index 4a247b04..6e57aa58 100644 --- a/tibuild/docs/swagger.json +++ b/tibuild/docs/swagger.json @@ -325,8 +325,8 @@ "component": { "type": "string" }, - "oras": { - "$ref": "#/definitions/service.OrasFile" + "ociFile": { + "$ref": "#/definitions/service.OciFile" }, "platform": { "type": "string" @@ -558,7 +558,7 @@ } } }, - "service.OrasFile": { + "service.OciFile": { "type": "object", "properties": { "file": { @@ -672,7 +672,7 @@ "name": { "type": "string" }, - "orasArtifacts": { + "ociArtifacts": { "type": "array", "items": { "$ref": "#/definitions/service.OciArtifact" diff --git a/tibuild/docs/swagger.yaml b/tibuild/docs/swagger.yaml index 1fee0ba8..d51be652 100644 --- a/tibuild/docs/swagger.yaml +++ b/tibuild/docs/swagger.yaml @@ -10,8 +10,8 @@ definitions: properties: component: type: string - oras: - $ref: '#/definitions/service.OrasFile' + ociFile: + $ref: '#/definitions/service.OciFile' platform: type: string sha256URL: @@ -165,7 +165,7 @@ definitions: tag: type: string type: object - service.OrasFile: + service.OciFile: properties: file: type: string @@ -252,7 +252,7 @@ definitions: type: array name: type: string - orasArtifacts: + ociArtifacts: items: $ref: '#/definitions/service.OciArtifact' type: array diff --git a/tibuild/pkg/rest/service/dev_build_service.go b/tibuild/pkg/rest/service/dev_build_service.go index c1ef3890..010e02d2 100644 --- a/tibuild/pkg/rest/service/dev_build_service.go +++ b/tibuild/pkg/rest/service/dev_build_service.go @@ -339,8 +339,8 @@ func (s DevbuildServer) inflate(entity *DevBuild) { } if entity.Status.BuildReport != nil { for i, bin := range entity.Status.BuildReport.Binaries { - if bin.URL == "" && bin.OrasFile != nil { - entity.Status.BuildReport.Binaries[i].URL = s.oras_to_file_url(*bin.OrasFile) + if bin.URL == "" && bin.OciFile != nil { + entity.Status.BuildReport.Binaries[i].URL = s.ociFileToUrl(*bin.OciFile) } } } @@ -392,7 +392,7 @@ func collectTektonArtifacts(pipelines []TektonPipeline, report *BuildReport) { for _, pipeline := range pipelines { report.GitHash = pipeline.GitHash for _, files := range pipeline.OciArtifacts { - report.Binaries = append(report.Binaries, oras_to_files(pipeline.Platform, files)...) + report.Binaries = append(report.Binaries, ociArtifactToFiles(pipeline.Platform, files)...) } for _, image := range pipeline.Images { img := ImageArtifact{Platform: pipeline.Platform, URL: image.URL} @@ -453,16 +453,16 @@ func getLatestEndAt(pipelines []TektonPipeline) *time.Time { return latest_endat } -func oras_to_files(platform Platform, oras OciArtifact) []BinArtifact { +func ociArtifactToFiles(platform Platform, artifact OciArtifact) []BinArtifact { var rt []BinArtifact - for _, file := range oras.Files { - rt = append(rt, BinArtifact{Platform: platform, OrasFile: &OrasFile{Repo: oras.Repo, Tag: oras.Tag, File: file}}) + for _, file := range artifact.Files { + rt = append(rt, BinArtifact{Platform: platform, OciFile: &OciFile{Repo: artifact.Repo, Tag: artifact.Tag, File: file}}) } return rt } -func (s DevbuildServer) oras_to_file_url(oras OrasFile) string { - return fmt.Sprintf("%s/%s?tag=%s&file=%s", s.OciFileserverURL, oras.Repo, oras.Tag, oras.File) +func (s DevbuildServer) ociFileToUrl(artifact OciFile) string { + return fmt.Sprintf("%s/%s?tag=%s&file=%s", s.OciFileserverURL, artifact.Repo, artifact.Tag, artifact.File) } type DevBuildRepository interface { diff --git a/tibuild/pkg/rest/service/dev_build_service_test.go b/tibuild/pkg/rest/service/dev_build_service_test.go index f9e412c3..37c0b5cf 100644 --- a/tibuild/pkg/rest/service/dev_build_service_test.go +++ b/tibuild/pkg/rest/service/dev_build_service_test.go @@ -274,7 +274,7 @@ func TestDevBuildGet(t *testing.T) { Jenkins: &mockedJenkins, Now: time.Now, TektonViewURL: "http://tekton.net", - OciFileserverURL: "http://orasdownload.net", + OciFileserverURL: "http://ocidownload.net", } t.Run("ok", func(t *testing.T) { @@ -285,13 +285,13 @@ func TestDevBuildGet(t *testing.T) { require.NoError(t, err) require.Equal(t, "https://cd.pingcap.net//blue/organizations/jenkins/devbuild/detail/devbuild/4/pipeline", entity.Status.PipelineViewURL) }) - t.Run("render oras file", func(t *testing.T) { + t.Run("render oci file", func(t *testing.T) { mockedRepo.saved = DevBuild{ID: 1, Spec: DevBuildSpec{Product: ProductTidb, Version: "v6.1.2", Edition: EnterpriseEdition, GitRef: "pull/23", PluginGitRef: "master"}, - Status: DevBuildStatus{PipelineBuildID: 4, BuildReport: &BuildReport{Binaries: []BinArtifact{{OrasFile: &OrasFile{Repo: "repo", Tag: "tag", File: "file"}}}}}} + Status: DevBuildStatus{PipelineBuildID: 4, BuildReport: &BuildReport{Binaries: []BinArtifact{{OciFile: &OciFile{Repo: "repo", Tag: "tag", File: "file"}}}}}} entity, err := server.Get(context.TODO(), 1, DevBuildGetOption{}) require.NoError(t, err) - require.Equal(t, "http://orasdownload.net/repo?tag=tag&file=file", entity.Status.BuildReport.Binaries[0].URL) + require.Equal(t, "http://ocidownload.net/repo?tag=tag&file=file", entity.Status.BuildReport.Binaries[0].URL) }) t.Run("render tekton pipeline", func(t *testing.T) { mockedRepo.saved = DevBuild{ID: 1, diff --git a/tibuild/pkg/rest/service/model.go b/tibuild/pkg/rest/service/model.go index e2f31684..79a0f10f 100644 --- a/tibuild/pkg/rest/service/model.go +++ b/tibuild/pkg/rest/service/model.go @@ -262,7 +262,7 @@ type TektonPipeline struct { Platform Platform `json:"platform,omitempty"` PipelineStartAt *time.Time `json:"pipelineStartAt,omitempty"` PipelineEndAt *time.Time `json:"pipelineEndAt,omitempty"` - OciArtifacts []OciArtifact `json:"orasArtifacts,omitempty"` + OciArtifacts []OciArtifact `json:"ociArtifacts,omitempty"` Images []ImageArtifact `json:"images,omitempty"` } @@ -296,14 +296,14 @@ var ( ) type BinArtifact struct { - Component string `json:"component,omitempty"` - Platform Platform `json:"platform"` - URL string `json:"url"` - Sha256URL string `json:"sha256URL"` - OrasFile *OrasFile `json:"oras,omitempty"` + Component string `json:"component,omitempty"` + Platform Platform `json:"platform"` + URL string `json:"url"` + Sha256URL string `json:"sha256URL"` + OciFile *OciFile `json:"ociFile,omitempty"` } -type OrasFile struct { +type OciFile struct { Repo string `json:"repo"` Tag string `json:"tag"` File string `json:"file"` diff --git a/tibuild/pkg/webhook/service/cloudevent.go b/tibuild/pkg/webhook/service/cloudevent.go index 23863348..97eeb6d5 100644 --- a/tibuild/pkg/webhook/service/cloudevent.go +++ b/tibuild/pkg/webhook/service/cloudevent.go @@ -138,7 +138,7 @@ func convertOciArtifacts(pipeline tekton.PipelineRun) []rest.OciArtifact { if r.Name == "pushed-binaries" { v, err := convertOciArtifact(r.Value.StringVal) if err != nil { - slog.Error("can not parse oras file", "error", err.Error()) + slog.Error("can not parse oci file", "error", err.Error()) // this make error can be seen by frontend, and not block other result v = &rest.OciArtifact{Repo: "parse_error", Tag: r.Value.StringVal, Files: []string{"error_parse_artifact"}} } @@ -148,7 +148,7 @@ func convertOciArtifacts(pipeline tekton.PipelineRun) []rest.OciArtifact { return rt } -type TektonOrasStruct struct { +type TektonOciArtifactStruct struct { OCI struct { Repo string `json:"repo"` Tag string `json:"tag"` @@ -158,15 +158,15 @@ type TektonOrasStruct struct { } func convertOciArtifact(text string) (*rest.OciArtifact, error) { - tekton_oras := TektonOrasStruct{} - err := yaml.Unmarshal([]byte(text), &tekton_oras) + tekton_oci_artifact := TektonOciArtifactStruct{} + err := yaml.Unmarshal([]byte(text), &tekton_oci_artifact) if err != nil { return nil, err } return &rest.OciArtifact{ - Repo: tekton_oras.OCI.Repo, - Tag: tekton_oras.OCI.Tag, - Files: tekton_oras.Files, + Repo: tekton_oci_artifact.OCI.Repo, + Tag: tekton_oci_artifact.OCI.Tag, + Files: tekton_oci_artifact.Files, }, nil }