Skip to content

Commit

Permalink
Merge branch 'master' into ab/domainupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
tolusha committed Apr 12, 2020
2 parents b0583b4 + f7851be commit 2e9c283
Show file tree
Hide file tree
Showing 20 changed files with 1,265 additions and 974 deletions.
36 changes: 36 additions & 0 deletions .ci/che-cert_generation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

#
# Copyright (c) 2012-2020 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation

#Declare CN
export CA_CN=eclipse-che-signer

#Create Root Key
openssl genrsa -out rootCA.key 4096

#Create and self sign the Root Certificate
openssl req -x509 -new -nodes -key rootCA.key -subj /CN=${CA_CN} -sha256 -days 1024 -out rootCA.crt

#Create the certificate key
openssl genrsa -out domain.key 2048

#Create the signing (csr)
openssl req -new -sha256 -key domain.key -subj "/C=US/ST=CK/O=RedHat/CN=${DOMAIN}" -out domain.csr

#Verify Csr
openssl req -in domain.csr -noout -text

#Generate the certificate using the domain csr and key along with the CA Root key
openssl x509 -req -in domain.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out domain.crt -days 500 -sha256

#Verify the certificate's content
openssl x509 -in domain.crt -text -noout
3 changes: 0 additions & 3 deletions .ci/cico_chectl_prcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ run() {
#Before to start to run the e2e tests we need to install all deps with yarn
yarn --cwd ${CHECTL_REPO}

# Temporal
sed -i "s/tlsSupport: true/tlsSupport: false/" ${CHECTL_REPO}/templates/che-operator/crds/org_v1_che_cr.yaml

for platform in 'minishift' 'minikube'
do
if [[ ${platform} == 'minishift' ]]; then
Expand Down
24 changes: 23 additions & 1 deletion .ci/cico_common.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#!/bin/bash
#
# Copyright (c) 2012-2020 Red Hat, Inc.
Expand Down Expand Up @@ -103,6 +104,27 @@ github_token_set() {
fi
}

self_signed_minishift() {
export DOMAIN=*.$(minishift ip).nip.io

source ${CHECTL_REPO}/.ci/che-cert_generation.sh

#Configure Router with generated certificate:

oc login -u system:admin --insecure-skip-tls-verify=true
oc project default
oc delete secret router-certs

cat domain.crt domain.key > minishift.crt
oc create secret tls router-certs --key=domain.key --cert=minishift.crt
oc rollout latest router

oc create namespace che

cp rootCA.crt ca.crt
oc create secret generic self-signed-certificate --from-file=ca.crt -n=che
}

minishift_installation() {
printInfo "Downloading Minishift binaries"
curl -L https://github.com/minishift/minishift/releases/download/v$MSFT_RELEASE/minishift-$MSFT_RELEASE-linux-amd64.tgz \
Expand All @@ -114,7 +136,7 @@ minishift_installation() {
github_token_set
minishift start --memory=8192 && eval $(minishift oc-env)

oc login -u system:admin
self_signed_minishift
printInfo "Successfully installed and initialized minishift"
}

Expand Down
13 changes: 13 additions & 0 deletions .ci/start-minikube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ export CHANGE_MINIKUBE_NONE_USER=true
export KUBECONFIG=$HOME/.kube/config
export TEST_OUTPUT=1

self_signed_minikube() {
export DOMAIN=*.$(minikube ip).nip.io

source ${CHECTL_REPO}/.ci/che-cert_generation.sh

kubectl create namespace che
kubectl create secret tls che-tls --key=domain.key --cert=domain.crt -n che
cp rootCA.crt ca.crt
kubectl create secret generic self-signed-certificate --from-file=ca.crt -n che
}

sudo mount --make-rshared /
sudo mount --make-rshared /proc
sudo mount --make-rshared /sys
Expand Down Expand Up @@ -75,3 +86,5 @@ rules:
verbs: ["*"]
EOF

self_signed_minikube
49 changes: 27 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ USAGE
* [`chectl workspace:inject`](#chectl-workspaceinject)
* [`chectl workspace:list`](#chectl-workspacelist)
* [`chectl workspace:logs`](#chectl-workspacelogs)
* [`chectl workspace:start`](#chectl-workspacestart)
* [`chectl workspace:stop`](#chectl-workspacestop)
* [`chectl workspace:start WORKSPACE`](#chectl-workspacestart-workspace)
* [`chectl workspace:stop WORKSPACE`](#chectl-workspacestop-workspace)

## `chectl autocomplete [SHELL]`

Expand Down Expand Up @@ -446,7 +446,11 @@ USAGE
$ chectl workspace:create
OPTIONS
-f, --devfile=devfile path or URL to a valid devfile
-d, --debug Debug workspace start. It is useful when workspace start fails and it is needed to
print more logs on startup. This flag is used in conjunction with --start flag.
-f, --devfile=devfile Path or URL to a valid devfile
-h, --help show CLI help
-n, --chenamespace=chenamespace [default: che] Kubernetes namespace where Eclipse Che server is supposed to be
Expand All @@ -456,7 +460,7 @@ OPTIONS
--access-token=access-token Eclipse Che OIDC Access Token
--name=name workspace name: overrides the workspace name to use instead of the one defined in the
--name=name Workspace name: overrides the workspace name to use instead of the one defined in the
devfile.
```

Expand Down Expand Up @@ -557,48 +561,49 @@ OPTIONS

_See code: [src/commands/workspace/logs.ts](https://github.com/che-incubator/chectl/blob/v0.0.2/src/commands/workspace/logs.ts)_

## `chectl workspace:start`
## `chectl workspace:start WORKSPACE`

Creates and starts workspace from a devfile
Starts a workspace

```
USAGE
$ chectl workspace:start
$ chectl workspace:start WORKSPACE
ARGUMENTS
WORKSPACE The workspace id to start
OPTIONS
-f, --devfile=devfile path or URL to a valid devfile
-d, --debug Debug workspace start. It is useful when workspace start fails and it is needed to
print more logs on startup.
-h, --help show CLI help
-n, --chenamespace=chenamespace [default: che] Kubernetes namespace where Eclipse Che server is supposed to be
deployed
-s, --start Starts the workspace after creation
--access-token=access-token Eclipse Che OIDC Access Token
--name=name workspace name: overrides the workspace name to use instead of the one defined in the
devfile.
```

_See code: [src/commands/workspace/start.ts](https://github.com/che-incubator/chectl/blob/v0.0.2/src/commands/workspace/start.ts)_

## `chectl workspace:stop`
## `chectl workspace:stop WORKSPACE`

stop a running workspace
Stop a running workspace

```
USAGE
$ chectl workspace:stop
$ chectl workspace:stop WORKSPACE
OPTIONS
-h, --help show CLI help
ARGUMENTS
WORKSPACE The workspace id to stop
-n, --chenamespace=chenamespace [default: che] Kubernetes namespace where Eclipse Che server is supposed to
be deployed
OPTIONS
-h, --help show CLI help
--access-token=access-token Eclipse Che OIDC Access Token
-n, --chenamespace=chenamespace [default: che] Kubernetes namespace where Eclipse Che server is supposed to be
deployed
--listr-renderer=default|silent|verbose [default: default] Listr renderer
--access-token=access-token Eclipse Che OIDC Access Token
```

_See code: [src/commands/workspace/stop.ts](https://github.com/che-incubator/chectl/blob/v0.0.2/src/commands/workspace/stop.ts)_
Expand Down
38 changes: 3 additions & 35 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
# `chectl` release process

#### Make release changes and push them to your personal fork
1. Launch release script

```bash
CHE_VERSION="7.7.0" && \
BRANCH_NAME="7.7.x" && \
FORK="l0rd/chectl" && \
./make-release.sh ${CHE_VERSION} ${BRANCH_NAME} ${FORK}
./make-release.sh ${RELEASE} ${BRANCH_NAME}
```

#### Create a PR using `hub`

[hub](https://hub.github.com/) is an extension to command-line git that helps you do everyday GitHub tasks without ever leaving the terminal.

```bash
GH_USER="l0rd" && \
RELEASE_ISSUE_LINK="https://github.com/eclipse/che/issues/15504" && \
hub pull-request --browse \
--base che-incubator:${BRANCH_NAME} \
--head ${GH_USER}:${BRANCH_NAME} \
-m "chore(release): release version ${CHE_VERSION}" \
-m "### What does this PR do?" \
-m "Release version ${CHE_VERSION}" \
-m "### What issues does this PR fix or reference?" \
-m "${RELEASE_ISSUE_LINK}"
```

Wait for a review approval and then merge it.

#### Release

1. Delete the old chectl **release** branch from GitHub if it exist ([manually](https://github.com/che-incubator/chectl/branches))
2. Push to **release** branch:

```bash
GIT_REMOTE_UPSTREAM=git@github.com:che-incubator/chectl.git && \
git push ${GIT_REMOTE_UPSTREAM} ${BRANCH_NAME}:release
```

3. Track [TravisCI Job](https://travis-ci.org/che-incubator/chectl/branches)
2. Wait until [TravisCI Job](https://travis-ci.org/che-incubator/chectl/branches) from `release` branch is completed
107 changes: 62 additions & 45 deletions make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ set -e
set -u

init() {
RED='\033[0;31m'
NC='\033[0m'
RELEASE="$1"
BRANCH=$(echo $RELEASE | sed 's/.$/x/')
GIT_REMOTE_UPSTREAM="git@github.com:che-incubator/chectl.git"
}

check() {
if [ $# -ne 3 ]; then
printf "%bError: %bWrong number of parameters.\nUsage: ./make-release.sh <version> <branch> <fork>\n" "${RED}" "${NC}"
if [[ $# -lt 1 ]]; then
echo "[ERROR] Wrong number of parameters.\nUsage: ./make-release.sh <version>"
exit 1
fi
}
Expand All @@ -34,57 +35,73 @@ apply_sed() {
fi
}

run() {

VERSION=$1
BRANCH_NAME=$2
FORK=$3
GIT_REMOTE_UPSTREAM="git@github.com:che-incubator/chectl.git"
GIT_REMOTE_FORK="git@github.com:${FORK}.git"

git checkout master

# reset local changes
while true; do
read -r -p "It will reset any local changes to the current branch? " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done

git fetch ${GIT_REMOTE_UPSTREAM}
if git show-ref -q --heads "release"; then
git branch -D release
fi
resetChanges() {
echo "[INFO] Reset changes in $1 branch"
git reset --hard
git checkout $1
git fetch ${GIT_REMOTE_UPSTREAM} --prune
git pull ${GIT_REMOTE_UPSTREAM} $1
}

# fetch latest changes from master branch
git pull ${GIT_REMOTE_UPSTREAM} master
checkoutToReleaseBranch() {
echo "[INFO] Checking out to $BRANCH branch."
local branchExist=$(git ls-remote -q --heads | grep $BRANCH | wc -l)
if [[ $branchExist == 1 ]]; then
echo "[INFO] $BRANCH exists."
resetChanges $BRANCH
else
echo "[INFO] $BRANCH does not exist. Will be created a new one from master."
resetChanges master
git push origin master:$BRANCH
fi
git checkout -B $RELEASE
}

# create a new local and push it to remote branch
git checkout -b ${BRANCH_NAME} master
git push ${GIT_REMOTE_UPSTREAM} ${BRANCH_NAME}
release() {
echo "[INFO] Releasing a new $RELEASE version"

# Create VERSION file
echo "$VERSION" > VERSION
echo "$RELEASE" > VERSION

# replace nightly versions by release version
apply_sed "s#quay.io/eclipse/che-server:nightly#quay.io/eclipse/che-server:${VERSION}#g" src/constants.ts
apply_sed "s#quay.io/eclipse/che-operator:nightly#quay.io/eclipse/che-operator:${VERSION}#g" src/constants.ts
apply_sed "s#quay.io/eclipse/che-server:nightly#quay.io/eclipse/che-server:${RELEASE}#g" src/constants.ts
apply_sed "s#quay.io/eclipse/che-operator:nightly#quay.io/eclipse/che-operator:${RELEASE}#g" src/constants.ts

# now replace package.json dependencies
apply_sed "s;github.com/eclipse/che#\(.*\)\",;github.com/eclipse/che#${VERSION}\",;g" package.json
apply_sed "s;github.com/eclipse/che-operator#\(.*\)\",;github.com/eclipse/che-operator#${VERSION}\",;g" package.json
apply_sed "s;github.com/eclipse/che#\(.*\)\",;github.com/eclipse/che#${RELEASE}\",;g" package.json
apply_sed "s;github.com/eclipse/che-operator#\(.*\)\",;github.com/eclipse/che-operator#${RELEASE}\",;g" package.json

# add VERSION file to commit
git add VERSION src package.json yarn.lock
# build
yarn
yarn pack
yarn test
}

commitChanges() {
echo "[INFO] Pushing changes to $RELEASE branch"
git add -A
git commit -s -m "chore(release): release version ${RELEASE}"
git push origin $RELEASE
}

git commit -a -s -m "chore(release): release version ${VERSION}"
createReleaseBranch() {
echo "[INFO] Create the release branch based on $RELEASE"
git push origin $RELEASE:release -f
}

git push ${GIT_REMOTE_FORK} ${BRANCH_NAME}
createPR() {
echo "[INFO] Creating a PR"
hub pull-request --base ${BRANCH} --head ${RELEASE} --browse -m "Release version ${RELEASE}"
}

run() {
checkoutToReleaseBranch
release
commitChanges
createReleaseBranch
createPR
}

init "$@"
check "$@"
run "$@"
init $@
check $@
run $@
Loading

0 comments on commit 2e9c283

Please sign in to comment.