Skip to content

Commit

Permalink
Deprecate and remove api/v1/
Browse files Browse the repository at this point in the history
Signed-off-by: gotjosh <josue.abreu@gmail.com>
  • Loading branch information
gotjosh committed Jun 29, 2022
1 parent 3f3e2ce commit e0d9502
Show file tree
Hide file tree
Showing 13 changed files with 11 additions and 3,902 deletions.
18 changes: 1 addition & 17 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/prometheus/common/model"
"github.com/prometheus/common/route"

apiv1 "github.com/prometheus/alertmanager/api/v1"
apiv2 "github.com/prometheus/alertmanager/api/v2"
"github.com/prometheus/alertmanager/cluster"
"github.com/prometheus/alertmanager/config"
Expand All @@ -37,7 +36,6 @@ import (

// API represents all APIs of Alertmanager.
type API struct {
v1 *apiv1.API
v2 *apiv2.API
requestsInFlight prometheus.Gauge
concurrencyLimitExceeded prometheus.Counter
Expand Down Expand Up @@ -110,15 +108,6 @@ func New(opts Options) (*API, error) {
}
}

v1 := apiv1.New(
opts.Alerts,
opts.Silences,
opts.StatusFunc,
opts.Peer,
log.With(l, "version", "v1"),
opts.Registry,
)

v2, err := apiv2.NewAPI(
opts.Alerts,
opts.GroupFunc,
Expand Down Expand Up @@ -154,7 +143,6 @@ func New(opts Options) (*API, error) {
}

return &API{
v1: v1,
v2: v2,
requestsInFlight: requestsInFlight,
concurrencyLimitExceeded: concurrencyLimitExceeded,
Expand All @@ -163,17 +151,14 @@ func New(opts Options) (*API, error) {
}, nil
}

// Register all APIs. It registers APIv1 with the provided router directly. As
// APIv2 works on the http.Handler level, this method also creates a new
// Register all APIs. As APIv2 works on the http.Handler level, this method also creates a new
// http.ServeMux and then uses it to register both the provided router (to
// handle "/") and APIv2 (to handle "<routePrefix>/api/v2"). The method returns
// the newly created http.ServeMux. If a timeout has been set on construction of
// API, it is enforced for all HTTP request going through this mux. The same is
// true for the concurrency limit, with the exception that it is only applied to
// GET requests.
func (api *API) Register(r *route.Router, routePrefix string) *http.ServeMux {
api.v1.Register(r.WithPrefix("/api/v1"))

mux := http.NewServeMux()
mux.Handle("/", api.limitHandler(r))

Expand All @@ -196,7 +181,6 @@ func (api *API) Register(r *route.Router, routePrefix string) *http.ServeMux {
// Update config and resolve timeout of each API. APIv2 also needs
// setAlertStatus to be updated.
func (api *API) Update(cfg *config.Config, setAlertStatus func(model.LabelSet)) {
api.v1.Update(cfg)
api.v2.Update(cfg, setAlertStatus)
}

Expand Down
Loading

0 comments on commit e0d9502

Please sign in to comment.