Skip to content

Commit

Permalink
Renamed ENV vars to use F8 prefix and binary from alm to wit (#1451)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hector Fernandez authored Jun 29, 2017
1 parent 0d4b890 commit 680ab16
Show file tree
Hide file tree
Showing 44 changed files with 226 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing to almigthy-core
# Contributing to fabric8-wit

You are welcome to contribute to this project. Here are few
suggestions to help you to contribute. You can contribute to this
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ _testmain.go
*.test
*.prof

# ALMighty specific artifacts
# Fabric8-wit specific artifacts
/debug
**/debug.test

# ALMighty binaries
# Fabric8-wit binaries
bin/

# Glide package manager
Expand Down
4 changes: 2 additions & 2 deletions .make/Makefile.lnx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/alm
BINARY_CLIENT_BIN=$(INSTALL_PREFIX)/alm-cli
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/wit
BINARY_CLIENT_BIN=$(INSTALL_PREFIX)/wit-cli
GLIDE_BIN=glide
GOAGEN_BIN=$(VENDOR_DIR)/github.com/goadesign/goa/goagen/goagen
GO_BINDATA_BIN=$(VENDOR_DIR)/github.com/jteeuwen/go-bindata/go-bindata/go-bindata
Expand Down
4 changes: 2 additions & 2 deletions .make/Makefile.win
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/alm.exe
BINARY_CLIENT_BIN=$(INSTALL_PREFIX)/alm-cli.exe
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/wit.exe
BINARY_CLIENT_BIN=$(INSTALL_PREFIX)/wit-cli.exe
GLIDE_BIN=glide.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
Expand Down
4 changes: 2 additions & 2 deletions .make/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,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 ALMIGHTY_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 ALMIGHTY_POSTGRES_HOST=$(ALMIGHTY_POSTGRES_HOST); make $(makecommand)'
$(eval F8_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 F8_POSTGRES_HOST=$(F8_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
16 changes: 8 additions & 8 deletions .make/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ GO_TEST_VERBOSITY_FLAG ?= -v

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

# Output directory for coverage information
COV_DIR = $(TMP_PATH)/coverage
Expand Down Expand Up @@ -144,7 +144,7 @@ test-unit: prebuild-check clean-coverage-unit $(COV_PATH_UNIT)
test-unit-no-coverage: prebuild-check $(SOURCES)
$(call log-info,"Running test: $@")
$(eval TEST_PACKAGES:=$(shell go list ./... | grep -v $(ALL_PKGS_EXCLUDE_PATTERN)))
ALMIGHTY_DEVELOPER_MODE_ENABLED=1 ALMIGHTY_RESOURCE_UNIT_TEST=1 go test $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)
F8_DEVELOPER_MODE_ENABLED=1 F8_RESOURCE_UNIT_TEST=1 go test $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)

.PHONY: test-integration
## Runs the integration tests and produces coverage files for each package.
Expand All @@ -157,7 +157,7 @@ test-integration: prebuild-check clean-coverage-integration migrate-database $(C
test-integration-no-coverage: prebuild-check migrate-database $(SOURCES)
$(call log-info,"Running test: $@")
$(eval TEST_PACKAGES:=$(shell go list ./... | grep -v $(ALL_PKGS_EXCLUDE_PATTERN)))
ALMIGHTY_DEVELOPER_MODE_ENABLED=1 ALMIGHTY_RESOURCE_DATABASE=1 ALMIGHTY_RESOURCE_UNIT_TEST=0 go test $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)
F8_DEVELOPER_MODE_ENABLED=1 F8_RESOURCE_DATABASE=1 F8_RESOURCE_UNIT_TEST=0 go test $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)

.PHONY: test-remote
## Runs the remote tests and produces coverage files for each package.
Expand All @@ -168,13 +168,13 @@ test-remote: prebuild-check clean-coverage-remote $(COV_PATH_REMOTE)
test-remote-no-coverage: prebuild-check $(SOURCES)
$(call log-info,"Running test: $@")
$(eval TEST_PACKAGES:=$(shell go list ./... | grep -v $(ALL_PKGS_EXCLUDE_PATTERN)))
ALMIGHTY_DEVELOPER_MODE_ENABLED=1 ALMIGHTY_RESOURCE_REMOTE=1 ALMIGHTY_RESOURCE_UNIT_TEST=0 go test $(GO_TEST_VERBOSITY_FLAG) $(TEST_PACKAGES)
F8_DEVELOPER_MODE_ENABLED=1 F8_RESOURCE_REMOTE=1 F8_RESOURCE_UNIT_TEST=0 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
ALMIGHTY_RESOURCE_DATABASE=1 go test $(GO_TEST_VERBOSITY_FLAG) github.com/fabric8-services/fabric8-wit/migration
F8_RESOURCE_DATABASE=1 go test $(GO_TEST_VERBOSITY_FLAG) github.com/fabric8-services/fabric8-wit/migration

