Complete adapts from the command line args and factory to the data required.
(f cmdutil.Factory)
| 149 | |
| 150 | // Complete adapts from the command line args and factory to the data required. |
| 151 | func (o *ProxyOptions) Complete(f cmdutil.Factory) error { |
| 152 | clientConfig, err := f.ToRESTConfig() |
| 153 | if err != nil { |
| 154 | return err |
| 155 | } |
| 156 | o.clientConfig = clientConfig |
| 157 | |
| 158 | if !strings.HasSuffix(o.staticPrefix, "/") { |
| 159 | o.staticPrefix += "/" |
| 160 | } |
| 161 | |
| 162 | if !strings.HasSuffix(o.apiPrefix, "/") { |
| 163 | o.apiPrefix += "/" |
| 164 | } |
| 165 | |
| 166 | if o.appendServerPath == false { |
| 167 | target, err := url.Parse(clientConfig.Host) |
| 168 | if err != nil { |
| 169 | return err |
| 170 | } |
| 171 | if target.Path != "" && target.Path != "/" { |
| 172 | klog.Warning("Your kube context contains a server path " + target.Path + ", use --append-server-path to automatically append the path to each request") |
| 173 | } |
| 174 | } |
| 175 | if o.disableFilter { |
| 176 | if o.unixSocket == "" { |
| 177 | klog.Warning("Request filter disabled, your proxy is vulnerable to XSRF attacks, please be cautious") |
| 178 | } |
| 179 | o.filter = nil |
| 180 | } else { |
| 181 | o.filter = &proxy.FilterServer{ |
| 182 | AcceptPaths: proxy.MakeRegexpArrayOrDie(o.acceptPaths), |
| 183 | RejectPaths: proxy.MakeRegexpArrayOrDie(o.rejectPaths), |
| 184 | AcceptHosts: proxy.MakeRegexpArrayOrDie(o.acceptHosts), |
| 185 | RejectMethods: proxy.MakeRegexpArrayOrDie(o.rejectMethods), |
| 186 | } |
| 187 | } |
| 188 | return nil |
| 189 | } |
| 190 | |
| 191 | // Validate checks to the ProxyOptions to see if there is sufficient information to run the command. |
| 192 | func (o ProxyOptions) Validate() error { |
no test coverage detected