├── example.cue ├── testdefaults.cue ├── testschema.cue ├── testdata ├── failure.txtar ├── success.txtar ├── withruntime.txtar └── withimport.txtar ├── go.mod ├── README.md ├── main_test.go ├── example_test.go ├── config.go ├── go.sum └── LICENSE /example.cue: -------------------------------------------------------------------------------- 1 | foo: 1 2 | bar: a: {} 3 | 4 | -------------------------------------------------------------------------------- /testdefaults.cue: -------------------------------------------------------------------------------- 1 | env: [_]: string 2 | foo: *1 | _ 3 | bar: [n=_]: { 4 | name: n 5 | blah: *env.SOMEVAR | _ 6 | } 7 | -------------------------------------------------------------------------------- /testschema.cue: -------------------------------------------------------------------------------- 1 | foo: int & >= 0 & <100 2 | bar: [string]: #Baz 3 | 4 | #Baz: { 5 | name: string 6 | blah: string 7 | foobie: [...int] 8 | } 9 | 10 | // This will be provided by the program, not the user. 11 | env: [_]: string 12 | -------------------------------------------------------------------------------- /testdata/failure.txtar: -------------------------------------------------------------------------------- 1 | ! cueconfig-test 2 | cmpenv stderr stderr.golden 3 | 4 | -- .exampleconfig/config.cue -- 5 | package example 6 | 7 | foo: 150 8 | 9 | -- stderr.golden -- 10 | error in configuration: foo: invalid value 150 (out of bound <100): 11 | $$schema.cue:1:19 12 | $WORK/.exampleconfig/config.cue:3:6 13 | 14 | -------------------------------------------------------------------------------- /testdata/success.txtar: -------------------------------------------------------------------------------- 1 | cueconfig-test 2 | cmp stdout stdout.golden 3 | 4 | -- .exampleconfig/config.cue -- 5 | package example 6 | 7 | foo: 75 8 | 9 | _#Bar: { 10 | blah: *"hello" | _ 11 | ... 12 | } 13 | 14 | bar: [_]: _#Bar 15 | bar: a: { 16 | foobie: [1, 2, 3] 17 | } 18 | bar: b: {} 19 | 20 | -- stdout.golden -- 21 | { 22 | "foo": 75, 23 | "bar": { 24 | "a": { 25 | "blah": "hello", 26 | "foobie": [ 27 | 1, 28 | 2, 29 | 3 30 | ] 31 | }, 32 | "b": { 33 | "blah": "hello", 34 | "foobie": [] 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /testdata/withruntime.txtar: -------------------------------------------------------------------------------- 1 | env FOO=hello 2 | cueconfig-test 3 | cmp stdout stdout.golden 4 | 5 | -- .exampleconfig/config.cue -- 6 | package example 7 | 8 | env: _ 9 | 10 | foo: 75 11 | 12 | _#Bar: { 13 | blah: *env.FOO | _ 14 | ... 15 | } 16 | 17 | bar: [_]: _#Bar 18 | bar: a: { 19 | foobie: [1, 2, 3] 20 | } 21 | bar: b: {} 22 | 23 | -- stdout.golden -- 24 | { 25 | "foo": 75, 26 | "bar": { 27 | "a": { 28 | "blah": "hello", 29 | "foobie": [ 30 | 1, 31 | 2, 32 | 3 33 | ] 34 | }, 35 | "b": { 36 | "blah": "hello", 37 | "foobie": [] 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /testdata/withimport.txtar: -------------------------------------------------------------------------------- 1 | cueconfig-test 2 | cmp stdout stdout.golden 3 | 4 | -- .exampleconfig/cue.mod/module.cue -- 5 | module: "example.com/example" 6 | 7 | language: version: "v0.12.0" 8 | 9 | -- .exampleconfig/cue.mod/pkg/example.com/cueconfigtest/schema.cue -- 10 | package cueconfigtest 11 | 12 | foo: int & >= 0 & <100 13 | bar: [string]: #Baz 14 | 15 | #Baz: { 16 | name: string 17 | blah: string 18 | foobie: [...int] 19 | } 20 | 21 | -- .exampleconfig/config.cue -- 22 | package example 23 | 24 | import "example.com/cueconfigtest" 25 | 26 | cueconfigtest 27 | 28 | foo: 75 29 | 30 | _#Bar: { 31 | blah: *"hello" | _ 32 | ... 33 | } 34 | 35 | bar: [_]: _#Bar 36 | bar: a: { 37 | foobie: [1, 2, 3] 38 | } 39 | bar: b: {} 40 | 41 | -- stdout.golden -- 42 | { 43 | "foo": 75, 44 | "bar": { 45 | "a": { 46 | "blah": "hello", 47 | "foobie": [ 48 | 1, 49 | 2, 50 | 3 51 | ] 52 | }, 53 | "b": { 54 | "blah": "hello", 55 | "foobie": [] 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/cue-exp/cueconfig 2 | 3 | go 1.23 4 | 5 | require ( 6 | cuelang.org/go v0.12.0 7 | github.com/rogpeppe/go-internal v1.14.1 8 | ) 9 | 10 | require ( 11 | cuelabs.dev/go/oci/ociregistry v0.0.0-20241125120445-2c00c104c6e1 // indirect 12 | github.com/cockroachdb/apd/v3 v3.2.1 // indirect 13 | github.com/emicklei/proto v1.13.4 // indirect 14 | github.com/google/uuid v1.6.0 // indirect 15 | github.com/mitchellh/go-wordwrap v1.0.1 // indirect 16 | github.com/opencontainers/go-digest v1.0.0 // indirect 17 | github.com/opencontainers/image-spec v1.1.0 // indirect 18 | github.com/pelletier/go-toml/v2 v2.2.3 // indirect 19 | github.com/protocolbuffers/txtpbfmt v0.0.0-20241112170944-20d2c9ebc01d // indirect 20 | golang.org/x/mod v0.22.0 // indirect 21 | golang.org/x/net v0.34.0 // indirect 22 | golang.org/x/oauth2 v0.25.0 // indirect 23 | golang.org/x/sys v0.29.0 // indirect 24 | golang.org/x/text v0.21.0 // indirect 25 | golang.org/x/tools v0.29.0 // indirect 26 | gopkg.in/yaml.v3 v3.0.1 // indirect 27 | ) 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cueconfig: use CUE to configure your Go programs 2 | 3 | Package `cueconfig` provides an API designed to make it straightforward 4 | to use the [CUE language](https://cuelang.org) as a configuration format 5 | for Go programs. 6 | 7 | It provides a single entry point, [Load](https://pkg.go.dev/github.com/cue-exp/cueconfig#Load), which is very roughly equivalent to [json.Unmarshal](https://pkg.go.dev/encoding/json#Unmarshal). It loads a configuration file (or directory) from disk and unmarshals it into a Go value. 8 | 9 | Optionally, `Load` can be provided with a CUE schema to verify the configuration before unmarshaling into the Go value, a set of default values to apply after any user-specified defaults, and some runtime-defined values to be made available to the configuration. 10 | 11 | There is a [full example](https://pkg.go.dev/github.com/cue-exp/cueconfig#example-Load) in the package documentation. 12 | 13 | ### Issue tracking 14 | 15 | Please raise all issues in [the main CUE 16 | repository](https://github.com/cue-lang/cue/issues), giving the title of the 17 | issue a `cueconfig: ` prefix. 18 | -------------------------------------------------------------------------------- /main_test.go: -------------------------------------------------------------------------------- 1 | package cueconfig_test 2 | 3 | import ( 4 | _ "embed" 5 | "encoding/json" 6 | "fmt" 7 | "os" 8 | "strings" 9 | "testing" 10 | 11 | "github.com/cue-exp/cueconfig" 12 | "github.com/rogpeppe/go-internal/testscript" 13 | ) 14 | 15 | func TestFoo(t *testing.T) { 16 | testscript.Run(t, testscript.Params{ 17 | Dir: "testdata", 18 | UpdateScripts: os.Getenv("SCRIPT_UPDATE") != "", 19 | }) 20 | } 21 | 22 | func TestMain(m *testing.M) { 23 | testscript.Main(m, map[string]func(){ 24 | "cueconfig-test": Main, 25 | }) 26 | } 27 | 28 | //go:embed testschema.cue 29 | var schema []byte 30 | 31 | //go:embed testdefaults.cue 32 | var defaults []byte 33 | 34 | type config struct { 35 | Foo int `json:"foo"` 36 | Bar map[string]Baz `json:"bar"` 37 | } 38 | 39 | type Baz struct { 40 | Blah string `json:"blah"` 41 | Foobie []int `json:"foobie"` 42 | } 43 | 44 | func Main() { 45 | configFile := ".exampleconfig" 46 | if len(os.Args) > 1 { 47 | configFile = os.Args[1] 48 | } 49 | runtime := struct { 50 | Env map[string]string `json:"env"` 51 | }{environ()} 52 | var cfg config 53 | if err := cueconfig.Load(configFile, schema, defaults, runtime, &cfg); err != nil { 54 | fmt.Fprintf(os.Stderr, "%v\n", err) 55 | os.Exit(1) 56 | } 57 | data, _ := json.MarshalIndent(cfg, "", "\t") 58 | fmt.Printf("%s\n", data) 59 | } 60 | 61 | func environ() map[string]string { 62 | m := make(map[string]string) 63 | for _, e := range os.Environ() { 64 | k, v, _ := strings.Cut(e, "=") 65 | m[k] = v 66 | } 67 | return m 68 | } 69 | -------------------------------------------------------------------------------- /example_test.go: -------------------------------------------------------------------------------- 1 | package cueconfig_test 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/cue-exp/cueconfig" 8 | ) 9 | 10 | type exampleConfig struct { 11 | Foo int `json:"foo"` 12 | Bar map[string]*exampleBar `json:"bar"` 13 | } 14 | 15 | type exampleBar struct { 16 | Amount float64 `json:"amount"` 17 | Something bool `json:"something"` 18 | Path string `json:"path"` 19 | } 20 | 21 | type exampleRuntime struct { 22 | CurrentDirectory string `json:"currentDirectory"` 23 | } 24 | 25 | func ExampleLoad() { 26 | // In this example, we use the example.cue from the package 27 | // but in practice this would be located whereever you'd want 28 | // your program's configuration file. 29 | configFile := "example.cue" 30 | 31 | // This is a placeholder for any runtime values provided 32 | // as input to the configuration. 33 | runtime := struct { 34 | Runtime exampleRuntime `json:"runtime"` 35 | }{ 36 | Runtime: exampleRuntime{ 37 | CurrentDirectory: "/path/to/current/directory", 38 | }, 39 | } 40 | // Load the configuration into the Go value cfg. 41 | var cfg exampleConfig 42 | if err := cueconfig.Load(configFile, exampleSchema, exampleDefaults, runtime, &cfg); err != nil { 43 | fmt.Printf("%v\n", err) 44 | return 45 | } 46 | // This is a placeholder for anything that the program might actually do 47 | // with the configuration. 48 | data, _ := json.MarshalIndent(cfg, "", "\t") 49 | fmt.Printf("%s\n", data) 50 | //Output: 51 | //{ 52 | // "foo": 1, 53 | // "bar": { 54 | // "a": { 55 | // "amount": 1.5, 56 | // "something": false, 57 | // "path": "/path/to/current/directory" 58 | // } 59 | // } 60 | //} 61 | } 62 | 63 | // exampleSchema holds the schema for the program's configuration. 64 | // It would be conventional to include it as an embedded file, 65 | // but we've included it inline here so that it shows up directly 66 | // in the example. 67 | var exampleSchema = []byte(` 68 | package example 69 | 70 | foo?: int 71 | bar?: [string]: #Bar 72 | 73 | #Bar: { 74 | amount?: number 75 | something?: bool 76 | path?: string 77 | } 78 | 79 | // runtime is provided by the program, not the user. 80 | runtime?: #Runtime 81 | #Runtime: { 82 | currentDirectory: string 83 | } 84 | `) 85 | 86 | // exampleDefaults holds any default values for the program 87 | // to apply. As with [exampleSchema] above, it would conventionally 88 | // be taken from an embedded file. 89 | var exampleDefaults = []byte(` 90 | runtime: _ 91 | foo: *100 | _ 92 | bar: [_]: { 93 | amount: *1.5 | _ 94 | something: *false | _ 95 | path: *runtime.currentDirectory | _ 96 | } 97 | `) 98 | -------------------------------------------------------------------------------- /config.go: -------------------------------------------------------------------------------- 1 | // Package `cueconfig` provides an API designed to make it straightforward 2 | // to use the CUE language (see https://cuelang.org) as a configuration format 3 | // for Go programs. 4 | package cueconfig 5 | 6 | import ( 7 | _ "embed" 8 | "fmt" 9 | "os" 10 | 11 | "cuelang.org/go/cue" 12 | "cuelang.org/go/cue/ast" 13 | "cuelang.org/go/cue/ast/astutil" 14 | "cuelang.org/go/cue/build" 15 | "cuelang.org/go/cue/cuecontext" 16 | "cuelang.org/go/cue/errors" 17 | "cuelang.org/go/cue/load" 18 | ) 19 | 20 | // Load loads the CUE configuration at the file or CUE package directory 21 | // configFilePath. If the file does not exist, an os.IsNotExist error is returned. 22 | // 23 | // The schema for the user configuration is given in schema. 24 | // Usually this will come from a CUE file embedded in the binary by the caller. 25 | // If it's empty then any configuration data will be allowed. 26 | // 27 | // The user configuration is first read and unified with the schema. 28 | // Then if runtime is non-nil, it is unified with the resulting value, 29 | // thus providing the user configuration with any desired runtime values (e.g. 30 | // environment variables). 31 | // 32 | // Then the result is finalised (applying any user-specified defaults), then 33 | // unified with the CUE contained in the defaults argument. 34 | // This allows the program to specify default values independently 35 | // from the user. 36 | // 37 | // The result is unmarshaled into the Go value pointed to by dest 38 | // using cue.Value.Decode (similar to json.Unmarshal). 39 | func Load(configFilePath string, schema, defaults []byte, runtime any, dest any) error { 40 | info, err := os.Stat(configFilePath) 41 | if err != nil { 42 | return err 43 | } 44 | var configInst *build.Instance 45 | if info.IsDir() { 46 | configInst = load.Instances([]string{"."}, &load.Config{ 47 | Dir: configFilePath, 48 | })[0] 49 | } else { 50 | configInst = load.Instances([]string{configFilePath}, nil)[0] 51 | } 52 | if err := configInst.Err; err != nil { 53 | return fmt.Errorf("cannot load configuration from %q: %v", configFilePath, err) 54 | } 55 | ctx := cuecontext.New() 56 | 57 | configVal := ctx.BuildInstance(configInst) 58 | if err := configVal.Validate(cue.All()); err != nil { 59 | return fmt.Errorf("invalid configuration from %q: %v", configFilePath, errors.Details(err, nil)) 60 | } 61 | 62 | // Compile the config schema. 63 | schemaVal := ctx.CompileBytes(schema, cue.Filename("$schema.cue")) 64 | if err := schemaVal.Err(); err != nil { 65 | return fmt.Errorf("unexpected error in configuration schema %q: %v", schema, errors.Details(err, nil)) 66 | } 67 | // Compile the defaults. 68 | defaultsVal := ctx.CompileBytes(defaults, cue.Filename("$defaults.cue")) 69 | if err := defaultsVal.Err(); err != nil { 70 | return fmt.Errorf("unexpected error in defaults %q: %v", defaults, errors.Details(err, nil)) 71 | } 72 | 73 | // Unify the user-provided config with the configuration schema. 74 | configVal = configVal.Unify(schemaVal) 75 | if err := configVal.Validate(cue.All()); err != nil { 76 | return fmt.Errorf("error in configuration: %v", errors.Details(err, nil)) 77 | } 78 | 79 | // If there's a runtime value provided, unify it with the runtime field. 80 | if runtime != nil { 81 | configVal = configVal.Unify(ctx.Encode(runtime)) 82 | if err := configVal.Validate(cue.All()); err != nil { 83 | return fmt.Errorf("config schema conflict on runtime values: %v", errors.Details(err, nil)) 84 | } 85 | } 86 | 87 | // The user layer is now complete. Now finalize it and apply any program-level 88 | // defaults. 89 | configVal, err = finalize(ctx, configVal) 90 | if err != nil { 91 | return fmt.Errorf("internal error: cannot finalize configuration value: %v", errors.Details(err, nil)) 92 | } 93 | // Unify with the defaults. 94 | configVal = configVal.Unify(defaultsVal) 95 | if err := configVal.Validate(cue.All()); err != nil { 96 | return fmt.Errorf("config schema error applying program-level defaults: %v", errors.Details(err, nil)) 97 | } 98 | 99 | if err := configVal.Decode(dest); err != nil { 100 | return fmt.Errorf("cannot decode final configuration: %v", errors.Details(err, nil)) 101 | } 102 | return nil 103 | } 104 | 105 | // finalize returns v with all references resolved and all default values selected. 106 | // This is a bit of a hack until similar functionality is implemented inside 107 | // the cue package itself. 108 | func finalize(ctx *cue.Context, v cue.Value) (cue.Value, error) { 109 | n := v.Syntax(cue.Final()) 110 | var f *ast.File 111 | switch n := n.(type) { 112 | case *ast.File: 113 | f = n 114 | case ast.Expr: 115 | var err error 116 | f, err = astutil.ToFile(n) 117 | if err != nil { 118 | return cue.Value{}, fmt.Errorf("cannot convert node to expr: %v", err) 119 | } 120 | default: 121 | return cue.Value{}, fmt.Errorf("unexpected type %#v", n) 122 | } 123 | return ctx.BuildFile(f), nil 124 | } 125 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cuelabs.dev/go/oci/ociregistry v0.0.0-20241125120445-2c00c104c6e1 h1:mRwydyTyhtRX2wXS3mqYWzR2qlv6KsmoKXmlz5vInjg= 2 | cuelabs.dev/go/oci/ociregistry v0.0.0-20241125120445-2c00c104c6e1/go.mod h1:5A4xfTzHTXfeVJBU6RAUf+QrlfTCW+017q/QiW+sMLg= 3 | cuelang.org/go v0.12.0 h1:q4W5I+RtDIA27rslQyyt6sWkXX0YS9qm43+U1/3e0kU= 4 | cuelang.org/go v0.12.0/go.mod h1:B4+kjvGGQnbkz+GuAv1dq/R308gTkp0sO28FdMrJ2Kw= 5 | github.com/cockroachdb/apd/v3 v3.2.1 h1:U+8j7t0axsIgvQUqthuNm82HIrYXodOV2iWLWtEaIwg= 6 | github.com/cockroachdb/apd/v3 v3.2.1/go.mod h1:klXJcjp+FffLTHlhIG69tezTDvdP065naDsHzKhYSqc= 7 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 8 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 9 | github.com/emicklei/proto v1.13.4 h1:myn1fyf8t7tAqIzV91Tj9qXpvyXXGXk8OS2H6IBSc9g= 10 | github.com/emicklei/proto v1.13.4/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= 11 | github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= 12 | github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= 13 | github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= 14 | github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 15 | github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= 16 | github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 17 | github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= 18 | github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= 19 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 20 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 21 | github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= 22 | github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= 23 | github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= 24 | github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= 25 | github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= 26 | github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= 27 | github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= 28 | github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= 29 | github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= 30 | github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= 31 | github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= 32 | github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= 33 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 34 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 35 | github.com/protocolbuffers/txtpbfmt v0.0.0-20241112170944-20d2c9ebc01d h1:HWfigq7lB31IeJL8iy7jkUmU/PG1Sr8jVGhS749dbUA= 36 | github.com/protocolbuffers/txtpbfmt v0.0.0-20241112170944-20d2c9ebc01d/go.mod h1:jgxiZysxFPM+iWKwQwPR+y+Jvo54ARd4EisXxKYpB5c= 37 | github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= 38 | github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= 39 | github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= 40 | github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 41 | golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= 42 | golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= 43 | golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= 44 | golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= 45 | golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70= 46 | golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= 47 | golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= 48 | golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 49 | golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= 50 | golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 51 | golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= 52 | golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= 53 | golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE= 54 | golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588= 55 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 56 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= 57 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 58 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 59 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------