Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/cmd/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ func attruuid(ctx context.Context, s *sdk.SDK, nsu, fqn string) (string, error)
}

func avuuid(ctx context.Context, s *sdk.SDK, auuid, vs string) (string, error) {
resp, err := s.Attributes.GetAttribute(ctx, &attributes.GetAttributeRequest{Id: auuid})
req := &attributes.GetAttributeRequest{
//nolint:staticcheck // the deprecated Id field is kept here deliberately; migrating to the identifier oneof is tracked separately
Id: auuid,
}
resp, err := s.Attributes.GetAttribute(ctx, req)
if err != nil {
slog.Error("failed to GetAttribute", slog.Any("error", err))
return "", errors.Join(err, ErrInvalidArgument)
Expand Down
4 changes: 2 additions & 2 deletions examples/cmd/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var config BenchmarkConfig
func init() {
benchmarkCmd := &cobra.Command{
Use: "benchmark",
Short: "OpenTDF benchmark tool",
Short: benchmarkCmdShort,
Long: `A OpenTDF benchmark tool to measure throughput and latency with configurable concurrency.`,
RunE: runBenchmark,
}
Expand Down Expand Up @@ -68,7 +68,7 @@ func runBenchmark(cmd *cobra.Command, _ []string) error {
}
}()

dataAttributes := []string{"https://example.com/attr/attr1/value/value1"}
dataAttributes := []string{exampleAttrValueFQN}
opts := []sdk.TDFOption{sdk.WithDataAttributes(dataAttributes...), sdk.WithAutoconfigure(false)}
if insecurePlaintextConn || strings.HasPrefix(platformEndpoint, "http://") {
opts = append(opts, sdk.WithKasInformation(
Expand Down
4 changes: 2 additions & 2 deletions examples/cmd/benchmark_bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
func init() {
benchmarkCmd := &cobra.Command{
Use: "benchmark-bulk",
Short: "OpenTDF benchmark tool",
Short: benchmarkCmdShort,
Long: `A OpenTDF benchmark tool to measure Bulk Rewrap.`,
RunE: runBenchmarkBulk,
}
Expand Down Expand Up @@ -49,7 +49,7 @@ func runBenchmarkBulk(cmd *cobra.Command, _ []string) error {
}
}()

dataAttributes := []string{"https://example.com/attr/attr1/value/value1"}
dataAttributes := []string{exampleAttrValueFQN}
opts := []sdk.TDFOption{sdk.WithDataAttributes(dataAttributes...), sdk.WithAutoconfigure(false)}
if insecurePlaintextConn || strings.HasPrefix(platformEndpoint, "http://") {
opts = append(opts, sdk.WithKasInformation(
Expand Down
4 changes: 2 additions & 2 deletions examples/cmd/benchmark_decision.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func init() {
benchmarkCmd := &cobra.Command{
Use: "benchmark-decision",
Short: "OpenTDF benchmark tool",
Short: benchmarkCmdShort,
Long: `A OpenTDF benchmark tool to measure throughput and latency with configurable concurrency.`,
RunE: runDecisionBenchmark,
}
Expand All @@ -31,7 +31,7 @@ func runDecisionBenchmark(_ *cobra.Command, _ []string) error {

ras := []*authorization.ResourceAttribute{}
for i := 0; i < config.RequestCount; i++ {
ras = append(ras, &authorization.ResourceAttribute{AttributeValueFqns: []string{"https://example.com/attr/attr1/value/value1"}})
ras = append(ras, &authorization.ResourceAttribute{AttributeValueFqns: []string{exampleAttrValueFQN}})
}

start := time.Now()
Expand Down
3 changes: 1 addition & 2 deletions examples/cmd/benchmark_decision_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ func runDecisionBenchmarkV2(_ *cobra.Command, _ []string) error {
}

var resources []*authzV2.Resource
attrValueFQN := "https://example.com/attr/attr1/value/value1"

for i := range config.RequestCount {
r := &authzV2.Resource{
EphemeralId: "resource-%d" + strconv.Itoa(i),
Resource: &authzV2.Resource_AttributeValues_{
AttributeValues: &authzV2.Resource_AttributeValues{
Fqns: []string{attrValueFQN},
Fqns: []string{exampleAttrValueFQN},
},
},
}
Expand Down
3 changes: 1 addition & 2 deletions examples/cmd/benchmark_experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
var (
payloadSize int
segmentChunk int
testAttr = "https://example.com/attr/attr1/value/value1"
)

func init() {
Expand Down Expand Up @@ -65,7 +64,7 @@ func runExperimentalWriterBenchmark(_ *cobra.Command, _ []string) error {
},
}

attrs = append(attrs, &policy.Value{Fqn: testAttr, KasKeys: []*policy.SimpleKasKey{simpleyKey}, Attribute: &policy.Attribute{Namespace: &policy.Namespace{Name: "example.com"}, Fqn: testAttr}})
attrs = append(attrs, &policy.Value{Fqn: exampleAttrValueFQN, KasKeys: []*policy.SimpleKasKey{simpleyKey}, Attribute: &policy.Attribute{Namespace: &policy.Namespace{Name: "example.com"}, Fqn: exampleAttrValueFQN}})
writer, err := tdf.NewWriter(context.Background(), tdf.WithDefaultKASForWriter(simpleyKey), tdf.WithInitialAttributes(attrs), tdf.WithSegmentIntegrityAlgorithm(tdf.HS256))
if err != nil {
return fmt.Errorf("failed to create writer: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion examples/cmd/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func init() {
RunE: encrypt,
Args: cobra.MinimumNArgs(1),
}
encryptCmd.Flags().StringSliceVarP(&dataAttributes, "data-attributes", "a", []string{"https://example.com/attr/attr1/value/value1"}, "space separated list of data attributes")
encryptCmd.Flags().StringSliceVarP(&dataAttributes, "data-attributes", "a", []string{exampleAttrValueFQN}, "space separated list of data attributes")
encryptCmd.Flags().BoolVar(&autoconfigure, "autoconfigure", true, "Use attribute grants to select kases")
encryptCmd.Flags().BoolVar(&noKIDInKAO, "no-kid-in-kao", false, "[deprecated] Disable storing key identifiers in TDF KAOs")
encryptCmd.Flags().StringVarP(&outputName, "output", "o", "sensitive.txt.tdf", "name or path of output file; - for stdout")
Expand Down
7 changes: 7 additions & 0 deletions examples/cmd/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import (
"github.com/spf13/cobra"
)

const (
// benchmarkCmdShort is the one-line description shared by the benchmark subcommands.
benchmarkCmdShort = "OpenTDF benchmark tool"
// exampleAttrValueFQN is the attribute value FQN the examples default to.
exampleAttrValueFQN = "https://example.com/attr/attr1/value/value1"
)

var (
platformEndpoint string
clientCredentials string
Expand Down
Loading