Load settings from config.toml file during CDI generation
Some checks are pending
CI Pipeline / code-scanning (push) Waiting to run
CI Pipeline / variables (push) Waiting to run
CI Pipeline / golang (push) Waiting to run
CI Pipeline / image (push) Blocked by required conditions
CI Pipeline / e2e-test (push) Blocked by required conditions

Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
This commit is contained in:
Carlos Eduardo Arango Gutierrez
2025-06-25 16:57:34 +02:00
parent 1676931fe0
commit c07257f21f
28 changed files with 5069 additions and 3 deletions

10
vendor/github.com/urfave/cli-altsrc/v3/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,10 @@
*.coverprofile
*.exe
*.orig
.*envrc
.envrc
.idea
/.local/
/site/
coverage.txt
vendor

View File

@@ -0,0 +1,75 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting urfave-governance@googlegroups.com, a members-only group
that is world-postable. All complaints will be reviewed and investigated and
will result in a response that is deemed necessary and appropriate to the
circumstances. The project team is obligated to maintain confidentiality with
regard to the reporter of an incident. Further details of specific enforcement
policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org

21
vendor/github.com/urfave/cli-altsrc/v3/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 urfave contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

14
vendor/github.com/urfave/cli-altsrc/v3/Makefile generated vendored Normal file
View File

@@ -0,0 +1,14 @@
.PHONY: all
all: vet test show-cover
.PHONY: vet
vet:
go vet -v ./...
.PHONY: test
test:
go test -v -cover -coverprofile=coverage.txt ./...
.PHONY: show-cover
show-cover:
go tool cover -func=coverage.txt

55
vendor/github.com/urfave/cli-altsrc/v3/README.md generated vendored Normal file
View File

