Skip to content

Commit

Permalink
Add ui build to release build.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackgr committed May 26, 2015
1 parent acfe557 commit ef97838
Show file tree
Hide file tree
Showing 10 changed files with 5,202 additions and 904 deletions.
6 changes: 1 addition & 5 deletions .gitignore
Expand Up @@ -52,11 +52,7 @@ network_closure.sh
.tags*

# Web UI
third_party/ui/**
pkg/ui/datafile.go
www/master/node_modules/**
www/master/node_modules/
www/master/npm-debug.log
www/app/**

# Karma output
www/test_out
2 changes: 0 additions & 2 deletions .travis.yml
Expand Up @@ -16,13 +16,11 @@ matrix:
install:
- if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
- go get github.com/mattn/goveralls
- go get github.com/jteeuwen/go-bindata/...
- ./hack/travis/install-etcd.sh
- ./hack/verify-gofmt.sh
- ./hack/verify-boilerplate.sh
- ./hack/verify-description.sh
- ./hack/travis/install-std-race.sh
- ./hack/ui/build-www.sh
- ./hack/build-go.sh
- GOPATH=$PWD/Godeps/_workspace:$GOPATH go install ./...
- PATH=$HOME/gopath/bin:./third_party/etcd:$PATH ./hack/verify-gendocs.sh
Expand Down
17 changes: 13 additions & 4 deletions hack/lib/ui.sh
Expand Up @@ -19,23 +19,32 @@ readonly KUBE_BUILD_OUTPUT_PATH="${KUBE_OUTPUT}/www"
readonly KUBE_BUILD_ASSETS=(
app
)
readonly KUBE_BUILD_ASSET_PATHS=$(printf "${KUBE_BUILD_OUTPUT_PATH}/%s/... " "${KUBE_BUILD_ASSETS[@]}" | xargs)
readonly KUBE_BUILD_TARGET=pkg/ui/datafile.go

function kube::ui::generate_asset_paths() {
local asset
for asset in "${KUBE_BUILD_ASSETS[@]}"; do
if [[ -d $"${KUBE_BUILD_OUTPUT_PATH}/${asset}" ]]; then
echo "${KUBE_BUILD_OUTPUT_PATH}/${asset}/..."
fi
done
}

function kube::ui::build_ui() {
if ! which go-bindata > /dev/null 2>&1 ; then
echo "Cannot find go-bindata. Install with \"go get github.com/jteeuwen/go-bindata/...\""
exit 1
fi

if ! go-bindata -nocompress -o $KUBE_BUILD_TARGET -prefix ${PWD} -pkg ui "${KUBE_BUILD_ASSET_PATHS[@]}" third_party/swagger-ui/... >/dev/null 2>&1 ; then
echo "Cannot package assets. Make sure \"hack/ui/build-www.sh\" has been run."
local -r asset_paths=$(kube::ui::generate_asset_paths)
if ! go-bindata -nocompress -o "${KUBE_BUILD_TARGET}" -prefix "${KUBE_OUTPUT}" -pkg ui "${asset_paths[@]}" third_party/swagger-ui/... >/dev/null 2>&1 ; then
echo "Cannot package assets."
exit 1
fi

local -r build_target=/tmp/datafile.go

cat hooks/boilerplate.go.txt > $build_target
sed "s/YEAR/$(date +'%Y')/" hooks/boilerplate.go.txt > $build_target
printf "// generated by hack/build-ui.sh; DO NOT EDIT\n" >> $build_target
cat "${KUBE_BUILD_TARGET}" >> $build_target

Expand Down
4 changes: 2 additions & 2 deletions hack/ui/www.sh
Expand Up @@ -61,11 +61,11 @@ EOF
exit 2
fi

# Skip this check on Travis.
# Check that npm is later than nodejs 0.10 release
if [[ "${TRAVIS:-}" != "true" ]]; then
local npm_version
npm_version="$(npm --version)"
if kube::www:check_version "${npm_version}" "2.7.3"; then
if kube::www:check_version "${npm_version}" "1.2.14"; then
kube::log::usage_from_stdin <<EOF
Detected npm version: ${npm_version}.
Expand Down
6,014 changes: 5,153 additions & 861 deletions pkg/ui/datafile.go

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions shippable.yml
Expand Up @@ -19,19 +19,15 @@ before_install:
- if [[ $SHIPPABLE_GO_VERSION == *release* ]]; then gvm install release; gvm use release; fi
- if [[ $SHIPPABLE_GO_VERSION =~ [0-9].[0-9] ]]; then gvm install go$SHIPPABLE_GO_VERSION; gvm use go$SHIPPABLE_GO_VERSION; fi
- export GOPATH=$SHIPPABLE_GOPATH
- shippable_retry curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
- shippable_retry sudo apt-get install -y nodejs

install:
- if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
- go get github.com/mattn/goveralls
- go get github.com/jteeuwen/go-bindata/...
- ./hack/travis/install-etcd.sh
- ./hack/verify-gofmt.sh
- ./hack/verify-boilerplate.sh
- ./hack/verify-description.sh
- ./hack/travis/install-std-race.sh
- ./hack/ui/build-www.sh
- ./hack/build-go.sh
- GOPATH=$PWD/Godeps/_workspace:$GOPATH go install ./...
- PATH=$HOME/gopath/bin:./third_party/etcd:$PATH ./hack/verify-gendocs.sh
Expand Down
42 changes: 20 additions & 22 deletions www/master/gulpfile.js
Expand Up @@ -53,7 +53,9 @@ var vendor = {
},
// vendor scripts to make to app work. Usually via lazy loading
app: {
source: require('./vendor.json'),
// instead of using require('./vendor.json') to pull the bower downloaded versions,
// use the hand edited versions of these files from the shared/vendor directory.
source: 'shared/vendor/**/*.*',
dest: '../app/vendor'
}
};
Expand Down Expand Up @@ -113,9 +115,9 @@ var source = {
},
views: {
source: ['shared/views/**/*.*'],
dest: '../app/views'
dest: '../app'
},
watch: ['index.html', 'views/**/*.*']
watch: ['shared/index.html', 'shared/views/**/*.*']
},

