Browse code

Add configuration options for logging and metrics endpoints

Samuel Padgett authored on 2015/10/06 02:58:03
Showing 11 changed files
... ...
@@ -99,5 +99,7 @@ window.OPENSHIFT_CONFIG = {
99 99
   	oauth_redirect_base: "https://localhost:9000",
100 100
   	oauth_client_id: "openshift-web-console",
101 101
   	logout_uri: ""
102
-  }
102
+  },
103
+  loggingURL: "",
104
+  metricsURL: ""
103 105
 };
... ...
@@ -138,6 +138,7 @@
138 138
         <script src="scripts/services/userstore.js"></script>
139 139
         <script src="scripts/services/auth.js"></script>
140 140
         <script src="scripts/services/data.js"></script>
141
+        <script src="scripts/services/discovery.js"></script>
141 142
         <script src="scripts/services/project.js"></script>
142 143
         <script src="scripts/services/applicationGenerator.js"></script>
143 144
         <script src="scripts/services/alertMessage.js"></script>
... ...
@@ -206,6 +206,8 @@ angular
206 206
   })
207 207
   .constant("API_CFG", angular.extend({}, (window.OPENSHIFT_CONFIG || {}).api))
208 208
   .constant("AUTH_CFG", angular.extend({}, (window.OPENSHIFT_CONFIG || {}).auth))
209
+  .constant("LOGGING_URL", (window.OPENSHIFT_CONFIG || {}).loggingURL)
210
+  .constant("METRICS_URL", (window.OPENSHIFT_CONFIG || {}).metricsURL)
209 211
   .config(function($httpProvider, AuthServiceProvider, RedirectLoginServiceProvider, AUTH_CFG, API_CFG) {
210 212
     $httpProvider.interceptors.push('AuthInterceptor');
211 213
 
212 214
new file mode 100644
... ...
@@ -0,0 +1,13 @@
0
+'use strict';
1
+
2
+angular.module('openshiftConsole')
3
+  .factory('APIDiscovery', ['LOGGING_URL', 'METRICS_URL', '$q', function(LOGGING_URL, METRICS_URL, $q) {
4
+    return {
5
+      getLoggingURL: function() {
6
+        return $q.when(LOGGING_URL);
7
+      },
8
+      getMetricsURL: function() {
9
+        return $q.when(METRICS_URL);
10
+      }
11
+    };
12
+  }]);
... ...
@@ -18071,7 +18071,7 @@ controller:"LogoutController"
18071 18071
 }).otherwise({
18072 18072
 redirectTo:"/"
18073 18073
 });
18074
-} ]).constant("API_CFG", angular.extend({}, (window.OPENSHIFT_CONFIG || {}).api)).constant("AUTH_CFG", angular.extend({}, (window.OPENSHIFT_CONFIG || {}).auth)).config([ "$httpProvider", "AuthServiceProvider", "RedirectLoginServiceProvider", "AUTH_CFG", "API_CFG", function(a, b, c, d) {
18074
+} ]).constant("API_CFG", angular.extend({}, (window.OPENSHIFT_CONFIG || {}).api)).constant("AUTH_CFG", angular.extend({}, (window.OPENSHIFT_CONFIG || {}).auth)).constant("LOGGING_URL", (window.OPENSHIFT_CONFIG || {}).loggingURL).constant("METRICS_URL", (window.OPENSHIFT_CONFIG || {}).metricsURL).config([ "$httpProvider", "AuthServiceProvider", "RedirectLoginServiceProvider", "AUTH_CFG", "API_CFG", function(a, b, c, d) {
18075 18075
 a.interceptors.push("AuthInterceptor"), b.LoginService("RedirectLoginService"), b.LogoutService("DeleteTokenLogoutService"), b.UserStore("LocalStorageUserStore"), c.OAuthClientID(d.oauth_client_id), c.OAuthAuthorizeURI(d.oauth_authorize_uri), c.OAuthRedirectURI(URI(d.oauth_redirect_base).segment("oauth").toString());
18076 18076
 } ]).config([ "$compileProvider", function(a) {
18077 18077
 a.aHrefSanitizationWhitelist(/^\s*(https?|mailto|git):/i);
... ...
@@ -18793,6 +18793,15 @@ namespace:a.metadata.name
18793 18793
 });
18794 18794
 }) :e.resolve(null), e.promise;
18795 18795
 }, new j();
