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 <[email protected]>
  • Loading branch information
gotjosh committed Nov 21, 2023
1 parent ca5089d commit a0d920f
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 2,885 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 a0d920f

Please sign in to comment.