(_ context.Context, r Reporter)
| 122 | |
| 123 | func (c EndpointFormatCheck) Name() string { return "Endpoint Format Check" } |
| 124 | func (c EndpointFormatCheck) Run(_ context.Context, r Reporter) Result { |
| 125 | res := Result{} |
| 126 | if len(c.File.Endpoints) == 0 { |
| 127 | r.Info("No endpoints to check") |
| 128 | return res |
| 129 | } |
| 130 | for _, name := range c.File.SortedNames() { |
| 131 | ep := c.File.Endpoints[name] |
| 132 | if ep.Endpoint == "" { |
| 133 | res.Issues++ |
| 134 | r.Warn(fmt.Sprintf("%s has no endpoint URL", name), |
| 135 | "Add a provider endpoint with 'cam provider add NAME --endpoint URL'") |
| 136 | continue |
| 137 | } |
| 138 | parsed, err := url.Parse(ep.Endpoint) |
| 139 | if err != nil || (parsed.Scheme != "http" && parsed.Scheme != "https") { |
| 140 | res.Issues++ |
| 141 | r.Fail(fmt.Sprintf("%s endpoint URL invalid: %s", name, ep.Endpoint), |
| 142 | "Use http:// or https://") |
| 143 | continue |
| 144 | } |
| 145 | r.Pass(fmt.Sprintf("%s endpoint URL format is valid", name)) |
| 146 | } |
| 147 | return res |
| 148 | } |
| 149 | |
| 150 | // CacheCheck reports the size of the CAM cache directory. |
| 151 | type CacheCheck struct { |
nothing calls this directly
no test coverage detected