components: {
Expand All @@ -140,8 +142,6 @@ var source = {

config: {
watch: [
'shared/config/development.json',
'shared/config/production.json',
'shared/config/development.json',
'shared/config/production.json'
],
Expand Down Expand Up @@ -258,7 +258,7 @@ gulp.task('scripts:app:base', function() {
.pipe(concat(build.scripts.app.main))
.pipe(ngAnnotate())
.on("error", handleError)
.pipe(isProduction ? uglify({preserveComments: 'some'}) : gutil.noop())
// .pipe(isProduction ? uglify({preserveComments: 'some'}) : gutil.noop())
.on("error", handleError)
.pipe(useSourceMaps ? sourcemaps.write() : gutil.noop())
.pipe(gulp.dest(build.scripts.app.dir));
Expand Down Expand Up @@ -339,23 +339,21 @@ gulp.task('config:base', function() {
});

gulp.task('config:copy', function() {
var environment = argv.env || 'development'; // change this to whatever default environment you need.

var environment = argv.env || (isProduction ? 'production' : 'development');
return gulp.src(['shared/config/' + environment + '.json', 'components/**/config/' + environment + '.json'])
.pipe(jsoncombine('generated-config.js',
function(data) {
var env = Object.keys(data).reduce(function(result, key) {
// Map the key "environment" to "/" and the keys "component/config/environment" to
// "component".
var newKey = key.replace(environment, '/').replace(/\/config\/\/$/, '');
result[newKey] = data[key];
return result;
}, {});

return new Buffer(JSON.stringify({'ENV': env}));
}))
.pipe(ngConstant({name: 'kubernetesApp.config', deps: [], constants: {ngConstant: true}}))
.pipe(gulp.dest(source.config.dest));
.pipe(jsoncombine('generated-config.js',
function(data) {
var env = Object.keys(data).reduce(function(result, key) {
// Map the key "environment" to "/" and the keys "component/config/environment" to "component".
var newKey = key.replace(environment, '/').replace(/\/config\/\/$/, '');
result[newKey] = data[key];
return result;
}, {});

return new Buffer(JSON.stringify({'ENV': env}));
}))
.pipe(ngConstant({name: 'kubernetesApp.config', deps: [], constants: {ngConstant: true}}))
.pipe(gulp.dest(source.config.dest));
});

gulp.task('copy:components', function() {
Expand Down
4 changes: 2 additions & 2 deletions www/master/shared/config/generated-config.js
Expand Up @@ -2,8 +2,8 @@ angular.module("kubernetesApp.config", [])

.constant("ENV", {
"/": {
"k8sApiServer": "http://127.0.0.1:8080/api/v1beta2",
"k8sApiv1beta3Server": "http://127.0.0.1:8080/api/v1beta3",
"k8sApiServer": "/api/v1beta2",
"k8sApiv1beta3Server": "/api/v1beta3",
"k8sDataServer": "/cluster",
"k8sDataPollMinIntervalSec": 10,
"k8sDataPollMaxIntervalSec": 120,
Expand Down
9 changes: 9 additions & 0 deletions www/master/shared/config/production.example.json
@@ -0,0 +1,9 @@
{
"k8sApiServer": "ENV_K8S_API_SERVER",
"k8sDataServer": "ENV_K8S_DATA_SERVER",
"k8sDataPollMinIntervalSec": "ENV_K8S_DATA_POLL_MIN_INTERVAL_SEC",
"k8sDataPollMaxIntervalSec": "ENV_K8S_DATA_POLL_MAX_INTERVAL_SEC",
"k8sDataPollErrorThreshold": "ENV_K8S_DATA_POLL_ERROR_THRESHOLD",
"cAdvisorProxy": "ENV_C_ADVISOR_PROXY",
"cAdvisorPort": "ENV_C_ADVISOR_PORT"
}
@@ -1,6 +1,6 @@
{
"k8sApiServer": "http://127.0.0.1:8080/api/v1beta2",
"k8sApiv1beta3Server": "http://127.0.0.1:8080/api/v1beta3",
"k8sApiServer": "/api/v1beta2",
"k8sApiv1beta3Server": "/api/v1beta3",
"k8sDataServer": "/cluster",
"k8sDataPollMinIntervalSec": 10,
"k8sDataPollMaxIntervalSec": 120,
Expand Down

0 comments on commit ef97838

Please sign in to comment.