feat: kubesphere 4.0 (#6115)

* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

---------

Signed-off-by: ci-bot <ci-bot@kubesphere.io>
Co-authored-by: ks-ci-bot <ks-ci-bot@example.com>
Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
KubeSphere CI Bot
2024-09-06 11:05:52 +08:00
committed by GitHub
parent b5015ec7b9
commit 447a51f08b
8557 changed files with 546695 additions and 1146174 deletions

View File

@@ -133,9 +133,11 @@ var DefaultBuiltins = [...]*Builtin{
TrimSpace,
Sprintf,
StringReverse,
RenderTemplate,
// Numbers
NumbersRange,
NumbersRangeStep,
RandIntn,
// Encoding
@@ -210,10 +212,13 @@ var DefaultBuiltins = [...]*Builtin{
CryptoSha256,
CryptoX509ParseCertificateRequest,
CryptoX509ParseRSAPrivateKey,
CryptoX509ParseKeyPair,
CryptoParsePrivateKeys,
CryptoHmacMd5,
CryptoHmacSha1,
CryptoHmacSha256,
CryptoHmacSha512,
CryptoHmacEqual,
// Graphs
WalkBuiltin,
@@ -244,6 +249,10 @@ var DefaultBuiltins = [...]*Builtin{
GraphQLIsValid,
GraphQLSchemaIsValid,
// JSON Schema
JSONSchemaVerify,
JSONMatchSchema,
// Cloud Provider Helpers
ProvidersAWSSignReqObj,
@@ -278,6 +287,7 @@ var DefaultBuiltins = [...]*Builtin{
// UUIDs
UUIDRFC4122,
UUIDParse,
// SemVers
SemVerIsValid,
@@ -1308,6 +1318,20 @@ var StringReverse = &Builtin{
Categories: stringsCat,
}
var RenderTemplate = &Builtin{
Name: "strings.render_template",
Description: `Renders a templated string with given template variables injected. For a given templated string and key/value mapping, values will be injected into the template where they are referenced by key.
For examples of templating syntax, see https://pkg.go.dev/text/template`,
Decl: types.NewFunction(
types.Args(
types.Named("value", types.S).Description("a templated string"),
types.Named("vars", types.NewObject(nil, types.NewDynamicProperty(types.S, types.A))).Description("a mapping of template variable keys to values"),
),
types.Named("result", types.S).Description("rendered template with template variables injected"),
),
Categories: stringsCat,
}
/**
* Numbers
*/
@@ -1340,6 +1364,23 @@ var NumbersRange = &Builtin{
),
}
var NumbersRangeStep = &Builtin{
Name: "numbers.range_step",
Description: `Returns an array of numbers in the given (inclusive) range incremented by a positive step.
If "a==b", then "range == [a]"; if "a > b", then "range" is in descending order.
If the provided "step" is less then 1, an error will be thrown.
If "b" is not in the range of the provided "step", "b" won't be included in the result.
`,
Decl: types.NewFunction(
types.Args(
types.Named("a", types.N),
types.Named("b", types.N),
types.Named("step", types.N),
),
types.Named("range", types.NewArray(nil, types.N)).Description("the range between `a` and `b` in `step` increments"),
),
}
/**
* Units
*/
@@ -1393,6 +1434,19 @@ var UUIDRFC4122 = &Builtin{
Nondeterministic: true,
}
var UUIDParse = &Builtin{
Name: "uuid.parse",
Description: "Parses the string value as an UUID and returns an object with the well-defined fields of the UUID if valid.",
Categories: nil,
Decl: types.NewFunction(
types.Args(
types.Named("uuid", types.S),
),
types.Named("result", types.NewObject(nil, types.NewDynamicProperty(types.S, types.A))).Description("Properties of UUID if valid (version, variant, etc). Undefined otherwise."),
),
Relation: false,
}
/**
* JSON
*/
@@ -2154,7 +2208,7 @@ var Format = &Builtin{
types.N,
types.NewArray([]types.Type{types.N, types.S}, nil),
types.NewArray([]types.Type{types.N, types.S, types.S}, nil),
)).Description("a number representing the nanoseconds since the epoch (UTC); or a two-element array of the nanoseconds, and a timezone string; or a three-element array of ns, timezone string and a layout string (see golang supported time formats)"),
)).Description("a number representing the nanoseconds since the epoch (UTC); or a two-element array of the nanoseconds, and a timezone string; or a three-element array of ns, timezone string and a layout string or golang defined formatting constant (see golang supported time formats)"),
),
types.Named("formatted timestamp", types.S).Description("the formatted timestamp represented for the nanoseconds since the epoch in the supplied timezone (or UTC)"),
),
@@ -2205,7 +2259,7 @@ var Weekday = &Builtin{
var AddDate = &Builtin{
Name: "time.add_date",
Description: "Returns the nanoseconds since epoch after adding years, months and days to nanoseconds. `undefined` if the result would be outside the valid time range that can fit within an `int64`.",
Description: "Returns the nanoseconds since epoch after adding years, months and days to nanoseconds. Month & day values outside their usual ranges after the operation and will be normalized - for example, October 32 would become November 1. `undefined` if the result would be outside the valid time range that can fit within an `int64`.",
Decl: types.NewFunction(
types.Args(
types.Named("ns", types.N).Description("nanoseconds since the epoch"),
@@ -2284,6 +2338,17 @@ var CryptoX509ParseCertificateRequest = &Builtin{
),
}
var CryptoX509ParseKeyPair = &Builtin{
Name: "crypto.x509.parse_keypair",
Description: "Returns a valid key pair",
Decl: types.NewFunction(
types.Args(
types.Named("cert", types.S).Description("string containing PEM or base64 encoded DER certificates"),
types.Named("pem", types.S).Description("string containing PEM or base64 encoded DER keys"),
),
types.Named("output", types.NewObject(nil, types.NewDynamicProperty(types.S, types.A))).Description("if key pair is valid, returns the tls.certificate(https://pkg.go.dev/crypto/tls#Certificate) as an object. If the key pair is invalid, nil and an error are returned."),
),
}
var CryptoX509ParseRSAPrivateKey = &Builtin{
Name: "crypto.x509.parse_rsa_private_key",
Description: "Returns a JWK for signing a JWT from the given PEM-encoded RSA private key.",
@@ -2295,6 +2360,19 @@ var CryptoX509ParseRSAPrivateKey = &Builtin{
),
}
var CryptoParsePrivateKeys = &Builtin{
Name: "crypto.parse_private_keys",
Description: `Returns zero or more private keys from the given encoded string containing DER certificate data.
If the input is empty, the function will return null. The input string should be a list of one or more concatenated PEM blocks. The whole input of concatenated PEM blocks can optionally be Base64 encoded.`,
Decl: types.NewFunction(
types.Args(
types.Named("keys", types.S).Description("PEM encoded data containing one or more private keys as concatenated blocks. Optionally Base64 encoded."),
),
types.Named("output", types.NewArray(nil, types.NewObject(nil, types.NewDynamicProperty(types.S, types.A)))).Description("parsed private keys represented as objects"),
),
}
var CryptoMd5 = &Builtin{
Name: "crypto.md5",
Description: "Returns a string representing the input string hashed with the MD5 function",
@@ -2376,6 +2454,18 @@ var CryptoHmacSha512 = &Builtin{
),
}
var CryptoHmacEqual = &Builtin{
Name: "crypto.hmac.equal",
Description: "Returns a boolean representing the result of comparing two MACs for equality without leaking timing information.",
Decl: types.NewFunction(
types.Args(
types.Named("mac1", types.S).Description("mac1 to compare"),
types.Named("mac2", types.S).Description("mac2 to compare"),
),
types.Named("result", types.B).Description("`true` if the MACs are equals, `false` otherwise"),
),
}
/**
* Graphs.
*/
@@ -2395,7 +2485,7 @@ var WalkBuiltin = &Builtin{
types.A,
},
nil,
)).Description("pairs of `path` and `value`: `path` is an array representing the pointer to `value` in `x`"),
)).Description("pairs of `path` and `value`: `path` is an array representing the pointer to `value` in `x`. If `path` is assigned a wildcard (`_`), the `walk` function will skip path creation entirely for faster evaluation."),
),
Categories: graphs,
}
@@ -2653,6 +2743,60 @@ var GraphQLSchemaIsValid = &Builtin{
),
}
/**
* JSON Schema
*/
// JSONSchemaVerify returns empty string if the input is valid JSON schema
// and returns error string for all other inputs.
var JSONSchemaVerify = &Builtin{
Name: "json.verify_schema",
Description: "Checks that the input is a valid JSON schema object. The schema can be either a JSON string or an JSON object.",
Decl: types.NewFunction(
types.Args(
types.Named("schema", types.NewAny(types.S, types.NewObject(nil, types.NewDynamicProperty(types.A, types.A)))).
Description("the schema to verify"),
),
types.Named("output", types.NewArray([]types.Type{
types.B,
types.NewAny(types.S, types.Null{}),
}, nil)).
Description("`output` is of the form `[valid, error]`. If the schema is valid, then `valid` is `true`, and `error` is `null`. Otherwise, `valid` is `false` and `error` is a string describing the error."),
),
Categories: objectCat,
}
// JSONMatchSchema returns empty array if the document matches the JSON schema,
// and returns non-empty array with error objects otherwise.
var JSONMatchSchema = &Builtin{
Name: "json.match_schema",
Description: "Checks that the document matches the JSON schema.",
Decl: types.NewFunction(
types.Args(
types.Named("document", types.NewAny(types.S, types.NewObject(nil, types.NewDynamicProperty(types.A, types.A)))).
Description("document to verify by schema"),
types.Named("schema", types.NewAny(types.S, types.NewObject(nil, types.NewDynamicProperty(types.A, types.A)))).
Description("schema to verify document by"),
),
types.Named("output", types.NewArray([]types.Type{
types.B,
types.NewArray(
nil, types.NewObject(
[]*types.StaticProperty{
{Key: "error", Value: types.S},
{Key: "type", Value: types.S},
{Key: "field", Value: types.S},
{Key: "desc", Value: types.S},
},
nil,
),
),
}, nil)).
Description("`output` is of the form `[match, errors]`. If the document is valid given the schema, then `match` is `true`, and `errors` is an empty array. Otherwise, `match` is `false` and `errors` is an array of objects describing the error(s)."),
),
Categories: objectCat,
}
/**
* Cloud Provider Helper Functions
*/
@@ -3097,6 +3241,21 @@ func category(cs ...string) []string {
return cs
}
// Minimal returns a shallow copy of b with the descriptions and categories and
// named arguments stripped out.
func (b *Builtin) Minimal() *Builtin {
cpy := *b
fargs := b.Decl.FuncArgs()
if fargs.Variadic != nil {
cpy.Decl = types.NewVariadicFunction(fargs.Args, fargs.Variadic, b.Decl.Result())
} else {
cpy.Decl = types.NewFunction(fargs.Args, b.Decl.Result())
}
cpy.Categories = nil
cpy.Description = ""
return &cpy
}
// IsDeprecated returns true if the Builtin function is deprecated and will be removed in a future release.
func (b *Builtin) IsDeprecated() bool {
return b.deprecated
@@ -3143,7 +3302,7 @@ func (b *Builtin) Ref() Ref {
// IsTargetPos returns true if a variable in the i-th position will be bound by
// evaluating the call expression.
func (b *Builtin) IsTargetPos(i int) bool {
return len(b.Decl.Args()) == i
return len(b.Decl.FuncArgs().Args) == i
}
func init() {