Skip to content

Commit

Permalink
Extracting cluster service from Auth. Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeykazakov committed Aug 13, 2018
1 parent 9d855d8 commit fe01248
Show file tree
Hide file tree
Showing 331 changed files with 384 additions and 39,550 deletions.
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing to fabric8-auth
# Contributing to fabric8-cluster

You are welcome to contribute to this project. Here are few
suggestions to help you to contribute. You can contribute to this
Expand All @@ -12,8 +12,8 @@ or

## Reporting Issues

All the issues related to fabric8-auth should be reported in the
[GitHub issue tracker](https://github.com/fabric8-services/fabric8-auth/issues/new).
All the issues related to fabric8-cluster should be reported in the
[GitHub issue tracker](https://github.com/fabric8-services/fabric8-cluster/issues/new).

## Pull Requests

Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Please, make sure to provide all the information asked for below and then delete

## Steps to reproduce the problem

* *Please describe how a developer can reproduce the issue that you faced. Make sure you include information how you've configured, built, or started the fabric8-auth server.*
* *Please describe how a developer can reproduce the issue that you faced. Make sure you include information how you've configured, built, or started the fabric8-cluster server.*

## Specifications

* Which version of fabric8-auth are you running?
* Which version of fabric8-cluster are you running?
* Which operating system do you use?
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@ _testmain.go
*.test
*.prof

# Fabric8-auth specific artifacts
# fabric8-cluster specific artifacts
/debug
**/debug.test

# Fabric8-auth binaries
# fabric8-cluster binaries
bin/

# Glide package manager
.glide
vendor/

# Generated assets
Expand Down
127 changes: 0 additions & 127 deletions .make/Makefile.dev

This file was deleted.

7 changes: 2 additions & 5 deletions .make/Makefile.lnx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/auth
BINARY_CLIENT_BIN=$(INSTALL_PREFIX)/auth-cli
GLIDE_BIN=glide
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/cluster
BINARY_CLIENT_BIN=$(INSTALL_PREFIX)/cluster-cli
GOAGEN_BIN=$(VENDOR_DIR)/github.com/goadesign/goa/goagen/goagen
GO_BINDATA_BIN=$(VENDOR_DIR)/github.com/jteeuwen/go-bindata/go-bindata/go-bindata
GO_BINDATA_DIR=$(VENDOR_DIR)/github.com/jteeuwen/go-bindata/go-bindata/
Expand All @@ -18,8 +17,6 @@ GOCYCLO_BIN=$(GOCYCLO_DIR)/gocyclo
GO_JUNIT_BIN=$(VENDOR_DIR)/github.com/jstemmer/go-junit-report/go-junit-report

GIT_BIN_NAME := git
GLIDE_BIN_NAME := glide
GO_BIN_NAME := go
ASCIIDOCTOR_BIN_NAME := asciidoctor

CHECK_GOPATH_BIN := $(INSTALL_PREFIX)/check_gopath
7 changes: 2 additions & 5 deletions .make/Makefile.win
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/auth.exe
BINARY_CLIENT_BIN=$(INSTALL_PREFIX)/auth-cli.exe
GLIDE_BIN=glide.exe
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/cluster.exe
BINARY_CLIENT_BIN=$(INSTALL_PREFIX)/cluster-cli.exe
GOAGEN_BIN=$(VENDOR_DIR)/github.com/goadesign/goa/goagen/goagen.exe
GO_BINDATA_BIN=$(VENDOR_DIR)/github.com/jteeuwen/go-bindata/go-bindata/go-bindata.exe
GO_BINDATA_DIR=$(VENDOR_DIR)/github.com/jteeuwen/go-bindata/go-bindata/
Expand All @@ -18,8 +17,6 @@ GOCYCLO_BIN=$(GOCYCLO_DIR)/gocyclo.exe
GO_JUNIT_BIN=$(VENDOR_DIR)/github.com/jstemmer/go-junit-report/go-junit-report.exe

GIT_BIN_NAME := git.exe
GLIDE_BIN_NAME := glide.exe
GO_BIN_NAME := go.exe
ASCIIDOCTOR_BIN_NAME := asciidoctor

CHECK_GOPATH_BIN := $(INSTALL_PREFIX)/check_gopath.exe
2 changes: 1 addition & 1 deletion .make/check_gopath.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
// under GOPATH[i]/src/packageName.
func main() {
var packageName string
flag.StringVar(&packageName, "packageName", "github.com/fabric8-services/fabric8-auth", "Package Name (e.g.)")
flag.StringVar(&packageName, "packageName", "github.com/fabric8-services/fabric8-cluster", "Package Name (e.g.)")
flag.Parse()

wd, err := os.Getwd()
Expand Down
10 changes: 5 additions & 5 deletions .make/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ docker-image-deploy:
.PHONY: docker-publish-deploy
## Tags the runnable image and pushes it to the docker hub.
docker-publish-deploy:
docker tag $(DOCKER_IMAGE_DEPLOY) fabric8-services/fabric8-auth:latest
docker push fabric8-services/fabric8-auth:latest
docker tag $(DOCKER_IMAGE_DEPLOY) fabric8-services/fabric8-cluster:latest
docker push fabric8-services/fabric8-cluster:latest

.PHONY: docker-build-dir
## Creates the docker build directory.
Expand Down Expand Up @@ -84,7 +84,7 @@ else
-t \
$(DOCKER_RUN_INTERACTIVE_SWITCH) \
--name="$(DOCKER_CONTAINER_NAME)" \
-e AUTH_POSTGRES_PORT=5432 \
-e CLUSTER_POSTGRES_PORT=5432 \
-v $(CUR_DIR):$(PACKAGE_PATH):Z \
-u $(shell id -u $(USER)):$(shell id -g $(USER)) \
-e GOPATH=$(GOPATH_IN_CONTAINER) \
Expand Down Expand Up @@ -114,8 +114,8 @@ endif
ifeq ($(strip $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' make_postgres_integration_test_1 2>/dev/null)),)
$(error Failed to find PostgreSQL container. Try running "make integration-test-env-prepare")
endif
$(eval AUTH_POSTGRES_HOST := $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' make_postgres_integration_test_1 2>/dev/null))
docker exec -t $(DOCKER_RUN_INTERACTIVE_SWITCH) "$(DOCKER_CONTAINER_NAME)" bash -ec 'export AUTH_POSTGRES_HOST=$(AUTH_POSTGRES_HOST); make $(makecommand)'
$(eval CLUSTER_POSTGRES_HOST := $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' make_postgres_integration_test_1 2>/dev/null))
docker exec -t $(DOCKER_RUN_INTERACTIVE_SWITCH) "$(DOCKER_CONTAINER_NAME)" bash -ec 'export CLUSTER_POSTGRES_HOST=$(CLUSTER_POSTGRES_HOST); make $(makecommand)'

# This is a wildcard target to let you call any make target from the normal makefile
# but it will run inside the docker container. This target will only get executed if
Expand Down
24 changes: 12 additions & 12 deletions .make/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
# ----------------------------
# Each package generates coverage outputs under tmp/coverage/$(PACKAGE) where
# $(PACKAGE) resolves to the Go package. Here's an example of a coverage file
# for the package "github.com/fabric8-services/fabric8-auth/models" with coverage mode
# for the package "github.com/fabric8-services/fabric8-cluster/models" with coverage mode
# "set" generated by the unit tests:
#
# tmp/coverage/github.com/fabric8-services/fabric8-auth/models/coverage.unit.mode-set
# tmp/coverage/github.com/fabric8-services/fabric8-cluster/models/coverage.unit.mode-set
#
# For unit-tests all results are combined into this file:
#
Expand Down Expand Up @@ -94,9 +94,9 @@ GO_TEST_VERBOSITY_FLAG ?=

# By default use the "localhost" or specify manually during make invocation:
#
# AUTH_POSTGRES_HOST=somehost make test-integration
# CLUSTER_POSTGRES_HOST=somehost make test-integration
#
AUTH_POSTGRES_HOST ?= localhost
CLUSTER_POSTGRES_HOST ?= localhost

# By default reduce the amount of log output from tests
F8_LOG_LEVEL ?= error
Expand Down Expand Up @@ -147,7 +147,7 @@ test-unit-with-coverage: prebuild-check clean-coverage-unit $(COV_PATH_UNIT)
test-unit: prebuild-check $(SOURCES)
$(call log-info,"Running test: $@")
$(eval TEST_PACKAGES:=$(shell go list ./... | grep -v $(ALL_PKGS_EXCLUDE_PATTERN)))
AUTH_DEVELOPER_MODE_ENABLED=1 AUTH_RESOURCE_UNIT_TEST=1 F8_LOG_LEVEL=$(F8_LOG_LEVEL) go test $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)
CLUSTER_DEVELOPER_MODE_ENABLED=1 CLUSTER_RESOURCE_UNIT_TEST=1 F8_LOG_LEVEL=$(F8_LOG_LEVEL) go test $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)

.PHONY: test-unit-junit
test-unit-junit: prebuild-check ${GO_JUNIT_BIN} ${TMP_PATH}
Expand All @@ -164,12 +164,12 @@ test-integration-with-coverage: prebuild-check clean-coverage-integration migrat
test-integration: prebuild-check migrate-database $(SOURCES)
$(call log-info,"Running test: $@")
$(eval TEST_PACKAGES:=$(shell go list ./... | grep -v $(ALL_PKGS_EXCLUDE_PATTERN)))
AUTH_DEVELOPER_MODE_ENABLED=1 AUTH_RESOURCE_DATABASE=1 AUTH_RESOURCE_UNIT_TEST=0 F8_LOG_LEVEL=$(F8_LOG_LEVEL) go test $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)
CLUSTER_DEVELOPER_MODE_ENABLED=1 CLUSTER_RESOURCE_DATABASE=1 CLUSTER_RESOURCE_UNIT_TEST=0 F8_LOG_LEVEL=$(F8_LOG_LEVEL) go test $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)

test-integration-benchmark: prebuild-check migrate-database $(SOURCES)
$(call log-info,"Running benchmarks: $@")
$(eval TEST_PACKAGES:=$(shell go list ./... | grep -v $(ALL_PKGS_EXCLUDE_PATTERN)))
AUTH_DEVELOPER_MODE_ENABLED=1 AUTH_LOG_LEVEL=error AUTH_RESOURCE_DATABASE=1 AUTH_RESOURCE_UNIT_TEST=0 F8_LOG_LEVEL=$(F8_LOG_LEVEL) go test -run=^$$ -bench=. -cpu 1,2,4 -test.benchmem $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)
CLUSTER_DEVELOPER_MODE_ENABLED=1 CLUSTER_LOG_LEVEL=error CLUSTER_RESOURCE_DATABASE=1 CLUSTER_RESOURCE_UNIT_TEST=0 F8_LOG_LEVEL=$(F8_LOG_LEVEL) go test -run=^$$ -bench=. -cpu 1,2,4 -test.benchmem $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)

.PHONY: test-remote-with-coverage
## Runs the remote tests and produces coverage files for each package.
Expand All @@ -180,13 +180,13 @@ test-remote-with-coverage: prebuild-check clean-coverage-remote $(COV_PATH_REMOT
test-remote: prebuild-check $(SOURCES)
$(call log-info,"Running test: $@")
$(eval TEST_PACKAGES:=$(shell go list ./... | grep -v $(ALL_PKGS_EXCLUDE_PATTERN)))
AUTH_DEVELOPER_MODE_ENABLED=1 AUTH_RESOURCE_REMOTE=1 AUTH_RESOURCE_UNIT_TEST=0 F8_LOG_LEVEL=$(F8_LOG_LEVEL) go test $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)
CLUSTER_DEVELOPER_MODE_ENABLED=1 CLUSTER_RESOURCE_REMOTE=1 CLUSTER_RESOURCE_UNIT_TEST=0 F8_LOG_LEVEL=$(F8_LOG_LEVEL) go test $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)

