Skip to content

Commit 4dd22f7

Browse files
base64 decode string before unmarhsalling json
1 parent eac622f commit 4dd22f7

File tree

7 files changed

+16
-7
lines changed

7 files changed

+16
-7
lines changed

examples/dotnet/provider-defang.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88
<ItemGroup>
99
<PackageReference Include="Pulumi" Version="3.*" />
10-
<PackageReference Include="DefangLabs.Defang" Version="1.2.0-alpha.1744682110" />
10+
<PackageReference Include="DefangLabs.Defang" Version="1.2.0-alpha.1744826391" />
1111
</ItemGroup>
1212

1313
</Project>

examples/go/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ go 1.20
44

55
require (
66
github.com/pulumi/pulumi/sdk/v3 v3.30.0
7-
github.com/DefangLabs/pulumi-defang/sdk v1.2.0-alpha.1744682110
7+
github.com/DefangLabs/pulumi-defang/sdk v1.2.0-alpha.1744826391
88
)

examples/nodejs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"dependencies": {
77
"typescript": "^4.0.0",
88
"@pulumi/pulumi": "^3.0.0",
9-
"@defang-io/pulumi-defang": "1.2.0-alpha.1744682110"
9+
"@defang-io/pulumi-defang": "1.2.0-alpha.1744826391"
1010
}
1111
}

examples/python/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pulumi-defang==1.2.0-alpha.1744682110
1+
pulumi-defang==1.2.0-alpha.1744826391
22
pulumi>=3.0.0,<4.0.0

provider/cmd/pulumi-resource-defang/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "defang",
3-
"version": "1.1.0-beta.9",
3+
"version": "1.1.0-beta.10",
44
"description": "Take your app from Docker Compose to a secure and scalable cloud deployment with Pulumi.",
55
"keywords": [
66
"category/cloud",

provider/project.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package provider
1616

1717
import (
1818
"context"
19+
"encoding/base64"
1920
"encoding/json"
2021
"errors"
2122
"fmt"
@@ -279,8 +280,13 @@ func getProjectState(etag string, projectUpdate *defangv1.ProjectUpdate) (Projec
279280
return state, errNilProjectOutputs
280281
}
281282

283+
decodedProjectOutputs, err := base64.StdEncoding.DecodeString(string(projectOutputs))
284+
if err != nil {
285+
return state, fmt.Errorf("failed to base64 decode project outputs: %w", err)
286+
}
287+
282288
var v1DefangProjectOutputs V1DefangProjectOutputs
283-
err := json.Unmarshal(projectOutputs, &v1DefangProjectOutputs)
289+
err = json.Unmarshal(decodedProjectOutputs, &v1DefangProjectOutputs)
284290
if err != nil {
285291
return state, fmt.Errorf("failed to unmarshal project update outputs: %w", err)
286292
}

tests/cloud_provider_mock.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package tests
22

33
import (
44
"context"
5+
"encoding/base64"
56
"encoding/json"
67
"fmt"
78

@@ -159,6 +160,8 @@ func (c CloudProviderMock) GetProjectUpdate(context.Context, string) (*defangv1.
159160
return nil, fmt.Errorf("failed to marshal project outputs: %w", err)
160161
}
161162

163+
encodedProjectOutputs := base64.StdEncoding.EncodeToString(projectOutputsJSON)
164+
162165
return &defangv1.ProjectUpdate{
163166
AlbArn: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188",
164167
Services: []*defangv1.ServiceInfo{
@@ -170,7 +173,7 @@ func (c CloudProviderMock) GetProjectUpdate(context.Context, string) (*defangv1.
170173
},
171174
},
172175
ProjectOutputsVersion: 1,
173-
ProjectOutputs: projectOutputsJSON,
176+
ProjectOutputs: []byte(encodedProjectOutputs),
174177
}, nil
175178
}
176179

0 commit comments

Comments
 (0)