Revision 5273a46cf7288144d3ccac825725cf024b40b565 authored by André Martins on 18 June 2024, 14:59:12 UTC, committed by André Martins on 20 June 2024, 19:00:01 UTC
The builder image is used to generate Kubernetes manifests and some Go code for Kubernetes clients. Currently, Docker run commands are executed as the root user inside the container, resulting in files being created with the root UID. This prevents the user who executed the Docker run command from managing these files. Running the Docker container with the executing user's UID causes "go run" commands to fail due to insufficient permissions to write to the /.cache directory. To resolve this, we need to create a /.cache directory with write permissions for all users. Signed-off-by: André Martins <andre@cilium.io>
1 parent 6f461ea
config_get.go
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package cmd
import (
"fmt"
"regexp"
"strings"
"github.com/spf13/cobra"
"github.com/cilium/cilium/pkg/command"
)
var (
removeHyphen = regexp.MustCompile(`[^\w]`)
)
// configGetCmd represents the config get command
var configGetCmd = &cobra.Command{
Use: "get <config name>",
Short: "Retrieve cilium configuration",
PreRun: requireConfigName,
Run: func(cmd *cobra.Command, args []string) {
// removing hyphen from the config name and transforming it to lower case
configName := removeHyphen.ReplaceAllString(strings.ToLower(args[0]), "")
resp, err := client.ConfigGet()
if err != nil {
Fatalf("Error while retrieving configuration: %s", err)
}
if resp.Status == nil {
Fatalf("Empty configuration status returned")
}
readWriteConfigMap := make(map[string]interface{})
readOnlyConfigMap := resp.Status.DaemonConfigurationMap
for k, v := range resp.Status.Realized.Options {
readWriteConfigMap[k] = v
}
readWriteConfigMap["PolicyEnforcement"] = resp.Status.Realized.PolicyEnforcement
// Key values are named as field names of `DaemonConfig` struct
// to match configuration input, map keys are transformed to lower case
readWriteConfigMap = mapKeysToLowerCase(readWriteConfigMap)
readOnlyConfigMap = mapKeysToLowerCase(readOnlyConfigMap)
// conifgMap holds both read-only and read-write configurations
configMap := mergeMaps(readOnlyConfigMap, readWriteConfigMap)
if value, ok := configMap[configName]; ok {
fmt.Printf("%v\n", value)
} else {
Fatalf("Configuration does not exist")
}
},
}
func init() {
configCmd.AddCommand(configGetCmd)
command.AddOutputOption(configGetCmd)
}
func requireConfigName(cmd *cobra.Command, args []string) {
if len(args) < 1 {
Usagef(cmd, "Missing config name argument")
}
if args[0] == "" {
Usagef(cmd, "Empty config argument")
}
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...