snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s

This commit is contained in:
upstream-mirror
2026-09-18 01:22:23 +05:00
commit 7e385fc126
8391 changed files with 1766236 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
package yaml
import (
"context"
"io"
"regexp"
"strings"
"github.com/cortezaproject/corteza/server/pkg/y7s"
. "github.com/cortezaproject/corteza/server/pkg/y7s"
"github.com/cortezaproject/corteza/server/pkg/envoy"
"github.com/cortezaproject/corteza/server/pkg/envoy/resource"
"gopkg.in/yaml.v3"
)
type (
// decoder is a wrapper struct for yaml related methods
decoder struct{}
EnvoyMarshler interface {
MarshalEnvoy() ([]resource.Interface, error)
}
)
var (
validReference = regexp.MustCompile(`^[A-Za-z1-9][0-9A-Za-z_\-.]*[A-Za-z0-9]$`)
)
func Decoder() *decoder {
return &decoder{}
}
// CanDecodeFile checks if the file can be handled by this decoder
//
// @todo Add support for this; current library is unable to detect this.
func (y *decoder) CanDecodeFile(f io.Reader) bool {
// relying on can-decode-ext for now
return true
}
func (y *decoder) CanDecodeExt(name string) bool {
var (
pt = strings.Split(name, ".")
ext = strings.TrimSpace(pt[len(pt)-1])
)
return ext == "yaml" || ext == "yml"
}
func (y *decoder) Decode(ctx context.Context, r io.Reader, dctx *envoy.DecoderOpts) ([]resource.Interface, error) {
var (
doc = &Document{}
)
if err := yaml.NewDecoder(r).Decode(doc); err != nil {
return nil, err
}
aaa, err := doc.Decode(ctx)
return aaa, err
}
// Checks validity of ref node and sets the value to given arg ptr
func decodeRef(n *yaml.Node, refType string, ref *string) error {
if n == nil {
return nil
}
if !IsKind(n, yaml.ScalarNode) {
return y7s.NodeErr(n, "%s reference must be scalar", refType)
}
if !IsValidRef(n.Value) {
return y7s.NodeErr(n, "%s reference must be a valid ID or Handle", refType)
}
*ref = n.Value
return nil
}
func IsValidRef(s string) bool {
return len(s) >= 2 && validReference.MatchString(s)
}