Skip to content

Commit

Permalink
Merge pull request #693 from eapearson/develop
Browse files Browse the repository at this point in the history
auth2 service version per env, service version check to console not throw error [SCT-1075]
  • Loading branch information
eapearson committed Jun 12, 2018
2 parents 26164cf + d347b72 commit d508a6a
Show file tree
Hide file tree
Showing 16 changed files with 165 additions and 50 deletions.
2 changes: 1 addition & 1 deletion config/app/dev/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ plugins:
-
name: auth2-client
globalName: kbase-ui-plugin-auth2-client
version: 1.3.2
version: 1.3.4
cwd: src/plugin
source:
bower: {}
Expand Down
1 change: 1 addition & 0 deletions config/app/dev/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ui:
route: {}
session: {}
rpc: {}
coreService: {}
# dynamic-service: {}
menu:
menus:
Expand Down
2 changes: 1 addition & 1 deletion config/app/prod/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ plugins:
-
name: auth2-client
globalName: kbase-ui-plugin-auth2-client
version: 1.3.2
version: 1.3.4
cwd: src/plugin
source:
bower: {}
Expand Down
1 change: 1 addition & 0 deletions config/app/prod/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ui:
route: {}
session: {}
rpc: {}
coreService: {}
# dynamic-service: {}
menu:
menus:
Expand Down
1 change: 1 addition & 0 deletions config/deploy/appdev.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services_narrative_url=https://appdev.kbase.us

services_auth2_providers=["Google", "Globus"]

services_auth2_version_minimum="0.2.0"

# services

Expand Down
2 changes: 2 additions & 0 deletions config/deploy/ci.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services_narrative_url=https://ci.kbase.us

services_auth2_providers=["Google", "Globus", "OrcID"]

services_auth2_version_minimum="0.2.5"

# services

# list of plugins to remove from the runtime even if specified in the build
Expand Down
2 changes: 2 additions & 0 deletions config/deploy/dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services_narrative_url=https://ci.kbase.us

services_auth2_providers=["Google", "Globus", "OrcID"]

services_auth2_version_minimum="0.2.5"

# services

# list of plugins to remove from the runtime even if specified in the build
Expand Down
2 changes: 2 additions & 0 deletions config/deploy/next.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services_narrative_url=https://next.kbase.us

services_auth2_providers=["Google", "Globus"]

services_auth2_version_minimum="0.2.0"

# services

# list of plugins to remove from the runtime even if specified in the build
Expand Down
2 changes: 2 additions & 0 deletions config/deploy/prod.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services_narrative_url=https://narrative.kbase.us

services_auth2_providers=["Google", "Globus"]

services_auth2_version_minimum="0.2.0"

# services

# list of plugins to remove from the runtime even if specified in the build
Expand Down
5 changes: 4 additions & 1 deletion deployment/ci/docker/kb-deployment/conf/config.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
"url": "{{ .Env.services_narrative_url }}"
},
"auth2": {
"providers": {{ default .Env.services_auth2_providers "null" }}
"providers": {{ default .Env.services_auth2_providers "null" }},
"version": {
"minimum": {{ .Env.services_auth2_version_minimum }}
}
}
}
}
47 changes: 34 additions & 13 deletions docs/dev/prerequisites.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,54 @@
# Prerequisites

The developer setup provides a workflow and set of tools to help develop kbase-ui, plugins, and associated libraries. The basic workflow consists of javascript development on your host (main desktop) environment, a Docker image for running kbase-ui behind nginx, and a separate Docker image for running a proxy for the kbase-ui container as well as KBase services.
The developer setup provides a workflow and set of tools to help develop _kbase-ui_, kbase-ui plugins, and libraries. The basic workflow consists of javascript development on your host (main desktop) environment, a Docker image for running kbase-ui behind nginx, and a separate Docker image for running a proxy for the kbase-ui container as well as KBase services.

[TOC]

## Basic Development Requirements

You will need to ensure that you have a basic set of development tools on your host desktop machine. These tools are available on Mac, Linux, and Windows.

| app | version | notes |
|-----|---------|------ |
| nodejs | 6 (LTS) | The V8 javascript system, required for building kbase-ui and running tests; we are currently on version 8. |
| git | ?? | the source revision management tool with integration into github |
| docker | ?? | the linux container manager you will use to run kbase-ui |
| make | ?? | all build tasks go through make |
| npm | 6 | |
| git | * | the source revision management tool with integration into github |
| docker | * | the linux container manager you will use to run kbase-ui |
| make | * | all build tasks go through make |

> \* we haven't documented any substantial differences between these tools regarding the kbase-ui development process. However, it is best to keep them always at the most recent version by updating your tool stack periodically
_kbase-ui_ is built not just on your local development workstation, but int the following places:

- in Travis CI, as part of the github workflow
- in the KBase Jenkins instance, as part of the CI deployment
- in a KBase VM (??) as part of the next/appdev/production deployment process