18796
+} ]), angular.module("openshiftConsole").factory("APIDiscovery", [ "LOGGING_URL", "METRICS_URL", "$q", function(a, b, c) {
18797
+return {
18798
+getLoggingURL:function() {
18799
+return c.when(a);
18800
+},
18801
+getMetricsURL:function() {
18802
+return c.when(b);
18803
+}
18804
+};
18796 18805
 } ]), angular.module("openshiftConsole").factory("project", [ "$q", "$routeParams", "AuthService", "DataService", function(a, b, c, d) {
18797 18806
 var e = {
18798 18807
 projectPromise:$.Deferred()
... ...
@@ -171,7 +171,9 @@ window.OPENSHIFT_CONFIG = {
171 171
   	oauth_redirect_base: "{{ .OAuthRedirectBase | js}}",
172 172
   	oauth_client_id: "{{ .OAuthClientID | js}}",
173 173
   	logout_uri: "{{ .LogoutURI | js}}"
174
-  }
174
+  },
175
+  loggingURL: "{{ .LoggingURL | js}}",
176
+  metricsURL: "{{ .MetricsURL | js}}"
175 177
 };
176 178
 `))
177 179
 
... ...
@@ -199,6 +201,10 @@ type WebConsoleConfig struct {
199 199
 	OAuthClientID string
200 200
 	// LogoutURI is an optional (absolute) URI to redirect to after completing a logout. If not specified, the built-in logout page is shown.
201 201
 	LogoutURI string
202
+	// LoggingURL is the endpoint for logging (optional)
203
+	LoggingURL string
204
+	// MetricsURL is the endpoint for metrics (optional)
205
+	MetricsURL string
202 206
 }
203 207
 
204 208
 func GeneratedConfigHandler(config WebConsoleConfig) (http.Handler, error) {
... ...
@@ -378,6 +378,12 @@ type AssetConfig struct {
378 378
 	// MasterPublicURL is how the web console can access the OpenShift api server
379 379
 	MasterPublicURL string
380 380
 
381
+	// LoggingPublicURL is the public endpoint for logging (optional)
382
+	LoggingPublicURL string
383
+
384
+	// MetricsPublicURL is the public endpoint for metrics (optional)
385
+	MetricsPublicURL string
386
+
381 387
 	// ExtensionScripts are file paths on the asset server files to load as scripts when the Web
382 388
 	// Console loads
383 389
 	ExtensionScripts []string
... ...
@@ -358,6 +358,12 @@ type AssetConfig struct {
358 358
 	// MasterPublicURL is how the web console can access the OpenShift v1 server
359 359
 	MasterPublicURL string `json:"masterPublicURL"`
360 360
 
361
+	// LoggingPublicURL is the public endpoint for logging (optional)
362
+	LoggingPublicURL string `json:"loggingPublicURL"`
363
+
364
+	// MetricsPublicURL is the public endpoint for metrics (optional)
365
+	MetricsPublicURL string `json:"metricsPublicURL"`
366
+
361 367
 	// ExtensionScripts are file paths on the asset server files to load as scripts when the Web
362 368
 	// Console loads
363 369
 	ExtensionScripts []string `json:"extensionScripts"`
... ...
@@ -64,8 +64,10 @@ assetConfig:
64 64
   - html5Mode: false
65 65
     name: ""
66 66
     sourceDirectory: ""
67
+  loggingPublicURL: ""
67 68
   logoutURL: ""
68 69
   masterPublicURL: ""
70
+  metricsPublicURL: ""
69 71
   publicURL: ""
70 72
   servingInfo:
71 73
     bindAddress: ""
... ...
@@ -287,6 +287,18 @@ func ValidateAssetConfig(config *api.AssetConfig) fielderrors.ValidationErrorLis
287 287
 		allErrs = append(allErrs, urlErrs...)
288 288
 	}
289 289
 
290
+	if len(config.LoggingPublicURL) > 0 {
291
+		if _, loggingURLErrs := ValidateSecureURL(config.LoggingPublicURL, "loggingPublicURL"); len(loggingURLErrs) > 0 {
292
+			allErrs = append(allErrs, loggingURLErrs...)
293
+		}
294
+	}
295
+
296
+	if len(config.MetricsPublicURL) > 0 {
297
+		if _, metricsURLErrs := ValidateSecureURL(config.MetricsPublicURL, "metricsPublicURL"); len(metricsURLErrs) > 0 {
298
+			allErrs = append(allErrs, metricsURLErrs...)
299
+		}
300
+	}
301
+
290 302
 	for i, scriptFile := range config.ExtensionScripts {
291 303
 		allErrs = append(allErrs, ValidateFile(scriptFile, fmt.Sprintf("extensionScripts[%d]", i))...)
292 304
 	}
... ...
@@ -198,6 +198,8 @@ func (c *AssetConfig) addHandlers(mux *http.ServeMux) error {
198 198
 		OAuthRedirectBase:   c.Options.PublicURL,
199 199
 		OAuthClientID:       OpenShiftWebConsoleClientID,
200 200
 		LogoutURI:           c.Options.LogoutURL,
201
+		LoggingURL:          c.Options.LoggingPublicURL,
202
+		MetricsURL:          c.Options.MetricsPublicURL,
201 203
 	}
202 204
 	configPath := path.Join(publicURL.Path, "config.js")
203 205
 	configHandler, err := assets.GeneratedConfigHandler(config)