@@ -0,0 +1,55 @@
# Welcome to `urfave/cli-altsrc/v3`
[![Run Tests](https://github.com/urfave/cli-altsrc/actions/workflows/main.yml/badge.svg)](https://github.com/urfave/cli-altsrc/actions/workflows/main.yml)
[![Go Reference](https://pkg.go.dev/badge/github.com/urfave/cli-altsrc/v3.svg)](https://pkg.go.dev/github.com/urfave/cli-altsrc/v3)
[![Go Report Card](https://goreportcard.com/badge/github.com/urfave/cli-altsrc/v3)](https://goreportcard.com/report/github.com/urfave/cli-altsrc/v3)
[`urfave/cli-altsrc/v3`](https://pkg.go.dev/github.com/urfave/cli-altsrc/v3) is an extension for [`urfave/cli/v3`] to read
flag values from JSON, YAML, and TOML. The extension keeps third-party libraries for these features away from [`urfave/cli/v3`].
[`urfave/cli/v3`]: https://github.com/urfave/cli
### Example
```go
configFiles := []string{
filepath.Join(testdataDir, "config.yaml"),
filepath.Join(testdataDir, "alt-config.yaml"),
}
app := &cli.Command{
Name: "greet",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Aliases: []string{"n"},
Sources: yaml.YAML("greet.name", configFiles...),
},
&cli.IntFlag{
Name: "enthusiasm",
Aliases: []string{"!"},
Sources: yaml.YAML("greet.enthusiasm", configFiles...),
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
punct := ""
if cmd.Int("enthusiasm") > 9000 {
punct = "!"
}
fmt.Fprintf(os.Stdout, "Hello, %[1]v%[2]v\n", cmd.String("name"), punct)
return nil
},
}
// Simulating os.Args
os.Args = []string{"greet"}
if err := app.Run(context.Background(), os.Args); err != nil {
fmt.Fprintf(os.Stdout, "OH NO: %[1]v\n", err)
}
// Output:
// Hello, Berry!
```

139
vendor/github.com/urfave/cli-altsrc/v3/altsrc.go generated vendored Normal file
View File

@@ -0,0 +1,139 @@
package altsrc
import (
"errors"
"fmt"
"os"
"runtime"
"strings"
)
var (
Err = errors.New("urfave/cli-altsrc error")
isTracingOn = os.Getenv("URFAVE_CLI_TRACING") == "on"
)
func tracef(format string, a ...any) {
if !isTracingOn {
return
}
if !strings.HasSuffix(format, "\n") {
format = format + "\n"
}
pc, file, line, _ := runtime.Caller(1)
cf := runtime.FuncForPC(pc)
fmt.Fprintf(
os.Stderr,
strings.Join([]string{
"## URFAVE CLI TRACE ",
file,
":",
fmt.Sprintf("%v", line),
" ",
fmt.Sprintf("(%s)", cf.Name()),
" ",
format,
}, ""),
a...,
)
}
// NestedVal returns a value from the given map. The lookup name may be a dot-separated path into the map.
// If that is the case, it will recursively traverse the map based on the '.' delimited sections to find
// a nested value for the key.
func NestedVal(name string, tree map[any]any) (any, bool) {
sections := strings.Split(name, ".")
if name == "" || len(sections) == 0 {
return nil, false
}
node := tree
// traverse into the map based on the dot-separated sections
if len(sections) >= 2 { // the last section is the value we want, we will return it directly at the end
for _, section := range sections[:len(sections)-1] {
child, ok := node[section]
if !ok {
return nil, false
}
switch child := child.(type) {
case map[string]any:
node = make(map[any]any, len(child))
for k, v := range child {
node[k] = v
}
case map[any]any:
node = child
default:
return nil, false
}
}
}
if val, ok := node[sections[len(sections)-1]]; ok {
return val, true
}
return nil, false
}
type Sourcer interface {
SourceURI() string
}
type StringSourcer string
func (s StringSourcer) SourceURI() string {
return string(s)
}
type StringPtrSourcer struct {
ptr *string
}
func NewStringPtrSourcer(p *string) StringPtrSourcer {
return StringPtrSourcer{
ptr: p,
}
}
func (s StringPtrSourcer) SourceURI() string {
return *s.ptr
}
type ValueSource struct {
key string
desc string
sourcer Sourcer
um func([]byte, any) error
}
func (vs *ValueSource) Lookup() (string, bool) {
maafsc := NewMapAnyAnyURISourceCache(vs.sourcer.SourceURI(), vs.um)
if v, ok := NestedVal(vs.key, maafsc.Get()); ok {
return fmt.Sprintf("%[1]v", v), ok
}
return "", false
}
func (vs *ValueSource) String() string {
return fmt.Sprintf("%s file %[2]q at key %[3]q", vs.desc, vs.sourcer.SourceURI(), vs.key)
}
func (vs *ValueSource) GoString() string {
return fmt.Sprintf("%sValueSource{file:%[2]q,keyPath:%[3]q}", vs.desc, vs.sourcer.SourceURI(), vs.key)
}
func NewValueSource(f func([]byte, any) error, desc string, key string, uriSrc Sourcer) *ValueSource {
return &ValueSource{
sourcer: uriSrc,
key: key,
desc: desc,
um: f,
}
}

26
vendor/github.com/urfave/cli-altsrc/v3/testutl.go generated vendored Normal file
View File

@@ -0,0 +1,26 @@
package altsrc
import (
"context"
"os/exec"
"path/filepath"
"strings"
)
func MustTestdataDir(ctx context.Context) string {
testdataDir, err := TestdataDir(ctx)
if err != nil {
panic(err)
}
return testdataDir
}
func TestdataDir(ctx context.Context) (string, error) {
topBytes, err := exec.CommandContext(ctx, "git", "rev-parse", "--show-toplevel").Output()
if err != nil {
return "", err
}
return filepath.Join(strings.TrimSpace(string(topBytes)), ".testdata"), nil
}

View File

@@ -0,0 +1,71 @@
package toml
import (
"fmt"
"reflect"
altsrc "github.com/urfave/cli-altsrc/v3"
)
type tomlMap struct {
Map map[any]any
}
func (tm *tomlMap) UnmarshalTOML(i any) error {
if v, err := unmarshalMap(i); err == nil {
tm.Map = v
} else {
return err
}
return nil
}
func unmarshalMap(i any) (ret map[any]any, err error) {
ret = make(map[any]any)
m := i.(map[string]any)
for key, val := range m {
v := reflect.ValueOf(val)
switch v.Kind() {
case reflect.Bool:
ret[key] = val.(bool)
case reflect.String:
ret[key] = val.(string)
case reflect.Int:
ret[key] = val.(int)
case reflect.Int8:
ret[key] = int(val.(int8))
case reflect.Int16:
ret[key] = int(val.(int16))
case reflect.Int32:
ret[key] = int(val.(int32))
case reflect.Int64:
ret[key] = int(val.(int64))
case reflect.Uint:
ret[key] = int(val.(uint))
case reflect.Uint8:
ret[key] = int(val.(uint8))
case reflect.Uint16:
ret[key] = int(val.(uint16))
case reflect.Uint32:
ret[key] = int(val.(uint32))
case reflect.Uint64:
ret[key] = int(val.(uint64))
case reflect.Float32:
ret[key] = float64(val.(float32))
case reflect.Float64:
ret[key] = val.(float64)
case reflect.Map:
if tmp, err := unmarshalMap(val); err == nil {
ret[key] = tmp
} else {
return nil, err
}
case reflect.Array, reflect.Slice:
ret[key] = val.([]any)
default:
return nil, fmt.Errorf("%[1]w: unsupported type %#[2]v", altsrc.Err, v.Kind())
}
}
return ret, nil
}

View File

@@ -0,0 +1,12 @@
package toml
import (
"github.com/BurntSushi/toml"
altsrc "github.com/urfave/cli-altsrc/v3"
)
// TOML is a helper function to encapsulate a number of
// tomlValueSource together as a cli.ValueSourceChain
func TOML(key string, source altsrc.Sourcer) *altsrc.ValueSource {
return altsrc.NewValueSource(toml.Unmarshal, "toml", key, source)
}

View File

@@ -0,0 +1,79 @@
package altsrc
import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"runtime"
"strings"
)
func readURI(uriString string) ([]byte, error) {
u, err := url.Parse(uriString)
if err != nil {
return nil, err
}
if u.Host != "" { // i have a host, now do i support the scheme?
switch u.Scheme {
case "http", "https":
res, err := http.Get(uriString)
if err != nil {
return nil, err
}
return io.ReadAll(res.Body)
default:
return nil, fmt.Errorf("%[1]w: scheme of %[2]q is unsupported", Err, uriString)
}
} else if u.Path != "" ||
(runtime.GOOS == "windows" && strings.Contains(u.String(), "\\")) {
if _, notFoundFileErr := os.Stat(uriString); notFoundFileErr != nil {
return nil, fmt.Errorf("%[1]w: cannot read from %[2]q because it does not exist", Err, uriString)
}
return os.ReadFile(uriString)
}
return nil, fmt.Errorf("%[1]w: unable to determine how to load from %[2]q", Err, uriString)
}
type URISourceCache[T any] struct {
uri string
m *T
unmarshaller func([]byte, any) error
}
func NewURISourceCache[T any](uri string, f func([]byte, any) error) *URISourceCache[T] {
return &URISourceCache[T]{
uri: uri,
unmarshaller: f,
}
}
func (fsc *URISourceCache[T]) Get() T {
if fsc.m == nil {
res := new(T)
if b, err := readURI(fsc.uri); err != nil {
tracef("failed to read uri %[1]q: %[2]v", fsc.uri, err)
} else if err := fsc.unmarshaller(b, res); err != nil {
tracef("failed to unmarshal from file %[1]q: %[2]v", fsc.uri, err)
} else {
fsc.m = res
}
}
if fsc.m == nil {
tracef("returning empty")
return *(new(T))
}
return *fsc.m
}
type MapAnyAnyURISourceCache = URISourceCache[map[any]any]
func NewMapAnyAnyURISourceCache(file string, f func([]byte, any) error) *MapAnyAnyURISourceCache {
return NewURISourceCache[map[any]any](file, f)
}