# Downloads docker-compose to tmp/docker-compose if it does not already exist.
define download-docker-compose
Expand Down Expand Up @@ -411,7 +411,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) ALMIGHTY_DEVELOPER_MODE_ENABLED=1 ALMIGHTY_POSTGRES_HOST=$(ALMIGHTY_POSTGRES_HOST) \
@$(ENV_VAR) F8_DEVELOPER_MODE_ENABLED=1 F8_POSTGRES_HOST=$(F8_POSTGRES_HOST) \
go test $(PACKAGE_NAME) \
$(GO_TEST_VERBOSITY_FLAG) \
-coverprofile $(COV_OUT_FILE) \
Expand Down Expand Up @@ -471,7 +471,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),ALMIGHTY_RESOURCE_DATABASE=1 ALMIGHTY_RESOURCE_UNIT_TEST=0,$(ALL_PKGS_COMMA_SEPARATED)))
$(foreach package, $(TEST_PACKAGES), $(call test-package,$(TEST_NAME),$(package),$(COV_PATH_INTEGRATION),$(ERRORS_FILE),F8_RESOURCE_DATABASE=1 F8_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
22 changes: 11 additions & 11 deletions Dockerfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ FROM centos:7
LABEL maintainer "Devtools <devtools@redhat.com>"
LABEL author "Konrad Kleine <kkleine@redhat.com>"
ENV LANG=en_US.utf8
ENV ALMIGHTY_INSTALL_PREFIX=/usr/local/alm
ENV F8_INSTALL_PREFIX=/usr/local/wit

# Create a non-root user and a group with the same name: "almighty"
ENV ALMIGHTY_USER_NAME=almighty
RUN useradd --no-create-home -s /bin/bash ${ALMIGHTY_USER_NAME}
# Create a non-root user and a group with the same name: "wit"
ENV F8_USER_NAME=wit
RUN useradd --no-create-home -s /bin/bash ${F8_USER_NAME}

COPY bin/alm ${ALMIGHTY_INSTALL_PREFIX}/bin/alm
COPY config.yaml ${ALMIGHTY_INSTALL_PREFIX}/etc/config.yaml
COPY bin/wit ${F8_INSTALL_PREFIX}/bin/wit
COPY config.yaml ${F8_INSTALL_PREFIX}/etc/config.yaml

# Install little pcp pmcd server for metrics collection
# would prefer only pmcd, and not the /bin/pm*tools etc.
COPY pcp.repo /etc/yum.repos.d/pcp.repo
RUN yum install -y pcp && yum clean all && \
mkdir -p /etc/pcp /var/run/pcp /var/lib/pcp /var/log/pcp && \
chown -R ${ALMIGHTY_USER_NAME} /etc/pcp /var/run/pcp /var/lib/pcp /var/log/pcp && \
chown -R ${F8_USER_NAME} /etc/pcp /var/run/pcp /var/lib/pcp /var/log/pcp && \
chmod -R ug+rw /etc/pcp /var/run/pcp /var/lib/pcp /var/log/pcp
COPY ./alm+pmcd.sh /alm+pmcd.sh
COPY ./wit+pmcd.sh /wit+pmcd.sh
EXPOSE 44321


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

WORKDIR ${ALMIGHTY_INSTALL_PREFIX}
ENTRYPOINT [ "/alm+pmcd.sh" ]
WORKDIR ${F8_INSTALL_PREFIX}
ENTRYPOINT [ "/wit+pmcd.sh" ]

EXPOSE 8080
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export GIT_COMMITTER_NAME
export GIT_COMMITTER_EMAIL

# Used as target and binary output names... defined in includes
CLIENT_DIR=tool/alm-cli
CLIENT_DIR=tool/wit-cli

COMMIT=$(shell git rev-parse HEAD)
GITUNTRACKEDCHANGES := $(shell git status --porcelain --untracked-files=no)
Expand Down Expand Up @@ -242,12 +242,12 @@ generate: app/controllers.go assets/js/client.js bindata_assetfs.go migration/sq

.PHONY: regenerate
## Runs the "clean-generated" and the "generate" target
regenerate: clean-generated generate
regenerate: clean-generated generate

.PHONY: dev
dev: prebuild-check deps generate $(FRESH_BIN)
docker-compose up -d db
ALMIGHTY_DEVELOPER_MODE_ENABLED=true $(FRESH_BIN)
F8_DEVELOPER_MODE_ENABLED=true $(FRESH_BIN)

include ./.make/test.mk

Expand Down
22 changes: 11 additions & 11 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,15 @@ github.secret : 2fe6736e90a9283036a37059d75ac0c82f4f5288
Although this is a YAML file, we highly suggest to stick to this rather lenghty notation instead of nesting structs.

To override configuration values using environment variables, use the prefix
`ALMIGHTY_` and replace the dots in the variables names with underscores.
`F8_` and replace the dots in the variables names with underscores.

For example to override `postgres.password`, set the environment variable `ALMIGHTY_POSTGRES_PASSWORD` to the value of you liking.
For example to override `postgres.password`, set the environment variable `F8_POSTGRES_PASSWORD` to the value of you liking.

NOTE: Environment variables override the default values and the ones you've set in your config file.

==== Development

Only files `+./*.go+`, `+./design/*.go+`, `+./models/*.go+` and `+./tool/alm-cli/main.go+` should be edited.
Only files `+./*.go+`, `+./design/*.go+`, `+./models/*.go+` and `+./tool/wit-cli/main.go+` should be edited.

These files and directory are generated:

Expand Down Expand Up @@ -360,26 +360,26 @@ NOTE: The CLI needs the API Server which was started on executing `make dev` to

Generate a token for future use.
----
./bin/alm-cli generate login -H localhost:8080 --pp
./bin/wit-cli generate login -H localhost:8080 --pp
----

You should get Token in response, save this token in your favourite editor as you need to use this token for POST API calls

Create a work item type (using above token).
----
./bin/alm-cli create workitemtype --key "<GENERATED TOKEN>" --payload '{"fields":{"system.owner":{"Type":{"Kind":"user"},"Required":true},"system.state":{"Type":{"Kind":"string"},"Required":false}},"name":"Epic"}' -H localhost:8080 --pp
./bin/wit-cli create workitemtype --key "<GENERATED TOKEN>" --payload '{"fields":{"system.owner":{"Type":{"Kind":"user"},"Required":true},"system.state":{"Type":{"Kind":"string"},"Required":false}},"name":"Epic"}' -H localhost:8080 --pp
----
Note: Work Item Type `Name` is unique. If one tries to create another work item type with same name, error will be trown.

Retrieve the work item type.

----
$ ./bin/alm-cli show workitemtype --name "Epic" -H localhost:8080
$ ./bin/wit-cli show workitemtype --name "Epic" -H localhost:8080
----

List all available work item types.
----
$ ./bin/alm-cli list workitemtype -H localhost:8080 --pp
$ ./bin/wit-cli list workitemtype -H localhost:8080 --pp
----

Create a work item.
Expand All @@ -388,13 +388,13 @@ Based on WorkItemType created above, we can create WorkItem.
We need to use name of work item type in the `type` field below.

----
$ ./bin/alm-cli create workitem --key "<GENERATED TOKEN>" --payload '{"type": "Epic", "fields": { "system.owner": "tmaeder", "system.state": "open" }}' -H localhost:8080
$ ./bin/wit-cli create workitem --key "<GENERATED TOKEN>" --payload '{"type": "Epic", "fields": { "system.owner": "tmaeder", "system.state": "open" }}' -H localhost:8080
----

Retrieve the work item.

----
$ ./bin/alm-cli show workitem --id 1 -H localhost:8080 --pp
$ ./bin/wit-cli show workitem --id 1 -H localhost:8080 --pp
----


Expand All @@ -410,11 +410,11 @@ System defined Work Item Types are
Use any one of above to create Work Item based on that type.
Following example creates a Work Item of type `userstory`
----
$ ./bin/alm-cli create workitem --key "<GENERATED TOKEN>" --payload '{ "data": { "attributes": { "system.owner": "tmaeder", "system.state": "open", "system.title": "Example of an Epic", "version": "1" }, "relationships": { "baseType": { "data": { "id": "Epic", "type": "workitemtypes" } } }, "type": "workitems" } }' -H localhost:8080
$ ./bin/wit-cli create workitem --key "<GENERATED TOKEN>" --payload '{ "data": { "attributes": { "system.owner": "tmaeder", "system.state": "open", "system.title": "Example of an Epic", "version": "1" }, "relationships": { "baseType": { "data": { "id": "Epic", "type": "workitemtypes" } } }, "type": "workitems" } }' -H localhost:8080
----

In response you should get ID of created item, using that you can retrieve the work item.

----
$ ./bin/alm-cli show workitem --id <ID> -H localhost:8080 --pp
$ ./bin/wit-cli show workitem --id <ID> -H localhost:8080 --pp
----
2 changes: 1 addition & 1 deletion assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</head>
<body>
<div class="container-fluid">
<h1>almighty tokens <small id="response">Loading..</small></h1>
<h1>Fabric8-wit tokens <small id="response">Loading..</small></h1>

<div id="tokens">
<div class="token" style="display:none">
Expand Down
2 changes: 1 addition & 1 deletion auth/authz_blackbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ func getClientIDAndEndpoint(t *testing.T) (string, string) {

func getProtectedAPITokenOK(t *testing.T) string {
r := &goa.RequestData{
Request: &http.Request{Host: "demo.api.almighty.io"},
Request: &http.Request{Host: "demo.api.openshift.io"},
}

endpoint, err := configuration.GetKeycloakEndpointToken(r)
Expand Down
8 changes: 4 additions & 4 deletions codebase/codebase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ func (test *TestCodebaseRepository) TestListCodebases() {
// given
spaceID := space.SystemSpace
repo := codebase.NewCodebaseRepository(test.DB)
codebase1 := newCodebase(spaceID, "golang-default", "my-used-last-workspace", "git", "git@github.com:almighty/almighty-core.git")
codebase2 := newCodebase(spaceID, "python-default", "my-used-last-workspace", "git", "git@github.com:aslakknutsen/almighty-core.git")
codebase1 := newCodebase(spaceID, "golang-default", "my-used-last-workspace", "git", "git@github.com:fabric8-services/fabric8-wit.git")
codebase2 := newCodebase(spaceID, "python-default", "my-used-last-workspace", "git", "git@github.com:aslakknutsen/fabric8-wit.git")

test.createCodebase(codebase1)
test.createCodebase(codebase2)
Expand All @@ -138,7 +138,7 @@ func (test *TestCodebaseRepository) TestExistsCodebase() {
// given
spaceID := space.SystemSpace
repo := codebase.NewCodebaseRepository(test.DB)
codebase := newCodebase(spaceID, "lisp-default", "my-used-lisp-workspace", "git", "git@github.com:hectorj2f/almighty-core.git")
codebase := newCodebase(spaceID, "lisp-default", "my-used-lisp-workspace", "git", "git@github.com:hectorj2f/fabric8-wit.git")
test.createCodebase(codebase)
// when
exists, err := repo.Exists(context.Background(), codebase.ID.String())
Expand All @@ -163,7 +163,7 @@ func (test *TestCodebaseRepository) TestLoadCodebase() {
// given
spaceID := space.SystemSpace
repo := codebase.NewCodebaseRepository(test.DB)
codebase := newCodebase(spaceID, "golang-default", "my-used-last-workspace", "git", "git@github.com:aslakknutsen/almighty-core.git")
codebase := newCodebase(spaceID, "golang-default", "my-used-last-workspace", "git", "git@github.com:aslakknutsen/fabric8-wit.git")
test.createCodebase(codebase)
// when
loadedCodebase, err := repo.Load(context.Background(), codebase.ID)
Expand Down
8 changes: 4 additions & 4 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func NewConfigurationData(configFilePath string) (*ConfigurationData, error) {
c := ConfigurationData{
v: viper.New(),
}
c.v.SetEnvPrefix("ALMIGHTY")
c.v.SetEnvPrefix("F8")
c.v.AutomaticEnv()
c.v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
c.v.SetTypeByDefaultValue(true)
Expand All @@ -121,7 +121,7 @@ func NewConfigurationData(configFilePath string) (*ConfigurationData, error) {

func getConfigFilePath() string {
// This was either passed as a env var Or, set inside main.go from --config
envConfigPath, ok := os.LookupEnv("ALMIGHTY_CONFIG_FILE_PATH")
envConfigPath, ok := os.LookupEnv("F8_CONFIG_FILE_PATH")
if !ok {
return ""
}
Expand Down Expand Up @@ -625,7 +625,7 @@ func (c *ConfigurationData) IsLogJSON() bool {
}

// GetValidRedirectURLs returns the RegEx of valid redirect URLs for auth requests
// If the ALMIGHTY_REDIRECT_VALID env var is not set then in Dev Mode all redirects allowed - *
// If the F8_REDIRECT_VALID env var is not set then in Dev Mode all redirects allowed - *
// In prod mode the default regex will be returned
func (c *ConfigurationData) GetValidRedirectURLs(req *goa.RequestData) (string, error) {
if c.v.IsSet(varValidRedirectURLs) {
Expand Down Expand Up @@ -727,7 +727,7 @@ vwIDAQAB
defaultCheStarterURL = "che-server"

// DefaultValidRedirectURLs is a regex to be used to whitelist redirect URL for auth
// If the ALMIGHTY_REDIRECT_VALID env var is not set then in Dev Mode all redirects allowed - *
// If the F8_REDIRECT_VALID env var is not set then in Dev Mode all redirects allowed - *
// In prod mode the following regex will be used by default:
DefaultValidRedirectURLs = "^(https|http)://([^/]+[.])?(?i:openshift[.]io)(/.*)?$" // *.openshift.io/*
devModeValidRedirectURLs = ".*"
Expand Down
Loading

0 comments on commit 680ab16

Please sign in to comment.