diff --git a/README.md b/README.md index 54a529f..e90cf68 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,16 @@ available under `rc profile go`, with identical flags and behavior: | `rc profile validate-extension` | Validate one imported binding package selected with `--package`. | | `rc profile version` | Show the linked Go profiler version. | +A profile does not have to come from a profiler. To check one written by hand, or by +an agent, against the extensions it declares (their definitions are downloaded from +their https ids, or read from `--catalog` directories): + +```sh +./rc profile validate profile.yaml +``` + +This checks the extension vocabulary and schemas, not the core profile fields. + For command help: ```sh diff --git a/internal/cli/profile.go b/internal/cli/profile.go index a7fa0be..e0956d3 100644 --- a/internal/cli/profile.go +++ b/internal/cli/profile.go @@ -28,7 +28,7 @@ func newProfileCommand(deps Dependencies) *cobra.Command { func newGoProfileCommands(api goProfilerAPI) *cobra.Command { profile := &cobra.Command{ - Use: "profile", Short: "Generate profiles with the built-in Go profiler", + Use: "profile", Short: "Generate profiles with the built-in Go profiler, or validate any profile", Long: "Generate profiles with the Go profiler linked into rc. Go analysis requires a working Go toolchain.", Example: " rc profile generate --dir ./service\n rc profile go generate --dir ./service", } @@ -42,7 +42,7 @@ func newGoProfileCommands(api goProfilerAPI) *cobra.Command { parent.AddCommand(newGoGenerateCommand(api), newGoValidateCommand(api, true), newGoValidateCommand(api, false), newGoVersionCommand()) } - profile.AddCommand(goCommand) + profile.AddCommand(goCommand, newProfileValidateCommand(linkedProfileValidateAPI())) return profile } diff --git a/internal/cli/profile_validate.go b/internal/cli/profile_validate.go new file mode 100644 index 0000000..f7ba080 --- /dev/null +++ b/internal/cli/profile_validate.go @@ -0,0 +1,224 @@ +package cli + +import ( + "context" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "os" + "path/filepath" + "strconv" + "strings" + "time" + + "github.com/runtimeconditions/go-rc-profiler/extensioncheck" + "github.com/spf13/cobra" + "go.yaml.in/yaml/v3" +) + +const ( + extensionDefinitionFile = "runtimeconditions.extension.yaml" + maxDefinitionBytes = 4 << 20 + maxDefinitions = 64 +) + +// profileValidateAPI holds what the command needs from outside the process, so tests can replace it. +type profileValidateAPI struct { + Validate func(profile []byte, catalogRoots []string) error + Client *http.Client +} + +func linkedProfileValidateAPI() profileValidateAPI { + return profileValidateAPI{ + Validate: func(profile []byte, catalogRoots []string) error { + return extensioncheck.ValidateProfileYAML(profile, extensioncheck.ProfileOptions{CatalogRoots: catalogRoots}) + }, + Client: &http.Client{Timeout: 20 * time.Second}, + } +} + +func newProfileValidateCommand(api profileValidateAPI) *cobra.Command { + var catalogs []string + cmd := &cobra.Command{ + Use: "validate ", + Short: "Validate a hand-written profile against its extensions", + Long: "Validate a Runtime Conditions Profile against the extensions it declares, whoever wrote it.\n\n" + + "By default the extension definitions are downloaded from the https ids the profile names, " + + "including their dependencies. With --catalog the definitions are read from local directories " + + "instead and nothing is downloaded. Use - to read the profile from standard input.\n\n" + + "This checks the profile against the extension vocabulary and schemas. It does not check the " + + "core profile fields (apiVersion, metadata, workload) against the core schema.", + Example: " rc profile validate profile.yaml\n rc profile validate profile.yaml --catalog ./extensions", + Args: usageArgs(cobra.ExactArgs(1)), + ValidArgsFunction: cobra.NoFileCompletions, + RunE: func(cmd *cobra.Command, args []string) error { + return validateProfileFile(cmd.Context(), api, args[0], catalogs, cmd.InOrStdin(), cmd.ErrOrStderr()) + }, + } + cmd.Flags().StringArrayVar(&catalogs, "catalog", nil, "directory of extension definitions to use instead of downloading them (repeatable)") + return cmd +} + +func validateProfileFile(ctx context.Context, api profileValidateAPI, path string, catalogs []string, stdin io.Reader, stderr io.Writer) error { + var data []byte + var err error + if path == "-" { + data, err = io.ReadAll(stdin) + } else { + data, err = os.ReadFile(path) + } + if err != nil { + return err + } + roots := catalogs + if len(roots) == 0 { + directory, err := os.MkdirTemp("", "rc-extensions-") + if err != nil { + return err + } + defer os.RemoveAll(directory) + if err := downloadDefinitions(ctx, api.Client, data, directory); err != nil { + return err + } + roots = []string{directory} + } + if err := api.Validate(data, roots); err != nil { + return err + } + _, err = fmt.Fprintln(stderr, "runtimeconditions: profile validated") + return err +} + +type extensionRef struct{ ID, Version string } + +// referencesOf reads a list of extension references written as a string +// ("" or ":") or as an id/version object. +func referencesOf(nodes []yaml.Node) ([]extensionRef, error) { + var refs []extensionRef + for _, node := range nodes { + switch node.Kind { + case yaml.ScalarNode: + if node.Value == "" { + return nil, errors.New("extension reference must not be empty") + } + id, version := node.Value, "" + colon, scheme := strings.LastIndex(id, ":"), strings.Index(id, "://") + if colon > 0 && colon > scheme+2 && colon > strings.LastIndex(id, "/") { + id, version = node.Value[:colon], node.Value[colon+1:] + } + refs = append(refs, extensionRef{id, version}) + case yaml.MappingNode: + var fields struct{ ID, Version string } + if err := node.Decode(&fields); err != nil { + return nil, err + } + refs = append(refs, extensionRef{fields.ID, fields.Version}) + default: + return nil, errors.New("extension reference must be a string or an id/version object") + } + } + return refs, nil +} + +func (r extensionRef) candidateURLs() []string { + if r.Version == "" { + return []string{r.ID} + } + return []string{strings.TrimRight(r.ID, "/") + "/" + r.Version + "/" + extensionDefinitionFile, r.ID} +} + +// downloadDefinitions fetches the definitions of the extensions a profile declares, and of their +// dependencies, into directory so the catalog loader can read them. +func downloadDefinitions(ctx context.Context, client *http.Client, profile []byte, directory string) error { + var document struct { + Extensions []yaml.Node `yaml:"extensions"` + } + if err := yaml.Unmarshal(profile, &document); err != nil { + return fmt.Errorf("read profile: %w", err) + } + queue, err := referencesOf(document.Extensions) + if err != nil { + return fmt.Errorf("profile extensions: %w", err) + } + fetched := map[string]bool{} + count := 0 + for len(queue) > 0 { + ref := queue[0] + queue = queue[1:] + address, body, err := fetchDefinition(ctx, client, ref) + if err != nil { + return err + } + // The same release can be named by a short reference and by its full id. + if fetched[address] { + continue + } + fetched[address] = true + if count++; count > maxDefinitions { + return fmt.Errorf("the profile needs more than %d extension definitions", maxDefinitions) + } + subdirectory := filepath.Join(directory, strconv.Itoa(count)) + if err := os.MkdirAll(subdirectory, 0o700); err != nil { + return err + } + if err := os.WriteFile(filepath.Join(subdirectory, extensionDefinitionFile), body, 0o600); err != nil { + return err + } + var definition struct { + Spec struct { + Dependencies []yaml.Node `yaml:"dependencies"` + } `yaml:"spec"` + } + if err := yaml.Unmarshal(body, &definition); err != nil { + return fmt.Errorf("read the definition of %s: %w", ref.ID, err) + } + dependencies, err := referencesOf(definition.Spec.Dependencies) + if err != nil { + return fmt.Errorf("dependencies of %s: %w", ref.ID, err) + } + queue = append(queue, dependencies...) + } + return nil +} + +func fetchDefinition(ctx context.Context, client *http.Client, ref extensionRef) (string, []byte, error) { + var failures []string + for _, candidate := range ref.candidateURLs() { + parsed, err := url.Parse(candidate) + if err != nil || parsed.Scheme != "https" || parsed.Host == "" { + failures = append(failures, candidate+": only https extension ids can be downloaded") + continue + } + body, err := get(ctx, client, candidate) + if err == nil { + return candidate, body, nil + } + failures = append(failures, err.Error()) + } + return "", nil, fmt.Errorf("cannot get the definition of extension %s (%s); use --catalog to read definitions from a directory", ref.ID, strings.Join(failures, "; ")) +} + +func get(ctx context.Context, client *http.Client, address string) ([]byte, error) { + request, err := http.NewRequestWithContext(ctx, http.MethodGet, address, nil) + if err != nil { + return nil, err + } + response, err := client.Do(request) + if err != nil { + return nil, fmt.Errorf("%s: %w", address, err) + } + defer response.Body.Close() + if response.StatusCode != http.StatusOK { + return nil, fmt.Errorf("%s: %s", address, response.Status) + } + body, err := io.ReadAll(io.LimitReader(response.Body, maxDefinitionBytes+1)) + if err != nil { + return nil, fmt.Errorf("%s: %w", address, err) + } + if len(body) > maxDefinitionBytes { + return nil, fmt.Errorf("%s: the definition is larger than %d bytes", address, maxDefinitionBytes) + } + return body, nil +} diff --git a/internal/cli/profile_validate_test.go b/internal/cli/profile_validate_test.go new file mode 100644 index 0000000..65d46ee --- /dev/null +++ b/internal/cli/profile_validate_test.go @@ -0,0 +1,154 @@ +package cli + +import ( + "bytes" + "errors" + "fmt" + "io" + "net/http" + "os" + "path/filepath" + "strings" + "testing" +) + +const ( + commonShort = "https://runtimeconditions.io/extensions/rc/common-integrations:v1alpha2" + envShort = "https://runtimeconditions.io/extensions/rc/env-configuration:v1alpha2" + validHTTP = `apiVersion: runtimeconditions.io/v1alpha1 +kind: RuntimeConditionsProfile +metadata: {name: orders} +workload: {uri: "https://example.test/orders"} +extensions: + - ` + commonShort + ` + - ` + envShort + ` +conditions: + - kind: cache + interface: {type: key_value, engine: redis} + configuration: + env: + - {property: url, name: REDIS_URL} +` +) + +var fixtureRoot = filepath.Join("..", "..", "testdata", "profile-validate", "extensions") + +// definitionServer serves the committed extension definitions for https://runtimeconditions.io/extensions/. +type definitionServer struct{ requests []string } + +func (s *definitionServer) RoundTrip(request *http.Request) (*http.Response, error) { + s.requests = append(s.requests, request.URL.String()) + status, body := http.StatusNotFound, "not found" + const prefix = "https://runtimeconditions.io/extensions/" + if address := request.URL.String(); strings.HasPrefix(address, prefix) { + if data, err := os.ReadFile(filepath.Join(fixtureRoot, filepath.FromSlash(strings.TrimPrefix(address, prefix)))); err == nil { + status, body = http.StatusOK, string(data) + } + } + return &http.Response{StatusCode: status, Status: fmt.Sprintf("%d %s", status, http.StatusText(status)), Body: io.NopCloser(strings.NewReader(body)), Request: request}, nil +} + +type refusingTransport struct{} + +func (refusingTransport) RoundTrip(*http.Request) (*http.Response, error) { + return nil, errors.New("the network must not be used") +} + +func runProfileValidate(t *testing.T, transport http.RoundTripper, profile string, args ...string) (string, error) { + t.Helper() + api := linkedProfileValidateAPI() + api.Client = &http.Client{Transport: transport} + command := newProfileValidateCommand(api) + var stderr bytes.Buffer + command.SetOut(io.Discard) + command.SetErr(&stderr) + command.SetIn(strings.NewReader(profile)) + command.SetArgs(append([]string{"-"}, args...)) + err := command.Execute() + return stderr.String(), err +} + +func TestValidateAcceptsAProfileAndDownloadsItsExtensionsAndDependencies(t *testing.T) { + server := &definitionServer{} + stderr, err := runProfileValidate(t, server, validHTTP) + if err != nil { + t.Fatalf("a valid profile was rejected: %v", err) + } + if !strings.Contains(stderr, "profile validated") { + t.Fatalf("missing success message: %q", stderr) + } + if len(server.requests) < 2 { + t.Fatalf("expected both extensions to be downloaded, got %v", server.requests) + } +} + +func TestValidateRejectsAValueTheExtensionDoesNotAllow(t *testing.T) { + _, err := runProfileValidate(t, &definitionServer{}, strings.Replace(validHTTP, "engine: redis", "engine: oracle", 1)) + if err == nil || !strings.Contains(err.Error(), "oracle") { + t.Fatalf("expected the engine to be rejected, got %v", err) + } +} + +func TestValidateRejectsConfigurationWhenItsExtensionIsNotDeclared(t *testing.T) { + withoutEnv := strings.Replace(validHTTP, " - "+envShort+"\n", "", 1) + _, err := runProfileValidate(t, &definitionServer{}, withoutEnv) + if err == nil || !strings.Contains(err.Error(), "configuration") { + t.Fatalf("expected configuration to be rejected without env-configuration, got %v", err) + } +} + +func TestValidateSaysHowToProceedWhenADefinitionCannotBeDownloaded(t *testing.T) { + profile := strings.Replace(validHTTP, "common-integrations:v1alpha2", "missing:v9", 1) + _, err := runProfileValidate(t, &definitionServer{}, profile) + if err == nil || !strings.Contains(err.Error(), "404") || !strings.Contains(err.Error(), "--catalog") { + t.Fatalf("expected a download error that mentions --catalog, got %v", err) + } +} + +func TestValidateDownloadsOnlyOverHTTPS(t *testing.T) { + profile := strings.Replace(validHTTP, "https://runtimeconditions.io/extensions/rc/common-integrations:v1alpha2", "http://runtimeconditions.io/extensions/rc/common-integrations:v1alpha2", 1) + server := &definitionServer{} + _, err := runProfileValidate(t, server, profile) + if err == nil || !strings.Contains(err.Error(), "only https") { + t.Fatalf("expected a plain http id to be refused, got %v", err) + } + for _, request := range server.requests { + if strings.HasPrefix(request, "http://") { + t.Fatalf("a plain http request was made: %s", request) + } + } +} + +func TestValidateReadsLocalDefinitionsWithoutTheNetworkWhenACatalogIsGiven(t *testing.T) { + stderr, err := runProfileValidate(t, refusingTransport{}, validHTTP, "--catalog", fixtureRoot) + if err != nil { + t.Fatalf("a valid profile was rejected with a local catalog: %v", err) + } + if !strings.Contains(stderr, "profile validated") { + t.Fatalf("missing success message: %q", stderr) + } +} + +func TestValidateReadsTheProfileFromAFile(t *testing.T) { + path := filepath.Join(t.TempDir(), "profile.yaml") + if err := os.WriteFile(path, []byte(validHTTP), 0o600); err != nil { + t.Fatal(err) + } + api := linkedProfileValidateAPI() + api.Client = &http.Client{Transport: refusingTransport{}} + command := newProfileValidateCommand(api) + command.SetOut(io.Discard) + command.SetErr(io.Discard) + command.SetArgs([]string{path, "--catalog", fixtureRoot}) + if err := command.Execute(); err != nil { + t.Fatalf("a valid profile file was rejected: %v", err) + } +} + +func TestValidateIsPartOfTheProfileCommand(t *testing.T) { + root := NewRootCommandWith(BuildInfo{}, IOStreams{}.normalized(), DefaultDependencies()) + command, _, err := root.Find([]string{"profile", "validate"}) + if err != nil || command.Name() != "validate" { + t.Fatalf("rc profile validate is not registered: %v %v", command, err) + } +} diff --git a/testdata/profile-validate/extensions/rc/common-integrations/v1alpha2/runtimeconditions.extension.yaml b/testdata/profile-validate/extensions/rc/common-integrations/v1alpha2/runtimeconditions.extension.yaml new file mode 100644 index 0000000..b6ff0c3 --- /dev/null +++ b/testdata/profile-validate/extensions/rc/common-integrations/v1alpha2/runtimeconditions.extension.yaml @@ -0,0 +1,159 @@ +apiVersion: runtimeconditions.io/v1alpha1 +kind: RuntimeConditionsExtensionDefinition +metadata: + id: https://runtimeconditions.io/extensions/rc/common-integrations/v1alpha2/runtimeconditions.extension.yaml + version: v1alpha2 +spec: + kinds: + - {name: api} + - {name: datastore} + - {name: cache} + interfaceTypes: + - {name: http, targetKind: api} + - {name: relational, targetKind: datastore} + - {name: document, targetKind: datastore} + - {name: key_value, targetKind: cache} + - {name: smtp, targetKind: api} + interfaceFields: + - {name: spec, targetKind: api, targetType: http} + - {name: operations, targetKind: api, targetType: http} + - {name: engine, targetKind: datastore, targetType: relational} + - {name: engine, targetKind: datastore, targetType: document} + - {name: engine, targetKind: cache, targetType: key_value} + - {name: operations, targetKind: api, targetType: smtp} + fieldValues: + - {field: interface.spec.format, targetKind: api, targetType: http, values: [openapi]} + - field: interface.operations[].method + targetKind: api + targetType: http + values: [GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE] + - field: interface.engine + targetKind: datastore + targetType: relational + values: [postgres, mysql, mariadb, sqlserver, oracle, sqlite] + - field: interface.engine + targetKind: datastore + targetType: document + values: [mongodb, couchbase] + - field: interface.engine + targetKind: cache + targetType: key_value + values: [redis, memcached] + - {field: 'interface.operations[]', targetKind: api, targetType: smtp, values: [send]} + schemas: + - id: api-http-interface + appliesToKind: api + appliesToInterfaceType: http + description: Validates HTTP API integration conditions. + schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + required: [kind, interface] + properties: + kind: {const: api} + interface: + type: object + required: [type] + properties: + type: {const: http} + spec: + type: object + required: [format, uri] + properties: + format: {const: openapi} + uri: {type: string, minLength: 1} + version: + type: string + pattern: ^(?:=?[0-9]+\.[0-9]+\.[0-9]+|[<>]=?[0-9]+\.[0-9]+\.[0-9]+|\^[0-9]+\.[0-9]+\.[0-9]+|~[0-9]+\.[0-9]+\.[0-9]+)$ + additionalProperties: false + operations: + type: array + minItems: 1 + items: + type: object + required: [method, path] + properties: + method: {enum: [GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE]} + path: {type: string, minLength: 1} + requestBodySchema: {$ref: '#/$defs/simpleSchema'} + responseSchema: {$ref: '#/$defs/simpleSchema'} + additionalProperties: false + anyOf: + - {required: [spec]} + - {required: [operations]} + additionalProperties: true + additionalProperties: true + $defs: + simpleSchema: + oneOf: + - {type: string, enum: [string, number, integer, boolean, 'null']} + - {type: object, additionalProperties: {$ref: '#/$defs/simpleSchema'}} + - {type: array, minItems: 1, maxItems: 1, items: {$ref: '#/$defs/simpleSchema'}} + - id: datastore-relational-interface + appliesToKind: datastore + appliesToInterfaceType: relational + description: Validates relational datastore integration conditions. + schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + required: [kind, interface] + properties: + kind: {const: datastore} + interface: + type: object + required: [type] + properties: + type: {const: relational} + engine: {enum: [postgres, mysql, mariadb, sqlserver, oracle, sqlite]} + additionalProperties: true + additionalProperties: true + - id: datastore-document-interface + appliesToKind: datastore + appliesToInterfaceType: document + description: Validates document datastore integration conditions. + schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + required: [kind, interface] + properties: + kind: {const: datastore} + interface: + type: object + required: [type] + properties: {type: {const: document}, engine: {enum: [mongodb, couchbase]}} + additionalProperties: true + additionalProperties: true + - id: cache-key-value-interface + appliesToKind: cache + appliesToInterfaceType: key_value + description: Validates key/value cache integration conditions. + schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + required: [kind, interface] + properties: + kind: {const: cache} + interface: + type: object + required: [type] + properties: {type: {const: key_value}, engine: {enum: [redis, memcached]}} + additionalProperties: true + additionalProperties: true + - id: api-smtp-interface + appliesToKind: api + appliesToInterfaceType: smtp + description: Validates SMTP email submission requirements. + schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + required: [kind, interface] + properties: + kind: {const: api} + interface: + type: object + required: [type, operations] + properties: + type: {const: smtp} + operations: {type: array, minItems: 1, uniqueItems: true, items: {enum: [send]}} + additionalProperties: true + additionalProperties: true diff --git a/testdata/profile-validate/extensions/rc/env-configuration/v1alpha2/runtimeconditions.extension.yaml b/testdata/profile-validate/extensions/rc/env-configuration/v1alpha2/runtimeconditions.extension.yaml new file mode 100644 index 0000000..7046084 --- /dev/null +++ b/testdata/profile-validate/extensions/rc/env-configuration/v1alpha2/runtimeconditions.extension.yaml @@ -0,0 +1,184 @@ +apiVersion: runtimeconditions.io/v1alpha1 +kind: RuntimeConditionsExtensionDefinition +metadata: + id: https://runtimeconditions.io/extensions/rc/env-configuration/v1alpha2/runtimeconditions.extension.yaml + version: v1alpha2 +spec: + dependencies: ['https://runtimeconditions.io/extensions/rc/common-integrations/v1alpha2/runtimeconditions.extension.yaml'] + conditionFields: + - {name: configuration, appliesToKinds: [api], appliesToInterfaceTypes: [http]} + - name: configuration + appliesToKinds: [datastore] + appliesToInterfaceTypes: [relational, document] + - {name: configuration, appliesToKinds: [cache], appliesToInterfaceTypes: [key_value]} + - {name: configuration, appliesToKinds: [api], appliesToInterfaceTypes: [smtp]} + fieldValues: + - field: configuration.env[].property + targetKind: api + targetType: http + values: [url, baseUrl, hostname, port, scheme, username, password, token, tls] + - field: configuration.alternatives[].env[].property + targetKind: api + targetType: http + values: [url, baseUrl, hostname, port, scheme, username, password, token, tls] + - field: configuration.env[].property + targetKind: datastore + targetType: relational + values: [url, hostname, port, scheme, username, password, database, tls] + - field: configuration.alternatives[].env[].property + targetKind: datastore + targetType: relational + values: [url, hostname, port, scheme, username, password, database, tls] + - field: configuration.env[].property + targetKind: datastore + targetType: document + values: [url, hostname, port, scheme, username, password, database, tls] + - field: configuration.alternatives[].env[].property + targetKind: datastore + targetType: document + values: [url, hostname, port, scheme, username, password, database, tls] + - field: configuration.env[].property + targetKind: cache + targetType: key_value + values: [url, hostname, port, scheme, username, password, database, token, tls] + - field: configuration.alternatives[].env[].property + targetKind: cache + targetType: key_value + values: [url, hostname, port, scheme, username, password, database, token, tls] + - field: configuration.env[].property + targetKind: api + targetType: smtp + values: [url, hostname, port, username, password, tlsMode, fromAddress, toAddress] + - field: configuration.alternatives[].env[].property + targetKind: api + targetType: smtp + values: [url, hostname, port, username, password, tlsMode, fromAddress, toAddress] + schemas: + - id: configuration-shape + description: Validates the environment configuration field shape. + schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + properties: + configuration: + type: object + oneOf: + - {required: [env], properties: {env: {$ref: '#/$defs/envList'}}, additionalProperties: false} + - required: [alternatives] + properties: + alternatives: + type: array + minItems: 2 + items: + type: object + required: [env] + properties: {env: {$ref: '#/$defs/envList'}} + additionalProperties: false + additionalProperties: false + additionalProperties: true + $defs: + envList: {type: array, minItems: 1, uniqueItems: true, items: {$ref: '#/$defs/envInput'}} + envInput: + type: object + required: [property, name] + properties: + property: {type: string, minLength: 1} + name: {type: string, pattern: '^[A-Za-z_][A-Za-z0-9_]*$'} + sensitive: {type: boolean} + required: {type: boolean} + additionalProperties: false + - id: configuration-properties-api-http + appliesToKind: api + appliesToInterfaceType: http + description: Validates allowed environment configuration properties for HTTP API integrations. + schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + properties: {configuration: {$ref: '#/$defs/configuration'}} + additionalProperties: true + $defs: + allowedProperty: {enum: [url, baseUrl, hostname, port, scheme, username, password, token, tls]} + configuration: + type: object + properties: + env: {type: array, items: {$ref: '#/$defs/envInput'}} + alternatives: + type: array + items: {type: object, properties: {env: {type: array, items: {$ref: '#/$defs/envInput'}}}} + envInput: {type: object, properties: {property: {$ref: '#/$defs/allowedProperty'}}} + - id: configuration-properties-datastore-relational + appliesToKind: datastore + appliesToInterfaceType: relational + description: Validates allowed environment configuration properties for relational datastore integrations. + schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + properties: {configuration: {$ref: '#/$defs/configuration'}} + additionalProperties: true + $defs: + allowedProperty: {enum: [url, hostname, port, scheme, username, password, database, tls]} + configuration: + type: object + properties: + env: {type: array, items: {$ref: '#/$defs/envInput'}} + alternatives: + type: array + items: {type: object, properties: {env: {type: array, items: {$ref: '#/$defs/envInput'}}}} + envInput: {type: object, properties: {property: {$ref: '#/$defs/allowedProperty'}}} + - id: configuration-properties-datastore-document + appliesToKind: datastore + appliesToInterfaceType: document + description: Validates allowed environment configuration properties for document datastore integrations. + schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + properties: {configuration: {$ref: '#/$defs/configuration'}} + additionalProperties: true + $defs: + allowedProperty: {enum: [url, hostname, port, scheme, username, password, database, tls]} + configuration: + type: object + properties: + env: {type: array, items: {$ref: '#/$defs/envInput'}} + alternatives: + type: array + items: {type: object, properties: {env: {type: array, items: {$ref: '#/$defs/envInput'}}}} + envInput: {type: object, properties: {property: {$ref: '#/$defs/allowedProperty'}}} + - id: configuration-properties-cache-key-value + appliesToKind: cache + appliesToInterfaceType: key_value + description: Validates allowed environment configuration properties for key/value cache integrations. + schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + properties: {configuration: {$ref: '#/$defs/configuration'}} + additionalProperties: true + $defs: + allowedProperty: {enum: [url, hostname, port, scheme, username, password, database, token, tls]} + configuration: + type: object + properties: + env: {type: array, items: {$ref: '#/$defs/envInput'}} + alternatives: + type: array + items: {type: object, properties: {env: {type: array, items: {$ref: '#/$defs/envInput'}}}} + envInput: {type: object, properties: {property: {$ref: '#/$defs/allowedProperty'}}} + - id: configuration-properties-api-smtp + appliesToKind: api + appliesToInterfaceType: smtp + description: Validates environment configuration properties for api/smtp. + schema: + $schema: https://json-schema.org/draft/2020-12/schema + type: object + properties: {configuration: {$ref: '#/$defs/configuration'}} + additionalProperties: true + $defs: + allowedProperty: {enum: [url, hostname, port, username, password, tlsMode, fromAddress, toAddress]} + configuration: + type: object + properties: + env: {type: array, items: {$ref: '#/$defs/envInput'}} + alternatives: + type: array + items: {type: object, properties: {env: {type: array, items: {$ref: '#/$defs/envInput'}}}} + envInput: {type: object, properties: {property: {$ref: '#/$defs/allowedProperty'}}}