.PHONY: test-migration
## Runs the migration tests and should be executed before running the integration tests
## in order to have a clean database
test-migration: prebuild-check
AUTH_RESOURCE_DATABASE=1 F8_LOG_LEVEL=$(F8_LOG_LEVEL) go test $(GO_TEST_VERBOSITY_FLAG) github.com/fabric8-services/fabric8-auth/migration
CLUSTER_RESOURCE_DATABASE=1 F8_LOG_LEVEL=$(F8_LOG_LEVEL) go test $(GO_TEST_VERBOSITY_FLAG) github.com/fabric8-services/fabric8-cluster/migration

# Downloads docker-compose to tmp/docker-compose if it does not already exist.
define download-docker-compose
Expand Down Expand Up @@ -408,7 +408,7 @@ gocov-remote-annotate: prebuild-check $(GOCOV_BIN) $(COV_PATH_REMOTE)
#
# Parameters:
# 1. Test name (e.g. "unit", "integration" or "remote")
# 2. package name "github.com/fabric8-services/fabric8-auth/model"
# 2. package name "github.com/fabric8-services/fabric8-cluster/model"
# 3. File in which to combine the output
# 4. Path to file in which to store names of packages that failed testing
# 5. Environment variable (in the form VAR=VALUE) to be specified for running
Expand All @@ -422,7 +422,7 @@ $(eval ENV_VAR := $(5))
$(eval ALL_PKGS_COMMA_SEPARATED := $(6))
@mkdir -p $(COV_DIR)/$(PACKAGE_NAME);
$(eval COV_OUT_FILE := $(COV_DIR)/$(PACKAGE_NAME)/coverage.$(TEST_NAME).mode-$(COVERAGE_MODE))
@$(ENV_VAR) AUTH_DEVELOPER_MODE_ENABLED=1 AUTH_POSTGRES_HOST=$(AUTH_POSTGRES_HOST) F8_LOG_LEVEL=$(F8_LOG_LEVEL) \
@$(ENV_VAR) CLUSTER_DEVELOPER_MODE_ENABLED=1 CLUSTER_POSTGRES_HOST=$(CLUSTER_POSTGRES_HOST) F8_LOG_LEVEL=$(F8_LOG_LEVEL) \
go test $(PACKAGE_NAME) \
$(GO_TEST_VERBOSITY_FLAG) \
-coverprofile $(COV_OUT_FILE) \
Expand Down Expand Up @@ -482,7 +482,7 @@ $(COV_PATH_INTEGRATION): $(SOURCES) $(GOCOVMERGE_BIN)
@-rm -f $(ERRORS_FILE)
$(eval TEST_PACKAGES:=$(shell go list ./... | grep -v $(ALL_PKGS_EXCLUDE_PATTERN)))
$(eval ALL_PKGS_COMMA_SEPARATED:=$(shell echo $(TEST_PACKAGES) | tr ' ' ,))
$(foreach package, $(TEST_PACKAGES), $(call test-package,$(TEST_NAME),$(package),$(COV_PATH_INTEGRATION),$(ERRORS_FILE),AUTH_RESOURCE_DATABASE=1 AUTH_RESOURCE_UNIT_TEST=0,$(ALL_PKGS_COMMA_SEPARATED)))
$(foreach package, $(TEST_PACKAGES), $(call test-package,$(TEST_NAME),$(package),$(COV_PATH_INTEGRATION),$(ERRORS_FILE),CLUSTER_RESOURCE_DATABASE=1 CLUSTER_RESOURCE_UNIT_TEST=0,$(ALL_PKGS_COMMA_SEPARATED)))
$(call check-test-results,$(ERRORS_FILE))

