@@ -12,7 +12,6 @@ import (
1212
1313 "github.com/gorilla/handlers"
1414 "github.com/gorilla/mux"
15- "github.com/openshift/monitoring-plugin/pkg/proxy"
1615 "github.com/sirupsen/logrus"
1716 "gopkg.in/yaml.v2"
1817 v1 "k8s.io/api/core/v1"
@@ -21,6 +20,8 @@ import (
2120 "k8s.io/client-go/kubernetes/scheme"
2221 "k8s.io/client-go/rest"
2322 "k8s.io/client-go/tools/record"
23+
24+ "github.com/openshift/monitoring-plugin/pkg/proxy"
2425)
2526
2627var log = logrus .WithField ("module" , "server" )
@@ -56,10 +57,11 @@ type PluginConfig struct {
5657type Feature string
5758
5859const (
59- AcmAlerting Feature = "acm-alerting"
60- Incidents Feature = "incidents"
61- DevConfig Feature = "dev-config"
62- PersesDashboards Feature = "perses-dashboards"
60+ AcmAlerting Feature = "acm-alerting"
61+ Incidents Feature = "incidents"
62+ DevConfig Feature = "dev-config"
63+ PersesDashboards Feature = "perses-dashboards"
64+ AlertManagementAPI Feature = "alert-management-api"
6365)
6466
6567func (pluginConfig * PluginConfig ) MarshalJSON () ([]byte , error ) {
@@ -103,6 +105,8 @@ func (s *PluginServer) Shutdown(ctx context.Context) error {
103105
104106func createHTTPServer (ctx context.Context , cfg * Config ) (* http.Server , error ) {
105107 acmMode := cfg .Features [AcmAlerting ]
108+ alertManagementAPIMode := cfg .Features [AlertManagementAPI ]
109+
106110 acmLocationsLength := len (cfg .AlertmanagerUrl ) + len (cfg .ThanosQuerierUrl )
107111
108112 if acmLocationsLength > 0 && ! acmMode {
@@ -116,15 +120,19 @@ func createHTTPServer(ctx context.Context, cfg *Config) (*http.Server, error) {
116120 return nil , fmt .Errorf ("cannot set default port to reserved port %d" , cfg .Port )
117121 }
118122
123+ var k8sconfig * rest.Config
124+ var err error
125+
119126 // Uncomment the following line for local development:
120- // k8sconfig, err := clientcmd.BuildConfigFromFlags("", "$HOME/.kube/config")
127+ // k8sconfig, err = clientcmd.BuildConfigFromFlags("", os.Getenv("KUBECONFIG"))
128+ // if err != nil {
129+ // return nil, fmt.Errorf("cannot get kubeconfig from file: %w", err)
130+ // }
121131
122132 // Comment the following line for local development:
123133 var k8sclient * dynamic.DynamicClient
124- if acmMode {
125-
126- k8sconfig , err := rest .InClusterConfig ()
127-
134+ if acmMode || alertManagementAPIMode {
135+ k8sconfig , err = rest .InClusterConfig ()
128136 if err != nil {
129137 return nil , fmt .Errorf ("cannot get in cluster config: %w" , err )
130138 }
0 commit comments