Revert "De-base64 SourceUnit.UnitData in the GitHub Source (#5248)" (#5269)
Lint / golangci-lint (push) Waiting to run
Lint / man-page-staleness (push) Waiting to run
Lint / semgrep (push) Waiting to run
Lint / checksecretparts (push) Waiting to run
Scan for secrets / test (push) Waiting to run
Test / test-community (push) Waiting to run
Test / test (push) Waiting to run
Release / mark-latest (push) Canceled after 0s
Release / Release (push) Canceled after 0s
Lint / golangci-lint (push) Waiting to run
Lint / man-page-staleness (push) Waiting to run
Lint / semgrep (push) Waiting to run
Lint / checksecretparts (push) Waiting to run
Scan for secrets / test (push) Waiting to run
Test / test-community (push) Waiting to run
Test / test (push) Waiting to run
Release / mark-latest (push) Canceled after 0s
Release / Release (push) Canceled after 0s
This reverts commit 0c952ace0f.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package github
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -130,12 +129,6 @@ type unitEnvelope struct {
|
||||
func (u unitEnvelope) SourceUnitID() (string, sources.SourceUnitKind) { return u.ID, u.Kind }
|
||||
func (u unitEnvelope) Display() string { return u.Name }
|
||||
|
||||
func decodeBase64(data []byte) ([]byte, error) {
|
||||
out := make([]byte, base64.StdEncoding.DecodedLen(len(data)))
|
||||
n, err := base64.StdEncoding.Decode(out, data)
|
||||
return out[:n], err
|
||||
}
|
||||
|
||||
func unmarshalSourceUnit[unitType sources.SourceUnit](data []byte) (unitType, error) {
|
||||
u := new(unitType)
|
||||
|
||||
@@ -171,20 +164,12 @@ func (s *Source) UnmarshalSourceUnit(data []byte) (sources.SourceUnit, error) {
|
||||
return env, nil
|
||||
case "repo":
|
||||
if len(env.UnitData) > 0 {
|
||||
decodedData, err := decodeBase64(env.UnitData)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error decoding repo unit data: %w", err)
|
||||
}
|
||||
return unmarshalSourceUnit[RepoUnit](decodedData)
|
||||
return unmarshalSourceUnit[RepoUnit](env.UnitData)
|
||||
}
|
||||
return RepoUnit{Name: env.Name, URL: env.ID}, nil
|
||||
case "gist":
|
||||
decodedData, err := decodeBase64(env.UnitData)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error decoding gist unit data: %w", err)
|
||||
}
|
||||
if len(env.UnitData) > 0 {
|
||||
return unmarshalSourceUnit[GistUnit](decodedData)
|
||||
return unmarshalSourceUnit[GistUnit](env.UnitData)
|
||||
}
|
||||
return GistUnit{Name: env.Name, URL: env.ID}, nil
|
||||
default:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package github
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@@ -25,9 +24,6 @@ func newMarshalledRepoUnit(t *testing.T, su sources.SourceUnit) []byte {
|
||||
unitData, err := json.Marshal(su)
|
||||
require.NoError(t, err)
|
||||
|
||||
// [CG] This additional base64 encoding mimics the pipeline's behavior
|
||||
unitData = []byte(base64.StdEncoding.EncodeToString(unitData))
|
||||
|
||||
out, err := json.Marshal(map[string]any{
|
||||
"id": id,
|
||||
"kind": string(kind),
|
||||
|
||||
Reference in New Issue
Block a user