MCPcopy Create free account
hub / github.com/google/go-cloud / OpenVariableURL

Method OpenVariableURL

runtimevar/awsparamstore/awsparamstore.go:108–132  ·  view source on GitHub ↗

OpenVariableURL opens the variable at the URL's path. See the package doc for more details.

(ctx context.Context, u *url.URL)

Source from the content-addressed store, hash-verified

106// OpenVariableURL opens the variable at the URL's path. See the package doc
107// for more details.
108func (o *URLOpener) OpenVariableURL(ctx context.Context, u *url.URL) (*runtimevar.Variable, error) {
109 q := u.Query()
110
111 decoderName := q.Get("decoder")
112 q.Del("decoder")
113 decoder, err := runtimevar.DecoderByName(ctx, decoderName, o.Decoder)
114 if err != nil {
115 return nil, fmt.Errorf("open variable %v: invalid decoder: %v", u, err)
116 }
117 opts := o.Options
118 if s := q.Get("wait"); s != "" {
119 q.Del("wait")
120 d, err := time.ParseDuration(s)
121 if err != nil {
122 return nil, fmt.Errorf("open variable %v: invalid wait %q: %v", u, s, err)
123 }
124 opts.WaitDuration = d
125 }
126
127 cfg, err := gcaws.V2ConfigFromURLParams(ctx, q)
128 if err != nil {
129 return nil, fmt.Errorf("open variable %v: %v", u, err)
130 }
131 return OpenVariable(ssm.NewFromConfig(cfg), path.Join(u.Host, u.Path), decoder, &opts)
132}
133
134// Options sets options.
135type Options struct {

Callers 1

OpenVariableURLMethod · 0.95

Calls 4

DecoderByNameFunction · 0.92
QueryMethod · 0.80
OpenVariableFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected