/* eslint-env node */ var pkg = require('../package.json'); var fs = require('fs'); var YAML = require('yamljs'); var mode = process.env.UI_MODE || 'oss'; // 'caas' or 'oss' var signup = process.env.UI_SIGNUP !== 'false'; // set to false to hide signup // host can be an ip "1.2.3.4" -> http://1.2.3.4:8080 // or a URL+port function normalizeHost(host,defaultPort) { if ( host.indexOf('http') !== 0 ) { if ( host.indexOf(':') === -1 ) { host = 'http://' + host + (defaultPort ? ':'+defaultPort : ''); } else { host = 'http://' + host; } } return host; } function readLocales(environment) { /* Parse the translations from the translations folder*/ /* ember intl getLocalesByTranslations does not work if intl is not managing them (bundled) */ /* This needs a little work to read the yaml files for the langugae name prop*/ var files = fs.readdirSync('./translations'); var translationsOut = {}; files.forEach(function(filename) { if ( !filename.match(/\.ya?ml$/) && !filename.match(/\.json$/) ) { // Ignore non-YAML files return; } if ( environment === 'production' && filename === 'none.yaml' ) { // Don't show the "None" language in prod return; } var ymlFile = YAML.load('./translations/' + filename); var label = ymlFile.languageName; var locale = filename.split('.')[0]; translationsOut[locale] = label; }); return translationsOut; } module.exports = function(environment) { var ENV = { modulePrefix: 'ui', environment: environment, exportApplicationGlobal: true, rootURL: '/', locationType: 'auto', EmberENV: { FEATURES: { // Here you can enable experimental features on an ember canary build // e.g. 'with-controller': true }, EXTEND_PROTOTYPES: { // Prevent Ember Data from overriding Date.parse. Date: false } }, minifyCSS: { enabled: false }, minifyJS: { enabled: false }, contentSecurityPolicy: { // Allow the occasional ... 'style-src': "'self' releases.rancher.com localhost:3000 'unsafe-inline'", 'font-src': "'self' releases.rancher.com", 'script-src': "'self' releases.rancher.com localhost:3000", 'object-src': "'self' releases.rancher.com", 'img-src': "'self' releases.rancher.com avatars.githubusercontent.com gravatar.com localhost:3000 data:", 'frame-src': "'self' releases.rancher.com", // Allow connect to anywhere, for console and event stream socket 'connect-src': '*' }, APP: { // Here you can pass flags/options to your application instance // when it is created version: pkg.version, appName: 'Rancher', mode: mode, isCaas: mode === 'caas', caasSignup: signup, environment: environment, apiServer: 'http://localhost:8080', legacyApiEndpoint: '/v2', apiEndpoint: '/v1-workload', clusterEndpoint: '/v1-cluster', authenticationEndpoint: '/v1-authn', authorizationEndpoint: '/v1-authz', // betaApiEndpoint: '/v3', catalogServer: '', catalogEndpoint: '/v1-catalog', authServer: '', authEndpoint: '/v1-auth', telemetryEndpoint: '/v1-telemetry', webhookEndpoint: '/v1-webhooks', clusterToken: '%CLUSTERID%', projectToken: '%PROJECTID%', magicEndpoint: '/r', kubernetesBase: '/k8s', kubectlEndpoint: '/r/projects/%PROJECTID%/kubectld:8091/v1-kubectl', kubernetesDashboard: '/k8s/clusters/%CLUSTERID%/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy/', projectEndpoint: '/v3/projects/%PROJECTID%', proxyEndpoint: '/v3/proxy', wsEndpoint: '/v3/projects/%PROJECTID%/subscribe' + '?eventNames=resource.change' + '&resourceType_ne=auditLog' + '&resourceType_ne=serviceLog' + '&resourceType_ne=deploymentUnit', baseAssets: '/', locales: readLocales(environment), stripe: { publishableKey: 'pk_test_g925RcuVORh2KgHWfFbE80by' }, }, }; if (environment === 'development') { // ENV.APP.LOG_RESOLVER = true; // ENV.APP.LOG_ACTIVE_GENERATION = true; ENV.APP.LOG_TRANSITIONS = true; ENV.APP.LOG_TRANSITIONS_INTERNAL = true; ENV.APP.LOG_VIEW_LOOKUPS = true; } if (environment === 'test') { // Testem prefers this... ENV.rootURL = '/'; ENV.locationType = 'none'; // keep test console output quieter ENV.APP.LOG_ACTIVE_GENERATION = false; ENV.APP.LOG_VIEW_LOOKUPS = false; ENV.APP.rootElement = '#ember-testing'; } if (process.env.BASE_URL) { ENV.rootURL = process.env.BASE_URL; } ENV.APP.rootURL = ENV.rootURL; if (process.env.FINGERPRINT) { ENV.APP.fingerprint = process.env.FINGERPRINT; } if (process.env.BASE_ASSETS) { ENV.APP.baseAssets = process.env.BASE_ASSETS; } // Override the Rancher server/endpoint with environment var var server = process.env.RANCHER; if ( server ) { ENV.APP.apiServer = normalizeHost(server,8080); } else if (environment === 'production') { ENV.APP.apiServer = ''; } // Override the Catalog server/endpoint with environment var server = process.env.CATALOG; if ( server ) { ENV.APP.catalogServer = normalizeHost(server,8088); } else if (environment === 'production') { ENV.APP.catalogServer = ''; } var pl = process.env.PL; if ( pl ) { ENV.APP.pl = pl; } else { ENV.APP.pl = 'rancher'; } return ENV; };