Skip to content

Commit

Permalink
webhook: Move httpapi into own package
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
  • Loading branch information
mrueg committed Nov 30, 2023
1 parent 832bcb5 commit 66f5259
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import (
"sigs.k8s.io/external-dns/provider/ultradns"
"sigs.k8s.io/external-dns/provider/vinyldns"
"sigs.k8s.io/external-dns/provider/vultr"
"sigs.k8s.io/external-dns/provider/webhook"
webhookapi "sigs.k8s.io/external-dns/provider/webhook/api"

Check failure on line 83 in main.go

View workflow job for this annotation

GitHub Actions / Build

could not import sigs.k8s.io/external-dns/provider/webhook/api (-: # sigs.k8s.io/external-dns/provider/webhook/api
"sigs.k8s.io/external-dns/registry"
"sigs.k8s.io/external-dns/source"
)
Expand Down Expand Up @@ -413,7 +413,7 @@ func main() {
}

if cfg.WebhookServer {
webhook.StartHTTPApi(p, nil, cfg.WebhookProviderReadTimeout, cfg.WebhookProviderWriteTimeout, "127.0.0.1:8888")
webhookapi.StartHTTPApi(p, nil, cfg.WebhookProviderReadTimeout, cfg.WebhookProviderWriteTimeout, "127.0.0.1:8888")
os.Exit(0)
}

Expand Down
12 changes: 6 additions & 6 deletions provider/webhook/httpapi.go → provider/webhook/api/httpapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package webhook
package api

import (
"context"
Expand All @@ -26,7 +26,7 @@ import (
"sigs.k8s.io/external-dns/endpoint"
"sigs.k8s.io/external-dns/plan"
"sigs.k8s.io/external-dns/provider"

"sigs.k8s.io/external-dns/provider/webhook"
log "github.com/sirupsen/logrus"
)

Expand All @@ -43,7 +43,7 @@ func (p *WebhookServer) RecordsHandler(w http.ResponseWriter, req *http.Request)
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Header().Set(contentTypeHeader, mediaTypeFormatAndVersion)
w.Header().Set(webhook.contentTypeHeader, webhook.mediaTypeFormatAndVersion)

Check failure on line 46 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.contentTypeHeader

Check failure on line 46 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.mediaTypeFormatAndVersion

Check failure on line 46 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: webhook.contentTypeHeader

Check failure on line 46 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: webhook.mediaTypeFormatAndVersion

Check failure on line 46 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.contentTypeHeader

Check failure on line 46 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.mediaTypeFormatAndVersion

Check failure on line 46 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.contentTypeHeader

Check failure on line 46 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.mediaTypeFormatAndVersion

Check failure on line 46 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.contentTypeHeader

Check failure on line 46 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.mediaTypeFormatAndVersion

Check failure on line 46 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.contentTypeHeader

Check failure on line 46 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.mediaTypeFormatAndVersion
w.WriteHeader(http.StatusOK)
if err := json.NewEncoder(w).Encode(records); err != nil {
log.Errorf("Failed to encode records: %v", err)
Expand All @@ -58,7 +58,7 @@ func (p *WebhookServer) RecordsHandler(w http.ResponseWriter, req *http.Request)
}
err := p.Provider.ApplyChanges(context.Background(), &changes)
if err != nil {
log.Errorf("Failed to Apply Changes: %v", err)
log.Errorf("Failed to apply changes: %v", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
Expand All @@ -83,7 +83,7 @@ func (p *WebhookServer) AdjustEndpointsHandler(w http.ResponseWriter, req *http.
w.WriteHeader(http.StatusBadRequest)
return
}
w.Header().Set(contentTypeHeader, mediaTypeFormatAndVersion)
w.Header().Set(webhook.contentTypeHeader, webhook.mediaTypeFormatAndVersion)

Check failure on line 86 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.contentTypeHeader

Check failure on line 86 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.mediaTypeFormatAndVersion

Check failure on line 86 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: webhook.contentTypeHeader

Check failure on line 86 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: webhook.mediaTypeFormatAndVersion

Check failure on line 86 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.contentTypeHeader

Check failure on line 86 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.mediaTypeFormatAndVersion

Check failure on line 86 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.contentTypeHeader

Check failure on line 86 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.mediaTypeFormatAndVersion

Check failure on line 86 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.contentTypeHeader

Check failure on line 86 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.mediaTypeFormatAndVersion
pve, err := p.Provider.AdjustEndpoints(pve)
if err != nil {
log.Errorf("Failed to call adjust endpoints: %v", err)
Expand All @@ -97,7 +97,7 @@ func (p *WebhookServer) AdjustEndpointsHandler(w http.ResponseWriter, req *http.
}

func (p *WebhookServer) NegotiateHandler(w http.ResponseWriter, req *http.Request) {
w.Header().Set(contentTypeHeader, mediaTypeFormatAndVersion)
w.Header().Set(webhook.contentTypeHeader, webhook.mediaTypeFormatAndVersion)

Check failure on line 100 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.contentTypeHeader

Check failure on line 100 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.mediaTypeFormatAndVersion

Check failure on line 100 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: webhook.contentTypeHeader

Check failure on line 100 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: webhook.mediaTypeFormatAndVersion

Check failure on line 100 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.contentTypeHeader

Check failure on line 100 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.mediaTypeFormatAndVersion

Check failure on line 100 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.contentTypeHeader

Check failure on line 100 in provider/webhook/api/httpapi.go

View workflow job for this annotation

GitHub Actions / Build

undefined: webhook.mediaTypeFormatAndVersion) (typecheck)
json.NewEncoder(w).Encode(p.Provider.GetDomainFilter())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package webhook
package api

import (
"bytes"
Expand Down

0 comments on commit 66f5259

Please sign in to comment.