From cb1fee4c8d6d96cfcebbc855b6887b2ded292e7f Mon Sep 17 00:00:00 2001 From: Eti Ijeoma Date: Mon, 7 Oct 2024 14:23:42 +0100 Subject: [PATCH 01/16] pull latest changes Signed-off-by: Eti Ijeoma --- .../build-and-release-snapshot-plugin.yml | 4 - Makefile | 9 +- build/Makefile.core.mk | 9 +- cmd/kanvas-snapshot/main.go | 84 +++++++++++-------- internal/errors/error.go | 12 +++ 5 files changed, 66 insertions(+), 52 deletions(-) diff --git a/.github/workflows/build-and-release-snapshot-plugin.yml b/.github/workflows/build-and-release-snapshot-plugin.yml index cfc2df49f0..9017633da6 100644 --- a/.github/workflows/build-and-release-snapshot-plugin.yml +++ b/.github/workflows/build-and-release-snapshot-plugin.yml @@ -36,10 +36,6 @@ jobs: RELEASE_CHANNEL: "stable" MESHERY_CLOUD_API_COOKIE: ${{ secrets.MESHERY_CLOUD_API_COOKIE }} MESHERY_API_COOKIE: ${{ secrets.MESHERY_API_COOKIE }} - OWNER: ${{ secrets.OWNER }} - REPO: ${{ secrets.REPO }} - WORKFLOW: ${{ secrets.WORKFLOW }} - BRANCH: ${{ secrets.BRANCH }} MESHERY_CLOUD_API_BASE_URL: ${{ secrets.MESHERY_CLOUD_API_BASE_URL }} MESHERY_API_BASE_URL: ${{ secrets.MESHERY_API_BASE_URL }} SYSTEM_ID: ${{ secrets.SYSTEM_ID }} diff --git a/Makefile b/Makefile index e1aa64058e..cff3d0aedf 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,8 @@ include build/Makefile.core.mk .PHONY: all all: dep-check build ## Lint check -# golangci: error dep-check -# golangci-lint run --exclude-use-default +golangci: error dep-check + golangci-lint run --exclude-use-default ## Analyze error codes error: dep-check @@ -58,13 +58,8 @@ BINNAME_WINDOWS ?= kanvas-snapshot-windows-$(ARCH).exe LDFLAGS := "\ - -X 'main.GithubToken=$(GITHUB_TOKEN)' \ -X 'main.MesheryCloudApiCookie=$(MESHERY_CLOUD_API_COOKIES)' \ -X 'main.MesheryApiCookie=$(MESHERY_API_COOKIES)' \ - -X 'main.Owner=$(OWNER)' \ - -X 'main.Repo=$(REPO)' \ - -X 'main.Workflow=$(WORKFLOW)' \ - -X 'main.Branch=$(BRANCH)' \ -X 'main.MesheryCloudApiBaseUrl=$(MESHERY_CLOUD_API_BASE_URL)' \ -X 'main.MesheryApiBaseUrl=$(MESHERY_API_BASE_URL)' \ -X 'main.SystemID=$(SYSTEM_ID)'" diff --git a/build/Makefile.core.mk b/build/Makefile.core.mk index 7c87132bf8..d20e5ca322 100644 --- a/build/Makefile.core.mk +++ b/build/Makefile.core.mk @@ -1,11 +1,6 @@ GOVERSION = 1.23 -GITHUB_TOKEN="" MESHERY_API_COOKIE="" MESHERY_CLOUD_API_COOKIE="" -OWNER="Aijeyomah" -REPO="Ng-depl" -WORKFLOW="meshmap.yml" -BRANCH="new-mesh" MESHERY_CLOUD_API_BASE_URL="http://localhost:9876" -MESHERY_API_BASE_URL="http://localhost:9081" -SYSTEM_ID="3ae41e77-5626-42d3-aa04-ee871ad3035c" +MESHERY_API_BASE_URL="http://localhost:3000" +SYSTEM_ID="ad8acecd-b742-4958-9af9-538c4183a177" diff --git a/cmd/kanvas-snapshot/main.go b/cmd/kanvas-snapshot/main.go index cafdeeaa5e..279ad6a56c 100644 --- a/cmd/kanvas-snapshot/main.go +++ b/cmd/kanvas-snapshot/main.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "net/http" + "net/url" "os" "path/filepath" "strings" @@ -18,19 +19,13 @@ import ( ) var ( - GithubToken string MesheryToken string MesheryCloudApiCookie string MesheryApiCookie string - Owner string - Repo string - Workflow string - Branch string MesheryApiBaseUrl string MesheryCloudApiBaseUrl string SystemID string Log logger.Handler - LogError logger.Handler ) var ( @@ -133,10 +128,15 @@ func ExtractNameFromURI(uri string) string { } func handleError(err error) { - if err != nil { - LogError.Error(err) - os.Exit(1) + if err == nil { + return + } + if Log != nil { + Log.Error(err) + } else { + fmt.Fprintf(os.Stderr, "Error: %v\n", err) } + os.Exit(1) } func CreateMesheryDesign(uri, name, email string) (string, error) { @@ -149,58 +149,64 @@ func CreateMesheryDesign(uri, name, email string) (string, error) { payloadBytes, err := json.Marshal(payload) if err != nil { - LogError.Error(err) - os.Exit(1) + Log.Info("Failed to marshal payload:", err) + return "", errors.ErrDecodingAPI(err) } + sourceType := "Helm Chart" - req, err := http.NewRequest("POST", fmt.Sprintf("%s/api/pattern/%s", MesheryApiBaseUrl, sourceType), bytes.NewBuffer(payloadBytes)) + encodedChartType := url.PathEscape(sourceType) + fullURL := fmt.Sprintf("%s/api/pattern/%s", MesheryApiBaseUrl, encodedChartType) + + // Create the request + req, err := http.NewRequest("POST", fullURL, bytes.NewBuffer(payloadBytes)) if err != nil { - LogError.Error(err) - os.Exit(1) + Log.Info("Failed to create new request:", err) + return "", errors.ErrHTTPPostRequest(err) } + // Set headers and log them req.Header.Set("Cookie", MesheryApiCookie) req.Header.Set("Origin", MesheryApiBaseUrl) req.Header.Set("Host", MesheryApiBaseUrl) - req.Header.Set("Content-Type", "application/json") + req.Header.Set("Content-Type", "text/plain;charset=UTF-8") req.Header.Set("Accept-Encoding", "gzip, deflate, br, zstd") req.Header.Set("Accept-Language", "en-GB,en-US;q=0.9,en;q=0.8") client := &http.Client{} + resp, err := client.Do(req) if err != nil { - return "", err + return "", errors.ErrHTTPPostRequest(err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - io.ReadAll(resp.Body) - return "", err + body, _ := io.ReadAll(resp.Body) + return "", errors.ErrUnexpectedResponseCode(resp.StatusCode, string(body)) } - // Expecting a JSON array in the response + + // Decode response var result []map[string]interface{} err = json.NewDecoder(resp.Body).Decode(&result) if err != nil { - return "", err + body, _ := io.ReadAll(resp.Body) + return "", errors.ErrDecodingAPI(fmt.Errorf("failed to decode json. body: %s, error: %w", body, err)) } + // Extracting the design ID from the result if len(result) > 0 { if id, ok := result[0]["id"].(string); ok { + Log.Infof("Successfully created Meshery design. ID: %s", id) return id, nil } } - return "", errors.ErrHTTPPostRequest(err) + return "", errors.ErrCreatingMesheryDesign(fmt.Errorf("failed to extract design ID from response")) } func GenerateSnapshot(designID, chartURI, email, assetLocation string) error { payload := map[string]interface{}{ - "Owner": Owner, - "Repo": Repo, - "Workflow": Workflow, - "Branch": Branch, - "github_token": GithubToken, "Payload": map[string]string{ "application_type": "Helm Chart", "designID": designID, @@ -231,14 +237,24 @@ func GenerateSnapshot(designID, chartURI, email, assetLocation string) error { req.Header.Set("Referer", fmt.Sprintf("%s/dashboard", MesheryCloudApiBaseUrl)) client := &http.Client{} + resp, err := client.Do(req) if err != nil { - return err + return errors.ErrHTTPPostRequest(err) } defer resp.Body.Close() - if resp.StatusCode != 200 { - _, err := io.ReadAll(resp.Body) - return err + + if resp.StatusCode != http.StatusOK { + body, _ := io.ReadAll(resp.Body) + return errors.ErrUnexpectedResponseCode(resp.StatusCode, string(body)) + } + + // Decode response + var result []map[string]interface{} + err = json.NewDecoder(resp.Body).Decode(&result) + if err != nil { + body, _ := io.ReadAll(resp.Body) + return errors.ErrDecodingAPI(fmt.Errorf("failed to decode json. body: %s, error: %w", body, err)) } return nil @@ -247,14 +263,14 @@ func GenerateSnapshot(designID, chartURI, email, assetLocation string) error { func main() { generateKanvasSnapshotCmd.Flags().StringVarP(&chartURI, "file", "f", "", "URI to Helm chart (required)") - generateKanvasSnapshotCmd.Flags().StringVarP(&designName, "design-name", "l", "", "Optional name for the Meshery design") + generateKanvasSnapshotCmd.Flags().StringVarP(&designName, "design-name", "n", "", "Optional name for the Meshery design") generateKanvasSnapshotCmd.Flags().StringVarP(&email, "email", "e", "", "Optional email to associate with the Meshery design") - generateKanvasSnapshotCmd.MarkFlagRequired("file") - generateKanvasSnapshotCmd.MarkFlagRequired("email") + _ = generateKanvasSnapshotCmd.MarkFlagRequired("file") + _ = generateKanvasSnapshotCmd.MarkFlagRequired("email") if err := generateKanvasSnapshotCmd.Execute(); err != nil { - LogError.Error(err) + Log.Error(err) os.Exit(1) } diff --git a/internal/errors/error.go b/internal/errors/error.go index e21a1c26fb..3ff49b8e0b 100644 --- a/internal/errors/error.go +++ b/internal/errors/error.go @@ -1,6 +1,8 @@ package errors import ( + "fmt" + "github.com/layer5io/meshkit/errors" ) @@ -11,6 +13,7 @@ var ( ErrHTTPPostRequestCode = "kanvas-snapshot-1003" ErrDecodingAPICode = "kanvas-snapshot-1004" ErrRequiredFieldNotProvidedCode = "kanvas-snapshot-1005" + ErrUnexpectedResponseCodeCode = "kanvas-snapshot-1006" ) func ErrInvalidChartURI(err error) error { @@ -57,3 +60,12 @@ func ErrDecodingAPI(err error) error { []string{"Ensure the Meshery API response format is correct."}, ) } + +func ErrUnexpectedResponseCode(statusCode int, body string) error { + return errors.New(ErrUnexpectedResponseCodeCode, errors.Alert, + []string{"Received unexpected response code from Meshery API."}, + []string{fmt.Sprintf("Status Code: %d, Body: %s", statusCode, body)}, + []string{"The API returned an unexpected status code."}, + []string{"Check the request details and ensure the Meshery API is functioning correctly."}, + ) +} From 67f57ef62d86dbeea4afdc42c8785d6fd5c9271c Mon Sep 17 00:00:00 2001 From: Eti Ijeoma Date: Fri, 4 Oct 2024 14:01:55 +0100 Subject: [PATCH 02/16] add goreleaser Signed-off-by: Eti Ijeoma --- .goreleaser.yml | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .goreleaser.yml diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000000..fcfbf66010 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,65 @@ +project_name: kanvas-snapshot + +before: + hooks: + - go mod tidy + +builds: + - main: ./main.go + + env: + - CGO_ENABLED=0 + + ldflags: + - -s -w + - -X main.MesheryCloudApiCookie={{.Env.MESHERY_CLOUD_API_COOKIE}} + - -X main.MesheryApiCookie={{.Env.MESHERY_API_COOKIE}} + - -X main.MesheryCloudApiBaseUrl={{.Env.MESHERY_CLOUD_API_BASE_URL}} + - -X main.MesheryApiBaseUrl={{.Env.MESHERY_API_BASE_URL}} + - -X main.SystemID={{.Env.SYSTEM_ID}} + + goos: + - darwin + - linux + - windows + + goarch: + - 386 + - amd64 + - arm + - arm64 + + ignore: + - goos: windows + goarch: arm + - goos: windows + goarch: arm64 + +archives: + - id: stable + name_template: >- + {{ .ProjectName }}_{{.Version}}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + format: tar.gz + format_overrides: + - goos: windows + format: zip + +checksum: + name_template: 'checksums.txt' + +snapshot: + name_template: "{{ .Tag }}-next" + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +release: + name_template: "Kanvas Snapshot {{.Tag}}" From 474b4b982865f01bb86dc6e65a6d8682f624ccf6 Mon Sep 17 00:00:00 2001 From: Eti Ijeoma Date: Fri, 4 Oct 2024 14:05:34 +0100 Subject: [PATCH 03/16] add goreleaser Signed-off-by: Eti Ijeoma --- .goreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index fcfbf66010..c2879d8a0a 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -5,7 +5,7 @@ before: - go mod tidy builds: - - main: ./main.go + - main: cmd/kanvas-snapshot/main.go env: - CGO_ENABLED=0 From bd6383b3b0253d86a328b498a35e339b338072ed Mon Sep 17 00:00:00 2001 From: Eti Ijeoma Date: Mon, 7 Oct 2024 14:25:06 +0100 Subject: [PATCH 04/16] pull latest changes Signed-off-by: Eti Ijeoma --- .github/workflows/go-testing-ci.yml | 91 +++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/go-testing-ci.yml diff --git a/.github/workflows/go-testing-ci.yml b/.github/workflows/go-testing-ci.yml new file mode 100644 index 0000000000..41d6935cd2 --- /dev/null +++ b/.github/workflows/go-testing-ci.yml @@ -0,0 +1,91 @@ +name: Golang Unit and Integration Tests +on: + push: + branches: + - "master" + paths: + - "**.go" + pull_request: + branches: + - "master" + paths: + - "**.go" + workflow_dispatch: + inputs: + logLevel: + description: "Log level" + required: true + default: "warning" + +jobs: + golangci: + strategy: + matrix: + go: [1.21] + os: [ubuntu-22.04] + name: golangci-lint + if: github.repository == 'meshery/helm-kanvas-snapshot' + runs-on: ${{ matrix.os }} + steps: + - uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go }} + - uses: actions/checkout@v4 + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.59 + args: --config=.golangci.yml --timeout=10m + unit-tests: + name: Unit tests + runs-on: ubuntu-22.04 + needs: golangci + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.21" + - name: Run coverage + run: go test --short ./... -race -coverprofile=coverage.txt -covermode=atomic + - name: Upload coverage to Codecov + if: github.repository == 'meshery/helm-kanvas-snapshot' + uses: codecov/codecov-action@v4.3.0 + with: + files: ./coverage.txt + flags: unittests + integration-tests: + name: Integration tests + runs-on: ubuntu-22.04 + needs: golangci + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.21" + - name: Install Docker Compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Create k8s Kind Cluster + uses: helm/kind-action@v1.10.0 + with: + cluster_name: "kind-cluster" + - name: Run coverage + run: + # TODO: add tests for snapshot + echo "Running kanvas snapshot test completed." + + - name: Upload coverage to Codecov + if: github.repository == 'meshery/helm-kanvas-snapshot' + uses: codecov/codecov-action@v4 + with: + files: ./coverage.txt + flags: gointegrationtests From d7f6ee3020e6bc315872b2ccb0079e7067deb10b Mon Sep 17 00:00:00 2001 From: Eti Ijeoma Date: Mon, 7 Oct 2024 14:17:28 +0100 Subject: [PATCH 05/16] replace meshery cookir with provider token Signed-off-by: Eti Ijeoma --- .../workflows/build-and-release-snapshot-plugin.yml | 7 ++----- .goreleaser.yml | 8 +++----- Makefile | 6 ++---- build/Makefile.core.mk | 4 +--- cmd/kanvas-snapshot/main.go | 10 +++------- 5 files changed, 11 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-and-release-snapshot-plugin.yml b/.github/workflows/build-and-release-snapshot-plugin.yml index 9017633da6..5deddcec94 100644 --- a/.github/workflows/build-and-release-snapshot-plugin.yml +++ b/.github/workflows/build-and-release-snapshot-plugin.yml @@ -34,11 +34,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RELEASE_CHANNEL: "stable" - MESHERY_CLOUD_API_COOKIE: ${{ secrets.MESHERY_CLOUD_API_COOKIE }} - MESHERY_API_COOKIE: ${{ secrets.MESHERY_API_COOKIE }} - MESHERY_CLOUD_API_BASE_URL: ${{ secrets.MESHERY_CLOUD_API_BASE_URL }} - MESHERY_API_BASE_URL: ${{ secrets.MESHERY_API_BASE_URL }} - SYSTEM_ID: ${{ secrets.SYSTEM_ID }} + PROVIDER_TOKEN: ${{ secrets.PROVIDER_TOKEN }} + with: version: '~> v2' args: release --clean --skip-validate diff --git a/.goreleaser.yml b/.goreleaser.yml index c2879d8a0a..68b6c58f08 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -12,11 +12,9 @@ builds: ldflags: - -s -w - - -X main.MesheryCloudApiCookie={{.Env.MESHERY_CLOUD_API_COOKIE}} - - -X main.MesheryApiCookie={{.Env.MESHERY_API_COOKIE}} - - -X main.MesheryCloudApiBaseUrl={{.Env.MESHERY_CLOUD_API_BASE_URL}} - - -X main.MesheryApiBaseUrl={{.Env.MESHERY_API_BASE_URL}} - - -X main.SystemID={{.Env.SYSTEM_ID}} + - -X main.providerToken=${{ .Env.PROVIDER_TOKEN }} + - -X main.MesheryCloudApiBaseUrl="https://meshery.layer5.io" + - -X main.MesheryApiBaseUrl="https://playground.meshery.io" goos: - darwin diff --git a/Makefile b/Makefile index cff3d0aedf..9288ead354 100644 --- a/Makefile +++ b/Makefile @@ -58,11 +58,9 @@ BINNAME_WINDOWS ?= kanvas-snapshot-windows-$(ARCH).exe LDFLAGS := "\ - -X 'main.MesheryCloudApiCookie=$(MESHERY_CLOUD_API_COOKIES)' \ - -X 'main.MesheryApiCookie=$(MESHERY_API_COOKIES)' \ + -X 'main.providerToken=$(PROVIDER_TOKEN)' \ -X 'main.MesheryCloudApiBaseUrl=$(MESHERY_CLOUD_API_BASE_URL)' \ - -X 'main.MesheryApiBaseUrl=$(MESHERY_API_BASE_URL)' \ - -X 'main.SystemID=$(SYSTEM_ID)'" + -X 'main.MesheryApiBaseUrl=$(MESHERY_API_BASE_URL)'" .PHONY: build build: diff --git a/build/Makefile.core.mk b/build/Makefile.core.mk index d20e5ca322..da52c51d42 100644 --- a/build/Makefile.core.mk +++ b/build/Makefile.core.mk @@ -1,6 +1,4 @@ GOVERSION = 1.23 -MESHERY_API_COOKIE="" -MESHERY_CLOUD_API_COOKIE="" +PROVIDER_TOKEN="" MESHERY_CLOUD_API_BASE_URL="http://localhost:9876" MESHERY_API_BASE_URL="http://localhost:3000" -SYSTEM_ID="ad8acecd-b742-4958-9af9-538c4183a177" diff --git a/cmd/kanvas-snapshot/main.go b/cmd/kanvas-snapshot/main.go index 279ad6a56c..fcfea0b04b 100644 --- a/cmd/kanvas-snapshot/main.go +++ b/cmd/kanvas-snapshot/main.go @@ -19,12 +19,9 @@ import ( ) var ( - MesheryToken string - MesheryCloudApiCookie string - MesheryApiCookie string + ProviderToken string MesheryApiBaseUrl string MesheryCloudApiBaseUrl string - SystemID string Log logger.Handler ) @@ -165,7 +162,7 @@ func CreateMesheryDesign(uri, name, email string) (string, error) { } // Set headers and log them - req.Header.Set("Cookie", MesheryApiCookie) + req.Header.Set("Cookie", ProviderToken) req.Header.Set("Origin", MesheryApiBaseUrl) req.Header.Set("Host", MesheryApiBaseUrl) req.Header.Set("Content-Type", "text/plain;charset=UTF-8") @@ -231,9 +228,8 @@ func GenerateSnapshot(designID, chartURI, email, assetLocation string) error { return err } - req.Header.Set("Cookie", MesheryCloudApiCookie) + req.Header.Set("Cookie", ProviderToken) req.Header.Set("Content-Type", "application/json") - req.Header.Set("SystemID", SystemID) req.Header.Set("Referer", fmt.Sprintf("%s/dashboard", MesheryCloudApiBaseUrl)) client := &http.Client{} From 8f84c269dc7dcdd76f9c317ffc6c0c09fd8ac854 Mon Sep 17 00:00:00 2001 From: Eti Ijeoma Date: Mon, 7 Oct 2024 14:40:49 +0100 Subject: [PATCH 06/16] update meshmap application url Signed-off-by: Eti Ijeoma --- .github/workflows/meshmap.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/meshmap.yml b/.github/workflows/meshmap.yml index 0b19d21c67..6912f78e70 100644 --- a/.github/workflows/meshmap.yml +++ b/.github/workflows/meshmap.yml @@ -42,5 +42,5 @@ jobs: githubToken: ${{ secrets.GITHUB_TOKEN }} # github's personal access token example: "ghp_...." mesheryToken: ${{ secrets.MESHERY_TOKEN }} # Meshery Cloud Authentication token, signin to meshery-cloud to get one, example: ey..... prNumber: ${{ env.PULL_NO }} # auto-filled from the above step - application_type: Kubernetes Manifest # your application type, could be any of three: "Kubernetes Manifest", "Docker Compose", "Helm Chart" - filePath: ${{ inputs.fileName == '' && 'install/deployment_yamls/k8s' || inputs.fileName }} # relative file-path from the root directory in the github-runner env, you might require to checkout the repository as described in step 2 + application_type: "Helm chart" # your application type, could be any of three: "Kubernetes Manifest", "Docker Compose", "Helm Chart" + application_url: "https://github.com/meshery/meshery.io/raw/refs/heads/master/charts/meshery-v0.7.110.tgz" From 6e8d45be0eac0167a4bf7cda74a91fe72ef4e469 Mon Sep 17 00:00:00 2001 From: Eti Ijeoma Date: Mon, 7 Oct 2024 14:55:26 +0100 Subject: [PATCH 07/16] upgrade meshmap snapshot version Signed-off-by: Eti Ijeoma --- .github/workflows/meshmap.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/meshmap.yml b/.github/workflows/meshmap.yml index 6912f78e70..db966e1f21 100644 --- a/.github/workflows/meshmap.yml +++ b/.github/workflows/meshmap.yml @@ -43,4 +43,4 @@ jobs: mesheryToken: ${{ secrets.MESHERY_TOKEN }} # Meshery Cloud Authentication token, signin to meshery-cloud to get one, example: ey..... prNumber: ${{ env.PULL_NO }} # auto-filled from the above step application_type: "Helm chart" # your application type, could be any of three: "Kubernetes Manifest", "Docker Compose", "Helm Chart" - application_url: "https://github.com/meshery/meshery.io/raw/refs/heads/master/charts/meshery-v0.7.110.tgz" + application_url: "https://github.com/meshery/meshery.io/raw/refs/heads/master/charts/meshery-v0.7.110.tgz" \ No newline at end of file From d4a5080d2b2db30465582e5ab1238ca3de80a58c Mon Sep 17 00:00:00 2001 From: Eti Ijeoma Date: Mon, 7 Oct 2024 14:57:31 +0100 Subject: [PATCH 08/16] use proper error code Signed-off-by: Eti Ijeoma --- internal/errors/error.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/errors/error.go b/internal/errors/error.go index 3ff49b8e0b..7338417035 100644 --- a/internal/errors/error.go +++ b/internal/errors/error.go @@ -7,13 +7,12 @@ import ( ) var ( - ErrInvalidChartURICode = "kanvas-snapshot-1000" - ErrCreatingMesheryDesignCode = "kanvas-snapshot-1001" - ErrGeneratingSnapshotCode = "kanvas-snapshot-1002" - ErrHTTPPostRequestCode = "kanvas-snapshot-1003" - ErrDecodingAPICode = "kanvas-snapshot-1004" - ErrRequiredFieldNotProvidedCode = "kanvas-snapshot-1005" - ErrUnexpectedResponseCodeCode = "kanvas-snapshot-1006" + ErrInvalidChartURICode = "kanvas-snapshot-900" + ErrCreatingMesheryDesignCode = "kanvas-snapshot-901" + ErrGeneratingSnapshotCode = "kanvas-snapshot-902" + ErrHTTPPostRequestCode = "kanvas-snapshot-903" + ErrDecodingAPICode = "kanvas-snapshot-905" + ErrUnexpectedResponseCodeCode = "kanvas-snapshot-906" ) func ErrInvalidChartURI(err error) error { From 7559b74132fc8d71658b0f4dbf1f116101ffc938 Mon Sep 17 00:00:00 2001 From: Lee Calcote Date: Tue, 8 Oct 2024 12:28:14 -0500 Subject: [PATCH 09/16] Update goreleaser config to v2; move config to .github folder Signed-off-by: Lee Calcote --- .goreleaser.yml => .github/.goreleaser.yml | 6 +++--- .github/workflows/build-and-release-snapshot-plugin.yml | 2 +- .github/workflows/golangci-lint.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename .goreleaser.yml => .github/.goreleaser.yml (91%) diff --git a/.goreleaser.yml b/.github/.goreleaser.yml similarity index 91% rename from .goreleaser.yml rename to .github/.goreleaser.yml index 68b6c58f08..c0f9a786c1 100644 --- a/.goreleaser.yml +++ b/.github/.goreleaser.yml @@ -1,5 +1,5 @@ project_name: kanvas-snapshot - +version: 2 before: hooks: - go mod tidy @@ -50,7 +50,7 @@ checksum: name_template: 'checksums.txt' snapshot: - name_template: "{{ .Tag }}-next" + version_template: "{{ .Tag }}-next" changelog: sort: asc @@ -60,4 +60,4 @@ changelog: - '^test:' release: - name_template: "Kanvas Snapshot {{.Tag}}" + name_template: "Helm Kanvas Snapshot {{.Tag}}" diff --git a/.github/workflows/build-and-release-snapshot-plugin.yml b/.github/workflows/build-and-release-snapshot-plugin.yml index 5deddcec94..bff6125138 100644 --- a/.github/workflows/build-and-release-snapshot-plugin.yml +++ b/.github/workflows/build-and-release-snapshot-plugin.yml @@ -38,4 +38,4 @@ jobs: with: version: '~> v2' - args: release --clean --skip-validate + args: release --clean --skip-validate -f .github/.goreleaser.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 9ab267d962..fff402e2c0 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -64,4 +64,4 @@ jobs: RELEASE_CHANNEL: "edge" with: version: latest - args: release --snapshot --skip-publish --clean + args: release --snapshot --skip-publish --clean -f .github/.goreleaser.yml From c645b8aa83f7b6b183e155e3e43d70805a8ef648 Mon Sep 17 00:00:00 2001 From: Lee Calcote Date: Tue, 8 Oct 2024 12:37:35 -0500 Subject: [PATCH 10/16] [chore] update goreleaser --skip parameter for v2 compliance Signed-off-by: Lee Calcote --- .github/workflows/build-and-release-snapshot-plugin.yml | 2 +- .github/workflows/golangci-lint.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release-snapshot-plugin.yml b/.github/workflows/build-and-release-snapshot-plugin.yml index bff6125138..bb40bb60e5 100644 --- a/.github/workflows/build-and-release-snapshot-plugin.yml +++ b/.github/workflows/build-and-release-snapshot-plugin.yml @@ -38,4 +38,4 @@ jobs: with: version: '~> v2' - args: release --clean --skip-validate -f .github/.goreleaser.yml + args: release --clean --skip validate -f .github/.goreleaser.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index fff402e2c0..43a70ea682 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -64,4 +64,4 @@ jobs: RELEASE_CHANNEL: "edge" with: version: latest - args: release --snapshot --skip-publish --clean -f .github/.goreleaser.yml + args: release --snapshot --skip publish --clean -f .github/.goreleaser.yml From f0f894929e50e6ede1b995cdaf4a5a34712303da Mon Sep 17 00:00:00 2001 From: Lee Calcote Date: Tue, 8 Oct 2024 12:53:50 -0500 Subject: [PATCH 11/16] Set default provider_token value Signed-off-by: Lee Calcote --- build/Makefile.core.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Makefile.core.mk b/build/Makefile.core.mk index da52c51d42..543b87375f 100644 --- a/build/Makefile.core.mk +++ b/build/Makefile.core.mk @@ -1,4 +1,4 @@ GOVERSION = 1.23 -PROVIDER_TOKEN="" +PROVIDER_TOKEN="dev_token" MESHERY_CLOUD_API_BASE_URL="http://localhost:9876" MESHERY_API_BASE_URL="http://localhost:3000" From 2f3163e8b49eabb50171c8e86ccdcdd8276a20b9 Mon Sep 17 00:00:00 2001 From: Lee Calcote Date: Tue, 8 Oct 2024 12:57:14 -0500 Subject: [PATCH 12/16] Change PROVIDER_TOKEN reference Signed-off-by: Lee Calcote --- .github/.goreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/.goreleaser.yml b/.github/.goreleaser.yml index c0f9a786c1..6425cc8c65 100644 --- a/.github/.goreleaser.yml +++ b/.github/.goreleaser.yml @@ -12,7 +12,7 @@ builds: ldflags: - -s -w - - -X main.providerToken=${{ .Env.PROVIDER_TOKEN }} + - -X main.providerToken={{ .Env.PROVIDER_TOKEN }} - -X main.MesheryCloudApiBaseUrl="https://meshery.layer5.io" - -X main.MesheryApiBaseUrl="https://playground.meshery.io" From c301ef8b53109e390a4435206be95c2fb2f45174 Mon Sep 17 00:00:00 2001 From: Lee Calcote Date: Tue, 8 Oct 2024 12:59:13 -0500 Subject: [PATCH 13/16] Update go-testing-ci.yml to disable caching during setup-go action Signed-off-by: Lee Calcote --- .github/workflows/go-testing-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/go-testing-ci.yml b/.github/workflows/go-testing-ci.yml index 41d6935cd2..43c917c4ab 100644 --- a/.github/workflows/go-testing-ci.yml +++ b/.github/workflows/go-testing-ci.yml @@ -30,6 +30,7 @@ jobs: - uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} + cache: false - uses: actions/checkout@v4 - name: golangci-lint uses: golangci/golangci-lint-action@v6 From eead3bff731183b90f6fbbb80393ceee34df5992 Mon Sep 17 00:00:00 2001 From: Lee Calcote Date: Tue, 8 Oct 2024 13:02:08 -0500 Subject: [PATCH 14/16] Update goreleaser config to v2; move config to .github folder Signed-off-by: Lee Calcote --- .github/workflows/golangci-lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 43a70ea682..b31293ae70 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -58,10 +58,10 @@ jobs: restore-keys: | ${{ runner.os }}-go- - name: goreleaser WITHOUT tag - uses: goreleaser/goreleaser-action@v5 + uses: goreleaser/goreleaser-action@v6 if: success() && startsWith(github.ref, 'refs/tags/') == false env: RELEASE_CHANNEL: "edge" with: - version: latest + version: 2 args: release --snapshot --skip publish --clean -f .github/.goreleaser.yml From 805de3bcd56d1e47b92315d674bbf8649e888fce Mon Sep 17 00:00:00 2001 From: Lee Calcote Date: Tue, 8 Oct 2024 13:03:55 -0500 Subject: [PATCH 15/16] rm meshmap.yaml. This can be setup later post-merge of PR #33 Signed-off-by: Lee Calcote --- .github/workflows/meshmap.yml | 46 ----------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 .github/workflows/meshmap.yml diff --git a/.github/workflows/meshmap.yml b/.github/workflows/meshmap.yml deleted file mode 100644 index db966e1f21..0000000000 --- a/.github/workflows/meshmap.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Kanvas Snapshot Service -on: # rebuild any PRs and main branch changes - pull_request_target: - types: [opened, synchronize, reopened] - - workflow_call: - inputs: - fileName: - description: Relative file path from the root directory - required: true - type: string - outputs: - resource_url: - description: "The URL of the generated resource." - value: ${{ jobs.MeshMapScreenshot.outputs.resource_url }} -permissions: - actions: read - contents: write - security-events: write - statuses: write - pull-requests: write - id-token: write - -jobs: - MeshMapScreenshot: - runs-on: ubuntu-latest - outputs: - resource_url: ${{ steps.test_result.outputs.resource_url }} - steps: - - name: Set PR number # To comment the final status on the Pull-request opened in any repository - run: | - export pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") - echo "PULL_NO=$pull_number" >> $GITHUB_ENV - - uses: actions/checkout@v4 - - uses: actions/checkout@v4 #this step would go away - with: - path: action - repository: layer5labs/kanvas-snapshot - - id: test_result - uses: layer5labs/kanvas-snapshot@v0.2.13 - with: - githubToken: ${{ secrets.GITHUB_TOKEN }} # github's personal access token example: "ghp_...." - mesheryToken: ${{ secrets.MESHERY_TOKEN }} # Meshery Cloud Authentication token, signin to meshery-cloud to get one, example: ey..... - prNumber: ${{ env.PULL_NO }} # auto-filled from the above step - application_type: "Helm chart" # your application type, could be any of three: "Kubernetes Manifest", "Docker Compose", "Helm Chart" - application_url: "https://github.com/meshery/meshery.io/raw/refs/heads/master/charts/meshery-v0.7.110.tgz" \ No newline at end of file From 90135047c26c6ae8dd3847f730e105a1f51ab001 Mon Sep 17 00:00:00 2001 From: Lee Calcote Date: Tue, 8 Oct 2024 13:11:43 -0500 Subject: [PATCH 16/16] Update goreleaser config to v2; fix providerToken reference Signed-off-by: Lee Calcote --- .github/.goreleaser.yml | 2 +- .github/workflows/build-and-release-snapshot-plugin.yml | 2 +- .github/workflows/go-testing-ci.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/.goreleaser.yml b/.github/.goreleaser.yml index 6425cc8c65..bed8c71424 100644 --- a/.github/.goreleaser.yml +++ b/.github/.goreleaser.yml @@ -12,7 +12,7 @@ builds: ldflags: - -s -w - - -X main.providerToken={{ .Env.PROVIDER_TOKEN }} + - -X main.providerToken={{.Env.PROVIDER_TOKEN}} - -X main.MesheryCloudApiBaseUrl="https://meshery.layer5.io" - -X main.MesheryApiBaseUrl="https://playground.meshery.io" diff --git a/.github/workflows/build-and-release-snapshot-plugin.yml b/.github/workflows/build-and-release-snapshot-plugin.yml index bb40bb60e5..015ab25224 100644 --- a/.github/workflows/build-and-release-snapshot-plugin.yml +++ b/.github/workflows/build-and-release-snapshot-plugin.yml @@ -37,5 +37,5 @@ jobs: PROVIDER_TOKEN: ${{ secrets.PROVIDER_TOKEN }} with: - version: '~> v2' + version: 2 args: release --clean --skip validate -f .github/.goreleaser.yml diff --git a/.github/workflows/go-testing-ci.yml b/.github/workflows/go-testing-ci.yml index 43c917c4ab..4919f6cb16 100644 --- a/.github/workflows/go-testing-ci.yml +++ b/.github/workflows/go-testing-ci.yml @@ -53,7 +53,7 @@ jobs: run: go test --short ./... -race -coverprofile=coverage.txt -covermode=atomic - name: Upload coverage to Codecov if: github.repository == 'meshery/helm-kanvas-snapshot' - uses: codecov/codecov-action@v4.3.0 + uses: codecov/codecov-action@v4 with: files: ./coverage.txt flags: unittests