mirror of https://github.com/knative/func.git
fix: refer correct version of schema in func.yaml (#2924)
Signed-off-by: Matej Vašek <mvasek@redhat.com>
This commit is contained in:
parent
630064caef
commit
6a3ef466f4
2
Makefile
2
Makefile
|
|
@ -28,7 +28,7 @@ VTAG := $(shell [ -z $(VTAG) ] && echo $(ETAG) || echo $(VTAG))
|
||||||
VERS ?= $(shell git describe --tags --match 'v*')
|
VERS ?= $(shell git describe --tags --match 'v*')
|
||||||
KVER ?= $(shell git describe --tags --match 'knative-*')
|
KVER ?= $(shell git describe --tags --match 'knative-*')
|
||||||
|
|
||||||
LDFLAGS := -X knative.dev/func/pkg/app.vers=$(VERS) -X knative.dev/func/pkg/app.kver=$(KVER) -X knative.dev/func/pkg/app.hash=$(HASH)
|
LDFLAGS := -X knative.dev/func/pkg/version.Vers=$(VERS) -X knative.dev/func/pkg/version.Kver=$(KVER) -X knative.dev/func/pkg/version.Hash=$(HASH)
|
||||||
|
|
||||||
FUNC_UTILS_IMG ?= ghcr.io/knative/func-utils:v2
|
FUNC_UTILS_IMG ?= ghcr.io/knative/func-utils:v2
|
||||||
LDFLAGS += -X knative.dev/func/pkg/k8s.SocatImage=$(FUNC_UTILS_IMG)
|
LDFLAGS += -X knative.dev/func/pkg/k8s.SocatImage=$(FUNC_UTILS_IMG)
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -11,6 +11,7 @@ require (
|
||||||
github.com/Microsoft/go-winio v0.6.2
|
github.com/Microsoft/go-winio v0.6.2
|
||||||
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2
|
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2
|
||||||
github.com/alecthomas/jsonschema v0.0.0-20220216202328-9eeeec9d044b
|
github.com/alecthomas/jsonschema v0.0.0-20220216202328-9eeeec9d044b
|
||||||
|
github.com/blang/semver/v4 v4.0.0
|
||||||
github.com/buildpacks/pack v0.36.4
|
github.com/buildpacks/pack v0.36.4
|
||||||
github.com/chainguard-dev/git-urls v1.0.2
|
github.com/chainguard-dev/git-urls v1.0.2
|
||||||
github.com/cloudevents/sdk-go/v2 v2.15.2
|
github.com/cloudevents/sdk-go/v2 v2.15.2
|
||||||
|
|
@ -111,7 +112,6 @@ require (
|
||||||
github.com/aws/smithy-go v1.22.2 // indirect
|
github.com/aws/smithy-go v1.22.2 // indirect
|
||||||
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20250205235911-d2398ba46815 // indirect
|
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20250205235911-d2398ba46815 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/blang/semver/v4 v4.0.0 // indirect
|
|
||||||
github.com/blendle/zapdriver v1.3.1 // indirect
|
github.com/blendle/zapdriver v1.3.1 // indirect
|
||||||
github.com/buildpacks/imgutil v0.0.0-20240605145725-186f89b2d168 // indirect
|
github.com/buildpacks/imgutil v0.0.0-20240605145725-186f89b2d168 // indirect
|
||||||
github.com/buildpacks/libcnb v1.30.3 // indirect
|
github.com/buildpacks/libcnb v1.30.3 // indirect
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,12 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/AlecAivazis/survey/v2/terminal"
|
"github.com/AlecAivazis/survey/v2/terminal"
|
||||||
|
|
||||||
"knative.dev/func/cmd"
|
"knative.dev/func/cmd"
|
||||||
"knative.dev/func/pkg/docker"
|
"knative.dev/func/pkg/docker"
|
||||||
|
"knative.dev/func/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
var vers, kver, hash string
|
|
||||||
|
|
||||||
func Main() {
|
func Main() {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
@ -32,9 +32,9 @@ func Main() {
|
||||||
cfg := cmd.RootCommandConfig{
|
cfg := cmd.RootCommandConfig{
|
||||||
Name: "func",
|
Name: "func",
|
||||||
Version: cmd.Version{
|
Version: cmd.Version{
|
||||||
Vers: vers,
|
Vers: version.Vers,
|
||||||
Kver: kver,
|
Kver: version.Kver,
|
||||||
Hash: hash,
|
Hash: version.Hash,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
if err := cmd.NewRootCmd(cfg).ExecuteContext(ctx); err != nil {
|
if err := cmd.NewRootCmd(cfg).ExecuteContext(ctx); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,12 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/blang/semver/v4"
|
||||||
"github.com/google/go-containerregistry/pkg/name"
|
"github.com/google/go-containerregistry/pkg/name"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
fnlabels "knative.dev/func/pkg/k8s/labels"
|
fnlabels "knative.dev/func/pkg/k8s/labels"
|
||||||
|
"knative.dev/func/pkg/version"
|
||||||
"knative.dev/pkg/ptr"
|
"knative.dev/pkg/ptr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -444,12 +447,12 @@ func (f Function) Write() (err error) {
|
||||||
}
|
}
|
||||||
defer rwFile.Close()
|
defer rwFile.Close()
|
||||||
|
|
||||||
tagVersion := f.SpecVersion
|
schemaURI := funcYamlSchemaURI()
|
||||||
|
|
||||||
// Write schema header
|
// Write schema header
|
||||||
schemaHeader := fmt.Sprintf(`# $schema: https://raw.githubusercontent.com/knative/func/refs/tags/v%s/schema/func_yaml-schema.json
|
schemaHeader := fmt.Sprintf(`# $schema: %s
|
||||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/knative/func/refs/tags/v%s/schema/func_yaml-schema.json
|
# yaml-language-server: $schema=%s
|
||||||
`, tagVersion, tagVersion)
|
`, schemaURI, schemaURI)
|
||||||
|
|
||||||
if _, err = rwFile.WriteString(schemaHeader); err != nil {
|
if _, err = rwFile.WriteString(schemaHeader); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -479,6 +482,25 @@ func (f Function) Write() (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func funcYamlSchemaURI() string {
|
||||||
|
var (
|
||||||
|
ref = "main"
|
||||||
|
kver semver.Version
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
kver, err = semver.Parse(strings.TrimPrefix(version.Kver, "knative-v"))
|
||||||
|
if err == nil {
|
||||||
|
ref = fmt.Sprintf("release-%d.%d", kver.Major, kver.Minor)
|
||||||
|
} else {
|
||||||
|
if version.Hash != "" {
|
||||||
|
ref = version.Hash
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("https://raw.githubusercontent.com/knative/func"+
|
||||||
|
"/%s/schema/func_yaml-schema.json", ref)
|
||||||
|
}
|
||||||
|
|
||||||
type stampOptions struct{ journal bool }
|
type stampOptions struct{ journal bool }
|
||||||
type stampOption func(o *stampOptions)
|
type stampOption func(o *stampOptions)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package version
|
||||||
|
|
||||||
|
var Vers, Kver, Hash string
|
||||||
Loading…
Reference in New Issue