Skip to content

Commit

Permalink
fix(OpenPipeline): Remove version and updateToken on download
Browse files Browse the repository at this point in the history
Both fields prevent a re-upload to the target environment, thus we remove them. Neither of them are required to correctly reupload them, the Dynatrace system takes care of it.
  • Loading branch information
Laubi committed Nov 14, 2024
1 parent e565222 commit 21c774b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions pkg/download/openpipeline/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package openpipeline
import (
"context"
"fmt"

"github.com/dynatrace/dynatrace-configuration-as-code-core/clients/openpipeline"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/log"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/log/field"
Expand Down Expand Up @@ -65,6 +66,10 @@ func createConfig(projectName string, response openpipeline.Response) (config.Co
return config.Config{}, fmt.Errorf("failed to extract id as string from payload")
}

// delete fields that prevent a re-upload of the configuration
jsonObj.Delete("version")
jsonObj.Delete("updateToken")

jsonRaw, err := jsonObj.ToJSON(true)
if err != nil {
return config.Config{}, fmt.Errorf("failed to marshal payload: %w", err)
Expand Down
14 changes: 8 additions & 6 deletions pkg/download/openpipeline/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
package openpipeline

import (
"net/http"
"os"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/dynatrace/dynatrace-configuration-as-code-core/api/rest"
"github.com/dynatrace/dynatrace-configuration-as-code-core/clients/openpipeline"
"github.com/dynatrace/dynatrace-configuration-as-code-core/testutils"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config/coordinate"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config/template"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"net/http"
"os"
"testing"
)

func TestDownloader_Download(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion pkg/download/openpipeline/testdata/getEvents.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"id": "events"
"id": "events",
"version": "1234567890-12345678890",
"updateToken": "VGhpcyBpcyBub3QgYSByZWFsIHVwZGF0ZVRva2VuICjila/CsOKWocKwKeKVr++4tSDilLvilIHilLs="
}
4 changes: 3 additions & 1 deletion pkg/download/openpipeline/testdata/getLogs.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"id": "logs"
"id": "logs",
"version": "1234567890-12345678890",
"updateToken": "VGhpcyBpcyBub3QgYSByZWFsIHVwZGF0ZVRva2VuICjila/CsOKWocKwKeKVr++4tSDilLvilIHilLs="
}

0 comments on commit 21c774b

Please sign in to comment.