# NOTE: We don't have prebuild-check as a dependency here because it would cause
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM centos:7
LABEL maintainer "Devtools <devtools@redhat.com>"
LABEL author "Konrad Kleine <kkleine@redhat.com>"
LABEL author "Devtools <devtools@redhat.com>"
ENV LANG=en_US.utf8
ARG USE_GO_VERSION_FROM_WEBSITE=0

Expand Down
22 changes: 11 additions & 11 deletions Dockerfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ FROM centos:7
LABEL maintainer "Devtools <devtools@redhat.com>"
LABEL author "Konrad Kleine <kkleine@redhat.com>"
ENV LANG=en_US.utf8
ENV AUTH_INSTALL_PREFIX=/usr/local/auth
ENV AUTH_INSTALL_PREFIX=/usr/local/cluster

# Create a non-root user and a group with the same name: "auth"
ENV AUTH_USER_NAME=auth
RUN useradd --no-create-home -s /bin/bash ${AUTH_USER_NAME}
# Create a non-root user and a group with the same name: "cluster"
ENV CLUSTER_USER_NAME=cluster
RUN useradd --no-create-home -s /bin/bash ${CLUSTER_USER_NAME}

COPY bin/auth ${AUTH_INSTALL_PREFIX}/bin/auth
COPY config.yaml ${AUTH_INSTALL_PREFIX}/etc/config.yaml
COPY bin/cluster ${CLUSTER_INSTALL_PREFIX}/bin/cluster
COPY config.yaml ${CLUSTER_INSTALL_PREFIX}/etc/config.yaml

