diff --git a/.gitmodules b/.gitmodules index 87dc586d..df36145e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,12 @@ -[submodule "mission-control/modules/canary-checker"] - path = mission-control/modules/canary-checker - url = https://github.com/flanksource/canary-checker.git +[submodule "mission-control/canary-checker/canary-checker"] + path = mission-control/canary-checker/canary-checker + url = https://github.com/flanksource/canary-checker [submodule "mission-control/modules/config-db"] path = mission-control/modules/config-db url = https://github.com/flanksource/config-db.git [submodule "mission-control/modules/mission-control"] path = mission-control/modules/mission-control url = https://github.com/flanksource/mission-control.git -[submodule "mission-control/canary-checker/canary-checker"] - path = mission-control/canary-checker/canary-checker +[submodule "mission-control/modules/canary-checker"] + path = mission-control/modules/canary-checker url = https://github.com/flanksource/canary-checker diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000..7d91fd3f --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,9 @@ +{ + "MD033": false, + "MD004": false, + "MD045": false, + "MD013": false, + "MD012": false, + "MD024": false, + "MD040": false +} diff --git a/canary-checker/README.md b/canary-checker/README.md index 0241da3d..92a1f798 100644 --- a/canary-checker/README.md +++ b/canary-checker/README.md @@ -140,7 +140,7 @@ Metrics exposed by. anary-checler | Metric | Type | Description | | ---------------------------------------------- | --------- | ------------------------------------------- | -| canary_check | Guage | Set to 0 when passing and 1 when failing | +| canary_check | Gauge | Set to 0 when passing and 1 when failing | | canary_check_success_count | Counter | | | canary_check_failed_count | Counter | | | canary_check_info | Info | | diff --git a/canary-checker/docs/comparisons/blackbox-exporter.md b/canary-checker/docs/comparisons/blackbox-exporter.md index 208f7e72..3cdfcb4a 100644 --- a/canary-checker/docs/comparisons/blackbox-exporter.md +++ b/canary-checker/docs/comparisons/blackbox-exporter.md @@ -1,10 +1,7 @@ # Canary-Checker vs Prometheus blackbox exporter - - [Prometheus Blackbox Exporter](https://github.com/prometheus/blackbox_exporter) is a prometheus exporter for probing HTTP, HTTPS, DNS, TCP, ICMP and gRPC. - | | Blackbox Exporter | Canary Checker | | ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | Prometheus Exporter | Yes | Yes | @@ -22,8 +19,7 @@ | Secrets | Via [Probe](https://prometheus-operator.dev/docs/operator/api/#monitoring.coreos.com/v1.Probe) | | | **Check Types** | | | | Synthetic | No | Builtin check types for any test exporting JUnit test results e.g. (k6, playwright, robot, postman, etc) | -| Infrastructre | No | Verify the ability to launch new pods, create new EC2 instances or push and pull from docker / helm / git repositories | +| Infrastructure | No | Verify the ability to launch new pods, create new EC2 instances or push and pull from docker / helm / git repositories | | Backup | No | Check backups via Restic, S3, SMB, SFTP, GCS | | Compliance | No | AWS Config Rules, Flanksource Config DB | | Alert Aggregation | No | Alert Manager, AWS Cloudwatch, Dynatrace | - diff --git a/canary-checker/docs/concepts/grafana.md b/canary-checker/docs/concepts/grafana.md index 5d82df12..96970c9c 100644 --- a/canary-checker/docs/concepts/grafana.md +++ b/canary-checker/docs/concepts/grafana.md @@ -10,8 +10,6 @@ Default grafana dashboards are available. After you deploy Grafana, these dashbo ![](/img/grafana-dashboard.png) - - ### Prometheus The helm chart can install a `ServiceMonitor` for the prometheus operator, by enabling the serviceMonitor flag diff --git a/canary-checker/docs/concepts/image-variants.md b/canary-checker/docs/concepts/image-variants.md deleted file mode 120000 index ca5bb0d0..00000000 --- a/canary-checker/docs/concepts/image-variants.md +++ /dev/null @@ -1 +0,0 @@ -../../../mission-control/docs/reference/canary-checker/image-variants.md \ No newline at end of file diff --git a/canary-checker/docs/concepts/metrics-exporter.md b/canary-checker/docs/concepts/metrics-exporter.md index d54604aa..84603e36 100644 --- a/canary-checker/docs/concepts/metrics-exporter.md +++ b/canary-checker/docs/concepts/metrics-exporter.md @@ -140,6 +140,7 @@ metadata: ``` This snippet will retrieve the `last_result.results.max` value from the last execution ensuring data is not duplicated or missed + ```go "@timestamp" : { {{- if last_result.results.max }} @@ -183,7 +184,7 @@ The max value is saved in the `transform` section using: | `valueExpr` | An expression to derive the header value from | `Expression` | | | `labels` | Labels for prometheus metric (values can be templated) | `map[string]string` | | -Expresions can make use of the following variables: +Expressions can make use of the following variables: ### **Expression Variables** @@ -194,7 +195,7 @@ Expresions can make use of the following variables: | `check.name` | Check name | `string` | | `check.description` | Check description | `string` | | `check.labels` | Dynamic labels attached to the check | `map[string]string` | -| `check.endpoint` | Endpoint (usally a URL) | `string` | +| `check.endpoint` | Endpoint (usually a URL) | `string` | | `check.duration` | Duration in milliseconds | `int64` | | `canary.name` | Canary name | `string` | | `canary.namespace` | Canary namespace | `string` | diff --git a/canary-checker/docs/concepts/secret-management.md b/canary-checker/docs/concepts/secret-management.md index 4554a488..bf7d6cf5 100644 --- a/canary-checker/docs/concepts/secret-management.md +++ b/canary-checker/docs/concepts/secret-management.md @@ -186,7 +186,7 @@ rules: ::: -# Recommendations +## Recommendations Kubernetes Secrets are, by default, stored unencrypted in the API server's underlying data store (etcd). Anyone with API access can retrieve or modify a Secret, and so can anyone with access to etcd. With this in mind, it is recommended to implement some level of security to prevent unauthorized access to your Kubernetes secrets. You may consider the following for your encryption and security needs: diff --git a/canary-checker/docs/examples/newman.mdx b/canary-checker/docs/examples/newman.mdx index 537b1a50..3e88bff1 100644 --- a/canary-checker/docs/examples/newman.mdx +++ b/canary-checker/docs/examples/newman.mdx @@ -32,7 +32,7 @@ spec: command: ["/start.sh"] ``` -By configuring newman to export JUnit to the `testResults` folder, canary-checker will pick up the results and make then available display formating and health evaluation. +By configuring newman to export JUnit to the `testResults` folder, canary-checker will pick up the results and make then available display formatting and health evaluation. ```bash title="start.sh" set -x diff --git a/canary-checker/docs/examples/playwright.mdx b/canary-checker/docs/examples/playwright.mdx index d5b1b873..6f30046d 100644 --- a/canary-checker/docs/examples/playwright.mdx +++ b/canary-checker/docs/examples/playwright.mdx @@ -32,7 +32,7 @@ spec: command: ["/start.sh"] ``` -By configuring playwright to export JUnit to the `testResults` folder, canary-checker will pick up the results and make then available display formating and health evaluation. +By configuring playwright to export JUnit to the `testResults` folder, canary-checker will pick up the results and make then available display formatting and health evaluation. ```bash title="start.sh" mkdir -p /tmp/junit-results diff --git a/canary-checker/docs/health-checks.mdx b/canary-checker/docs/health-checks.mdx index 3b62ff69..db3b73f4 100644 --- a/canary-checker/docs/health-checks.mdx +++ b/canary-checker/docs/health-checks.mdx @@ -1,4 +1,6 @@ --- +pagination_next: notifications/index +pagination_prev: topology/index slug: /canary-checker title: Health Checks --- @@ -22,7 +24,7 @@ Active infrastructure checks provision infrastructure (e.g. EC2 Instances, Kuber - + Integration checks run automated test suites using tools like Playwright, JUnit, Newman and K6 to validate end-to-end functionality across services and infrastructure. diff --git a/canary-checker/docs/reference/1-alert-manager.mdx b/canary-checker/docs/reference/1-alert-manager.mdx index 92248a1c..8a807c86 100644 --- a/canary-checker/docs/reference/1-alert-manager.mdx +++ b/canary-checker/docs/reference/1-alert-manager.mdx @@ -47,11 +47,6 @@ spec: description: "A list of alert prefix names to include", scheme: '[]string' }, - { - field: "relationships", - description: "Link the check results to components and configs using lookup expressions.", - scheme: '[Relationships](#relationships)' - }, { field: "ignore", description: "A list of alert prefix names to exclude", diff --git a/canary-checker/docs/reference/1-folder.mdx b/canary-checker/docs/reference/1-folder.mdx index 74e0c002..945885a9 100644 --- a/canary-checker/docs/reference/1-folder.mdx +++ b/canary-checker/docs/reference/1-folder.mdx @@ -43,7 +43,7 @@ spec: {field: "minCount", description: "The minimum number of files inside the `path`", scheme: "int"}, {field: "maxCount", description: "The maximum number of files inside the `path`, can be used in conjunction with `filter.regex` to detect error files", scheme: "int"}, {field: "minAge", description: "The youngest age a file can be", scheme: "Duration"}, - {field: "maxAge", description: "The oldest age a file can be, often used to check for unprocessed files or filess that have not been cleaned up", scheme: "Duration"}, + {field: "maxAge", description: "The oldest age a file can be, often used to check for unprocessed files or files that have not been cleaned up", scheme: "Duration"}, {field: "minSize", description: "The minimum file size, can be used to detect backups that did not upload successfully", scheme: "Size"}, {field: "maxSize", description: "The maximim file size", scheme: "Size"} diff --git a/canary-checker/docs/reference/1-git.mdx b/canary-checker/docs/reference/1-git.mdx index 2fd1924c..dae661dd 100644 --- a/canary-checker/docs/reference/1-git.mdx +++ b/canary-checker/docs/reference/1-git.mdx @@ -16,7 +16,7 @@ spec: schedule: "@every 1m" github: - githubToken: - query: SELECT count(*) FROM commits WHERE author_email = 'user@email.com' + query: SELECT count(*) FROM commits WHERE author_email = 'user@email.com' ``` Escaping variables -
+
```yaml title="metrics.yaml" file=../../../modules/canary-checker/fixtures/minimal/metrics-transformed.yaml diff --git a/canary-checker/docs/reference/1-kubernetes.mdx b/canary-checker/docs/reference/1-kubernetes.mdx index 777d394b..db97681a 100644 --- a/canary-checker/docs/reference/1-kubernetes.mdx +++ b/canary-checker/docs/reference/1-kubernetes.mdx @@ -7,8 +7,8 @@ sidebar_class_name: popular The Kubernetes check performs requests on Kubernetes resources such as Pods to get the desired information. -```yaml title="junit.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-minimal_pass.yaml +```yaml title="junit.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-minimal_pass.yaml ``` ```yaml title="junit.yaml" file=../../../modules/canary-checker/fixtures/k8s/certmanager.yaml - ``` -
diff --git a/canary-checker/docs/reference/1-prometheus.mdx b/canary-checker/docs/reference/1-prometheus.mdx index 3216d040..87eaa2e9 100644 --- a/canary-checker/docs/reference/1-prometheus.mdx +++ b/canary-checker/docs/reference/1-prometheus.mdx @@ -8,7 +8,7 @@ sidebar_class_name: popular The Prometheus Check connects to the Prometheus host, performs the desired query, and displays the results. -```yaml title="promtheus.yaml" file=../../../modules/canary-checker/fixtures/datasources/prometheus.yaml +```yaml title="prometheus.yaml" file=../../../modules/canary-checker/fixtures/datasources/prometheus.yaml ``` `template` expressions use the [Go Text Template](https://pkg.go.dev/text/template) library with some additional functions provided by the [gomplate](https://docs.gomplate.ca/) library. In this example we get the current exchange rate: @@ -16,7 +16,6 @@ spec: template: "$1 = €{{.json.rates.EUR}}, £{{.json.rates.GBP}}, ₪{{.json.rates.ILS}}" ``` - ## Escaping In case you might need to pass in a template variable without templating it, then you can put the template inside a string. @@ -32,7 +31,7 @@ To send `{{ .secret }}` as it is do this {{`{{ .secret }}`}} ``` -## Encoding +## Encoding ### Encode @@ -50,17 +49,18 @@ Decode a Base64 string. This supports both standard ([RFC4648 §4](https://t This function outputs the data as a string, so it may not be appropriate for decoding binary data. Use [`base64.DecodeBytes`](#base64.DecodeBytes) for binary data. - - ```go {{ base64.Decode "aGVsbG8gd29ybGQ=" }} // hello world {{ "aGVsbG8gd29ybGQ=" | base64.Decode }} // hello world ``` -##### Implementation Note + +:::note + For the functions that return an array, a Go `[]interface{}` is returned, regardless of whether or not the input was a different type. +::: -## Collection +## Collection ### dict @@ -74,8 +74,6 @@ For creating more complex maps, see [`data.JSON`](#json) or [`data.YAML`](#yaml) For creating arrays, see [`coll.Slice`](#slice). - - ```go {{ coll.Dict "name" "Frank" "age" 42 | data.ToYAML }} @@ -85,6 +83,7 @@ For creating arrays, see [`coll.Slice`](#slice). {{ dict 1 2 3 | toJSON }} // {"1":2,"3":""} ``` + ```go {{ define "T1" }}Hello {{ .thing }}!{{ end -}} {{ template "T1" (dict "thing" "world")}} @@ -99,8 +98,6 @@ For creating arrays, see [`coll.Slice`](#slice). Creates a slice (like an array or list). Useful when needing to `range` over a bunch of variables. - - ```go {{ range slice "Bart" "Lisa" "Maggie" }}Hello, {{ . }}{{ end }} @@ -109,13 +106,10 @@ Creates a slice (like an array or list). Useful when needing to `range` over a b // Hello, Maggie ``` - ### has Reports whether a given object has a property with the given key, or whether a given array/slice contains the given value. Can be used with `if` to prevent the template from trying to access a non-existent property in an object. - - ```go {{ $l := slice "foo" "bar" "baz" }}there is {{ if has $l "bar" }}a{{else}}no{{end}} bar // there is a bar @@ -127,39 +121,33 @@ Reports whether a given object has a property with the given key, or whether a g ``` - ### jsonpath -Extracts portions of an input object or list using a [JSONPath][] expression. +Extracts portions of an input object or list using a [JSONPath](https://goessner.net/articles/JsonPath) expression. Any object or list may be used as input. The output depends somewhat on the expression; if multiple items are matched, an array is returned. -JSONPath expressions can be validated at https://jsonpath.com - -[JSONPath]: https://goessner.net/articles/JsonPath - ```go {{ .books | jsonpath `$..works[?( @.edition_count > 400 )].title` }} // [Alice's Adventures in Wonderland Gulliver's Travels] ``` - ### jq Filters an input object or list using the [jq](https://stedolan.github.io/jq/) language, as implemented by [gojq](https://github.com/itchyny/gojq). Any JSON datatype may be used as input (NOTE: strings are not JSON-parsed but passed in as is). If the expression results in multiple items (no matter if streamed or as an array) they are wrapped in an array. Otherwise a single item is returned (even if resulting in an array with a single contained element). -JQ filter expressions can be tested at https://jqplay.org/ +JQ filter expressions can be tested at [jqplay](https://jqplay.org/) See also: - [jq manual](https://stedolan.github.io/jq/manual/) - [gojq differences to jq](https://github.com/itchyny/gojq#difference-to-jq) +Where books is from [fantasy.json](https://openlibrary.org/subjects/fantasy.json) -Where books is from https://openlibrary.org/subjects/fantasy.json ```go {{ .books | jq `[.works[]|{"title":.title,"authors":[.authors[].name],"published":.first_publish_year}][0]` }} @@ -167,7 +155,6 @@ Where books is from https://openlibrary.org/subjects/fantasy.json ``` - ### Keys Return a list of keys in one or more maps. @@ -176,13 +163,11 @@ The keys will be ordered first by map position (if multiple maps are given), the See also [`coll.Values`](#values). - ```go {{ coll.Keys (dict "foo" 1 "bar" 2) }} // [bar foo] ``` - ### Values Return a list of values in one or more maps. @@ -191,35 +176,27 @@ The values will be ordered first by map position (if multiple maps are given), t See also [`coll.Keys`](#keys). - - - ```go {{ coll.Values (dict "foo" 1 "bar" 2) }} // [2 1] ``` - ### append Append a value to the end of a list. _Note that this function does not change the given list; it always produces a new one._ - ```go {{ slice 1 1 2 3 | append 5 }} // [1 1 2 3 5] ``` - ### prepend Prepend a value to the beginning of a list. _Note that this function does not change the given list; it always produces a new one._ - - ```go {{ slice 4 3 2 1 | prepend 5 }} // [5 4 3 2 1] ``` @@ -230,40 +207,31 @@ Remove any duplicate values from the list, without changing order. _Note that this function does not change the given list; it always produces a new one._ - - ```go {{ slice 1 2 3 2 3 4 1 5 | uniq }} // [1 2 3 4 5] ``` - ### flatten Flatten a nested list. Defaults to completely flattening all nested lists, but can be limited with `depth`. _Note that this function does not change the given list; it always produces a new one._ - - ```go {{ "[[1,2],[],[[3,4],[[[5],6],7]]]" | jsonArray | flatten }} // [1 2 3 4 5 6 7] {{ coll.Flatten 2 ("[[1,2],[],[[3,4],[[[5],6],7]]]" | jsonArray) }} // [1 2 3 4 [[5] 6] 7] ``` - ### reverse Reverse a list. _Note that this function does not change the given list; it always produces a new one._ - - ```go {{ slice 4 3 2 1 | reverse }} // [1 2 3 4] ``` - ### Sort Sort a given list. Uses the natural sort order if possible. For inputs that are not sortable (either because the elements are of different types, or of an un-sortable type), the input will simply be returned, unmodified. @@ -272,15 +240,14 @@ Maps and structs can be sorted by a named key. _Note that this function does not modify the input._ - ```go {{ slice "foo" "bar" "baz" | coll.Sort }} // [bar baz foo] ``` + ```go {{ sort (slice 3 4 1 2 5) }} // [1 2 3 4 5] ``` - ### Merge Merge maps together by overriding src with dst. In other words, the src map can be configured the "default" map, whereas the dst @@ -288,7 +255,6 @@ map can be configured the "overrides". Many source maps can be provided. Precede _Note that this function does not modify the input._ - ```go {{ $default := dict "foo" 1 "bar" 2}} {{ $config := dict "foo" 8 }} @@ -296,6 +262,7 @@ _Note that this function does not modify the input._ // map[bar:2 foo:8] ``` + ```go {{ $dst := dict "foo" 1 "bar" 2 }} {{ $src1 := dict "foo" 8 "baz" 4 }} @@ -312,7 +279,6 @@ Given a map, returns a new map with any entries that have the given keys. All keys are converted to strings. _Note that this function does not modify the input._ - ```go {{ $data := dict "foo" 1 "bar" 2 "baz" 3 }} {{ $pickedData := coll.Pick "foo" "baz" $data }} @@ -327,10 +293,8 @@ Given a map, returns a new map without any entries that have the given keys. All keys are converted to strings. - _Note that this function does not modify the input._ - ```go {{ $data := dict "foo" 1 "bar" 2 "baz" 3 }} {{ $newData := coll.Omit "foo" "baz" $data }} @@ -339,7 +303,7 @@ _Note that this function does not modify the input._ // map[bar:2] ``` -## Convert +## Convert ### bool @@ -347,7 +311,6 @@ _Note that this function does not modify the input._ Converts a true-ish string to a boolean. Can be used to simplify conditional statements based on environment variables or other text input. - ```go {{ $FOO := true }} {{ if $FOO }}foo{{ else }}bar{{ end }} // foo @@ -359,8 +322,6 @@ Provides a default value given an empty input. Empty inputs are `0` for numeric Note that this will not provide a default for the case where the input is undefined (i.e. referencing things like `.foo` where there is no `foo` field of `.`), but [`conv.Has`](#has) can be used for that. - - ```go {{ "" | default "foo" }} // foo {{ "bar" | default "baz" }} // bar @@ -379,8 +340,6 @@ For creating more complex maps, see [`data.JSON`](#json) or [`data.YAML`](#yaml) For creating arrays, see [`conv.Slice`](#slice). - - ```go {{ $dict := conv.Dict "name" "Frank" "age" 42 }} {{ $yaml := data.ToYAML $dict }} @@ -396,8 +355,6 @@ For creating arrays, see [`conv.Slice`](#slice). Creates a slice (like an array or list). Useful when needing to `range` over a bunch of variables. - - ```go {{ range slice "Bart" "Lisa" "Maggie" }}Hello, {{ . }}{{ end }} // Hello, Bart @@ -409,33 +366,29 @@ Creates a slice (like an array or list). Useful when needing to `range` over a b Reports whether a given object has a property with the given key, or whether a given array/slice contains the given value. Can be used with `if` to prevent the template from trying to access a non-existent property in an object. - - ```go {{ $l := slice "foo" "bar" "baz" }}there is {{ if has $l "bar" }}a{{else}}no{{end}} bar // there is a bar ``` + ```go {{ $o := dict "foo" "bar" }} // Defining a map with keys and values {{ if has $o "foo" }}{{ index $o "foo" }}{{ else }}THERE IS NO FOO{{ end }} // bar ``` + ```go {{ $o := dict "baz" "quix" }} {{ if has $o "foo" }}{{ index $o "foo" }}{{ else }}THERE IS NO FOO{{ end }} // THERE IS NO FOO ``` - ### join Concatenates the elements of an array to create a string. The separator string `sep` is placed between elements in the resulting string. - - ```go {{ $a := slice 1 2 3 }}{{ join $a "-" }} // 1-2-3 ``` - ### urlParse Parses a string as a URL for later use. Equivalent to [url.Parse](https://golang.org/pkg/net/url/#Parse) @@ -453,8 +406,6 @@ _**Note:**_ See [`conv.ToInt64`](#toint64) instead for a simpler and more flexib Parses a string as an int64. Equivalent to [strconv.ParseInt](https://golang.org/pkg/strconv/#ParseInt) - - ```go {{ $hexVal := "7C0" }} {{/* Equivalent to 1984 in decimal */}} {{ $val := int64 0 }} {{/* Initialize $val to ensure it's of the right type for ParseInt */}} @@ -466,12 +417,10 @@ The value in decimal is {{ $val }} ### ParseFloat -_**Note:**_ See [`conv.ToFloat`](#`tofloat) instead for a simpler and more flexible variant of this function. +_**Note:**_ See [`conv.ToFloat`](#tofloat) instead for a simpler and more flexible variant of this function. Parses a string as an float64 for later use. Equivalent to [strconv.ParseFloat](https://golang.org/pkg/strconv/#ParseFloat) - - ```go {{ $pi := "3.14159265359" }} {{ $piFloat := conv.ParseFloat $pi 64 }} @@ -486,8 +435,6 @@ pi is greater than 3 Parses a string as an uint64 for later use. Equivalent to [strconv.ParseUint](https://golang.org/pkg/strconv/#ParseUint) - - ```go {{ $BIG := "FFFFFFFFFFFFFFFF" }} {{ $maxInt64 := conv.ParseInt $BIG 16 64 }} is max int64 // 9223372036854775807 is max int64 @@ -508,7 +455,6 @@ Converts the input to a boolean value. Possible `true` values are: `1` or the st Converts a list of inputs to an array of boolean values. Possible `true` values are: `1` or the strings `"t"`, `"true"`, or `"yes"` (any capitalizations). All other values are considered `false`. - ```go {{ conv.ToBools "yes" true "0x01" }} // [true true true] {{ conv.ToBools false "blah" 0 }} // [false false false] @@ -518,12 +464,10 @@ Converts a list of inputs to an array of boolean values. Possible `true` values Converts the input to an `int64` (64-bit signed integer). -This function attempts to convert most types of input (strings, numbers, and booleans), but behaviour when the input can not be converted is undefined and subject to change. Unconvertable inputs may result in errors, or `0` or `-1`. +This function attempts to convert most types of input (strings, numbers, and booleans), but behavior when the input can not be converted is undefined and subject to change. Unconvertible inputs may result in errors, or `0` or `-1`. Floating-point numbers (with decimal points) are truncated. - - ```go {{conv.ToInt64 "9223372036854775807"}} // 9223372036854775807 {{conv.ToInt64 "0x42"}} // 66 @@ -532,14 +476,12 @@ Floating-point numbers (with decimal points) are truncated. ### ToInt -Converts the input to an `int` (signed integer, 32- or 64-bit depending on platform). This is similar to [`conv.ToInt64`](#`toint64) on 64-bit platforms, but is useful when input to another function must be provided as an `int`. +Converts the input to an `int` (signed integer, 32- or 64-bit depending on platform). This is similar to [`conv.ToInt64`](#toint64) on 64-bit platforms, but is useful when input to another function must be provided as an `int`. On 32-bit systems, given a number that is too large to fit in an `int`, the result is `-1`. This is done to protect against [CWE-190](https://cwe.mitre.org/data/definitions/190.html) and [CWE-681](https://cwe.mitre.org/data/definitions/681.html). -See also [`conv.ToInt64`](#`toint64). - - +See also [`conv.ToInt64`](#toint64). ```go {{conv.ToInt "9223372036854775807"}} // 9223372036854775807 @@ -559,8 +501,6 @@ Converts the inputs to an array of `int64`s. Converts the inputs to an array of `int`s. - - ```go {{ conv.ToInts true 0x42 "123,456.99" "1.2345e+3"}} // [1 66 123456 1234] ``` @@ -569,9 +509,7 @@ Converts the inputs to an array of `int`s. Converts the input to a `float64`. -This function attempts to convert most types of input (strings, numbers, and booleans), but behaviour when the input can not be converted is undefined and subject to change. Unconvertable inputs may result in errors, or `0` or `-1`. - - +This function attempts to convert most types of input (strings, numbers, and booleans), but behavior when the input can not be converted is undefined and subject to change. Unconvertible inputs may result in errors, or `0` or `-1`. ```go {{ conv.ToFloat64 "8.233e-1"}} // 0.8233 @@ -582,9 +520,7 @@ This function attempts to convert most types of input (strings, numbers, and boo Converts the inputs to an array of `float64`s. -This delegates to [`conv.ToFloat64`](#`tofloat64) for each input argument. - - +This delegates to [`conv.ToFloat64`](#tofloat64) for each input argument. ```go {{ conv.ToFloat64s true 0x42 "123,456.99" "1.2345e+3"}} // [1 66 123456.99 1234.5] @@ -596,8 +532,6 @@ Converts the input (of any type) to a `string`. The input will always be represented in _some_ way. - - ```go {{ conv.ToString 0xFF }} // 255 {{ dict "foo" "bar" | conv.ToString}} // map[foo:bar] @@ -608,67 +542,56 @@ The input will always be represented in _some_ way. Converts the inputs (of any type) to an array of `string`s - ```go {{ conv.ToStrings nil 42 true 0xF (slice 1 2 3) }} // [nil 42 true 15 [1 2 3]] ``` - -## Cryptography +## Cryptography ### crypto.SHA1 - Compute a checksum with a SHA-1 or SHA-2 algorithm as defined in [RFC 3174](https://tools.ietf.org/html/rfc3174) (SHA-1) and [FIPS 180-4](http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf) (SHA-2). These functions output the binary result as a hexadecimal string. _Warning: SHA-1 is cryptographically broken and should not be used for secure applications._ - ```go {{ crypto.SHA1 "foo" }} // f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 {{ crypto.SHA512 "bar" }} // cc06808cbbee0510331aa97974132e8dc296aeb795be229d064bae784b0a87a5cf4281d82e8c99271b75db2148f08a026c1a60ed9cabdb8cac6d24242dac4063 ``` - -## Data +## Data ### json Converts a JSON string into an object. Works for JSON Objects, but will also parse JSON Arrays. Will not parse other valid JSON types. -For more explict JSON Array support, see [`data.JSONArray`](#jsonarray). - +For more explicit JSON Array support, see [`data.JSONArray`](#jsonarray). ```go {{ ('{"hello":"world"}' | json).hello }} // world ``` - ### jsonArray Converts a JSON string into a slice. Only works for JSON Arrays. - ```go {{ ('[ "you", "world" ]' | jsonArray) 1 }} // world ``` - ### yaml Converts a YAML string into an object. Works for YAML Objects but will also parse YAML Arrays. This can be used to access properties of YAML objects. -For more explict YAML Array support, see [`data.JSONArray`](#yamlarray). - +For more explicit YAML Array support, see [`data.JSONArray`](#yamlarray). ```go {{ $FOO := "hello: world" }} Hello {{ (yaml $FOO).hello }} // Hello world ``` - ### yamlArray Converts a YAML string into a slice. Only works for YAML Arrays. @@ -678,7 +601,6 @@ Converts a YAML string into a slice. Only works for YAML Arrays. Hello {{ (yaml $FOO).hello }} // Hello world ``` - ### toml Converts a [TOML](https://github.com/toml-lang/toml) document into an object. This can be used to access properties of TOML documents. @@ -689,14 +611,12 @@ hello = "world"` }} Hello {{ (toml $t).data.hello }} //Hello world ``` - ### csv Converts a CSV-format string into a 2-dimensional string array. By default, the [RFC 4180](https://tools.ietf.org/html/rfc4180) format is supported, but any single-character delimiter can be specified. - ``` {{ $c := `C,32 Go,25 @@ -736,12 +656,10 @@ Go has 25 keywords. COBOL has 357 keywords. ``` - ### csvByColumn Like [`csvByRow`](#csvbyrow), except that the data is presented as a columnar (column-oriented) map. - ``` {{ $c := `C;32 Go;25 @@ -759,19 +677,14 @@ Go COBOL ``` - ### toJSON Converts an object to a JSON document. Input objects may be the result of `json`, `yaml`, `jsonArray`, or `yamlArray` functions - - ```go {{ (`{"foo":{"hello":"world"}}` | json).foo | toJSON }} // {"hello":"world"} ``` - - ### toJSONPretty Converts an object to a pretty-printed (or _indented_) JSON document. Input objects may be the result of functions like `data.JSON`, `data.YAML`, `data.JSONArray`, or `data.YAMLArray` functions. @@ -792,33 +705,27 @@ The indent string must be provided as an argument. Converts an object to a YAML document. Input objects may be the result of `data.JSON`, `data.YAML`, `data.JSONArray`, or `data.YAMLArray` functions. - - _This is obviously contrived - `data.JSON` is used to create an object._ - ```go {{ (`{"foo":{"hello":"world"}}` | data.JSON).foo | data.ToYAML }} // hello: world ``` - ### toTOML Converts an object to a [TOML](https://github.com/toml-lang/toml) document. - - ```go {{ `{"foo":"bar"}` | data.JSON | data.ToTOML }} // foo = "bar" ``` - ### toCSV Converts an object to a CSV document. The input object must be a 2-dimensional array of strings (a `[][]string`). Objects produced by [`data.CSVByRow`](#csvbyrow) and [`data.CSVByColumn`](#csvbycolumn) cannot yet be converted back to CSV documents. **Note:** With the exception that a custom delimiter can be used, `data.ToCSV` outputs according to the [RFC 4180](https://tools.ietf.org/html/rfc4180) format, which means that line terminators are `CRLF` (Windows format, or `\r\n`). If you require `LF` (UNIX format, or `\n`), the output can be piped through [`strings.ReplaceAll`](#replaceall) to replace `"\r\n"` with `"\n"`. +**Note:** With the exception that a custom delimiter can be used, `data.ToCSV` outputs according to the [RFC 4180](https://tools.ietf.org/html/rfc4180) format, which means that line terminators are `CRLF` (Windows format, or `\r\n`). If you require `LF` (UNIX format, or `\n`), the output can be piped through [`strings.ReplaceAll`](#replaceall) to replace `"\r\n"` with `"\n"`. ```go {{ $rows := (jsonArray `[["first","second"],["1","2"],["3","4"]]`) -}} @@ -831,9 +738,7 @@ first,second 3,4 ``` - - -## filepath +## filepath ### Base @@ -841,8 +746,6 @@ Returns the last element of path. Trailing path separators are removed before ex A wrapper for Go's [`filepath.Base`](https://golang.org/pkg/path/filepath/#Base) function. - - ```go {{ filepath.Base "/tmp/foo" }} // foo ``` @@ -853,8 +756,6 @@ Clean returns the shortest path name equivalent to path by purely lexical proces A wrapper for Go's [`filepath.Clean`](https://golang.org/pkg/path/filepath/#Clean) function. - - ```go {{ filepath.Clean "/tmp//foo/../" }} // /tmp ``` @@ -865,8 +766,6 @@ Returns all but the last element of path, typically the path's directory. A wrapper for Go's [`filepath.Dir`](https://golang.org/pkg/path/filepath/#Dir) function. - - ```go {{ filepath.Dir "/tmp/foo" }} // /tmp ``` @@ -877,8 +776,6 @@ Returns the file name extension used by path. A wrapper for Go's [`filepath.Ext`](https://golang.org/pkg/path/filepath/#Ext) function. - - ```go {{ filepath.Ext "/tmp/foo.csv" }} // .csv ``` @@ -889,8 +786,6 @@ Returns the result of replacing each slash (`/`) character in the path with the A wrapper for Go's [`filepath.FromSlash`](https://golang.org/pkg/path/filepath/#FromSlash) function. - - ```go {{ filepath.FromSlash "/foo/bar" }} // /foo/bar ``` @@ -901,8 +796,6 @@ Reports whether the path is absolute. A wrapper for Go's [`filepath.IsAbs`](https://golang.org/pkg/path/filepath/#IsAbs) function. - - ```go {{ (filepath.IsAbs "/tmp/foo.csv") }} // true ``` @@ -913,8 +806,6 @@ Joins any number of path elements into a single path, adding a separator if nece A wrapper for Go's [`filepath.Join`](https://golang.org/pkg/path/filepath/#Join) function. - - ```go {{ filepath.Join "/tmp" "foo" "bar" }} // /tmp/foo/bar ``` @@ -925,8 +816,6 @@ Reports whether name matches the shell file name pattern. A wrapper for Go's [`filepath.Match`](https://golang.org/pkg/path/filepath/#Match) function. - - ```go {{ filepath.Match "*.csv" "foo.csv" }} // true ``` @@ -937,8 +826,6 @@ Returns a relative path that is lexically equivalent to targetpath when joined t A wrapper for Go's [`filepath.Rel`](https://golang.org/pkg/path/filepath/#Rel) function. - - ```go {{ filepath.Rel "/a" "/a/b/c" }} // b/c ``` @@ -951,7 +838,6 @@ The function returns an array with two values, the first being the diretory, and A wrapper for Go's [`filepath.Split`](https://golang.org/pkg/path/filepath/#Split) function. - ```go {{ $p := filepath.Split "/tmp/foo" }}{{ $dir := index $p 0 }}{{ $file := index $p 1 }}dir is {{$dir}}, file is {{$file}} // dir is /tmp/, file is foo ``` @@ -962,7 +848,6 @@ Returns the result of replacing each separator character in path with a slash (` A wrapper for Go's [`filepath.ToSlash`](https://golang.org/pkg/path/filepath/#ToSlash) function. - ```go {{ filepath.ToSlash "/foo/bar" }} // /foo/bar ``` @@ -973,32 +858,23 @@ Returns the leading volume name. Given `C:\foo\bar` it returns `C:` on Windows. A wrapper for Go's [`filepath.VolumeName`](https://golang.org/pkg/path/filepath/#VolumeName) function. - - ```go {{ filepath.VolumeName "C:/foo/bar" }} // C: {{ filepath.VolumeName "/foo/bar" }} // ``` - - -## math +## math Returns the absolute value of a given number. When the input is an integer, the result will be an `int64`, otherwise it will be a `float64`. - - ```go {{ math.Abs -3.5 }} {{ math.Abs 3.5 }} {{ math.Abs -42 }} // 3.5 3.5 42 ``` - ### Add Adds all given operators. When one of the inputs is a floating-point number, the result will be a `float64`, otherwise it will be an `int64`. - - ```go {{ math.Add 1 2 3 4 }} {{ math.Add 1.5 2 3 }} // 10 6.5 ``` @@ -1009,8 +885,6 @@ Returns the least integer value greater than or equal to a given floating-point **Note:** the return value of this function is a `float64` so that the special-cases `NaN` and `Inf` can be returned appropriately. - - ```go {{ range (slice 5.1 42 "3.14" "0xFF" "NaN" "Inf" "-0") }}ceil {{ printf "%#v" . }} = {{ math.Ceil . }}{{"\n"}}{{ end }} @@ -1023,13 +897,10 @@ Returns the least integer value greater than or equal to a given floating-point // ceil "-0" = 0 ``` - ### Div Divide the first number by the second. Division by zero is disallowed. The result will be a `float64`. - - ```go {{ math.Div 8 2 }} {{ math.Div 3 2 }} // 4 1.5 ``` @@ -1040,8 +911,6 @@ Returns the greatest integer value less than or equal to a given floating-point **Note:** the return value of this function is a `float64` so that the special-cases `NaN` and `Inf` can be returned appropriately. - - ```go {{ range (slice 5.1 42 "3.14" "0xFF" "NaN" "Inf" "-0") }}floor {{ printf "%#v" . }} = {{ math.Floor . }}{{"\n"}}{{ end }} @@ -1060,8 +929,6 @@ Returns whether or not the given number can be interpreted as a floating-point l **Note:** If a decimal point is part of the input number, it will be considered a floating-point number, even if the decimal is `0`. - - ```go {{ range (slice 1.0 "-1.0" 5.1 42 "3.14" "foo" "0xFF" "NaN" "Inf" "-0") }}{{ if (math.IsFloat .) }}{{.}} is a float{{"\n"}}{{ end }}{{end}} @@ -1077,8 +944,6 @@ Returns whether or not the given number can be interpreted as a floating-point l Returns whether or not the given number is an integer. - - ```go {{ range (slice 1.0 "-1.0" 5.1 42 "3.14" "foo" "0xFF" "NaN" "Inf" "-0") }}{{ if (math.IsInt .) }}{{.}} is an integer{{"\n"}}{{ end }}{{end}} @@ -1091,8 +956,6 @@ Returns whether or not the given number is an integer. Returns whether the given input is a number. Useful for `if` conditions. - - ```go {{ math.IsNum "foo" }} // false {{ math.IsNum 0xDeadBeef }} // true @@ -1102,8 +965,6 @@ Returns whether the given input is a number. Useful for `if` conditions. Returns the largest number provided. If any values are floating-point numbers, a `float64` is returned, otherwise an `int64` is returned. The same special-cases as Go's [`math.Max`](https://golang.org/pkg/math/#Max) are followed. - - ```go {{ math.Max 0 8.0 4.5 "-1.5e-11" }} // 8 ``` @@ -1112,42 +973,32 @@ Returns the largest number provided. If any values are floating-point numbers, a Returns the smallest number provided. If any values are floating-point numbers, a `float64` is returned, otherwise an `int64` is returned. The same special-cases as Go's [`math.Min`](https://golang.org/pkg/math/#Min) are followed. - - ```go {{ math.Min 0 8 4.5 "-1.5e-11" }} // -1.5e-11 ``` - ### Mul Multiply all given operators together. - - ```go {{ math.Mul 8 8 2 }} // 128 ``` - ### Pow Calculate an exponent - _bn_. This wraps Go's [`math.Pow`](https://golang.org/pkg/math/#Pow). If any values are floating-point numbers, a `float64` is returned, otherwise an `int64` is returned. - - ```go {{ math.Pow 10 2 }} // 100 {{ math.Pow 2 32 }} // 4294967296 {{ math.Pow 1.5 2 }} // 2.2 ``` - ### Rem Return the remainder from an integer division operation. - ```go {{ math.Rem 5 3 }} // 2 {{ math.Rem -5 3 }} // -2 @@ -1159,8 +1010,6 @@ Returns the nearest integer, rounding half away from zero. **Note:** the return value of this function is a `float64` so that the special-cases `NaN` and `Inf` can be returned appropriately. - - ```go {{ range (slice -6.5 5.1 42.9 "3.5" 6.5) }}round {{ printf "%#v" . }} = {{ math.Round . }}{{"\n"}}{{ end }} @@ -1176,8 +1025,6 @@ Returns the nearest integer, rounding half away from zero. Return a sequence from `start` to `end`, in steps of `step`. Can handle counting down as well as up, including with negative numbers. Note that the sequence _may_ not end at `end`, if `end` is not divisible by `step`. - - ```go {{ range (math.Seq 5) }}{{.}} {{end}} // 1 2 3 4 5 {{ conv.Join (math.Seq 10 -3 2) ", " }} // 10, 8, 6, 4, 2, 0, -2 @@ -1187,20 +1034,18 @@ Note that the sequence _may_ not end at `end`, if `end` is not divisible by `ste Subtract the second from the first of the given operators. When one of the inputs is a floating-point number, the result will be a `float64`, otherwise it will be an `int64`. - ```go {{ math.Sub 3 1 }} // 2 ``` -## Path +## Path + ### Base Returns the last element of path. Trailing slashes are removed before extracting the last element. If the path is empty, Base returns `.`. If the path consists entirely of slashes, Base returns `/`. A wrapper for Go's [`path.Base`](https://golang.org/pkg/path/#Base) function. - - ```go {{ path.Base "/tmp/foo" }} // foo ``` @@ -1211,8 +1056,6 @@ Clean returns the shortest path name equivalent to path by purely lexical proces A wrapper for Go's [`path.Clean`](https://golang.org/pkg/path/#Clean) function. - - ```go {{ path.Clean "/tmp//foo/../" }} // /tmp ``` @@ -1223,8 +1066,6 @@ Returns all but the last element of path, typically the path's directory. A wrapper for Go's [`path.Dir`](https://golang.org/pkg/path/#Dir) function. - - ```go {{ path.Dir "/tmp/foo" }} // /tmp ``` @@ -1233,7 +1074,6 @@ A wrapper for Go's [`path.Dir`](https://golang.org/pkg/path/#Dir) function. Returns the file name extension used by path. - ```go {{ path.Ext "/tmp/foo.csv" }} // .csv ``` @@ -1244,7 +1084,6 @@ Reports whether the path is absolute. A wrapper for Go's [`path.IsAbs`](https://golang.org/pkg/path/#IsAbs) function. - ```go {{ (path.IsAbs "/tmp/foo.csv") }} // true {{ (path.IsAbs "../foo.csv") }} // false @@ -1256,8 +1095,6 @@ Joins any number of path elements into a single path, adding a separating slash A wrapper for Go's [`path.Join`](https://golang.org/pkg/path/#Join) function. - - ```go {{ path.Join "/tmp" "foo" "bar" }} // /tmp/foo/bar ``` @@ -1268,8 +1105,6 @@ Reports whether name matches the shell file name pattern. A wrapper for Go's [`path.Match`](https://golang.org/pkg/path/#Match) function. - - ```go {{ path.Match "*.csv" "foo.csv" }} // true ``` @@ -1282,18 +1117,16 @@ The function returns an array with two values, the first being the directory, an A wrapper for Go's [`path.Split`](https://golang.org/pkg/path/#Split) function. - ```go {{ index (path.Split "/tmp/foo") }} // tmp ``` -## Random +## Random + ### ASCII Generates a random string of a desired length, containing the set of printable characters from the 7-bit [ASCII](https://en.wikipedia.org/wiki/ASCII) set. This includes _space_ (' '), but no other whitespace characters. - - ```go {{ random.ASCII 8 }} // _woJ%D&K ``` @@ -1302,8 +1135,6 @@ Generates a random string of a desired length, containing the set of printable c Generates a random alphabetical (`A-Z`, `a-z`) string of a desired length. - - ```go {{ random.Alpha 42 }} // oAqHKxHiytYicMxTMGHnUnAfltPVZDhFkVkgDvatJK ``` @@ -1312,8 +1143,6 @@ Generates a random alphabetical (`A-Z`, `a-z`) string of a desired length. Generates a random alphanumeric (`0-9`, `A-Z`, `a-z`) string of a desired length. - - ```go {{ random.AlphaNum 16 }} // 4olRl9mRmVp1nqSm ``` @@ -1328,8 +1157,6 @@ A different set of characters can be specified with a regular expression, or by When given a range of Unicode code-points, `random.String` will discard non-printable characters from the selection. This may result in a much smaller set of possible characters than intended, so check the [Unicode character code charts](http://www.unicode.org/charts/) to verify the correct code-points. - - ```go {{ random.String 8 }} // FODZ01u_ {{ random.String 16 `[[:xdigit:]]` }} // B9e0527C3e45E1f3 @@ -1341,8 +1168,6 @@ When given a range of Unicode code-points, `random.String` will discard non-prin Pick an element at a random from a given slice or array. - - ```go {{ random.Item (seq 0 5) }} // 4 {{'["red", "green", "blue"]' | jsonArray | random.Item }} // blue @@ -1354,8 +1179,6 @@ Pick a random integer. By default, a number between `0` and `100` (inclusive) is Note that the difference between `min` and `max` can not be larger than a 63-bit integer (i.e. the unsigned portion of a 64-bit signed integer). The result is given as an `int64`. - - ```go {{ random.Number }} // 55 {{ random.Number -10 10 }} // -3 @@ -1368,24 +1191,21 @@ Pick a random decimal floating-point number. By default, a number between `0.0` The result is given as a `float64`. - - ```go {{ random.Float }} // 0.2029946480303966 {{ random.Float 100 }} // 71.28595374161743 {{ random.Float -100 200 }} // 105.59119437834909 ``` -## regexp +## regexp + ### Find Returns a string holding the text of the leftmost match in `input` of the regular expression `expression`. -This function provides the same behaviour as Go's +This function provides the same behavior as Go's [`regexp.FindString`](https://golang.org/pkg/regexp/#Regexp.FindString) function. - - ```go {{ regexp.Find "[a-z]{3}" "foobar"}} // foo @@ -1398,10 +1218,9 @@ Returns a list of all successive matches of the regular expression. This can be called with 2 or 3 arguments. When called with 2 arguments, the `n` argument (number of matches) will be set to `-1`, causing all matches to be returned. -This function provides the same behaviour as Go's +This function provides the same behavior as Go's [`regexp.FindAllString`](https://golang.org/pkg/regexp/#Regexp.FindAllString) function. - ```go {{ regexp.FindAll "[a-z]{3}" "foobar" | toJSON}} // ["foo", "bar"] @@ -1414,8 +1233,6 @@ Returns `true` if a given regular expression matches a given input. This returns a boolean which can be used in an `if` condition, for example. - - ```go {{ "hairyhenderson"| regexp.Match `^h`) }} // true ``` @@ -1424,11 +1241,9 @@ This returns a boolean which can be used in an `if` condition, for example. Escapes all regular expression metacharacters in the input. The returned string is a regular expression matching the literal text. -This function provides the same behaviour as Go's +This function provides the same behavior as Go's [`regexp.QuoteMeta`](https://golang.org/pkg/regexp/#Regexp.QuoteMeta) function. - - ```go {{ `{hello}` | regexp.QuoteMeta }} // \{hello\} ``` @@ -1439,8 +1254,7 @@ Replaces matches of a regular expression with the replacement string. The replacement is substituted after expanding variables beginning with `$`. -This function provides the same behaviour as Go's [`regexp.ReplaceAllString`](https://golang.org/pkg/regexp/#Regexp.ReplaceAllString) function. - +This function provides the same behavior as Go's [`regexp.ReplaceAllString`](https://golang.org/pkg/regexp/#Regexp.ReplaceAllString) function. ```go {{ regexp.Replace "(foo)bar" "$1" "foobar"}} // foo @@ -1454,8 +1268,7 @@ Replaces matches of a regular expression with the replacement string. The replacement is substituted directly, without expanding variables beginning with `$`. -This function provides the same behaviour as Go's [`regexp.ReplaceAllLiteralString`](https://golang.org/pkg/regexp/#Regexp.ReplaceAllLiteralString) function. - +This function provides the same behavior as Go's [`regexp.ReplaceAllLiteralString`](https://golang.org/pkg/regexp/#Regexp.ReplaceAllLiteralString) function. ```go {{ regexp.ReplaceLiteral "(foo)bar" "$1" "foobar"}} // $1 @@ -1471,16 +1284,14 @@ This can be called with 2 or 3 arguments. When called with 2 arguments, the `n` This is equivalent to [`strings.SplitN`](#splitn), except that regular expressions are supported. -This function provides the same behaviour as Go's [`regexp.Split`](https://golang.org/pkg/regexp/#Regexp.Split) function. +This function provides the same behavior as Go's [`regexp.Split`](https://golang.org/pkg/regexp/#Regexp.Split) function. ```go {{ regexp.Split `[\s,.]` "foo bar,baz.qux" | toJSON}} // ["foo","bar","baz","qux"] {{ "foo bar.baz,qux" | regexp.Split `[\s,.]` 3 | toJSON}} // ["foo","bar","baz"] ``` - -## Strings - +## Strings ### Abbrev @@ -1488,8 +1299,6 @@ Abbreviates a string using `...` (ellipses). Takes an optional offset from the b _Also see [`strings.Trunc`](#trunc)._ - - ```go {{ "foobarbazquxquux" | strings.Abbrev 9 }} // foobar... {{ "foobarbazquxquux" | strings.Abbrev 6 9 }} // ...baz... @@ -1499,17 +1308,14 @@ _Also see [`strings.Trunc`](#trunc)._ Reports whether a substring is contained within a string. - ```go {{ "foo" | strings.Contains "f" }} // true ``` - ### HasPrefix Tests whether a string begins with a certain prefix. - ```go {{ "http://example.com" | strings.HasSuffix "http://")}} // true ``` @@ -1518,8 +1324,6 @@ Tests whether a string begins with a certain prefix. Tests whether a string ends with a certain suffix. - - ```go {{if not ("http://example.com" | strings.HasSuffix ":80")}}:80{{end}} // :80 ``` @@ -1528,15 +1332,12 @@ Tests whether a string ends with a certain suffix. http://example.com:80 ``` - ### Indent Indents a string. If the input string has multiple lines, each line will be indented. - This function can be especially useful when adding YAML snippets into other YAML documents, where indentation is important: - ``` foo: {{ `{"bar": {"baz": 2}}` | json | toYAML | strings.Indent " " }} @@ -1560,8 +1361,6 @@ foo: Returns an alphanumerically-sorted copy of a given string list. - - ```go {{ (slice "foo" "bar" "baz") | strings.Sort }} // [bar baz foo] ``` @@ -1570,13 +1369,14 @@ Returns an alphanumerically-sorted copy of a given string list. Creates a slice by splitting a string on a given delimiter. - Use on its own to produce an array: + ```go {{ "Bart,Lisa,Maggie" | strings.Split "," }} // [Bart Lisa Maggie] ``` Use in combination with `range` to iterate over all items: + ```go {{range ("Bart,Lisa,Maggie" | strings.Split ",") }}Hello, {{.}}{{end}} // Hello, Bart @@ -1585,11 +1385,11 @@ Use in combination with `range` to iterate over all items: ``` Use in combination with `index` function to pick a specific value from the resulting array + ```go {{index ("Bart,Lisa,Maggie" | strings.Split ",") 0 }} // Bart ``` - ### SplitN Creates a slice by splitting a string on a given delimiter. The count determines the number of substrings to return. @@ -1600,12 +1400,10 @@ Creates a slice by splitting a string on a given delimiter. The count determines // bar:baz ``` - ### Quote Surrounds an input string with double-quote characters (`"`). If the input is not a string, converts first. `"` characters in the input are first escaped with a `\` character. - ```go {{ "in" | quote }} // "in" {{ strings.Quote 500 }} // "500" @@ -1619,13 +1417,10 @@ It errors if `count` is negative or if the length of `input` multiplied by `coun This wraps Go's [`strings.Repeat`](https://golang.org/pkg/strings/#Repeat). - - ```go {{ "hello " | strings.Repeat 5 }} // hello hello hello hello hello ``` - ### ReplaceAll Replaces all occurrences of a given string with another. @@ -1639,7 +1434,6 @@ Replaces all occurrences of a given string with another. Creates a a "slug" from a given string - supports Unicode correctly. This wraps the [github.com/gosimple/slug](https://github.com/gosimple/slug) package. See [the github.com/gosimple/slug docs](https://godoc.org/github.com/gosimple/slug) for more information. - ```go {{ "Hello, world!" | strings.Slug }} // hello-world ``` @@ -1649,17 +1443,16 @@ Creates a a "slug" from a given string - supports Unicode correctly. This wraps Given a string, emits a version of that string that will evaluate to its literal data when expanded by any POSIX-compliant shell. Given an array or slice, emit a single string which will evaluate to a series of shell words, one per item in that array or slice. - ```go {{ slice "one word" "foo='bar baz'" | shellQuote }} // 'one word' 'foo='"'"'bar baz'"'"'' ``` + ```go {{ strings.ShellQuote "it's a banana" }} // 'it'"'"'s a banana' ``` - ### squote Surrounds an input string with a single-quote (apostrophe) character (`'`). If the input is not a string, converts first. @@ -1671,7 +1464,6 @@ Surrounds an input string with a single-quote (apostrophe) character (`'`). If t {{ "it's a banana" | squote }} // 'it''s a banana' ``` - ### Title Convert to title-case. @@ -1711,18 +1503,15 @@ Returns a string without the provided leading prefix string, if the prefix is pr This wraps Go's [`strings.TrimPrefix`](https://golang.org/pkg/strings/#TrimPrefix). - ```go {{ "hello, world" | strings.TrimPrefix "hello, " }} // world ``` - ### TrimSpace Trims a string by removing whitespace from the beginning and end of the string. - ```go {{ " \n\t foo" | strings.TrimSpace }} // foo ``` @@ -1743,7 +1532,6 @@ Returns a string truncated to the given length. _Also see [`strings.Abbrev`](#abbrev)._ - ```go {{ "hello, world" | strings.Trunc 5 }} // hello ``` @@ -1756,7 +1544,6 @@ All non-alphanumeric characters are stripped, and the beginnings of words are up See [CamelCase on Wikipedia](https://en.wikipedia.org/wiki/Camel_case) for more details. - ```go {{ "Hello, World!" | strings.CamelCase }} // HelloWorld @@ -1771,8 +1558,6 @@ All non-alphanumeric characters are stripped, and spaces are replaced with an un See [Snake Case on Wikipedia](https://en.wikipedia.org/wiki/Snake_case) for more details. - - ```go {{ "Hello, World!" | strings.SnakeCase }} // Hello_world {{ "hello jello" | strings.SnakeCase }} // hello_jello @@ -1783,8 +1568,6 @@ See [Snake Case on Wikipedia](https://en.wikipedia.org/wiki/Snake_case) for more Converts a sentence to kebab-case, i.e. `The quick brown fox` becomes `The-quick-brown-fox`. All non-alphanumeric characters are stripped, and spaces are replaced with a hyphen (`-`). If the input begins with a lower-case letter, the result will also begin with a lower-case letter. See [Kebab Case on Wikipedia](https://en.wikipedia.org/wiki/Kebab_case) for more details. - - ```go {{ "Hello, World!" | strings.KebabCase }} // Hello-world {{ "hello jello" | strings.KebabCase }} // hello-jello @@ -1796,11 +1579,11 @@ Inserts new line breaks into the input string so it ends up with lines that are The line-break sequence defaults to `\n` (i.e. the LF/Line Feed character), regardless of OS. - ```go {{ "Hello, World!" | strings.WordWrap 7 }} // Hello, World! ``` + ```go {{ strings.WordWrap 20 "\\\n" "a string with a long url http://example.com/a/very/long/url which should not be broken" }} // a string with a long url @@ -1817,7 +1600,6 @@ Inputs will first be converted to strings, and multiple inputs are concatenated. This wraps Go's [`utf8.RuneCountInString`](https://golang.org/pkg/unicode/utf8/#RuneCountInString) function. - ```go {{ range (slice "\u03a9" "\u0030" "\u1430") }}{{ printf "%s is %d bytes and %d runes\n" . (len .) (strings.RuneCount .) }}{{ end }} // Ω is 2 bytes and 1 runes @@ -1831,7 +1613,6 @@ This wraps Go's [`utf8.RuneCountInString`](https://golang.org/pkg/unicode/utf8/# Contains reports whether the second string is contained within the first. Equivalent to [strings.Contains](https://golang.org/pkg/strings#Contains) - ```go {{ $FOO := "foo" }} {{ if contains $FOO "f" }}yes{{ else }}no{{ end }} // yes @@ -1843,9 +1624,6 @@ Contains reports whether the second string is contained within the first. Equiva Tests whether the string begins with a certain substring. Equivalent to [strings.HasPrefix](https://golang.org/pkg/strings#HasPrefix) - - - ```go {{ $URL := "http://example.com" }} {{ if hasPrefix $URL "https" }}foo{{ else }}bar{{ end }} // bar @@ -1857,9 +1635,6 @@ Tests whether the string begins with a certain substring. Equivalent to [strings Tests whether the string ends with a certain substring. Equivalent to [strings.HasSuffix](https://golang.org/pkg/strings#HasSuffix) - - - ```go {{ $URL := "http://example.com" }} {{ $URL }}{{ if not (hasSuffix $URL ":80") }}:80{{ end }} // http://example.com:80 @@ -1871,8 +1646,6 @@ Tests whether the string ends with a certain substring. Equivalent to [strings.H Creates a slice by splitting a string on a given delimiter. Equivalent to [strings.Split](https://golang.org/pkg/strings#Split) - - ```go {{ range split "Bart,Lisa,Maggie" "," }} Hello, {{ . }} @@ -1889,7 +1662,6 @@ Hello, {{ . }} Creates a slice by splitting a string on a given delimiter. The count determines the number of substrings to return. Equivalent to [strings.SplitN](https://golang.org/pkg/strings#SplitN) - ```go {{ range splitN "foo:bar:baz" ":" 2 }} {{ . }} @@ -1909,7 +1681,7 @@ Trims a string by removing the given characters from the beginning and end of th {{trim " world " " "}} // world ``` -## Test +## Test ### Fail @@ -1938,13 +1710,13 @@ In addition, the special kind `number` is accepted by this function, to represen See also [`test.Kind`](#kind). - ```go {{ $data := "hello world" }} {{ if isKind "string" $data }}{{ $data }} is a string{{ end }} // hello world is a string ``` + ```go {{ $object := dict "key1" true "key2" "foobar" }} {{ if test.IsKind "map" $object }} @@ -1968,15 +1740,11 @@ If you need to know the precise type of a value, use `printf "%T" $value`. See also [`test.IsKind`](#iskind) - - ```go {{ kind "hello world" }} // string {{ dict "key1" true "key2" "foobar" | test.Kind }} // map ``` - - ### ternary Returns one of two values depending on whether the third is true. Note that the third value does not have to be a boolean - it is converted first by the [`conv.ToBool`](#tobool) function (values like `true`, `1`, `"true"`, `"Yes"`, etc... are considered true). @@ -1989,14 +1757,13 @@ This is effectively a short-form of the following template: Keep in mind that using an explicit `if`/`else` block is often easier to understand than ternary expressions! - - ```go {{ ternary "FOO" "BAR" false }} // BAR {{ ternary "FOO" "BAR" "yes" }} // FOO ``` -## Time +## Time + ### Now Returns the current local time, as a `time.Time`. This wraps [`time.Now`](https://golang.org/pkg/time/#Now). @@ -2041,7 +1808,6 @@ Just like [`time.Now`](#time-now), this is usually used in conjunction with othe _Note: In the absence of a time zone indicator, `time.Parse` returns a time in UTC._ - Usage with [`Format`](https://golang.org/pkg/time/#Time.Format): ```go @@ -2056,8 +1822,6 @@ A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as `300ms`, `-1.5h` or `2h45m`. Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. - - ```go {{ (time.Now).Format time.Kitchen }} // 12:43AM {{ ((time.Now).Add (time.ParseDuration "2h30m")).Format time.Kitchen }} // 3:13AM @@ -2067,7 +1831,6 @@ time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. Same as [`time.Parse`](#parse), except that in the absence of a time zone indicator, the timestamp wil be parsed in the local timezone. - Usage with [`Format`](https://golang.org/pkg/time/#Time.Format): ```go @@ -2080,9 +1843,8 @@ Same as [`time.Parse`](#parse), except that the time is parsed in the given loca This wraps [`time.ParseInLocation`](https://golang.org/pkg/time/#ParseInLocation). - - Usage with [`Format`](https://golang.org/pkg/time/#Time.Format): + ```go {{ (time.ParseInLocation time.Kitchen "Africa/Luanda" "6:00AM").Format "15:04 MST" }} // 06:00 LMT ``` @@ -2101,13 +1863,14 @@ It is shorthand for `time.Now.Sub t`. Returns the local `Time` corresponding to the given Unix time, in seconds since January 1, 1970 UTC. Note that fractional seconds can be used to denote milliseconds, but must be specified as a string, not a floating point number. - _with whole seconds:_ + ```go {{ (time.Unix 42).UTC.Format time.Stamp}} // Jan 1, 00:00:42 ``` _with fractional seconds:_ + ```go {{ (time.Unix "123456.789").UTC.Format time.StampMilli}} // Jan 2 10:17:36.789 ``` @@ -2123,6 +1886,7 @@ It is shorthand for `$t.Sub time.Now`. ``` Or, less precise: + ```go {{ $t := time.Parse time.RFC3339 "2020-01-01T00:00:00Z" }}only {{ (time.Until $t).Round (time.Hour 1) }} to go... // only 14923h0m0s to go... ``` @@ -2131,8 +1895,6 @@ Or, less precise: Return the local system's time zone's name. - - ```go {{time.ZoneName}} // EDT ``` @@ -2141,21 +1903,18 @@ Return the local system's time zone's name. Return the local system's time zone offset, in seconds east of UTC. - - ```go {{time.ZoneOffset}} // -14400 ``` -## UUID +## UUID + ### V1 Create a version 1 UUID (based on the current MAC address and the current date/time). Use [`uuid.V4`](#v4) instead in most cases. - - ```go {{ uuid.V1 }} // 4d757e54-446d-11e9-a8fa-72000877c7b0 ``` @@ -2166,8 +1925,6 @@ Create a version 4 UUID (randomly generated). This function consumes entropy. - - ```go {{ uuid.V4 }} // 40b3c2d2-e491-4b19-94cd-461e6fa35a60 ``` @@ -2177,8 +1934,6 @@ This function consumes entropy. Returns the _nil_ UUID, that is, `00000000-0000-0000-0000-000000000000`, mostly for testing scenarios. - - ```go {{ uuid.Nil }} // 00000000-0000-0000-0000-000000000000 ``` @@ -2187,7 +1942,6 @@ mostly for testing scenarios. Checks that the given UUID is in the correct format. It does not validate whether the version or variant are correct. - ```go {{ if uuid.IsValid "totally invalid" }}valid{{ else }}invalid{{ end }} // invalid {{ uuid.IsValid "urn:uuid:12345678-90ab-cdef-fedc-ba9876543210" }} // true @@ -2201,7 +1955,6 @@ This function returns a `UUID` struct, as defined in the [github.com/google/uuid Both the standard UUID forms of `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` and `urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` are decoded as well as the Microsoft encoding `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}` and the raw hex encoding (`xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`). - ```go {{ $u := uuid.Parse uuid.V4 }}{{ $u.Version }}, {{ $u.Variant}} // VERSION_4, RFC4122 {{ (uuid.Parse "000001f5-4470-21e9-9b00-72000877c7b0").Domain }} // Person diff --git a/canary-checker/docs/scripting/javascript.md b/canary-checker/docs/scripting/javascript.md index a1ea974f..112d9143 100644 --- a/canary-checker/docs/scripting/javascript.md +++ b/canary-checker/docs/scripting/javascript.md @@ -53,5 +53,3 @@ spec: return currencyCodes[currency] + rate; }).join(", "); ``` - -## diff --git a/canary-checker/docs/security.md b/canary-checker/docs/security.md index bd2c9650..ad01858a 100644 --- a/canary-checker/docs/security.md +++ b/canary-checker/docs/security.md @@ -4,16 +4,10 @@ title: Security -Canary checker is essentially a remote command execution platform, which from a security perspective can be challengin +Canary checker is essentially a remote command execution platform, which from a security perspective can be challenging ## Threat Model - - - - - - ## Hardening You can take following steps to harden your installation. @@ -22,9 +16,8 @@ You can take following steps to harden your installation. | Path | Value | Impact | | -------------------------- | ------- | ------------------------------------------------------------ | -| `image.type` | miminal | The full image includes a java installation and other test execution frameworks | +| `image.type` | minimal | The full image includes a java installation and other test execution frameworks | | `dockerSocket` | false | Attaching to the host docker socket gives access to all containers running on the machine | | `containerSocket` | false | | | `ingress.enabled` | false | If possible disable the ingress to limit any attach surface | | `allowPrivilegeEscalation` | false | | - diff --git a/canary-checker/sidebars.js b/canary-checker/sidebars.js index d639fa21..8db0f6c1 100644 --- a/canary-checker/sidebars.js +++ b/canary-checker/sidebars.js @@ -200,7 +200,7 @@ module.exports = { }, { type: 'doc', - id: 'reference/configdb', + id: 'reference/catalog', label: 'Flanksource Catalog' }, { diff --git a/canary-checker/tutorials/getting-started.md b/canary-checker/tutorials/getting-started.md index d6d53e70..3addffa0 100644 --- a/canary-checker/tutorials/getting-started.md +++ b/canary-checker/tutorials/getting-started.md @@ -161,7 +161,7 @@ CREATE TABLE users( insert into users (id, username) values (1, 'admin') ``` -Now, running the Canary again, you see the expected behaviour occurs - and our data is validated as expected. +Now, running the Canary again, you see the expected behavior occurs - and our data is validated as expected. ```bash canary-checker run ../postgres-canaries/postgres-canary-local-does-admin-user-exist.yaml diff --git a/canary-checker/tutorials/prereqs.md b/canary-checker/tutorials/prereqs.md index 8c7315e6..597b172a 100644 --- a/canary-checker/tutorials/prereqs.md +++ b/canary-checker/tutorials/prereqs.md @@ -15,7 +15,9 @@ To ensure you are getting metrics run: ``` kubectl get --raw /metrics ``` + The command will give display metrics something like this: + ```shell workqueue_work_duration_seconds_bucket{name="open_api_aggregation_controller",le="0.01"} 966 workqueue_work_duration_seconds_bucket{name="open_api_aggregation_controller",le="0.1"} 966 @@ -71,6 +73,7 @@ You should then be able to see custom resources, `servicemonitors` by running: ``` kubectl get crd ``` + And see there is a `servicemonitors.monitoring.coreos.com` custom resource definition. Once that is defined you can install the rest of the monitoring components: diff --git a/cspell.json b/cspell.json new file mode 100644 index 00000000..ff94866e --- /dev/null +++ b/cspell.json @@ -0,0 +1,159 @@ +// cSpell Settings +{ + // Version of the setting file. Always 0.2 + "version": "0.2", + // language - current active spelling language + "language": "en", + // words - list of words to be always considered correct + "words": [ + "aggs", + "alertmanager", + "alertname", + "arkade", + "asciicast", + "Asciinema", + "azuredevops", + "basepath", + "Bitnami", + "blackbox", + "Bools", + "certificaterequest", + "certmanager", + "chartmuseum", + "cifs", + "classname", + "Cloudprober", + "cloudsql", + "clusterrole", + "clusterrolebinding", + "CNCF", + "configmap", + "containerd", + "controllerrevision", + "conv", + "coredns", + "crashlooping", + "CRD's", + "customresourcedefinition", + "datasource", + "distro", + "Dynatrace", + "endpointslices", + "Entra", + "exactreply", + "exitcode", + "filestore", + "filestores", + "FIPS", + "flanksource", + "fluentd", + "flux", + "fluxcd", + "folderfilter", + "gcloud", + "gitea", + "githubusercontent", + "gitops", + "gojq", + "gomplate", + "googlechat", + "gosimple", + "gotemplate", + "gotify", + "helmrelease", + "inet", + "jmeter", + "JSONNET", + "jwks", + "keyspace", + "KHTML", + "kratos", + "KSOPS", + "kubeadm", + "kubeconfig", + "kubelet", + "Kuberhealthy", + "kuebconfig", + "kustomization", + "Kustomizations", + "kustomize", + "LDAPS", + "loglevel", + "millicores", + "millis", + "Minio", + "minrecords", + "mkdirp", + "MTTR", + "myfile", + "nodemetrics", + "nodeoutofmemory", + "NSSM", + "ntfy", + "nvarchar", + "oidc", + "opensearch", + "opsgenie", + "organisation", + "packetloss", + "pgrst", + "plpgsql", + "podinfo", + "podmetrics", + "POSIX", + "postgrest", + "println", + "protobuf", + "psql", + "pushbullet", + "querytype", + "rabbitmq", + "Redistributable", + "relname", + "replicaset", + "replicset", + "resourcefilter", + "restic", + "rocketchat", + "rolebinding", + "SDLC", + "selfservice", + "serviceaccount", + "serviceaccounts", + "servicemonitor", + "shoutrrr", + "SLO's", + "squote", + "sslmode", + "statefulset", + "storageclass", + "streetsidesoftware", + "struct", + "structs", + "subchart", + "subcomponent", + "svix", + "templatable", + "templating", + "trivy", + "trunc", + "tsdb", + "tsmerge", + "Unmarshaler", + "urldecode", + "urlencode", + "varchar", + "visualstudio", + "vsmarketplacebadge", + "webserver", + "workqueue", + "X", + "zulip" + ], + // flagWords - list of words to be always considered incorrect + // This is useful for offensive words and common spelling errors. + // For example "hte" should be "the" + "flagWords": [ + "hte" + ] +} diff --git a/docs/incidents/concepts/done-definition.md b/docs/incidents/concepts/done-definition.md index 217e1bff..9c0f5fab 100644 --- a/docs/incidents/concepts/done-definition.md +++ b/docs/incidents/concepts/done-definition.md @@ -6,7 +6,7 @@ Incidents can be programatically resolved using done definition. When an evidenc Done definitions are checked periodically every 5 minutes. -## Examples: +## Examples ### A. Using config analysis diff --git a/mission-control/docs/architecture.md b/mission-control/docs/architecture.md index d7cb01f5..a8a4b39c 100644 --- a/mission-control/docs/architecture.md +++ b/mission-control/docs/architecture.md @@ -1,20 +1,12 @@ - --- title: Architecture --- - - ![](/img/architecture.svg) - - - - Mission Control has a micro-service architecture with a shared data source with multiple deployment models. - 1. CLI 2. Kubernetes (Helm Chart) 3. SaaS @@ -34,7 +26,6 @@ Postgres is the only data store used by Mission Control and relies heavily on JS All services use a shared database and model via the [duty](https://github.com/flanksource/duty) project, this provides the following benefits: - * Limit RPC calls improving latency and performance * Services can run with slightly different versions of the library, limiting the need for coordinated migrations * Library updates happen automatically using dependabot diff --git a/mission-control/docs/config-db/concepts/retention.md b/mission-control/docs/config-db/concepts/retention.md index 32f52ec0..4360f3c7 100644 --- a/mission-control/docs/config-db/concepts/retention.md +++ b/mission-control/docs/config-db/concepts/retention.md @@ -34,7 +34,7 @@ spec: - name: Kubernetes::Pod deletedAge: 7d # keep deleted pods around for 7 days - name: Kubernetes::Replicaset - deletedAge: 60m # we don't care about replicasets remove then quickly + deletedAge: 60m # we don't care about replicasets remove then quickly // highlight-end kubernetes: clusterName: local @@ -62,8 +62,6 @@ spec: Changes can quickly accumulate and grow large over time. While it's important to retain some changes, others can be discarded after a period. - - | Field | Description | Scheme | Required | | ------- | ------------------------------------------------------- | ------------------------------------- | -------- | | `name` | Name of the change type | `string` | `true` | @@ -79,8 +77,8 @@ spec: retention: // highlight-start changes: - - name: PullSuceeded - age: 7d # Only keep one week of PullSuceeded changes + - name: PullSucceeded + age: 7d # Only keep one week of PullSucceeded changes // highlight-end kubernetes: clusterName: local diff --git a/mission-control/docs/config-db/concepts/transform.md b/mission-control/docs/config-db/concepts/transform.md index 29792667..26977ace 100644 --- a/mission-control/docs/config-db/concepts/transform.md +++ b/mission-control/docs/config-db/concepts/transform.md @@ -4,8 +4,6 @@ title: Transform Transformations allows you to transform the scraped configs before they are saved to config db. - - | Field | Description | Scheme | | --------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | `transform.exclude` | Remove fields from a scraped `config` | [[]Exclude](#field-exclusions) | @@ -15,8 +13,6 @@ Transformations allows you to transform the scraped configs before they are save | `transform.expr` | | [CEL](/reference/scripting/cel) | | `transform.relationship` | Create relationships between items | [Relationships](./relationships) | - - ## Config Items ### Field Exclusions @@ -40,15 +36,11 @@ spec: //highlight-end ``` - - | Field | Description | Scheme | Required | | ---------- | ------------------------------------------------------------ | ------------------------------------------------- | -------- | | `jsonpath` | All matching elements will be removed from the `config` | `jsonpath` | `true` | | `types` | Only run exclusion rules for these config types, if empty apply to all | `[]string` | | - - ### Masking Masking allows replacing sensitive fields with a hash or static string. @@ -68,7 +60,7 @@ spec: mask: - selector: config.name == 'Config1' jsonpath: $.password - value: md5sum # Change detection will pick up that a change has occured, but not what the change was + value: md5sum # Change detection will pick up that a change has occurred, but not what the change was - selector: config.name == 'Config1' jsonpath: $.secret value: '***' # Replace the secret with a fixed mask, no change detection will be possible @@ -87,9 +79,6 @@ spec: Masks are applied in the order they are specified in the configuration file. ::: - - - ## Changes ### Exclusions @@ -114,8 +103,6 @@ spec: //highlight-end ``` - - ### Mapping When you encounter a diff change, unlike an event based change, it can sometimes appear cryptic. The summary of the change may not immediately indicate what the change is about. For example, the change 'status.images' might not be self-explanatory. To address this issue, we can assign types to these diff changes using mapping. @@ -130,7 +117,7 @@ spec: - clusterName: local-kind-cluster transform: changes: - //highlight-start + //highlight-start mapping: - filter: > change.change_type == 'diff' && change.summary == "status.containerStatuses" && @@ -151,20 +138,14 @@ spec: | `type` | New change type | `string` | | `summary` | New summary of the change | [Go Template](/reference/scripting/template) | - - ## Scripting Scripting allows you to modify the scraped configuration using CEL before saving it to the database. This is useful for data normalization, default value population, sensitive field masking etc. - - | Field | Description | Scheme | Context | | ------ | ----------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | `expr` | Transform a config item | CEL that returns [[]ScrapeResult](/reference/config-db/scrape-result) | `config` `JSON`
`result` [Scrape Result](/reference/config-db/scrape-result) | - - ```yaml title="file-scraper.yaml" apiVersion: configs.flanksource.com/v1 kind: ScrapeConfig diff --git a/mission-control/docs/config-db/index.mdx b/mission-control/docs/config-db/index.mdx index 7a9df9a1..261fb9eb 100644 --- a/mission-control/docs/config-db/index.mdx +++ b/mission-control/docs/config-db/index.mdx @@ -23,7 +23,7 @@ Some key benefits include: * **Automatic Discovery** - Automatically discovers resources by scraping external systems like Kubernetes, AWS, Git, SQL, etc * **Changes** - Track changes to resources over time through diff or event based change detection, improving MTTR drastically. -* **Insights** - Aggreate security, cost, performance and reliability insights from AWS Trusted Advisor, Config Rules, Azure Monitor, Trivy etc. +* **Insights** - Aggregate security, cost, performance and reliability insights from AWS Trusted Advisor, Config Rules, Azure Monitor, Trivy etc. * **Dependency Mapping** - Automatically map dependencies between resources to understand impact of changes. * **Single Pane of Glass** - Browse, search and take action on resources without the need to switch between multiple consoles. @@ -34,7 +34,7 @@ Under the hood the catalog is powered by [github.com/flanksource/config-db](http The catalog is comprised of: -* **Config Items** are individual reaources e.g. `Pod`, `EBS`, `IAM Role`, `postgres.conf` scraped from external sources like [AWS](/config-db/scrapers/aws), [Kubernetes](/config-db/scrapers/kubernetes), [Azure](/config-db/scrapers/azure), [Azure Devops](/config-db/scrapers/azure-devops) , [Github](/config-db/scrapers/github) +* **Config Items** are individual resources e.g. `Pod`, `EBS`, `IAM Role`, `postgres.conf` scraped from external sources like [AWS](/config-db/scrapers/aws), [Kubernetes](/config-db/scrapers/kubernetes), [Azure](/config-db/scrapers/azure), [Azure Devops](/config-db/scrapers/azure-devops) , [Github](/config-db/scrapers/github) * **Changes** recorded against config items either through automatic change detection (diffs) or from sources like [Cloud Trail](/config-db/scrapers/aws#cloud-trail) or [Kubernetes Events](/config-db/scrapers/kubernetes#events) * **Insights** recorded against config items from external sources like [AWS Trusted Advisor](/config-db/scrapers/aws#trusted-advisor) or [Trivy](/config-db/scrapers/trivy) * **Relationships** between configuration items @@ -47,7 +47,7 @@ Config items, insights and change are ingested using scrapers which are jobs tha -Native scrapers ingest config items from common sources like [AWS](/config-db/scrapers/aws), [Kubernetes](/config-db/scrapers/kubernetes), [Azure](/config-db/scrapers/azure) and automatically add metadata and relationshops +Native scrapers ingest config items from common sources like [AWS](/config-db/scrapers/aws), [Kubernetes](/config-db/scrapers/kubernetes), [Azure](/config-db/scrapers/azure) and automatically add metadata and relationships diff --git a/mission-control/docs/config-db/scrapers/azure.md b/mission-control/docs/config-db/scrapers/azure.md index 29e4db92..00708e4e 100644 --- a/mission-control/docs/config-db/scrapers/azure.md +++ b/mission-control/docs/config-db/scrapers/azure.md @@ -35,17 +35,17 @@ The Azure scrapers scrapes your azure account to fetch all the resources & save | `tenantID` | Azure tenant ID | `string` | | | `clientID` | Microsoft Entra ID app client id | _EnvVar_ | | | `clientSecret` | Microsoft Entra ID app client secret | _EnvVar_ | | -| `exclusions` | Specifies the Azure projects to scrape | [`Exclusion`](#azure-exclusion) | | +| `exclusions` | Specifies the Azure projects to scrape | [`Exclusion`](#exclusion) | | | `properties` | Custom templatable properties for the scraped config items. | [`[]ConfigProperty`](/reference/config-db/properties) | | | `transform` | Field to transform result | [`Transform`](/config-db/concepts/transform) | | | `tags` | Set custom tags on the scraped config items | `map[string]string` | | :::note -Either the connection name or the credentials (clientID, clientSecret & tenatnID) are required +Either the `connection` name or the credentials (`clientID`, `clientSecret` & `tenantID`) are required ::: -#### Azure Exclusion +#### Exclusion | Field | Description | Scheme | Required | | -------------- | -------------------------------------------------- | ---------- | -------- | diff --git a/mission-control/docs/config-db/scrapers/custom/file.md b/mission-control/docs/config-db/scrapers/custom/file.md index e0d5b4ed..e4353b8c 100644 --- a/mission-control/docs/config-db/scrapers/custom/file.md +++ b/mission-control/docs/config-db/scrapers/custom/file.md @@ -26,7 +26,7 @@ spec: | `schedule` | Specify the interval to scrape in cron format. Defaults to every 60 minutes. | `string` | | | `full` | Set to `true` to extract changes from scraped configurations. Defaults to `false`. | `bool` | | | `retention` | Settings for retaining changes, analysis and scraped items | [`Retention`](/config-db/concepts/retention) | | -| `file` | Specifies the list of File configurations to scrape. | [`[]File`](#file-1) | | +| `file` | Specifies the list of File configurations to scrape. | [`[]File`](#file) | | ### File diff --git a/mission-control/docs/config-db/scrapers/custom/index.md b/mission-control/docs/config-db/scrapers/custom/index.md index bc6adc59..4e63e24e 100644 --- a/mission-control/docs/config-db/scrapers/custom/index.md +++ b/mission-control/docs/config-db/scrapers/custom/index.md @@ -52,19 +52,21 @@ Custom scrapers need to define the id, type & class for each items that are scra ## Formats -#### JSON +### JSON + Config items are stored as `jsonb` fields in PostgreSQL. The JSON used is typically returned by resource provider e.g. `kubectl get -o json` or `aws --output=json` The UI will convert from JSON to YAML when showing the config. -#### XML / Properties / etc. +### XML / Properties + [**Custom**](./concepts/custom-scraper) scrapers can ingest non-JSON config which is represented as: ```yaml { - "format": "xml", + "format": "xml", "content": ".." } ``` @@ -84,7 +86,7 @@ kind: ScrapeConfig metadata: name: file-scraper spec: - full: true + full: true file: - type: Car id: $.reg_no diff --git a/mission-control/docs/config-db/scrapers/custom/sql.md b/mission-control/docs/config-db/scrapers/custom/sql.md index cd0ca07e..0fb29aba 100644 --- a/mission-control/docs/config-db/scrapers/custom/sql.md +++ b/mission-control/docs/config-db/scrapers/custom/sql.md @@ -81,7 +81,7 @@ spec: | `schedule` | Specify the interval to scrape in cron format. Defaults to every 60 minutes. | `string` | | | `full` | Set to `true` to extract changes from scraped configurations. Defaults to `false`. | `bool` | | | `retention` | Settings for retaining changes, analysis and scraped items | [`Retention`](/config-db/concepts/retention) | | -| `sql` | Specifies the list of SQL configurations to scrape. | [`[]SQL`](#sql-1) | | +| `sql` | Specifies the list of SQL configurations to scrape. | [`[]SQL`](#sql) | | ### SQL diff --git a/mission-control/docs/config-db/scrapers/kubernetes.md b/mission-control/docs/config-db/scrapers/kubernetes.md index 7eff0a2c..8bf515a2 100644 --- a/mission-control/docs/config-db/scrapers/kubernetes.md +++ b/mission-control/docs/config-db/scrapers/kubernetes.md @@ -7,7 +7,7 @@ sidebar_position: 4 :::tip Registry -The registry has an [Kuebrnetes](/registry/kubernetes) Helm chart that provides a pre-configured Scraper and Topology with some common defaults +The registry has an [Kubernetes](/registry/kubernetes) Helm chart that provides a pre-configured Scraper and Topology with some common defaults ::: @@ -23,7 +23,7 @@ The `kubernetes` config type scrapes the configurations of your Kubernetes resou | `logLevel` | Specify the level of logging. | `string` | | | `schedule` | Specify the interval to scrape in cron format. Defaults to every 60 minutes. | `string` | | | `retention` | Settings for retaining changes, analysis and scraped items | [`Retention`](/config-db/concepts/retention) | | -| `kubernetes` | Specifies the list of Kubernetes configurations to scrape. | [`[]Kubernetes`](#kubernetes-1) | | +| `kubernetes` | Specifies the list of Kubernetes configurations to scrape. | [`[]Kubernetes`](#kubernetes) | | ### Kubernetes @@ -55,7 +55,7 @@ In addition, you can also specify keywords used to identify the severity of the | `exclusions` | A list of keywords used to exclude event objects based on the reason | `[]string` | | | `severityKeywords` | Specify keywords used to identify the severity of the Kubernetes Event based on the reason | [`SeverityKeywords`](#severitykeywords) | | -#### SeverityKeywords +### SeverityKeywords | Field | Description | Scheme | Required | | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | -------- | diff --git a/mission-control/docs/config-db/scrapers/trivy.mdx b/mission-control/docs/config-db/scrapers/trivy.mdx index 982cce50..529c7240 100644 --- a/mission-control/docs/config-db/scrapers/trivy.mdx +++ b/mission-control/docs/config-db/scrapers/trivy.mdx @@ -40,7 +40,7 @@ _Fig: A detailed view of the analysis on the postgres container_ | `scanners` | Scanners to use. | `[]string` | | | `severity` | severities of security issues to be displayed s(comma separated)_(default "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL")_. | `string` | | | `timeout` | Trivy timeout | `string` | | -| `version` | Specify the Trivy version to use. s(default 0.40.0) | `string` | | +| `version` | Specify the Trivy version to use. (default 0.40.0) | `string` | | | `vulnType` | comma-separated list of vulnerability types s(comma separated)_(default "os,library")_. | `string` | | ### K8sOptions diff --git a/mission-control/docs/installation/aws-eks.mdx b/mission-control/docs/installation/aws-eks.mdx index 785d0969..c9a86368 100644 --- a/mission-control/docs/installation/aws-eks.mdx +++ b/mission-control/docs/installation/aws-eks.mdx @@ -125,24 +125,24 @@ helm install mission-control \ (b) Modify the trust policy of the IAM role by changing the OIDC arn, OIDC endpoint and the namespace below. ```json { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Principal": { - "Federated": "arn:aws:iam::7458xxxxxxxx:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/4D3C9C8xxxx" - }, - "Action": "sts:AssumeRoleWithWebIdentity", - "Condition": { - "StringEquals": { - "oidc.eks.us-east-1.amazonaws.com/id/4D3C9C8xxxx:sub": "system:serviceaccount:namespace:config-db-sa", - "oidc.eks.us-east-1.amazonaws.com/id/4D3C9C8xxxx:sub": "system:serviceaccount:namespace:mission-control-sa", - "oidc.eks.us-east-1.amazonaws.com/id/4D3C9C8xxxx:sub": "system:serviceaccount:namespace:canary-checker-sa", - "oidc.eks.us-east-1.amazonaws.com/id/4D3C9C8xxxx:aud": "sts.amazonaws.com" - } - } - } - ] + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "Federated": "arn:aws:iam::7458xxxxxxxx:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/4D3C9C8xxxx" + }, + "Action": "sts:AssumeRoleWithWebIdentity", + "Condition": { + "StringEquals": { + "oidc.eks.us-east-1.amazonaws.com/id/4D3C9C8xxxx:sub": "system:serviceaccount:namespace:config-db-sa", + "oidc.eks.us-east-1.amazonaws.com/id/4D3C9C8xxxx:sub": "system:serviceaccount:namespace:mission-control-sa", + "oidc.eks.us-east-1.amazonaws.com/id/4D3C9C8xxxx:sub": "system:serviceaccount:namespace:canary-checker-sa", + "oidc.eks.us-east-1.amazonaws.com/id/4D3C9C8xxxx:aud": "sts.amazonaws.com" + } + } + } + ] } ``` diff --git a/mission-control/docs/installation/database.md b/mission-control/docs/installation/database.md index 26a261aa..90df3666 100644 --- a/mission-control/docs/installation/database.md +++ b/mission-control/docs/installation/database.md @@ -36,6 +36,7 @@ If you ever need to connect to the database, you can do so by forwarding the por kubectl port-forward svc/postgres 5432:5432 psql -U postgres localhost -p 5432 mission_control ``` + ::: ## Using an External Database diff --git a/mission-control/docs/installation/helm.md b/mission-control/docs/installation/helm.md index a40ce9d0..762ca83b 100644 --- a/mission-control/docs/installation/helm.md +++ b/mission-control/docs/installation/helm.md @@ -22,6 +22,9 @@ helm repo update + + + To set custom values file for your mission-control helm chart installation to override existing values in [`mission-control-chart`](https://github.com/flanksource/mission-control-chart/blob/main/chart/values.yaml). ```yaml title="values.yaml" diff --git a/mission-control/docs/installation/kind_linux.md b/mission-control/docs/installation/kind_linux.md index 84db0c78..cd12a669 100644 --- a/mission-control/docs/installation/kind_linux.md +++ b/mission-control/docs/installation/kind_linux.md @@ -32,6 +32,7 @@ nodes: hostPort: 8443 protocol: TCP ``` + A single node cluster will be provisioned, hosting both the control plane and workloads. Configure the hostPort bindings onto free ports, in this case 8080 and 8443 are used. Provision the kind cluster with @@ -79,14 +80,15 @@ flanksource-ui: - "127.0.0.1.nip.io" ``` -for a full list of configuration options, see https://github.com/flanksource/mission-control-chart/blob/main/chart/values.yaml +for a full list of configuration options, see [values.yaml](https://github.com/flanksource/mission-control-chart/blob/main/chart/values.yaml) This configuration sets the storage for the database to use the kind default local-path storage, and sets the ingress address to use [nip.io](nip.io)'s dummy DNS response to return localhost. Save the configuration to a `kind-values.yaml` file, then deploy using ```bash helm upgrade -i mission-control-demo flanksource/mission-control -f kind-values.yaml ``` -Monitor that the deployment has application has successfully intialised by checking `kubectl get pods`, it may take some time for the database to initialise for the first time after installation. + +Monitor that the deployment has application has successfully initialized by checking `kubectl get pods`, it may take some time for the database to initialize for the first time after installation. ## Verify UI @@ -99,7 +101,7 @@ password: admin ## Create example checks -Create a file containing canary defintions, for example: +Create a file containing canary definitions, for example: ```yaml title=canaries.yaml apiVersion: canaries.flanksource.com/v1 @@ -124,7 +126,7 @@ spec: interval: 30 dns: - server: 8.8.8.8 - name: "DNS healthly" + name: "DNS healthy" port: 53 query: "flanksource.com" querytype: "A" diff --git a/mission-control/docs/installation/oidc.md b/mission-control/docs/installation/oidc.md index d7f11e7c..a64a7c02 100644 --- a/mission-control/docs/installation/oidc.md +++ b/mission-control/docs/installation/oidc.md @@ -28,7 +28,7 @@ See [Providers](https://www.ory.sh/docs/kratos/social-signin/overview) more deta Get the `Tenant ID` (Directory ID) from [Directories](https://portal.azure.com/#settings/directory) - + Jsonnet is used to [map](https://www.ory.sh/docs/kratos/social-signin/data-mapping) the claims provided by Azure AD, to the Kratos [Identity Schema](https://github.com/flanksource/mission-control-chart/blob/main/chart/files/kratos-identity-schema.json) diff --git a/mission-control/docs/notifications/channels.md b/mission-control/docs/notifications/channels.md index f7042ba3..96212a0a 100644 --- a/mission-control/docs/notifications/channels.md +++ b/mission-control/docs/notifications/channels.md @@ -7,16 +7,16 @@ Mission control uses [Shoutrrr](https://github.com/containrrr/shoutrrr/) under t | Services | URL Format | | ----------- | ---------------------------------------------------------------------------------------- | | Bark | `bark://devicekey@host` | -| Discord | `discord://token@id ` | +| Discord | `discord://token@id` | | Email | `smtp://username:password@host:port/?from=fromAddress&to=recipient1[,recipient2,...]` | | Gotify | `gotify://gotify-host/token` | -| Google Chat | `googlechat://chat.googleapis.com/v1/spaces/FOO/messages?key=bar&token=baz ` | -| IFTTT | `ifttt://key/?events=event1[,event2,...]&value1=value1&value2=value2&value3=value3 ` | +| Google Chat | `googlechat://chat.googleapis.com/v1/spaces/FOO/messages?key=bar&token=baz` | +| IFTTT | `ifttt://key/?events=event1[,event2,...]&value1=value1&value2=value2&value3=value3` | | Join | `join://shoutrrr:api-key@join/?devices=device1[,device2, ...][&icon=icon][&title=title]` | | Mattermost | `mattermost://[username@]mattermost-host/token[/channel]` | -| Matrix | `matrix://username:password@host:port/[?rooms=!roomID1[,roomAlias2]] ` | +| Matrix | `matrix://username:password@host:port/[?rooms=!roomID1[,roomAlias2]]` | | Ntfy | `ntfy://username:password@ntfy.sh/topic` | -| OpsGenie | `opsgenie://host/token?responders=responder1[,responder2] ` | +| OpsGenie | `opsgenie://host/token?responders=responder1[,responder2]` | | Pushbullet | `pushbullet://api-token[/device/#channel/email]` | | Pushover | `pushover://shoutrrr:apiToken@userKey/?devices=device1[,device2, ...]` | | Rocketchat | `rocketchat://[username@]rocketchat-host/token[/channel\| @recipient]` | @@ -25,4 +25,4 @@ Mission control uses [Shoutrrr](https://github.com/containrrr/shoutrrr/) under t | Telegram | `telegram://token@telegram?chats=@channel-1[,chat-id-1,...]` | | Zulip Chat | `zulip://bot-mail:bot-key@zulip-domain/?stream=name-or-id&topic=name` | -For more details please visit: [https://containrrr.dev/shoutrrr/0.8/services/overview/](https://containrrr.dev/shoutrrr/0.7/services/overview/) +For more details please visit: [https://containrrr.dev/shoutrrr/0.8/services/overview/](https://containrrr.dev/shoutrrr/0.8/services/overview/) diff --git a/mission-control/docs/notifications/events/components.md b/mission-control/docs/notifications/events/components.md index fc732a9f..616b8ec6 100644 --- a/mission-control/docs/notifications/events/components.md +++ b/mission-control/docs/notifications/events/components.md @@ -15,7 +15,7 @@ Component status updates emit the following events | Field | Description | Schema | Optional | | ----------- | ----------------------------- | ------------------------- | -------- | | `component` | The component object | [`Component`](#component) | | -| `agent` | Agent details (if applicable) | [`Agent`](#check) | `true` | +| `agent` | Agent details (if applicable) | [`Agent`](#agent) | `true` | | `permalink` | A link to the health check | `string` | | ### Component diff --git a/mission-control/docs/notifications/index.md b/mission-control/docs/notifications/index.md index e83ea1e4..4c196a11 100644 --- a/mission-control/docs/notifications/index.md +++ b/mission-control/docs/notifications/index.md @@ -27,7 +27,7 @@ spec: | Field | Description | Scheme | Required | Templatable | | ---------- | ------------------------------------------------------------------ | ------------------------- | -------- | ----------- | | `events` | [List of events](./events/) that trigger this notification. | `[]string` | `true` | -| `to` | Specify the receipients. | [`Recipient`](#recipient) | `true` | +| `to` | Specify the recipients. | [`Recipient`](#recipient) | `true` | | `title` | Title of the notification. [See templating](./concepts/templating) | `string` | | `true` | | `template` | Body of the notification. [See templating](./concepts/templating) | `string` | | `true` | | `filter` | Filter of notification. | `string` | | | diff --git a/mission-control/docs/playbooks/Actions/github.mdx b/mission-control/docs/playbooks/Actions/github.mdx index 5e717c35..52d6e082 100644 --- a/mission-control/docs/playbooks/Actions/github.mdx +++ b/mission-control/docs/playbooks/Actions/github.mdx @@ -5,7 +5,7 @@ import Templating from "../../reference/playbooks/context.mdx" # Github Action -Github Acion allows you to invoke GitHub workflows from the playbooks. +Github Action allows you to invoke GitHub workflows from the playbooks. :::note You must configure your GitHub Actions workflow to run when the [workflow_dispatch](https://docs.github.com/en/webhooks/webhook-events-and-payloads#workflow_dispatch) webhook event occurs @@ -17,7 +17,7 @@ You must configure your GitHub Actions workflow to run when the [workflow_dispat diff --git a/mission-control/docs/playbooks/Actions/gitops.mdx b/mission-control/docs/playbooks/Actions/gitops.mdx index 75e5906e..1f0f4ac9 100644 --- a/mission-control/docs/playbooks/Actions/gitops.mdx +++ b/mission-control/docs/playbooks/Actions/gitops.mdx @@ -77,11 +77,11 @@ spec: diff --git a/mission-control/docs/playbooks/Actions/index.md b/mission-control/docs/playbooks/Actions/index.md index 1fb018d2..ef3aba73 100644 --- a/mission-control/docs/playbooks/Actions/index.md +++ b/mission-control/docs/playbooks/Actions/index.md @@ -25,8 +25,6 @@ Actions are the fundamental tasks executed by a playbook. A playbook can compris Specify one or more actions; but at least one. ::: - - ## Templating Templating allows your playbook actions to work in context of a config, health check or a component. @@ -49,7 +47,6 @@ spec: script: kubectl scale --replicas={{.params.replicas}} --namespace={{.config.tags.namespace}} deployment {{.config.name}} ``` - ### Accessing results of another action You can base your filters based on result of a previous action. The following two cel functions can be used: diff --git a/mission-control/docs/playbooks/_api.md b/mission-control/docs/playbooks/_api.md index e1f4eef2..37cbbeaa 100644 --- a/mission-control/docs/playbooks/_api.md +++ b/mission-control/docs/playbooks/_api.md @@ -56,16 +56,14 @@ POST `/playbook/list?component_id={component_id}` ### Query Parameters -!!! info "Info" - - Should provide exactly one of the parameters. - | Parameter | Description | Type | | -------------- | ------------------------ | -------- | | `config_id` | ID of the config item | `string` | | `check_id` | ID of the Check | `string` | | `component_id` | ID of the component item | `string` | +> Provide only 1 parameter + ### Response Returns a list of Playbook diff --git a/mission-control/docs/playbooks/_templating.mdx b/mission-control/docs/playbooks/_templating.mdx index 1603eac2..6bf5f4e1 100644 --- a/mission-control/docs/playbooks/_templating.mdx +++ b/mission-control/docs/playbooks/_templating.mdx @@ -7,5 +7,5 @@ The action parameters can be used | ----------- | ---------------------------------------- | -------------------------------------------- | | `config` | Config passed to the playbook | [`ConfigItem`](./reference/config-db) | | `component` | Component passed to the playbook | [`Component`](../references/component) | -| `check` | Canary Check passed to the playbook | [`Check`](/reference/canary-checker/checl) | +| `check` | Canary Check passed to the playbook | [`Check`](/reference/canary-checker/check) | | `params` | User provided parameters to the playbook | `map[string]string` | diff --git a/mission-control/docs/playbooks/examples/gitops-k8s-cluster-role-binding.md b/mission-control/docs/playbooks/examples/gitops-k8s-cluster-role-binding.md index e8d98e52..8df6a2d6 100644 --- a/mission-control/docs/playbooks/examples/gitops-k8s-cluster-role-binding.md +++ b/mission-control/docs/playbooks/examples/gitops-k8s-cluster-role-binding.md @@ -69,7 +69,7 @@ spec: ## Screenshots -### 1. Triggering playbook manully from a Cluster component +### 1. Triggering playbook manually from a Cluster component ![Playbook option on the component page](/img/playbook-eg-gitops-playbook-on-cluster-component.png) _Fig: Playbook option on the component page_ diff --git a/mission-control/docs/playbooks/examples/restart-pod-on-check-failure.md b/mission-control/docs/playbooks/examples/restart-pod-on-check-failure.md index 7ee6ad55..0b947b3f 100644 --- a/mission-control/docs/playbooks/examples/restart-pod-on-check-failure.md +++ b/mission-control/docs/playbooks/examples/restart-pod-on-check-failure.md @@ -2,8 +2,7 @@ title: Auto Delete Pods --- - - Restart pod when check fails for more than 10 times in the last hour +Restart pod when check fails for more than 10 times in the last hour ```yaml title="stop-pod-of-failing-check.yaml" apiVersion: mission-control.flanksource.com/v1 diff --git a/mission-control/docs/reference/connections/index.md b/mission-control/docs/reference/connections/index.md index a6f834c4..6ffd7099 100644 --- a/mission-control/docs/reference/connections/index.md +++ b/mission-control/docs/reference/connections/index.md @@ -6,6 +6,7 @@ sidebar_position: 2 Connections are an easy way to authenticate against sources. It can be created via a CRD or by adding it in the settings page A sample connection CRD looks like: + ```yaml apiVersion: mission-control.flanksource.com/v1 kind: Connection @@ -66,6 +67,7 @@ spec: name: opensearch-credentials key: OPENSEARCH_URL ``` + ::: ## Schema diff --git a/mission-control/docs/reference/playbooks/index.md b/mission-control/docs/reference/playbooks/index.md index 46952ce9..e0a74764 100644 --- a/mission-control/docs/reference/playbooks/index.md +++ b/mission-control/docs/reference/playbooks/index.md @@ -18,8 +18,8 @@ sidebar_position: 6 | `components` | Which components can this playbook run on | [`[]ResourceSelector`](/reference/resource-selector) | | `env` | Variables to lookup, available as `env` map in templating/filters | [[]EnvVar](/reference/env-var) | | `parameters` | Variables to be supplied by the user, Do not use parameters for sensitive values. | [`[]Parameter`](./parameters) | -| `actions` | Individual actions or steps to perform | [`[]Action`](#action) | -| `approval` | Optional approvals required before a playbooks runs | [`Approval`](#approval) | +| `actions` | Individual actions or steps to perform | [`[]Action`](#actions) | +| `approval` | Optional approvals required before a playbooks runs | [`Approval`](#approvals) | ## Actions diff --git a/mission-control/docs/reference/playbooks/parameters.md b/mission-control/docs/reference/playbooks/parameters.md index ebe60669..b6bb8e31 100644 --- a/mission-control/docs/reference/playbooks/parameters.md +++ b/mission-control/docs/reference/playbooks/parameters.md @@ -75,7 +75,7 @@ When running the playbook on a `Deployment` named `mysql` the following will be | Field | Description | Schema | | ---------- | ----------------------------------------- | -------- | -| `language` | Langauge name e.g. yaml, json, toml, etc. | `string` | +| `language` | e.g. `yaml`, `json`, `toml`, etc. | `string` | ### people @@ -87,7 +87,7 @@ When running the playbook on a `Deployment` named `mysql` the following will be | Field | Description | Schema | | ----------- | ------------------------------------------------------- | --------- | -| `multiline` | Whether the text field should be rendered as a text are | `boolean` | +| `multiline` | Render a multiline textarea | `boolean` | ### list diff --git a/mission-control/docs/registry/aws.md b/mission-control/docs/registry/aws.md index 572f607a..61c44a90 100644 --- a/mission-control/docs/registry/aws.md +++ b/mission-control/docs/registry/aws.md @@ -67,6 +67,7 @@ The following table lists the configurable parameters and their default values: If you have setup IAM Roles for Service Account, you do not have to do anything else. If you do not have that setup, you can use AWS Access and Secret Keys as well Example: + ```yaml title="values.yaml" connectionDetails: accessKey: diff --git a/mission-control/docs/registry/kubernetes.md b/mission-control/docs/registry/kubernetes.md index 28186ad8..df913d83 100644 --- a/mission-control/docs/registry/kubernetes.md +++ b/mission-control/docs/registry/kubernetes.md @@ -36,7 +36,7 @@ On clicking the topology, you can access nodes, namespaces and pods And we also have added a catalog scraper which populated our catalog -![Kuberenetes Catalog](/img/kubernetes-registry-catalog-scraper.png) +![Kubernetes Catalog](/img/kubernetes-registry-catalog-scraper.png) ## Values @@ -85,8 +85,8 @@ To use this, the Kustomization file must have [originAnnotations](https://kubect | Parameter | Description | Schema | Default | | --- | --- | --- | --- | -| `playbooks.edit_kubernetes_manifests.enabled` | Enable this to have a playbook to edit and commit flux resources back to git | bool | `false` -| `playbooks.edit_kubernetes_manifests.git_connection` | Connection string to be used with git credentials | [Connection](/reference/connections/git) | `""` +| `playbooks.edit_kubernetes_manifests.enabled` | Enable this to have a playbook to edit and commit flux resources back to git | bool | `false` | +| `playbooks.edit_kubernetes_manifests.git_connection` | Connection string to be used with git credentials | [Connection](/reference/connections/git) | `""` | After enabling the playbook, you can see a `Edit Kustomize Resource` option in playbooks for any catalog item that is linked to flux diff --git a/mission-control/docs/security.md b/mission-control/docs/security.md index eabea533..1a296d00 100644 --- a/mission-control/docs/security.md +++ b/mission-control/docs/security.md @@ -30,7 +30,7 @@ All the code for Mission Control self-hosted is publicly available and free to u ## Security Dashboard -| Project | Description | License | Scorecard | CII Best Practises | +| Project | Description | License | Scorecard | CII Best Practices | | -------------------- | ------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | Mission Control | Primary microservice and orchestrator | Static Badge | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/flanksource/mission-control/badge)](https://securityscorecards.dev/viewer/?uri=github.com/flanksource/mission-control) | | | Canary Checker | Health checks and topology scanning | GitHub License | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/flanksource/canary-checker/badge)](https://securityscorecards.dev/viewer/?uri=github.com/flanksource/canary-checker) | CII Best Practices | @@ -40,7 +40,7 @@ All the code for Mission Control self-hosted is publicly available and free to u | Gomplate | Go and CEL templating library | GitHub License | ![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/flanksource/gomplate/badge) | | | Flanksource UI | Dashboard | Static Badge | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/flanksource/flanksource-ui/badge)](https://securityscorecards.dev/viewer/?uri=github.com/flanksource/flanksource-ui) | | | **External Dependencies** | | | | | -| PostgREST | REST API for Daytabase | GitHub License | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/PostgREST/postgrest/badge)](https://securityscorecards.dev/viewer/?uri=github.com/PostgREST/postgrest) | | +| PostgREST | REST API for Database | GitHub License | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/PostgREST/postgrest/badge)](https://securityscorecards.dev/viewer/?uri=github.com/PostgREST/postgrest) | | | Kratos (Self-Hosted) | 3rd Party Application for Authentication | GitHub License | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/ory/kratos/badge)](https://securityscorecards.dev/viewer/?uri=github.com/ory/kratos) | | | Clerk (SaaS) | 3rd Party Service for Authentication | | [Docs](https://clerk.com/docs/security/overview) | | diff --git a/mission-control/docs/topology/lookups/kubernetes.md b/mission-control/docs/topology/lookups/kubernetes.md index 914bd5fb..7e0396f8 100644 --- a/mission-control/docs/topology/lookups/kubernetes.md +++ b/mission-control/docs/topology/lookups/kubernetes.md @@ -49,8 +49,8 @@ spec: | Field | Description | Scheme | Required | | ------------- | ------------------------------------------------------------------------- | -------- | -------- | | name | Name of Kubernetes resource | _string_ | | -| labelSelector | Select Kubernetes resource based on label. e.g. app, canary. | _string_ | -| fieldSelector | Select Kubernetes resource based on the value of specified resource field | _string_ | +| labelSelector | Select Kubernetes resource based on label. e.g. app, canary. | _string_ | | +| fieldSelector | Select Kubernetes resource based on the value of specified resource field | _string_ | | ## Results diff --git a/mission-control/docs/topology/lookups/mongo.md b/mission-control/docs/topology/lookups/mongo.md index c6280d39..dd451176 100644 --- a/mission-control/docs/topology/lookups/mongo.md +++ b/mission-control/docs/topology/lookups/mongo.md @@ -49,5 +49,5 @@ spec: | Field | Description | Scheme | Required | | ---------------- | ----------------------------------------------------------------------------- | ------------------------------------------------- | -------- | | **`connection`** | Connection string to connect to the Mongo server | _string_ | Yes | -| **`password`** | Set password for authentication using string, configMapKeyRef, or SecretKeyRef. | *EnvVar* | Yes | -| **`username`** | Set username for authentication using string, configMapKeyRef, or SecretKeyRef. | *EnvVar* | Yes | +| **`password`** | Set password for authentication using string, configMapKeyRef, or SecretKeyRef. | _EnvVar_ | Yes | +| **`username`** | Set username for authentication using string, configMapKeyRef, or SecretKeyRef. | _EnvVar_ | Yes | diff --git a/mission-control/docs/topology/lookups/redis.md b/mission-control/docs/topology/lookups/redis.md index 47bc6e9d..66519254 100644 --- a/mission-control/docs/topology/lookups/redis.md +++ b/mission-control/docs/topology/lookups/redis.md @@ -35,7 +35,7 @@ spec: | **`addr`** | host:port address | string | Yes | | **`password`** | Set password for authentication using string, configMapKeyRef, or SecretKeyRef. | *EnvVar* | Yes | | **`username`** | Set username for authentication using string, configMapKeyRef, or SecretKeyRef. | *EnvVar* | Yes | -| **`db`** | Database to be selected after connecting to the server | _int_ | Yes | +| **`db`** | Database to be selected after connecting to the server | *int* | Yes | ## Authentication diff --git a/mission-control/modules/canary-checker b/mission-control/modules/canary-checker index 0f2a3389..3cd7af59 160000 --- a/mission-control/modules/canary-checker +++ b/mission-control/modules/canary-checker @@ -1 +1 @@ -Subproject commit 0f2a33894abdf193b507d5a8078a3e4741b6aaff +Subproject commit 3cd7af599f0ea65412de01880026c9dc917d727e diff --git a/mission-control/modules/config-db b/mission-control/modules/config-db index dc2a9942..81a5c2ef 160000 --- a/mission-control/modules/config-db +++ b/mission-control/modules/config-db @@ -1 +1 @@ -Subproject commit dc2a9942e8f9c6b2153e11e23a1eb644d61b3ba3 +Subproject commit 81a5c2efdac561079ff1d423e7af0a9f2b130b22 diff --git a/mission-control/modules/mission-control b/mission-control/modules/mission-control index 780ba02d..935f364c 160000 --- a/mission-control/modules/mission-control +++ b/mission-control/modules/mission-control @@ -1 +1 @@ -Subproject commit 780ba02d051367f5733e50772720d837d185f50a +Subproject commit 935f364c0fe9d62e6409600aac555a3423e2a14f diff --git a/mission-control/sidebars.js b/mission-control/sidebars.js index bb608473..948966c2 100644 --- a/mission-control/sidebars.js +++ b/mission-control/sidebars.js @@ -41,7 +41,8 @@ const sidebars = { type: 'doc', id: 'canary-checker/cli', label: 'CLI' - } + }, + ] }, { @@ -115,25 +116,34 @@ const sidebars = { label: 'Blackbox Exporter' } ] - } + }, + ], configdbSidebar: [ { type: 'autogenerated', dirName: 'config-db' - } + + }, ], playbooksSidebar: [ + { type: 'autogenerated', dirName: 'playbooks' - } + + }, + ], topologySidebar: [ + + { type: 'autogenerated', dirName: 'topology' - } + + }, + ], notificationsSidebar: [ { @@ -175,7 +185,7 @@ const sidebars = { type: 'doc', id: 'notifications/events/health-checks', label: 'Health Checks' - } + }, // { // type: 'doc', // id: 'notifications/events/incidents', @@ -220,7 +230,7 @@ const sidebars = { reference: [ { type: 'autogenerated', - dirName: 'reference' + dirName: "reference" } ], overview: [