diff --git a/.drone.yml b/.drone.yml index e4578c7..834dff6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,7 +4,7 @@ name: default steps: -- name: test +- name: 2. test image: golang volumes: - name: deps @@ -12,15 +12,15 @@ steps: commands: - go test ./... -- name: build +- name: 3. build image: golang volumes: - name: deps path: /go commands: - - go build ./... + - go build -v -race -a ./... -- name: deploy +- name: 4. deploy image: alpine volumes: - name: ssh_key @@ -31,7 +31,7 @@ steps: - apk add --no-cache openssh - ssh -p21022 -o StrictHostKeyChecking=accept-new -i /root/.ssh/id_rsa.kubehost mtc@bosub-kub-int.metacoaching.pro "hostname" -- name: notify fail +- name: 5. notify fail image: bash:4.4 environment: ZULIP_HOST: https://zulip.meta-tech.academy @@ -44,16 +44,17 @@ steps: from_secret: ZULIP_TOKEN commands: - apk add --no-cache curl + - printenv - export ZULIP_STATUS=":prohibited:" - export ZULIP_MESSAGE=$${DRONE_COMMIT_MESSAGE:-2} - export SHORT_COMMIT=$${DRONE_COMMIT:0:7} - export REMOTE_URL=$${DRONE_REMOTE_URL:0:-4} - - curl -s -X POST "$ZULIP_HOST/api/v1/messages" -u "$ZULIP_USER:$ZULIP_TKN" --data-urlencode "type=stream" --data-urlencode "to=\"$ZULIP_STREAM\"" --data-urlencode "topic=$ZULIP_TOPIC" --data "content=$ZULIP_STATUS **[build %23${DRONE_BUILD_NUMBER}](${DRONE_BUILD_LINK})**%0A> **${DRONE_BUILD_EVENT}** event on **${DRONE_COMMIT_BRANCH}** branch *by* **${DRONE_COMMIT_AUTHOR}** ([$SHORT_COMMIT]($REMOTE_URL/commit/${DRONE_COMMIT}))%0A> $ZULIP_MESSAGE" + - curl -s -X POST "$ZULIP_HOST/api/v1/messages" -u "$ZULIP_USER:$ZULIP_TKN" --data-urlencode "type=stream" --data-urlencode "to=\"$ZULIP_STREAM\"" --data-urlencode "topic=$ZULIP_TOPIC" --data "content=$ZULIP_STATUS **[build %23${DRONE_BUILD_NUMBER}](${DRONE_BUILD_LINK})**%0A> **${DRONE_BUILD_EVENT}** event on **${DRONE_COMMIT_BRANCH}** branch *by* **${DRONE_COMMIT_AUTHOR}** ([$SHORT_COMMIT]($REMOTE_URL/commit/${DRONE_COMMIT}))%0A> ***failed at ${DRONE_FAILED_STEPS}*** %0A> $ZULIP_MESSAGE" when: status: - failure -- name: notify done +- name: 5. notify done image: bash:4.4 environment: ZULIP_HOST: https://zulip.meta-tech.academy @@ -66,6 +67,7 @@ steps: from_secret: ZULIP_TOKEN commands: - apk add --no-cache curl + - printenv - export ZULIP_STATUS=":check:" - export ZULIP_MESSAGE=$${DRONE_COMMIT_MESSAGE:-2} - export SHORT_COMMIT=$${DRONE_COMMIT:0:7} diff --git a/util/util.go b/util/util.go index 5f53ea7..e09b6f3 100644 --- a/util/util.go +++ b/util/util.go @@ -74,7 +74,7 @@ func GetBytesAsHex(key []byte) []byte { hex.Encode(dst, key) return dst } - +func func GetBytesFromHex(key []byte) []byte { dst := make([]byte, hex.DecodedLen(len(key))) n, err := hex.Decode(dst, key)