mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-30 09:56:21 -05:00
60bf770e62
* refactor `debugd` file structure * create `hack`-tool to deploy logcollection to non-debug clusters * integrate changes into CI * update fields * update workflow input names * use `working-directory` * add opensearch creds to upgrade workflow * make template func generic * make templating func generic * linebreaks * remove magic defaults * move `os.Exit` to main package * make logging index configurable * make templating generic * remove excess brace * update fields * copy fields * fix flag name * fix linter warnings Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> * remove unused workflow inputs * remove makefiles * fix command * bazel: fix output paths of container This fixes the output paths of builds within the container by mounting directories to paths that exist on the host. We also explicitly set the output path in a .bazelrc to the user specific path. The rc file is mounted into the container and overrides the host rc. Also adding automatic stop in case start is called and a containers is already running. Sym links like bazel-out and paths bazel outputs should generally work with this change. Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> * tabs -> spaces --------- Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
72 lines
2.3 KiB
Go
72 lines
2.3 KiB
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
package fields
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// THIS FILE IS A DUPLICATE OF debugd/internal/debugd/logcollector/fields.go
|
|
|
|
var (
|
|
// DebugdLogcollectPrefix is the prefix for all OpenSearch fields specified by the user when starting through debugd.
|
|
DebugdLogcollectPrefix = "logcollect."
|
|
// AllowedFields are the fields that are allowed to be used in the logcollection.
|
|
AllowedFields = map[string]struct{}{
|
|
"admin": {}, // name of the person running the cdbg command
|
|
"is_debug_cluster": {}, // whether the cluster is a debug cluster
|
|
// GitHub workflow information, see https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
|
|
"github.actor": {},
|
|
"github.workflow": {},
|
|
"github.run-id": {},
|
|
"github.run-attempt": {},
|
|
"github.ref-name": {},
|
|
"github.sha": {},
|
|
"github.runner-os": {},
|
|
"github.e2e-test-payload": {},
|
|
"github.is-debug-cluster": {},
|
|
// cloud provider used in e2e test. If deployed with debugd, this is a duplicate as its also
|
|
// available in the metadata. If deployed through K8s in e2e tests with a stable image, this
|
|
// is where the cloud provider is saved in.
|
|
"github.e2e-test-provider": {},
|
|
"deployment-type": {}, // deployment type, e.g. "debugd", "k8s"
|
|
}
|
|
)
|
|
|
|
// FromMap returns new Fields from the given map.
|
|
func FromMap(m map[string]string) Fields {
|
|
return Fields(m)
|
|
}
|
|
|
|
// Fields are the OpenSearch fields that are associated with a log message.
|
|
type Fields map[string]string
|
|
|
|
// Extend adds the fields from other to f and returns the result.
|
|
func (f Fields) Extend(other Fields) Fields {
|
|
for k, v := range other {
|
|
f[k] = v
|
|
}
|
|
return f
|
|
}
|
|
|
|
// Check checks whether all the fields in f are allowed. For fields that are prefixed with the debugd logcollect prefix are
|
|
// only the subkeys are checked.
|
|
func (f Fields) Check() error {
|
|
for k := range f {
|
|
if !strings.HasPrefix(k, DebugdLogcollectPrefix) {
|
|
continue
|
|
}
|
|
subkey := strings.TrimPrefix(k, DebugdLogcollectPrefix)
|
|
|
|
if _, ok := AllowedFields[subkey]; !ok {
|
|
return fmt.Errorf("invalid subkey %q for info key %q", subkey, fmt.Sprintf("%s%s", DebugdLogcollectPrefix, k))
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|