-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply secrets to function result properties marked as such
- Loading branch information
1 parent
c63d6b6
commit ccaf7eb
Showing
4 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2024, Pulumi Corporation. | ||
// | ||
// 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. | ||
|
||
package tests | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/blang/semver" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
p "github.com/pulumi/pulumi-go-provider" | ||
"github.com/pulumi/pulumi-go-provider/infer" | ||
"github.com/pulumi/pulumi-go-provider/integration" | ||
"github.com/pulumi/pulumi/sdk/v3/go/common/resource" | ||
) | ||
|
||
type inv struct{} | ||
|
||
type invInput struct { | ||
Field string `pulumi:"field"` | ||
} | ||
|
||
type invOutput struct { | ||
Out string `pulumi:"out" provider:"secret"` | ||
} | ||
|
||
func (inv) Call(ctx context.Context, args invInput) (invOutput, error) { | ||
return invOutput{ | ||
Out: args.Field + "-secret", | ||
}, nil | ||
} | ||
|
||
var _ infer.Annotated = inv{} | ||
|
||
func (c inv) Annotate(a infer.Annotator) { a.SetToken("index", "inv") } | ||
|
||
func TestInferInvokeSecrets(t *testing.T) { | ||
t.Parallel() | ||
|
||
resp, err := integration.NewServer("test", semver.MustParse("0.0.0"), infer.Provider(infer.Options{ | ||
Functions: []infer.InferredFunction{ | ||
infer.Function[inv, invInput, invOutput](), | ||
}, | ||
})).Invoke(p.InvokeRequest{ | ||
Token: "test:index:inv", | ||
Args: map[resource.PropertyKey]resource.PropertyValue{ | ||
"field": resource.NewProperty("value"), | ||
}, | ||
}) | ||
require.NoError(t, err) | ||
require.Empty(t, resp.Failures) | ||
assert.Equal(t, resource.PropertyMap{ | ||
"out": resource.MakeSecret(resource.NewProperty("value-secret")), | ||
}, resp.Return) | ||
} |