diff --git a/.github/workflows/build-and-release-snapshot-plugin.yml b/.github/workflows/build-and-release-snapshot-plugin.yml index 79a3d0efd5..ed9e2636c9 100644 --- a/.github/workflows/build-and-release-snapshot-plugin.yml +++ b/.github/workflows/build-and-release-snapshot-plugin.yml @@ -19,7 +19,8 @@ jobs: - name: Check out code uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 1 + ref: ${{ inputs.branch }} - name: Set up Go uses: actions/setup-go@v5 diff --git a/.gitignore b/.gitignore index e1f680a0fd..25ac166e43 100644 --- a/.gitignore +++ b/.gitignore @@ -26,26 +26,6 @@ fortio_chart.js **/node_modules/ **/out/ -**/ui/playground/ -ui/.next/ -ui/out/ -ui/node_modules/ - -provider-ui/out/ -provider-ui/.next/ -provider-ui/node_modules/ - -# mesheryctl -mesheryctl/cmd/mesheryctl/mesheryctl -mesheryctl/.meshery/ -mesheryctl/mesheryctl -mesheryctl/default.profraw -main - -# Meshery -cmd/meshery - -log.txt # Docs docs/_site @@ -53,11 +33,6 @@ docs/.sass-cache docs/.jekyll-metadata docs/.jekyll-cache -docs/v0.4 -docs/v0.5 -docs/v0.6 -docs/v0.* - dist/ */npm-debug.log @@ -75,7 +50,3 @@ default.profraw **errorutil_analyze_summary.json **errorutil_errors_export.json .ruby-version - -wasm/policies/temp-bundle-extract-dir/** -.nvim.lua - diff --git a/.golangci.yml b/.golangci.yml index 6b9369812e..b30c766043 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,17 @@ run: timeout: 5m +linters: + disable-all: true + enable: + - gofmt + - gosimple + - govet + - misspell + - revive + - unused + - staticcheck + +linters-settings: + gofmt: + simplify: true \ No newline at end of file diff --git a/helpers/Makefile.core.mk b/helpers/Makefile.core.mk index 543b87375f..0047349e21 100644 --- a/helpers/Makefile.core.mk +++ b/helpers/Makefile.core.mk @@ -1,4 +1,4 @@ -GOVERSION = 1.23 +GOVERSION = 1.21 PROVIDER_TOKEN="dev_token" MESHERY_CLOUD_API_BASE_URL="http://localhost:9876" MESHERY_API_BASE_URL="http://localhost:3000" diff --git a/plugin.yaml b/plugin.yaml index e3fb36cb12..c0b0b9c338 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,13 +1,12 @@ name: "helm-kanvas-snapshot" -version: "0.1.0" -usage: "Generate a visual snapshot of your Helm chart as a Meshery Snapshot" -description: "A Helm plugin to generate Meshery Snapshots from Helm charts using a custom Go binary" +version: "0.2.0" +usage: "Generate a visual snapshot of your Helm chart as a Meshery Design" +description: "A Helm plugin to generate Meshery designs from Helm charts and snapshot their visual representation." useTunnel: true command: "$HELM_PLUGIN_DIR/bin/helm-kanvas-snapshot" hooks: install: | echo "Snapshot plugin installed." - update: | echo "Snapshot plugin updated." $HELM_PLUGIN_DIR/install-binary.sh diff --git a/scripts/install-binary.sh b/scripts/install-binary.sh new file mode 100755 index 0000000000..336bfb5be3 --- /dev/null +++ b/scripts/install-binary.sh @@ -0,0 +1,164 @@ +# // Copyright Meshery Authors +# // +# // Licensed under the Apache License, Version 2.0 (the "License"); +# // you may not use this file except in compliance with the License. +# // You may obtain a copy of the License at +# // +# // http://www.apache.org/licenses/LICENSE-2.0 +# // +# // Unless required by applicable law or agreed to in writing, software +# // distributed under the License is distributed on an "AS IS" BASIS, +# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# // See the License for the specific language governing permissions and +# // limitations under the License. + +# This script installs the Helm Kanvas Snapshot plugin. + +#!/usr/bin/env sh + +echo "Installing Helm Kanvas Snapshot plugin..." + +CLI="kanvas-snapshot" +REPO_NAME="helm-kanvas-snapshot" +PROJECT_ORG="${PROJECT_ORG:-meshery}" +PROJECT_GH="$PROJECT_ORG/$REPO_NAME" +HELM_BIN="/usr/local/bin/helm" +export GREP_COLOR="never" + +HELM_MAJOR_VERSION=$("${HELM_BIN}" version --client --short | awk -F '.' '{print $1}') + +# : ${HELM_PLUGIN_DIR:="$("${HELM_BIN}" home --debug=false)/plugins/helm-diff"} + +# Handle HELM_PLUGIN_DIR filepath based on OS. Use *nix-based filepathing + +if type cygpath >/dev/null 2>&1; then + HELM_PLUGIN_DIR=$(cygpath -u $HELM_PLUGIN_DIR) +fi + +if [ "$SKIP_BIN_INSTALL" = "1" ]; then + echo "Skipping binary install" + exit +fi + +# Identify systm architecture +initArch() { + ARCH=$(uname -m) + case $ARCH in + armv5*) ARCH="armv5" ;; + armv6*) ARCH="armv6" ;; + armv7*) ARCH="armv7" ;; + aarch64) ARCH="arm64" ;; + x86) ARCH="386" ;; + x86_64) ARCH="x86_64" ;; + i686) ARCH="386" ;; + i386) ARCH="386" ;; + esac + echo "ARCH: $ARCH" +} + +# Identify operating system +initOS() { + OS=$(uname | tr '[:upper:]' '[:lower:]') + + case "$OS" in + # Msys support + msys*) OS='windows' ;; + # Minimalist GNU for Windows + mingw*) OS='windows' ;; + darwin) OS='darwin' ;; + esac + echo "OS: $OS" +} + +# verifySupported checks that the os/arch combination is supported for +# binary builds. +verifySupported() { + supported="linux_amd64\ndarwin_x86_64\nlinux_arm64\ndarwin_arm64\nwindows_amd64" + if ! echo "${supported}" | grep -q "${OS}_${ARCH}"; then + echo "No prebuilt binary for ${OS}_${ARCH}." + exit 1 + fi + + if ! type "curl" >/dev/null && ! type "wget" >/dev/null; then + echo "Either curl or wget is required" + exit 1 + fi +} + +# getDownloadURL checks the latest available version. +getDownloadURL() { + #version=$(git -C "$HELM_PLUGIN_DIR" describe --tags --exact-match 2>/dev/null || :) + echo "OS: $OS" + + version="$(cat $HELM_PLUGIN_DIR/plugin.yaml | grep "version" | cut -d '"' -f 2)" + if [ -n "$version" ]; then +DOWNLOAD_URL="https://github.com/$PROJECT_GH/releases/download/v$version/$CLI_$version_$OS_$ARCH.tar.gz" + echo "DOWNLOAD_URL1: $DOWNLOAD_URL" + # https://github.com/meshery/helm-kanvas-snapshot/releases/download/v0.2.0/kanvas-snapshot_0.2.0_Darwin_x86_64.tar.gz + else + # Use the GitHub API to find the download url for this project. + url="https://api.github.com/repos/$PROJECT_GH/releases/latest" + if type "curl" >/dev/null; then + DOWNLOAD_URL=$(curl -s $url | grep $OS_$ARCH\" | awk '/\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}') + echo "DOWNLOAD_URL2: $DOWNLOAD_URL" + + elif type "wget" >/dev/null; then + DOWNLOAD_URL=$(wget -q -O - $url | grep $OS_$ARCH\" | awk '/\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}') + echo "DOWNLOAD_URL3: $DOWNLOAD_URL" + + fi + fi + +} + +# downloadFile downloads the latest binary package and also the checksum +# for that binary. +downloadFile() { + BINDIR="$HELM_PLUGIN_DIR/bin" + rm -rf "$BINDIR" + mkdir -p "$BINDIR" + echo "Downloading $DOWNLOAD_URL" + if type "curl" >/dev/null; then + HTTP_CODE=$(curl -sL --write-out "%{http_code}" "$DOWNLOAD_URL" --output "$BINDIR/$CLI") + if [ ${HTTP_CODE} -ne 200 ]; then + exit 1 + fi + elif type "wget" >/dev/null; then + wget -q -O "$BINDIR/$CLI" "$DOWNLOAD_URL" + fi + + chmod +x "$BINDIR/$CLI" + +} + +# fail_trap is executed if an error occurs. +fail_trap() { + result=$? + if [ "$result" != "0" ]; then + echo "Failed to install $CLI" + printf "\tFor support, go to https://discuss.layer5.io.\n" + fi + exit $result +} + +# testVersion tests the installed client to make sure it is working. +testVersion() { + set +e + echo "$CLI installed into $HELM_PLUGIN_DIR/$CLI" + "${HELM_PLUGIN_DIR}/bin/$CLI" version + echo "`helm $CLI --help` to get started." + set -e +} + + +# Execution + +#Stop execution on any error +trap "fail_trap" EXIT +set -e +initArch +initOS +verifySupported +getDownloadURL +downloadFile +testVersion \ No newline at end of file