As such, we need to ensure that each part of the build toolchain is consistent in each environment. Thus, even though a different version of the above tools may work for you (and of course no-one is watching you to make sure you aren't!) please be advised that it is possible that you can introduce dependencies upon a version of a tool which will break in one of the other KBase build environments.

### nodejs

Node and npm are used together to build _kbase-ui_ and to run tests. Node and npm change _very_ frequently, and the number of transitive dependencies involved in the build and test toolchain number in the _thousands_. Therefore, we must always be cautious when making changes to both the toolchain and dependencies. On the other hand, they are only used for building and testing _kbase-ui_, and not the runtime operation.

### git

[ to be done ]

### docker

[ to be done ]

### make

[ to be done]

## Basic Development Requirements

### Overview

The KBase UI should build and run on any modern system: Mac OS X, Linux, Windows.

Procedures for installation of system level packages depends on ... the system you use! Even within a platform there may be multiple ways to install a given package. In this document we provide instructions for installation on platforms in use at KBase using methods that we have employed and work.
_kbase-ui_ should build and run on any modern system: Mac OS X, Linux, Windows.

| app | version | notes |
| ------ | ------- | ------------------------------------------------------------ |
| nodejs | 6 (LTS) | The V8 javascript system, required for building kbase-ui and running tests; we are currently on version 8. |
| git | ?? | the source revision management tool with integration into github |
| docker | ?? | the linux container manager you will use to run kbase-ui |
| make | ?? | all build tasks go through make |
Procedures for installation of system level packages depends on the system you use, and your toolchain preferences. In this document we provide instructions for installation on platforms in use at KBase using methods that we have employed and work.

## Installation

Expand Down
4 changes: 2 additions & 2 deletions src/client/modules/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ define([
});
}

function checkServices() {
function checkCoreServices() {
let manager = new kbaseServiceManager.KBaseServiceManager({
runtime: api
});
Expand Down Expand Up @@ -204,7 +204,7 @@ define([
return pluginManager.installPlugins(plugins);
})
.then(() => {
return checkServices();
return checkCoreServices();
})
.then(function () {
return appServiceManager.startServices();
Expand Down
44 changes: 44 additions & 0 deletions src/client/modules/app/services/coreService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
define([

], function (

) {
'use strict';

class CoreService {
constructor({moduleName, minimumVersion, url, versionMethod, versionPath}) {
this.moduleName = moduleName;
this.minimumVersion = minimumVersion;
this.url = url;
this.versionMethod = versionMethod;
this.versionPath = versionPath;
}
}

class CoreServicesMonitor {
constructor({runtime}) {
this.runtime = runtime;

this.services = {};
}

start () {

}

stop () {

}

pluginHandler(config) {
// console.log('plugin handler', config);
}

addCoreServiceDepenency(dep) {

}
}


return {ServiceClass: CoreServicesMonitor};
});
11 changes: 9 additions & 2 deletions src/client/modules/lib/appServiceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ define([
var service = services[name],
moduleName = [moduleBasePath, service.module].join('/');
require([moduleName], function (serviceFactory) {
var serviceInstance = serviceFactory.make(services[name].config);
services[name].instance = serviceInstance;
var serviceInstance;
if (serviceFactory.make) {
serviceInstance = serviceFactory.make(services[name].config);
} else {
serviceInstance = new serviceFactory.ServiceClass({
config: services[name].config
});
}
service.instance = serviceInstance;
resolve();
}, function (err) {
reject(err);
Expand Down
40 changes: 34 additions & 6 deletions src/client/modules/lib/kbaseServiceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ define([
'use strict';

class KBaseServiceManager {
constructor({runtime}) {
constructor({runtime, throwErrors}) {
this.runtime = runtime;
this.servicesToCheck = this.runtime.config('coreServices');
this.timeout = runtime.config('ui.constants.service_check_timeouts.hard');
this.throwErrors = throwErrors || false;
}

checkREST(serviceConfig) {
Expand All @@ -33,12 +34,23 @@ define([
.then((result) => {
let contentType = result.header.getHeader('content-type');
if (contentType !== 'application/json') {
throw new Error('Unexpected content type; expected "application/json", received "' + contentType + '"');
let errorMessage = 'Unexpected content type; expected "application/json", received "' + contentType + '"';
if (this.throwErrors) {
throw new Error(errorMessage);
} else {
console.error(errorMessage);
}
}
return JSON.parse(result.response);
})
.catch((err) => {
throw new Error('An error was encountered checking the service "' + serviceConfig.module + '": ' + err.message);
let errorMessage = 'An error was encountered checking the service "' + serviceConfig.module + '": ' + err.message;
if (this.throwErrors) {
throw new Error(errorMessage);
} else {
console.error(errorMessage);
}

});
}

Expand All @@ -53,7 +65,12 @@ define([
return result;
})
.catch((err) => {
throw new Error('An error was encountered checking the service "' + serviceConfig.module + '": ' + err.message);
let errorMessage = 'An error was encountered checking the service "' + serviceConfig.module + '": ' + err.message;
if (this.throwErrors) {
throw new Error(errorMessage);
} else {
console.error(errorMessage);
}
});
}

Expand All @@ -67,7 +84,12 @@ define([
case 'rest':
return this.checkREST(serviceConfig);
default:
throw new Error('Unsupported core service type: ' + serviceConfig.type);
var errorMessage = 'Unsupported core service type: ' + serviceConfig.type;
if (this.throwErrors) {
throw new Error(errorMessage);
} else {
console.error(errorMessage);
}
}
}).then((result) => {
let version;
Expand Down Expand Up @@ -105,7 +127,13 @@ define([
} else {
prefix = 'Incompatible services';
}
throw new Error(prefix + ': ' + message);
let errorMessage = prefix + ': ' + message;
if (this.throwErrors) {
throw new Error(errorMessage);
} else {
console.error(errorMessage);
}

}
});
}
Expand Down
Loading

0 comments on commit d508a6a

Please sign in to comment.