# Install little pcp pmcd server for metrics collection
# would prefer only pmcd, and not the /bin/pm*tools etc.
Expand All @@ -18,14 +18,14 @@ RUN yum install -y pcp pcp-pmda-prometheus && yum clean all && \
mkdir -p /etc/pcp /var/run/pcp /var/lib/pcp /var/log/pcp && \
chgrp -R root /etc/pcp /var/run/pcp /var/lib/pcp /var/log/pcp && \
chmod -R g+rwX /etc/pcp /var/run/pcp /var/lib/pcp /var/log/pcp
COPY ./auth+pmcd.sh /auth+pmcd.sh
COPY ./cluster+pmcd.sh /cluster+pmcd.sh
EXPOSE 44321


# From here onwards, any RUN, CMD, or ENTRYPOINT will be run under the following user
USER ${AUTH_USER_NAME}
USER ${CLUSTER_USER_NAME}

WORKDIR ${AUTH_INSTALL_PREFIX}
ENTRYPOINT [ "/auth+pmcd.sh" ]
WORKDIR ${CLUSTER_INSTALL_PREFIX}
ENTRYPOINT [ "/cluster+pmcd.sh" ]

EXPOSE 8089
EXPOSE 8087
Loading

0 comments on commit fe01248

Please sign in to comment.