From a25d377adde1e4317b4aea415a1ff611db68c162 Mon Sep 17 00:00:00 2001 From: Ilya Lesikov Date: Thu, 4 Aug 2022 06:24:21 +0300 Subject: [PATCH] chore: remove unused scripts Signed-off-by: Ilya Lesikov --- playground/docker_with_fuse_buildah/main.go | 108 ------------------ scripts/buildah/Dockerfile | 9 -- scripts/buildah/build.sh | 12 -- scripts/create_release_tag.sh | 19 --- scripts/lib/release/bintray.sh | 92 --------------- scripts/lib/release/create_release_message.sh | 9 -- scripts/lib/release/git_tag_template.md | 13 --- scripts/lib/release/github.sh | 38 ------ scripts/lib/release/global_data.sh | 12 -- scripts/lib/release/publish.sh | 7 -- scripts/publish_release.sh | 18 --- 11 files changed, 337 deletions(-) delete mode 100644 playground/docker_with_fuse_buildah/main.go delete mode 100644 scripts/buildah/Dockerfile delete mode 100755 scripts/buildah/build.sh delete mode 100755 scripts/create_release_tag.sh delete mode 100644 scripts/lib/release/bintray.sh delete mode 100644 scripts/lib/release/create_release_message.sh delete mode 100644 scripts/lib/release/git_tag_template.md delete mode 100644 scripts/lib/release/github.sh delete mode 100644 scripts/lib/release/global_data.sh delete mode 100644 scripts/lib/release/publish.sh delete mode 100755 scripts/publish_release.sh diff --git a/playground/docker_with_fuse_buildah/main.go b/playground/docker_with_fuse_buildah/main.go deleted file mode 100644 index 815bc0d9da..0000000000 --- a/playground/docker_with_fuse_buildah/main.go +++ /dev/null @@ -1,108 +0,0 @@ -package main - -import ( - "context" - "fmt" - "io" - "os" - - "github.com/google/uuid" - - "github.com/werf/werf/pkg/buildah" - "github.com/werf/werf/pkg/docker" - "github.com/werf/werf/pkg/util" - "github.com/werf/werf/pkg/werf" -) - -func do(ctx context.Context) error { - if err := werf.Init("", ""); err != nil { - return err - } - - if err := docker.Init(ctx, "", false, false, ""); err != nil { - return err - } - - b, err := buildah.NewBuildah(buildah.ModeDockerWithFuse, buildah.BuildahOpts{}) - if err != nil { - return err - } - - if len(os.Args) != 3 { - return fmt.Errorf("usage: %s DOCKERFILE_PATH CONTEXT_DIR", os.Args[0]) - } - dockerfilePath := os.Args[1] - if dockerfilePath == "" { - return fmt.Errorf("usage: %s DOCKERFILE_PATH CONTEXT_DIR", os.Args[0]) - } - contextDir := os.Args[2] - if contextDir == "" { - return fmt.Errorf("usage: %s DOCKERFILE_PATH CONTEXT_DIR", os.Args[0]) - } - - dockerfileData, err := os.ReadFile(dockerfilePath) - if err != nil { - return fmt.Errorf("error reading %q: %w", dockerfilePath, err) - } - - errCh := make(chan error, 0) - buildDoneCh := make(chan string, 0) - - contextTar := util.BufferedPipedWriterProcess(func(w io.WriteCloser) { - if err := util.WriteDirAsTar((contextDir), w); err != nil { - errCh <- fmt.Errorf("unable to write dir %q as tar: %w", contextDir, err) - return - } - - if err := w.Close(); err != nil { - errCh <- fmt.Errorf("unable to close buffered piped writer for context dir %q: %w", contextDir, err) - return - } - }) - - go func() { - imageID, err := b.BuildFromDockerfile(ctx, dockerfileData, buildah.BuildFromDockerfileOpts{ - ContextTar: contextTar, - CommonOpts: buildah.CommonOpts{ - LogWriter: os.Stdout, - }, - }) - if err != nil { - errCh <- fmt.Errorf("BuildFromDockerfile failed: %w", err) - return - } - - buildDoneCh <- imageID - close(buildDoneCh) - }() - - var imageID string - select { - case err := <-errCh: - close(errCh) - return err - - case imageID = <-buildDoneCh: - } - - fmt.Printf("BUILT NEW IMAGE %q\n", imageID) - - containerName := uuid.New().String() - - if _, err := b.FromCommand(ctx, containerName, imageID, buildah.FromCommandOpts{LogWriter: os.Stdout}); err != nil { - return err - } - - if err := b.RunCommand(ctx, containerName, []string{"ls"}, buildah.RunCommandOpts{CommonOpts: buildah.CommonOpts{LogWriter: os.Stdout}}); err != nil { - return err - } - - return nil -} - -func main() { - if err := do(context.Background()); err != nil { - fmt.Fprintf(os.Stderr, "ERROR: %s\n", err) - os.Exit(1) - } -} diff --git a/scripts/buildah/Dockerfile b/scripts/buildah/Dockerfile deleted file mode 100644 index ac81628db7..0000000000 --- a/scripts/buildah/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -ARG version - -FROM quay.io/buildah/stable:$version - -# make /dev/fuse available for user build in Docker Desktop -RUN usermod -a -G root build - -# extend subuid/subgid range -RUN sed -i -e 's/build:2000:50000/build:2000:100000/' /etc/subuid /etc/subgid diff --git a/scripts/buildah/build.sh b/scripts/buildah/build.sh deleted file mode 100755 index b925ae9072..0000000000 --- a/scripts/buildah/build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -e - -BUILDAH_VERSION=v1.22.3 -IMAGE_VERSION=$BUILDAH_VERSION-1 - -IMAGE_NAME=registry-write.werf.io/werf/buildah:$IMAGE_VERSION - -docker build --build-arg version=$BUILDAH_VERSION -t $IMAGE_NAME scripts/buildah - -docker push $IMAGE_NAME diff --git a/scripts/create_release_tag.sh b/scripts/create_release_tag.sh deleted file mode 100755 index 5e14e95be7..0000000000 --- a/scripts/create_release_tag.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -e - -for f in $(find scripts/lib -type f -name "*.sh"); do - source $f -done - -VERSION=$1 -if [ -z "$VERSION" ] ; then - echo "Required version argument!" 1>&2 - echo 1>&2 - echo "Usage: $0 VERSION" 1>&2 - exit 1 -fi - -( which git > /dev/null ) || ( echo "Cannot find git command!" 1>&2 && exit 1 ) - -( create_release_message $VERSION ) || ( echo "Failed to create release message!" 1>&2 && exit 1 ) diff --git a/scripts/lib/release/bintray.sh b/scripts/lib/release/bintray.sh deleted file mode 100644 index 64ca6c94bc..0000000000 --- a/scripts/lib/release/bintray.sh +++ /dev/null @@ -1,92 +0,0 @@ -bintray_create_version() { - VERSION=$1 - - PAYLOAD=$(cat <<- JSON - { - "name": "${VERSION}", - "desc": "${VERSION}", - "vcs_tag": "${GIT_TAG}" - } -JSON -) - - curlResponse=$(mktemp) - status=$(curl -s -w %{http_code} -o $curlResponse \ - --request POST \ - --user $PUBLISH_BINTRAY_AUTH \ - --header "Content-type: application/json" \ - --data "$PAYLOAD" \ - https://api.bintray.com/packages/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${BINTRAY_PACKAGE}/versions - ) - - echo "Bintray create version: curl return status $status with response" - cat $curlResponse - echo - rm $curlResponse - - ret=0 - if [ "x$(echo $status | cut -c1)" != "x2" ] - then - ret=1 - fi - - return $ret -} - -# upload file to $GIT_TAG version -bintray_upload_file_into_version() { - VERSION=$1 - UPLOAD_FILE_PATH=$2 - DESTINATION_PATH=$3 - - curlResponse=$(mktemp) - status=$(curl -s -w %{http_code} -o $curlResponse \ - --header "Content-type: application/binary" \ - --request PUT \ - --user $PUBLISH_BINTRAY_AUTH \ - --upload-file $UPLOAD_FILE_PATH \ - https://api.bintray.com/content/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${BINTRAY_PACKAGE}/$VERSION/$VERSION/$DESTINATION_PATH - ) - - echo "Bintray upload $DESTINATION_PATH: curl return status $status with response" - cat $curlResponse - echo - rm $curlResponse - - ret=0 - if [ "x$(echo $status | cut -c1)" != "x2" ] - then - ret=1 - else - dlUrl="https://dl.bintray.com/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${VERSION}/${DESTINATION_PATH}" - echo "Bintray: $DESTINATION_PATH uploaded to ${dlURL}" - fi - - return $ret -} - -bintray_publish_files_in_version() { - local VERSION=$1 - - curlResponse=$(mktemp) - status=$(curl -s -w '%{http_code}' -o "$curlResponse" \ - --request POST \ - --user "$PUBLISH_BINTRAY_AUTH" \ - --header "Content-type: application/json" \ - "https://api.bintray.com/content/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${BINTRAY_PACKAGE}/${VERSION}/publish" - ) - - echo "Bintray publish files in version ${VERSION}: curl return status $status with response" - cat "$curlResponse" - echo - rm "$curlResponse" - - ret=0 - if [ "x$(echo "$status" | cut -c1)" != "x2" ] - then - ret=1 - fi - - return $ret -} - diff --git a/scripts/lib/release/create_release_message.sh b/scripts/lib/release/create_release_message.sh deleted file mode 100644 index 191ca5fcf5..0000000000 --- a/scripts/lib/release/create_release_message.sh +++ /dev/null @@ -1,9 +0,0 @@ -create_release_message() { - VERSION=$1 - - TAG_TEMPLATE=scripts/lib/release/git_tag_template.md - - ( cat $TAG_TEMPLATE | VERSION=$VERSION envsubst | git tag --cleanup=verbatim --annotate --file - --edit $VERSION ) || ( return 1 ) - - git push --tags -} diff --git a/scripts/lib/release/git_tag_template.md b/scripts/lib/release/git_tag_template.md deleted file mode 100644 index 3246a1b7b0..0000000000 --- a/scripts/lib/release/git_tag_template.md +++ /dev/null @@ -1,13 +0,0 @@ -RELEASE_TEXT - -# Installation - -[Linux amd64](https://storage.yandexcloud.net/werf/targets/releases/$VERSION/werf-linux-amd64-$VERSION) - -[Linux arm64](https://storage.yandexcloud.net/werf/targets/releases/$VERSION/werf-linux-arm64-$VERSION) - -[Darwin amd64](https://storage.yandexcloud.net/werf/targets/releases/$VERSION/werf-darwin-amd64-$VERSION) - -[Darwin arm64](https://storage.yandexcloud.net/werf/targets/releases/$VERSION/werf-darwin-arm64-$VERSION) - -[Windows amd64](https://storage.yandexcloud.net/werf/targets/releases/$VERSION/werf-windows-amd64-$VERSION.exe) diff --git a/scripts/lib/release/github.sh b/scripts/lib/release/github.sh deleted file mode 100644 index 573619a8d2..0000000000 --- a/scripts/lib/release/github.sh +++ /dev/null @@ -1,38 +0,0 @@ -create_github_release() { - VERSION=$1 - - TAG_RELEASE_MESSAGE=$(git for-each-ref --format="%(contents)" refs/tags/$VERSION | jq -R -s '.' ) - - GHPAYLOAD=$(cat <<- JSON - { - "tag_name": "$VERSION", - "name": "werf $VERSION", - "body": $TAG_RELEASE_MESSAGE, - "draft": false, - "prerelease": false - } -JSON -) - - curlResponse=$(mktemp) - status=$(curl -s -w %{http_code} -o $curlResponse \ - --request POST \ - --header "Authorization: token $PUBLISH_GITHUB_TOKEN" \ - --header "Accept: application/vnd.github.v3+json" \ - --data "$GHPAYLOAD" \ - https://api.github.com/repos/$GITHUB_OWNER/$GITHUB_REPO/releases - ) - - echo "Github create release: curl return status $status with response" - cat $curlResponse - echo - rm $curlResponse - - ret=0 - if [ "x$(echo $status | cut -c1)" != "x2" ] - then - ret=1 - fi - - return $ret -} diff --git a/scripts/lib/release/global_data.sh b/scripts/lib/release/global_data.sh deleted file mode 100644 index 6b22328d60..0000000000 --- a/scripts/lib/release/global_data.sh +++ /dev/null @@ -1,12 +0,0 @@ -#PUBLISH_BINTRAY_AUTH= # bintray auth user:TOKEN -BINTRAY_SUBJECT=flant # bintray organization -BINTRAY_REPO=werf # bintray repository -BINTRAY_PACKAGE=werf # bintray package in repository - -GITHUB_OWNER=werf # github user/org -GITHUB_REPO=werf # github repository -#PUBLISH_GITHUB_TOKEN # github token granted permission to create releases - -RELEASE_BUILD_DIR=release-build - -GIT_REMOTE=origin # can be changed to upstream with env diff --git a/scripts/lib/release/publish.sh b/scripts/lib/release/publish.sh deleted file mode 100644 index 60aaf3a67d..0000000000 --- a/scripts/lib/release/publish.sh +++ /dev/null @@ -1,7 +0,0 @@ -publish_binaries() { - VERSION=$1 - - echo "Publish version $VERSION from git tag $VERSION" - - docker run --rm -v $(pwd):/project --workdir /project -e AWS_ACCESS_KEY_ID=$S3_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$S3_SECRET_ACCESS_KEY amazon/aws-cli --endpoint-url $S3_ENDPOINT --region $S3_REGION s3 cp --recursive $RELEASE_BUILD_DIR/$VERSION s3://$S3_BUCKET_NAME/targets/releases/$VERSION -} diff --git a/scripts/publish_release.sh b/scripts/publish_release.sh deleted file mode 100755 index 749d4a0868..0000000000 --- a/scripts/publish_release.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -set -e - -for f in $(find scripts/lib -type f -name "*.sh"); do - source $f -done - -VERSION=$1 -if [ -z "$VERSION" ] ; then - echo "Required version argument!" 1>&2 - echo 1>&2 - echo "Usage: $0 VERSION" 1>&2 - exit 1 -fi - -( go_build $VERSION ) || ( echo "Failed to build!" 1>&2 && exit 1 ) -( publish_binaries $VERSION ) || ( echo "Failed to publish release binaries!" 1>&2 && exit 1 )