OpenVariableURL opens the variable at the URL's path. See the package doc for more details.
(ctx context.Context, u *url.URL)
| 106 | // OpenVariableURL opens the variable at the URL's path. See the package doc |
| 107 | // for more details. |
| 108 | func (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. |
| 135 | type Options struct { |
no test coverage detected