From 3d9d7d0723bf2b52118a149404ab4bca98ac41a9 Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Wed, 13 Mar 2024 16:57:36 -0400 Subject: [PATCH 01/13] consume latest changes in platform generated code throughout CLI --- cmd/dev.go | 3 - cmd/policy-attributes.go | 6 +- cmd/policy-namespaces.go | 1 - ...appings.go => policy-resource_mappings.go} | 12 +-- cmd/policy-subject_condition_sets.go | 1 + cmd/policy-subject_mappings.go | 19 ++-- go.mod | 67 +++++++----- go.sum | 100 ++++++++++++++++++ pkg/cli/sdkHelpers.go | 4 +- pkg/handlers/attribute.go | 43 ++++---- pkg/handlers/attribute_values.go | 7 +- pkg/handlers/kas-registry.go | 26 +---- pkg/handlers/namespaces.go | 13 +-- pkg/handlers/resourceMappings.go | 27 +++-- pkg/handlers/sdk.go | 17 +-- pkg/handlers/subjectmappings.go | 29 ++--- 16 files changed, 224 insertions(+), 151 deletions(-) rename cmd/{policy-resourceMappings.go => policy-resource_mappings.go} (91%) create mode 100644 cmd/policy-subject_condition_sets.go diff --git a/cmd/dev.go b/cmd/dev.go index a988d8fa..dd549894 100644 --- a/cmd/dev.go +++ b/cmd/dev.go @@ -59,9 +59,6 @@ func getMetadataRows(m *common.Metadata) [][]string { } metadataRows = append(metadataRows, []string{"Labels", cli.CommaSeparated(labelRows)}) } - if m.Description != "" { - metadataRows = append(metadataRows, []string{"Description", m.Description}) - } return metadataRows } return nil diff --git a/cmd/policy-attributes.go b/cmd/policy-attributes.go index b2b22ac3..2f57ad0e 100644 --- a/cmd/policy-attributes.go +++ b/cmd/policy-attributes.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/opentdf/platform/protocol/go/policy/attributes" + "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/tructl/pkg/cli" "github.com/spf13/cobra" ) @@ -51,7 +51,7 @@ used to define the access controls based on subject encodings and entity entitle } // create attribute values - attrValues := make([]*attributes.Value, 0, len(values)) + attrValues := make([]*policy.Value, 0, len(values)) valueErrors := make(map[string]error) for _, value := range values { v, err := h.CreateAttributeValue(attr.Id, value) @@ -61,7 +61,7 @@ used to define the access controls based on subject encodings and entity entitle attrValues = append(attrValues, v) } - a := cli.GetSimpleAttribute(&attributes.Attribute{ + a := cli.GetSimpleAttribute(&policy.Attribute{ Id: attr.Id, Name: attr.Name, Rule: attr.Rule, diff --git a/cmd/policy-namespaces.go b/cmd/policy-namespaces.go index 0b093e47..46a89963 100644 --- a/cmd/policy-namespaces.go +++ b/cmd/policy-namespaces.go @@ -157,7 +157,6 @@ or different attributes tied to each. if _, err := h.UpdateNamespace( id, - name, ); err != nil { cli.ExitWithError("Could not update namespace", err) } diff --git a/cmd/policy-resourceMappings.go b/cmd/policy-resource_mappings.go similarity index 91% rename from cmd/policy-resourceMappings.go rename to cmd/policy-resource_mappings.go index 97a63b5e..c78b8745 100644 --- a/cmd/policy-resourceMappings.go +++ b/cmd/policy-resource_mappings.go @@ -47,7 +47,7 @@ var ( fmt.Println(cli.SuccessMessage("Resource mapping created")) fmt.Println(cli.NewTabular().Rows([][]string{ {"Id", resourceMapping.Id}, - {"Attribute Id", resourceMapping.AttributeValue.AttributeId}, + {"Attribute Value Id", resourceMapping.AttributeValue.Id}, {"Attribute Value", resourceMapping.AttributeValue.Value}, {"Terms", strings.Join(resourceMapping.Terms, ", ")}, }...).Render()) @@ -71,7 +71,7 @@ var ( fmt.Println(cli.NewTabular().Rows([][]string{ {"Id", resourceMapping.Id}, - {"Attribute Id", resourceMapping.AttributeValue.AttributeId}, + {"Attribute Value Id", resourceMapping.AttributeValue.Id}, {"Attribute Value", resourceMapping.AttributeValue.Value}, {"Terms", strings.Join(resourceMapping.Terms, ", ")}, }...).Render()) @@ -91,9 +91,9 @@ var ( } t := cli.NewTable() - t.Headers("Id", "Attribute Id", "Attribute Value", "Terms") + t.Headers("Id", "Attribute Value Id", "Attribute Value", "Terms") for _, resourceMapping := range r { - t.Row(resourceMapping.Id, resourceMapping.AttributeValue.AttributeId, resourceMapping.AttributeValue.Value, strings.Join(resourceMapping.Terms, ", ")) + t.Row(resourceMapping.Id, resourceMapping.AttributeValue.Id, resourceMapping.AttributeValue.Value, strings.Join(resourceMapping.Terms, ", ")) } fmt.Println(t.Render()) }, @@ -119,7 +119,7 @@ var ( fmt.Println(cli.SuccessMessage("Resource mapping updated")) fmt.Println(cli.NewTabular().Rows([][]string{ {"Id", resourceMapping.Id}, - {"Attribute Id", resourceMapping.AttributeValue.AttributeId}, + {"Attribute Value Id", resourceMapping.AttributeValue.Id}, {"Attribute Value", resourceMapping.AttributeValue.Value}, {"Terms", strings.Join(resourceMapping.Terms, ", ")}, }...).Render()) @@ -146,7 +146,7 @@ var ( fmt.Println(cli.SuccessMessage("Resource mapping deleted")) fmt.Println(cli.NewTabular().Rows([][]string{ {"Id", resourceMapping.Id}, - {"Attribute Id", resourceMapping.AttributeValue.AttributeId}, + {"Attribute Value Id", resourceMapping.AttributeValue.Id}, {"Attribute Value", resourceMapping.AttributeValue.Value}, {"Terms", strings.Join(resourceMapping.Terms, ", ")}, }...).Render()) diff --git a/cmd/policy-subject_condition_sets.go b/cmd/policy-subject_condition_sets.go new file mode 100644 index 00000000..1d619dd0 --- /dev/null +++ b/cmd/policy-subject_condition_sets.go @@ -0,0 +1 @@ +package cmd diff --git a/cmd/policy-subject_mappings.go b/cmd/policy-subject_mappings.go index 04d8f17b..69b4ebaf 100644 --- a/cmd/policy-subject_mappings.go +++ b/cmd/policy-subject_mappings.go @@ -1,13 +1,16 @@ package cmd -import ( - // "encoding/json" - "fmt" - // "strings" - // "github.com/opentdf/tructl/pkg/cli" - // "github.com/opentdf/tructl/pkg/handlers" - // "github.com/spf13/cobra" -) +import "fmt" + +// import ( +// "encoding/json" +// "fmt" +// "strings" + +// "github.com/opentdf/tructl/pkg/cli" +// "github.com/opentdf/tructl/pkg/handlers" +// "github.com/spf13/cobra" +// ) // var ( // policy_subjectMappingsCmds = []string{ diff --git a/go.mod b/go.mod index 244516ed..73f1a3ac 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/opentdf/tructl -go 1.21.7 +go 1.21.8 toolchain go1.22.0 @@ -11,14 +11,14 @@ require ( github.com/charmbracelet/huh v0.3.0 github.com/charmbracelet/lipgloss v0.9.1 github.com/muesli/reflow v0.3.0 - github.com/opentdf/platform/protocol/go v0.0.0-20240301211102-04107b3757a9 - github.com/opentdf/platform/sdk v0.0.0-20240305152130-b34c2fe9ad70 + github.com/opentdf/platform/protocol/go v0.0.0-20240313200110-bcc04e006182 + github.com/opentdf/platform/sdk v0.0.0-20240313200110-bcc04e006182 github.com/spf13/cobra v1.8.0 - google.golang.org/grpc v1.61.0 + google.golang.org/grpc v1.62.1 ) require ( - buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1 // indirect + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/BurntSushi/toml v0.3.1 // indirect github.com/atotto/clipboard v0.1.4 // indirect @@ -26,59 +26,74 @@ require ( github.com/catppuccin/go v0.2.0 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/coreos/go-oidc/v3 v3.9.0 // indirect + github.com/creasty/defaults v1.7.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect - github.com/go-jose/go-jose/v3 v3.0.1 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/go-jose/go-jose/v3 v3.0.3 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/klauspost/compress v1.17.2 // indirect github.com/lestrrat-go/blackmagic v1.0.2 // indirect github.com/lestrrat-go/httpcc v1.0.1 // indirect - github.com/lestrrat-go/httprc v1.0.4 // indirect + github.com/lestrrat-go/httprc v1.0.5 // indirect github.com/lestrrat-go/iter v1.0.2 // indirect - github.com/lestrrat-go/jwx/v2 v2.0.19 // indirect + github.com/lestrrat-go/jwx/v2 v2.0.21 // indirect github.com/lestrrat-go/option v1.0.1 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect + github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/termenv v0.15.2 // indirect - github.com/opentdf/backend-go v0.1.16 // indirect + github.com/opentdf/backend-go v0.1.17 // indirect + github.com/pelletier/go-toml/v2 v2.1.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/rivo/uniseg v0.4.4 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/sagikazarmark/locafero v0.4.0 // indirect + github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f // indirect github.com/segmentio/asm v1.2.0 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect + github.com/spf13/afero v1.11.0 // indirect + github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/viper v1.18.2 // indirect + github.com/subosito/gotenv v1.6.0 // indirect github.com/virtru/access-pdp v1.11.0 // indirect - go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect + go.uber.org/zap v1.27.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect + golang.org/x/net v0.22.0 // indirect + golang.org/x/oauth2 v0.18.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/term v0.16.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.16.1 // indirect + golang.org/x/tools v0.18.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect - google.golang.org/protobuf v1.32.0 // indirect - gopkg.in/go-jose/go-jose.v2 v2.6.2 // indirect + google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 // indirect + google.golang.org/protobuf v1.33.0 // indirect + gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index a9289cf5..6ffc3d25 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1 h1:u0olL4yf2p7Tl5jfsAK5keaFi+JFJuv1CDHrbiXkxkk= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1/go.mod h1:tiTMKD8j6Pd/D2WzREoweufjzaJKHZg35f/VGcZ2v3I= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1 h1:0nWhrRcnkgw1kwJ7xibIO8bqfOA7pBzBjGCDBxIHch8= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1/go.mod h1:Tgn5bgL220vkFOI0KPStlcClPeOJzAv4uT+V8JXGUnw= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= @@ -39,7 +41,10 @@ github.com/coreos/go-oidc/v3 v3.9.0/go.mod h1:rTKz2PYwftcrtoCzV5g5kvfJoWcm0Mk8AF github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creasty/defaults v1.7.0 h1:eNdqZvc5B509z18lD8yc212CAqJNvfT1Jq6L8WowdBA= +github.com/creasty/defaults v1.7.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= @@ -54,8 +59,12 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA= github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= +github.com/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k= +github.com/go-jose/go-jose/v3 v3.0.3/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -73,14 +82,19 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= @@ -99,10 +113,14 @@ github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZ github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= github.com/lestrrat-go/httprc v1.0.4 h1:bAZymwoZQb+Oq8MEbyipag7iSq6YIga8Wj6GOiJGdI8= github.com/lestrrat-go/httprc v1.0.4/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= +github.com/lestrrat-go/httprc v1.0.5 h1:bsTfiH8xaKOJPrg1R+E3iE/AWZr/x0Phj9PBTG/OLUk= +github.com/lestrrat-go/httprc v1.0.5/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI= github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= github.com/lestrrat-go/jwx/v2 v2.0.19 h1:ekv1qEZE6BVct89QA+pRF6+4pCpfVrOnEJnTnT4RXoY= github.com/lestrrat-go/jwx/v2 v2.0.19/go.mod h1:l3im3coce1lL2cDeAjqmaR+Awx+X8Ih+2k8BuHNJ4CU= +github.com/lestrrat-go/jwx/v2 v2.0.21 h1:jAPKupy4uHgrHFEdjVjNkUgoBKtVDgrQPB/h55FHrR0= +github.com/lestrrat-go/jwx/v2 v2.0.21/go.mod h1:09mLW8zto6bWL9GbwnqAli+ArLf+5M33QLQPDggkUWM= github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= @@ -120,6 +138,8 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU= github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= @@ -144,12 +164,20 @@ github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/ github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/opentdf/backend-go v0.1.16 h1:t7OD3ShBCeuAZWUKZNYJJBfC01d4X0EL5a6J1UnIdx4= github.com/opentdf/backend-go v0.1.16/go.mod h1:4RAZ3K19YOJkpxSh4jl6vtjOUkK3H/zqA32LeBf3CDQ= +github.com/opentdf/backend-go v0.1.17 h1:RA/9Mj7OKycnvOrkIZTJCsSyROCcioXzzqMUlnCxP48= +github.com/opentdf/backend-go v0.1.17/go.mod h1:4RAZ3K19YOJkpxSh4jl6vtjOUkK3H/zqA32LeBf3CDQ= github.com/opentdf/platform/protocol/go v0.0.0-20240301211102-04107b3757a9 h1:7E2tnDEZjIwHys0gPPs56Emf+sw1dKXmr+Ho/n/jH8M= github.com/opentdf/platform/protocol/go v0.0.0-20240301211102-04107b3757a9/go.mod h1:O0Wolf3NAhKII0hfDcEPtpsXe/VcUI7Lq/rNqh8I7Wk= +github.com/opentdf/platform/protocol/go v0.0.0-20240313200110-bcc04e006182 h1:iBhem3wapJaRI15yZ2Kv60MjikiD0wYbgtZOaWlAdbk= +github.com/opentdf/platform/protocol/go v0.0.0-20240313200110-bcc04e006182/go.mod h1:qwJ2OQqNVtucVgkLlZhz6O1I1fxqHTXrl5HVRu9AO4Y= github.com/opentdf/platform/sdk v0.0.0-20240301211102-04107b3757a9 h1:NY4GcZ5IETFH2NyexuEENgkL79ZiSQNaZhzs9OkozaI= github.com/opentdf/platform/sdk v0.0.0-20240301211102-04107b3757a9/go.mod h1:ugS04emTB9g96A4sqNjOFVn0Ip4B/VVYQ+eAKD7OFxM= github.com/opentdf/platform/sdk v0.0.0-20240305152130-b34c2fe9ad70 h1:FjKH+bwYRho7mJqPjX3vFnZu5jv7sjdupPhAI37xYgM= github.com/opentdf/platform/sdk v0.0.0-20240305152130-b34c2fe9ad70/go.mod h1:secHYA6In0KqYB67IzB6b/GdFciPPSZUsjAXjvWkuU0= +github.com/opentdf/platform/sdk v0.0.0-20240313200110-bcc04e006182 h1:zW4WrX92tV8kLJdmPDLBIhq7dJJFxztWvCVxF76inek= +github.com/opentdf/platform/sdk v0.0.0-20240313200110-bcc04e006182/go.mod h1:oDdaR1hll4VtRfBuy1g6pE4d7iPgug2pZ6+akzLAyQA= +github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI= +github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -164,6 +192,10 @@ github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= +github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= +github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= +github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f h1:MvTmaQdww/z0Q4wrYjDSCcZ78NoftLQyHBSLW/Cx79Y= github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= @@ -174,15 +206,29 @@ github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFt github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= +github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= +github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= +github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= +github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= +github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= +github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= +github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/testcontainers/testcontainers-go v0.28.0 h1:1HLm9qm+J5VikzFDYhOd+Zw12NtOl+8drH2E8nTY1r8= github.com/testcontainers/testcontainers-go v0.28.0/go.mod h1:COlDpUXbwW3owtpMkEB1zo9gwb1CoKVKlyrVPejF4AU= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= @@ -198,36 +244,60 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 h1:x8Z78aZ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0/go.mod h1:62CPTSry9QZtOaSsE3tOzhx6LzDhHnXJ6xHeMNNiM6Q= go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= +golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -238,45 +308,75 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= +golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe h1:USL2DhxfgRchafRvt/wYyyQNzwgL7ZiURcozOE/Pkvo= google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:cc8bqMqtv9gMOr0zHg2Vzff5ULhhL2IXP4sbcn32Dro= +google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 h1:ImUcDPHjTrAqNhlOkSocDLfG9rrNHH7w7uoKWPaWZ8s= +google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7/go.mod h1:/3XmxOjePkvmKrHuBy4zNFw7IzxJXtAgdpXi8Ll990U= google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 h1:x9PwdEgd11LgK+orcck69WVRo7DezSO4VUMPI4xpc8A= google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014/go.mod h1:rbHMSEDyoYX62nRVLOCc4Qt1HbsdytAYoVwgjiOhF3I= +google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 h1:oqta3O3AnlWbmIE3bFnWbu4bRxZjfbWCp0cKSuZh01E= +google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7/go.mod h1:VQW3tUculP/D4B+xVCo+VgSq8As6wA9ZjHl//pmk+6s= google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe h1:bQnxqljG/wqi4NTXu2+DJ3n7APcEA882QZ1JvhQAq9o= google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 h1:8EeVk1VKMD+GD/neyEHGmz7pFblqPjHoi+PGQIlLx2s= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= +google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= +google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/go-jose/go-jose.v2 v2.6.2 h1:Rl5+9rA0kG3vsO1qhncMPRT5eHICihAMQYJkD7u/i4M= gopkg.in/go-jose/go-jose.v2 v2.6.2/go.mod h1:zzZDPkNNw/c9IE7Z9jr11mBZQhKQTMzoEEIoEdZlFBI= +gopkg.in/go-jose/go-jose.v2 v2.6.3 h1:nt80fvSDlhKWQgSWyHyy5CfmlQr+asih51R8PTWNKKs= +gopkg.in/go-jose/go-jose.v2 v2.6.3/go.mod h1:zzZDPkNNw/c9IE7Z9jr11mBZQhKQTMzoEEIoEdZlFBI= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/pkg/cli/sdkHelpers.go b/pkg/cli/sdkHelpers.go index 844dd306..bfcae94a 100644 --- a/pkg/cli/sdkHelpers.go +++ b/pkg/cli/sdkHelpers.go @@ -1,7 +1,7 @@ package cli import ( - "github.com/opentdf/platform/protocol/go/policy/attributes" + "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/tructl/pkg/handlers" ) @@ -13,7 +13,7 @@ type SimpleAttribute struct { Namespace string } -func GetSimpleAttribute(a *attributes.Attribute) SimpleAttribute { +func GetSimpleAttribute(a *policy.Attribute) SimpleAttribute { values := []string{} for _, v := range a.Values { values = append(values, v.Value) diff --git a/pkg/handlers/attribute.go b/pkg/handlers/attribute.go index 006175ed..4a9d4b74 100644 --- a/pkg/handlers/attribute.go +++ b/pkg/handlers/attribute.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/opentdf/platform/protocol/go/common" + "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/platform/protocol/go/policy/attributes" ) @@ -29,7 +30,7 @@ func (e *CreateAttributeError) Error() string { return "Error creating attribute" } -func (h Handler) GetAttribute(id string) (*attributes.Attribute, error) { +func (h Handler) GetAttribute(id string) (*policy.Attribute, error) { resp, err := h.sdk.Attributes.GetAttribute(h.ctx, &attributes.GetAttributeRequest{ Id: id, }) @@ -40,7 +41,7 @@ func (h Handler) GetAttribute(id string) (*attributes.Attribute, error) { return resp.Attribute, nil } -func (h Handler) ListAttributes() ([]*attributes.Attribute, error) { +func (h Handler) ListAttributes() ([]*policy.Attribute, error) { resp, err := h.sdk.Attributes.ListAttributes(h.ctx, &attributes.ListAttributesRequest{}) if err != nil { return nil, err @@ -48,18 +49,17 @@ func (h Handler) ListAttributes() ([]*attributes.Attribute, error) { return resp.Attributes, err } -func (h Handler) CreateAttribute(name string, rule string, namespace string) (*attributes.Attribute, error) { +// TODO: allow creation of a value with the attribute simultaneously? +func (h Handler) CreateAttribute(name string, rule string, namespace string) (*policy.Attribute, error) { r, err := GetAttributeRuleFromReadableString(rule) if err != nil { return nil, err } attrReq := &attributes.CreateAttributeRequest{ - Attribute: &attributes.AttributeCreateUpdate{ - NamespaceId: namespace, - Name: name, - Rule: r, - }, + NamespaceId: namespace, + Name: name, + Rule: r, } resp, err := h.sdk.Attributes.CreateAttribute(h.ctx, attrReq) @@ -69,7 +69,7 @@ func (h Handler) CreateAttribute(name string, rule string, namespace string) (*a attr := resp.Attribute - return &attributes.Attribute{ + return &policy.Attribute{ Id: attr.Id, Name: attr.Name, Rule: attr.Rule, @@ -77,19 +77,18 @@ func (h Handler) CreateAttribute(name string, rule string, namespace string) (*a }, nil } +// TODO: verify updation behavior func (h *Handler) UpdateAttribute( id string, fns ...func(*common.MetadataMutable) *common.MetadataMutable, ) (*attributes.UpdateAttributeResponse, error) { return h.sdk.Attributes.UpdateAttribute(h.ctx, &attributes.UpdateAttributeRequest{ - Id: id, - Attribute: &attributes.AttributeCreateUpdate{ - Metadata: buildMetadata(&common.MetadataMutable{}, fns...), - }, + Id: id, + Metadata: buildMetadata(&common.MetadataMutable{}, fns...), }) } -func (h Handler) DeactivateAttribute(id string) (*attributes.Attribute, error) { +func (h Handler) DeactivateAttribute(id string) (*policy.Attribute, error) { resp, err := h.sdk.Attributes.DeactivateAttribute(h.ctx, &attributes.DeactivateAttributeRequest{ Id: id, }) @@ -111,27 +110,27 @@ func GetAttributeRuleOptions() []string { } } -func GetAttributeRuleFromAttributeType(rule attributes.AttributeRuleTypeEnum) string { +func GetAttributeRuleFromAttributeType(rule policy.AttributeRuleTypeEnum) string { switch rule { - case attributes.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ALL_OF: + case policy.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ALL_OF: return AttributeRuleAllOf - case attributes.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ANY_OF: + case policy.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ANY_OF: return AttributeRuleAnyOf - case attributes.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_HIERARCHY: + case policy.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_HIERARCHY: return AttributeRuleHierarchy default: return "" } } -func GetAttributeRuleFromReadableString(rule string) (attributes.AttributeRuleTypeEnum, error) { +func GetAttributeRuleFromReadableString(rule string) (policy.AttributeRuleTypeEnum, error) { switch rule { case AttributeRuleAllOf: - return attributes.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ALL_OF, nil + return policy.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ALL_OF, nil case AttributeRuleAnyOf: - return attributes.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ANY_OF, nil + return policy.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ANY_OF, nil case AttributeRuleHierarchy: - return attributes.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_HIERARCHY, nil + return policy.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_HIERARCHY, nil } return 0, fmt.Errorf("invalid attribute rule: %s", rule) } diff --git a/pkg/handlers/attribute_values.go b/pkg/handlers/attribute_values.go index f26008e7..ea587355 100644 --- a/pkg/handlers/attribute_values.go +++ b/pkg/handlers/attribute_values.go @@ -1,15 +1,14 @@ package handlers import ( + "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/platform/protocol/go/policy/attributes" ) -func (h *Handler) CreateAttributeValue(attributeId string, value string) (*attributes.Value, error) { +func (h *Handler) CreateAttributeValue(attributeId string, value string) (*policy.Value, error) { resp, err := h.sdk.Attributes.CreateAttributeValue(h.ctx, &attributes.CreateAttributeValueRequest{ AttributeId: attributeId, - Value: &attributes.ValueCreateUpdate{ - Value: value, - }, + Value: value, }) if err != nil { return nil, err diff --git a/pkg/handlers/kas-registry.go b/pkg/handlers/kas-registry.go index 12002128..07416006 100644 --- a/pkg/handlers/kas-registry.go +++ b/pkg/handlers/kas-registry.go @@ -16,65 +16,47 @@ func (h Handler) GetKasRegistryEntry(id string) (*kasregistry.KeyAccessServer, e return resp.KeyAccessServer, nil } -// ListKasRegistryEntries lists the KeyAccessServer entries in the project. func (h Handler) ListKasRegistryEntries() ([]*kasregistry.KeyAccessServer, error) { - // Create a request to list the KeyAccessServer entries. req := &kasregistry.ListKeyAccessServersRequest{} - // List the KeyAccessServer entries using the SDK. resp, err := h.sdk.KeyAccessServerRegistry.ListKeyAccessServers(h.ctx, req) if err != nil { return nil, err } - // Return the list of KeyAccessServer entries. return resp.KeyAccessServers, nil } -// CreateKasRegistryEntry creates a KeyAccessServer entry in the project. -// map[string]interface{} used to handle arbitarily structured metadata func (h Handler) CreateKasRegistryEntry(uri string, publicKey *kasregistry.PublicKey, metadata *common.MetadataMutable) (*kasregistry.KeyAccessServer, error) { - // Create a request to create a KeyAccessServer entry. req := &kasregistry.CreateKeyAccessServerRequest{ - KeyAccessServer: &kasregistry.KeyAccessServerCreateUpdate{ - Uri: uri, - PublicKey: publicKey, - Metadata: metadata, - }, + Uri: uri, + PublicKey: publicKey, + Metadata: metadata, } - // Create the KeyAccessServer entry using the SDK. resp, err := h.sdk.KeyAccessServerRegistry.CreateKeyAccessServer(h.ctx, req) if err != nil { return nil, err } - // Return the created KeyAccessServer entry. return resp.KeyAccessServer, nil } -// UpdateKasRegistryEntry updates a KeyAccessServer entry in the project. -// note: we are specifically building the request on the otherside, due to so manu of the options being optional +// TODO: verify updation behavior func (h Handler) UpdateKasRegistryEntry(id string, kasUpdateReq *kasregistry.UpdateKeyAccessServerRequest) (*kasregistry.KeyAccessServer, error) { - - // Update the KeyAccessServer entry using the SDK. resp, err := h.sdk.KeyAccessServerRegistry.UpdateKeyAccessServer(h.ctx, kasUpdateReq) if err != nil { return nil, err } - // Return the updated KeyAccess Server entry. return resp.KeyAccessServer, nil } -// DeleteKasRegistryEntry deletes a KeyAccessServer entry from the project. func (h Handler) DeleteKasRegistryEntry(id string) error { - // Create a request to delete a KeyAccessServer entry. req := &kasregistry.DeleteKeyAccessServerRequest{ Id: id, } - // Delete the KeyAccessServer entry using the SDK. _, err := h.sdk.KeyAccessServerRegistry.DeleteKeyAccessServer(h.ctx, req) if err != nil { return err diff --git a/pkg/handlers/namespaces.go b/pkg/handlers/namespaces.go index 17218182..6e0eb18c 100644 --- a/pkg/handlers/namespaces.go +++ b/pkg/handlers/namespaces.go @@ -1,10 +1,11 @@ package handlers import ( + "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/platform/protocol/go/policy/namespaces" ) -func (h Handler) GetNamespace(id string) (*namespaces.Namespace, error) { +func (h Handler) GetNamespace(id string) (*policy.Namespace, error) { resp, err := h.sdk.Namespaces.GetNamespace(h.ctx, &namespaces.GetNamespaceRequest{ Id: id, }) @@ -15,7 +16,7 @@ func (h Handler) GetNamespace(id string) (*namespaces.Namespace, error) { return resp.Namespace, nil } -func (h Handler) ListNamespaces() ([]*namespaces.Namespace, error) { +func (h Handler) ListNamespaces() ([]*policy.Namespace, error) { resp, err := h.sdk.Namespaces.ListNamespaces(h.ctx, &namespaces.ListNamespacesRequest{}) if err != nil { return nil, err @@ -24,7 +25,7 @@ func (h Handler) ListNamespaces() ([]*namespaces.Namespace, error) { return resp.Namespaces, nil } -func (h Handler) CreateNamespace(name string) (*namespaces.Namespace, error) { +func (h Handler) CreateNamespace(name string) (*policy.Namespace, error) { resp, err := h.sdk.Namespaces.CreateNamespace(h.ctx, &namespaces.CreateNamespaceRequest{ Name: name, }) @@ -35,10 +36,10 @@ func (h Handler) CreateNamespace(name string) (*namespaces.Namespace, error) { return resp.Namespace, nil } -func (h Handler) UpdateNamespace(id string, name string) (*namespaces.Namespace, error) { +// TODO: verify updation of metadata +func (h Handler) UpdateNamespace(id string) (*policy.Namespace, error) { resp, err := h.sdk.Namespaces.UpdateNamespace(h.ctx, &namespaces.UpdateNamespaceRequest{ - Id: id, - Name: name, + Id: id, }) if err != nil { return nil, err diff --git a/pkg/handlers/resourceMappings.go b/pkg/handlers/resourceMappings.go index cfb3426e..9f241f58 100644 --- a/pkg/handlers/resourceMappings.go +++ b/pkg/handlers/resourceMappings.go @@ -3,6 +3,7 @@ package handlers import ( "context" + "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/platform/protocol/go/policy/resourcemapping" ) @@ -12,12 +13,10 @@ type ResourceMapping struct { Terms []string } -func (h *Handler) CreateResourceMapping(attributeId string, terms []string) (*resourcemapping.ResourceMapping, error) { +func (h *Handler) CreateResourceMapping(attributeId string, terms []string) (*policy.ResourceMapping, error) { res, err := h.sdk.ResourceMapping.CreateResourceMapping(context.Background(), &resourcemapping.CreateResourceMappingRequest{ - ResourceMapping: &resourcemapping.ResourceMappingCreateUpdate{ - AttributeValueId: attributeId, - Terms: terms, - }, + AttributeValueId: attributeId, + Terms: terms, }) if err != nil { return nil, err @@ -26,7 +25,7 @@ func (h *Handler) CreateResourceMapping(attributeId string, terms []string) (*re return res.ResourceMapping, nil } -func (h *Handler) GetResourceMapping(id string) (*resourcemapping.ResourceMapping, error) { +func (h *Handler) GetResourceMapping(id string) (*policy.ResourceMapping, error) { res, err := h.sdk.ResourceMapping.GetResourceMapping(context.Background(), &resourcemapping.GetResourceMappingRequest{ Id: id, }) @@ -37,7 +36,7 @@ func (h *Handler) GetResourceMapping(id string) (*resourcemapping.ResourceMappin return res.ResourceMapping, nil } -func (h *Handler) ListResourceMappings() ([]*resourcemapping.ResourceMapping, error) { +func (h *Handler) ListResourceMappings() ([]*policy.ResourceMapping, error) { res, err := h.sdk.ResourceMapping.ListResourceMappings(context.Background(), &resourcemapping.ListResourceMappingsRequest{}) if err != nil { return nil, err @@ -46,23 +45,21 @@ func (h *Handler) ListResourceMappings() ([]*resourcemapping.ResourceMapping, er return res.ResourceMappings, nil } -func (h *Handler) UpdateResourceMapping(id string, attrValueId string, terms []string) (*resourcemapping.ResourceMapping, error) { +// TODO: verify updation behavior +func (h *Handler) UpdateResourceMapping(id string, attrValueId string, terms []string) (*policy.ResourceMapping, error) { res, err := h.sdk.ResourceMapping.UpdateResourceMapping(context.Background(), &resourcemapping.UpdateResourceMappingRequest{ - Id: id, - ResourceMapping: &resourcemapping.ResourceMappingCreateUpdate{ - AttributeValueId: attrValueId, - Terms: terms, - }, + Id: id, + AttributeValueId: attrValueId, + Terms: terms, }) if err != nil { return nil, err } return res.ResourceMapping, nil - } -func (h *Handler) DeleteResourceMapping(id string) (*resourcemapping.ResourceMapping, error) { +func (h *Handler) DeleteResourceMapping(id string) (*policy.ResourceMapping, error) { resp, err := h.sdk.ResourceMapping.DeleteResourceMapping(context.Background(), &resourcemapping.DeleteResourceMappingRequest{ Id: id, }) diff --git a/pkg/handlers/sdk.go b/pkg/handlers/sdk.go index f5091ecf..643dfd76 100644 --- a/pkg/handlers/sdk.go +++ b/pkg/handlers/sdk.go @@ -34,23 +34,11 @@ func (h Handler) Close() error { return h.sdk.Close() } -// Replace the description in the metadata -func (h Handler) WithDescriptionMetadata(metadata *common.Metadata, description string) func() *common.Metadata { - return func() *common.Metadata { - nextMetadata := &common.Metadata{ - Labels: metadata.Labels, - Description: description, - } - return nextMetadata - } -} - // Replace all labels in the metadata func (h Handler) WithReplaceLabelsMetadata(metadata *common.MetadataMutable, labels map[string]string) func(*common.MetadataMutable) *common.MetadataMutable { return func(*common.MetadataMutable) *common.MetadataMutable { nextMetadata := &common.MetadataMutable{ - Labels: labels, - Description: metadata.Description, + Labels: labels, } return nextMetadata } @@ -62,8 +50,7 @@ func (h Handler) WithLabelMetadata(metadata *common.MetadataMutable, key, value labels := metadata.Labels labels[key] = value nextMetadata := &common.MetadataMutable{ - Labels: labels, - Description: metadata.Description, + Labels: labels, } return nextMetadata } diff --git a/pkg/handlers/subjectmappings.go b/pkg/handlers/subjectmappings.go index a2bd8903..3c50f857 100644 --- a/pkg/handlers/subjectmappings.go +++ b/pkg/handlers/subjectmappings.go @@ -1,13 +1,14 @@ -// SubjectMappings are pretty unstable right now -// and undergoing active arch changes, so for now we're completely -// commenting them out. -// We'll uncomment them once we have a stable version of the SubjectMappings in a few days - package handlers -import ( - "fmt" -) +// import ( +// "fmt" +// "slices" +// "strings" + +// "github.com/opentdf/platform/protocol/go/common" +// "github.com/opentdf/platform/protocol/go/policy" +// "github.com/opentdf/platform/protocol/go/policy/subjectmapping" +// ) // const ( // SubjectMappingOperatorIn = "IN" @@ -17,7 +18,7 @@ import ( // var SubjectMappingOperatorEnumChoices = []string{SubjectMappingOperatorIn, SubjectMappingOperatorNotIn, SubjectMappingOperatorUnspecified} -// func (h Handler) GetSubjectMapping(id string) (*subjectmapping.SubjectMapping, error) { +// func (h Handler) GetSubjectMapping(id string) (*policy.SubjectMapping, error) { // resp, err := h.sdk.SubjectMapping.GetSubjectMapping(h.ctx, &subjectmapping.GetSubjectMappingRequest{ // Id: id, // }) @@ -28,7 +29,7 @@ import ( // return resp.SubjectMapping, nil // } -// func (h Handler) ListSubjectMappings() ([]*subjectmapping.SubjectMapping, error) { +// func (h Handler) ListSubjectMappings() ([]*policy.SubjectMapping, error) { // resp, err := h.sdk.SubjectMapping.ListSubjectMappings(h.ctx, &subjectmapping.ListSubjectMappingsRequest{}) // if err != nil { // return nil, err @@ -115,11 +116,3 @@ import ( // return SubjectMappingOperatorUnspecified // } // } - -func placeholder() { - fmt.Println("This is a placeholder for the subjectmappings.go file, once the subject mappings have been stablized") -} - -func main() { - placeholder() -} From 6b9c5c5e9b56d1c915e5a529718266c28cf64fe0 Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Wed, 13 Mar 2024 17:01:38 -0400 Subject: [PATCH 02/13] casing --- cmd/policy-resource_mappings.go | 54 ++++++++++++++++----------------- cmd/policy-subject_mappings.go | 22 +++++++------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/cmd/policy-resource_mappings.go b/cmd/policy-resource_mappings.go index c78b8745..7722b1df 100644 --- a/cmd/policy-resource_mappings.go +++ b/cmd/policy-resource_mappings.go @@ -11,22 +11,22 @@ import ( ) var ( - policy_resourceMappingsTerms []string + policy_resource_mappingsTerms []string - policy_resourceMappingsCmd = &cobra.Command{ + policy_resource_mappingsCmd = &cobra.Command{ Use: man.PolicyResourceMappings["en"].Command, Aliases: man.PolicyResourceMappings["en"].Aliases, Short: man.PolicyResourceMappings["en"].ShortWithSubCommands([]string{ - policy_resourceMappingsCreateCmd.Use, - policy_resourceMappingsGetCmd.Use, - policy_resourceMappingsListCmd.Use, - policy_resourceMappingsUpdateCmd.Use, - policy_resourceMappingsDeleteCmd.Use, + policy_resource_mappingsCreateCmd.Use, + policy_resource_mappingsGetCmd.Use, + policy_resource_mappingsListCmd.Use, + policy_resource_mappingsUpdateCmd.Use, + policy_resource_mappingsDeleteCmd.Use, }), Long: man.PolicyResourceMappings["en"].Long, } - policy_resourceMappingsCreateCmd = &cobra.Command{ + policy_resource_mappingsCreateCmd = &cobra.Command{ Use: "create", Short: "Create resource mappings", Run: func(cmd *cobra.Command, args []string) { @@ -35,7 +35,7 @@ var ( flagHelper := cli.NewFlagHelper(cmd) attrId := flagHelper.GetRequiredString("attribute-value-id") - terms := flagHelper.GetStringSlice("terms", policy_resourceMappingsTerms, cli.FlagHelperStringSliceOptions{ + terms := flagHelper.GetStringSlice("terms", policy_resource_mappingsTerms, cli.FlagHelperStringSliceOptions{ Min: 1, }) @@ -54,7 +54,7 @@ var ( }, } - policy_resourceMappingsGetCmd = &cobra.Command{ + policy_resource_mappingsGetCmd = &cobra.Command{ Use: "get", Short: "Get resource mappings", Run: func(cmd *cobra.Command, args []string) { @@ -78,7 +78,7 @@ var ( }, } - policy_resourceMappingsListCmd = &cobra.Command{ + policy_resource_mappingsListCmd = &cobra.Command{ Use: "list", Short: "List resource mappings", Run: func(cmd *cobra.Command, args []string) { @@ -99,7 +99,7 @@ var ( }, } - policy_resourceMappingsUpdateCmd = &cobra.Command{ + policy_resource_mappingsUpdateCmd = &cobra.Command{ Use: "update", Short: "Update resource mappings", Run: func(cmd *cobra.Command, args []string) { @@ -109,7 +109,7 @@ var ( flagHelper := cli.NewFlagHelper(cmd) id := flagHelper.GetRequiredString("id") attrValueId := flagHelper.GetOptionalString("attribute-value-id") - terms := flagHelper.GetStringSlice("terms", policy_resourceMappingsTerms, cli.FlagHelperStringSliceOptions{}) + terms := flagHelper.GetStringSlice("terms", policy_resource_mappingsTerms, cli.FlagHelperStringSliceOptions{}) resourceMapping, err := h.UpdateResourceMapping(id, attrValueId, terms) if err != nil { @@ -126,7 +126,7 @@ var ( }, } - policy_resourceMappingsDeleteCmd = &cobra.Command{ + policy_resource_mappingsDeleteCmd = &cobra.Command{ Use: "delete", Short: "Delete resource mappings", Run: func(cmd *cobra.Command, args []string) { @@ -155,22 +155,22 @@ var ( ) func init() { - policyCmd.AddCommand(policy_resourceMappingsCmd) + policyCmd.AddCommand(policy_resource_mappingsCmd) - policy_resourceMappingsCmd.AddCommand(policy_resourceMappingsCreateCmd) - policy_resourceMappingsCreateCmd.Flags().String("attribute-value-id", "", "Attribute Value ID") - policy_resourceMappingsCreateCmd.Flags().StringSliceVar(&policy_resourceMappingsTerms, "terms", []string{}, "Synonym terms") + policy_resource_mappingsCmd.AddCommand(policy_resource_mappingsCreateCmd) + policy_resource_mappingsCreateCmd.Flags().String("attribute-value-id", "", "Attribute Value ID") + policy_resource_mappingsCreateCmd.Flags().StringSliceVar(&policy_resource_mappingsTerms, "terms", []string{}, "Synonym terms") - policy_resourceMappingsCmd.AddCommand(policy_resourceMappingsGetCmd) - policy_resourceMappingsGetCmd.Flags().String("id", "", "Resource Mapping ID") + policy_resource_mappingsCmd.AddCommand(policy_resource_mappingsGetCmd) + policy_resource_mappingsGetCmd.Flags().String("id", "", "Resource Mapping ID") - policy_resourceMappingsCmd.AddCommand(policy_resourceMappingsListCmd) + policy_resource_mappingsCmd.AddCommand(policy_resource_mappingsListCmd) - policy_resourceMappingsCmd.AddCommand(policy_resourceMappingsUpdateCmd) - policy_resourceMappingsUpdateCmd.Flags().String("id", "", "Resource Mapping ID") - policy_resourceMappingsUpdateCmd.Flags().String("attribute-value-id", "", "Attribute Value ID") - policy_resourceMappingsUpdateCmd.Flags().StringSliceVar(&policy_resourceMappingsTerms, "terms", []string{}, "Synonym terms") + policy_resource_mappingsCmd.AddCommand(policy_resource_mappingsUpdateCmd) + policy_resource_mappingsUpdateCmd.Flags().String("id", "", "Resource Mapping ID") + policy_resource_mappingsUpdateCmd.Flags().String("attribute-value-id", "", "Attribute Value ID") + policy_resource_mappingsUpdateCmd.Flags().StringSliceVar(&policy_resource_mappingsTerms, "terms", []string{}, "Synonym terms") - policy_resourceMappingsCmd.AddCommand(policy_resourceMappingsDeleteCmd) - policy_resourceMappingsDeleteCmd.Flags().String("id", "", "Resource Mapping ID") + policy_resource_mappingsCmd.AddCommand(policy_resource_mappingsDeleteCmd) + policy_resource_mappingsDeleteCmd.Flags().String("id", "", "Resource Mapping ID") } diff --git a/cmd/policy-subject_mappings.go b/cmd/policy-subject_mappings.go index 69b4ebaf..be7a9e0a 100644 --- a/cmd/policy-subject_mappings.go +++ b/cmd/policy-subject_mappings.go @@ -13,19 +13,19 @@ import "fmt" // ) // var ( -// policy_subjectMappingsCmds = []string{ +// policy_subject_mappingsCmds = []string{ // policy_subjectMappingCreateCmd.Use, // policy_subjectMappingGetCmd.Use, -// policy_subjectMappingsListCmd.Use, +// policy_subject_mappingsListCmd.Use, // policy_subjectMappingUpdateCmd.Use, // policy_subjectMappingDeleteCmd.Use, // } // subjectValues []string -// policy_subjectMappingsCmd = &cobra.Command{ +// policy_subject_mappingsCmd = &cobra.Command{ // Use: "subject-mappings", -// Short: "Manage subject mappings [" + strings.Join(policy_subjectMappingsCmds, ", ") + "]", +// Short: "Manage subject mappings [" + strings.Join(policy_subject_mappingsCmds, ", ") + "]", // Long: ` // Subject Mappings - commands to manage relationships between subjects (PEs, NPEs, etc) and attributes. @@ -76,7 +76,7 @@ import "fmt" // }, // } -// policy_subjectMappingsListCmd = &cobra.Command{ +// policy_subject_mappingsListCmd = &cobra.Command{ // Use: "list", // Short: "List subject mappings", // Run: func(cmd *cobra.Command, args []string) { @@ -226,21 +226,21 @@ import "fmt" // ) // func init() { -// policyCmd.AddCommand(policy_subjectMappingsCmd) +// policyCmd.AddCommand(policy_subject_mappingsCmd) -// policy_subjectMappingsCmd.AddCommand(policy_subjectMappingGetCmd) +// policy_subject_mappingsCmd.AddCommand(policy_subjectMappingGetCmd) // policy_subjectMappingGetCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") -// policy_subjectMappingsCmd.AddCommand(policy_subjectMappingsListCmd) +// policy_subject_mappingsCmd.AddCommand(policy_subject_mappingsListCmd) -// policy_subjectMappingsCmd.AddCommand(policy_subjectMappingCreateCmd) +// policy_subject_mappingsCmd.AddCommand(policy_subjectMappingCreateCmd) // policy_subjectMappingCreateCmd.Flags().StringP("attribute-value-id", "a", "", "Id of the attribute value") // policy_subjectMappingCreateCmd.Flags().StringP("subject-attribute", "s", "", "Subject attribute") // policy_subjectMappingCreateCmd.Flags().StringSliceVarP(&subjectValues, "subject-values", "v", []string{}, "Subject values") // policy_subjectMappingCreateCmd.Flags().StringP("operator", "o", "", "Operator") // policy_subjectMappingCreateCmd.Flags().StringP("metadata", "m", "", "Metadata (optional): labels and description") -// policy_subjectMappingsCmd.AddCommand(policy_subjectMappingUpdateCmd) +// policy_subject_mappingsCmd.AddCommand(policy_subjectMappingUpdateCmd) // policy_subjectMappingUpdateCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") // policy_subjectMappingUpdateCmd.Flags().StringP("attribute-value-id", "a", "", "Id of the attribute value") // policy_subjectMappingUpdateCmd.Flags().StringP("subject-attribute", "s", "", "Subject attribute") @@ -248,7 +248,7 @@ import "fmt" // policy_subjectMappingUpdateCmd.Flags().StringP("operator", "o", "", "Operator: [IN, NOT_IN]") // policy_subjectMappingUpdateCmd.Flags().StringP("metadata", "m", "", "Metadata (optional): labels and description") -// policy_subjectMappingsCmd.AddCommand(policy_subjectMappingDeleteCmd) +// policy_subject_mappingsCmd.AddCommand(policy_subjectMappingDeleteCmd) // policy_subjectMappingDeleteCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") // } From a8d6c24f8d500c2984b9e617b10cdc9fef85a303 Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Wed, 13 Mar 2024 17:04:01 -0400 Subject: [PATCH 03/13] casing --- cmd/policy-subject_mappings.go | 500 ++++++++++++++++----------------- 1 file changed, 249 insertions(+), 251 deletions(-) diff --git a/cmd/policy-subject_mappings.go b/cmd/policy-subject_mappings.go index be7a9e0a..5c42a42d 100644 --- a/cmd/policy-subject_mappings.go +++ b/cmd/policy-subject_mappings.go @@ -1,256 +1,254 @@ package cmd -import "fmt" - -// import ( -// "encoding/json" -// "fmt" -// "strings" - -// "github.com/opentdf/tructl/pkg/cli" -// "github.com/opentdf/tructl/pkg/handlers" -// "github.com/spf13/cobra" -// ) - -// var ( -// policy_subject_mappingsCmds = []string{ -// policy_subjectMappingCreateCmd.Use, -// policy_subjectMappingGetCmd.Use, -// policy_subject_mappingsListCmd.Use, -// policy_subjectMappingUpdateCmd.Use, -// policy_subjectMappingDeleteCmd.Use, -// } - -// subjectValues []string - -// policy_subject_mappingsCmd = &cobra.Command{ -// Use: "subject-mappings", -// Short: "Manage subject mappings [" + strings.Join(policy_subject_mappingsCmds, ", ") + "]", -// Long: ` -// Subject Mappings - commands to manage relationships between subjects (PEs, NPEs, etc) and attributes. - -// For example: a subject mapping could be created such that the AcmeCorp engineering -// team member named "Alice" is "IN" the value "Engineering" for attribute "Teams" in -// namespace "acmecorp.com", but is not mapped to the attribute value "Sales" within the -// same attribute and namespace. -// `, -// } - -// policy_subjectMappingGetCmd = &cobra.Command{ -// Use: "get", -// Short: "Get a subject mapping by id", -// Run: func(cmd *cobra.Command, args []string) { -// h := cli.NewHandler(cmd) -// defer h.Close() - -// flagHelper := cli.NewFlagHelper(cmd) -// id := flagHelper.GetRequiredString("id") - -// mapping, err := h.GetSubjectMapping(id) -// if err != nil { -// errMsg := fmt.Sprintf("Could not find subject mapping (%s)", id) -// cli.ExitWithNotFoundError(errMsg, err) -// cli.ExitWithError(errMsg, err) -// } - -// rows := [][]string{ -// {"Id", mapping.Id}, -// {"Subject Attribute", mapping.SubjectAttribute}, -// {"Operator", handlers.GetSubjectMappingOperatorChoiceFromEnum(mapping.Operator)}, -// {"Subject Values", strings.Join(mapping.SubjectValues, ", ")}, -// } - -// if mdRows := getMetadataRows(mapping.Metadata); mdRows != nil { -// rows = append(rows, mdRows...) -// } - -// if !jsonOutput { -// cli.PrintSuccessTable(cmd, id, cli.NewTabular().Rows(rows...)) -// } else { -// if output, err := json.MarshalIndent(mapping, "", " "); err != nil { -// cli.ExitWithError("Error marshalling subject mapping", err) -// } else { -// fmt.Println(string(output)) -// } -// } -// }, -// } - -// policy_subject_mappingsListCmd = &cobra.Command{ -// Use: "list", -// Short: "List subject mappings", -// Run: func(cmd *cobra.Command, args []string) { -// h := cli.NewHandler(cmd) -// defer h.Close() - -// list, err := h.ListSubjectMappings() -// if err != nil { -// cli.ExitWithError("Could not get subject mappings", err) -// } - -// if jsonOutput { -// if output, err := json.MarshalIndent(list, "", " "); err != nil { -// cli.ExitWithError("Error marshalling subject mappings", err) -// } else { -// fmt.Println(string(output)) -// } -// return -// } - -// t := cli.NewTable().Width(180) -// t.Headers("Id", "Subject Attribute", "Operator", "Subject Values", "Attribute Value ID") -// for _, sm := range list { -// rowCells := []string{ -// sm.Id, -// sm.SubjectAttribute, -// handlers.GetSubjectMappingOperatorChoiceFromEnum(sm.Operator), -// strings.Join(sm.SubjectValues, ", "), -// sm.AttributeValue.Id, -// } -// t.Row(rowCells...) -// } -// cli.PrintSuccessTable(cmd, "", t) -// }, -// } - -// policy_subjectMappingCreateCmd = &cobra.Command{ -// Use: "create", -// Short: "Create a new subject mapping", -// Run: func(cmd *cobra.Command, args []string) { -// h := cli.NewHandler(cmd) -// defer h.Close() - -// flagHelper := cli.NewFlagHelper(cmd) -// attrValueId := flagHelper.GetRequiredString("attribute-value-id") -// subjectAttribute := flagHelper.GetRequiredString("subject-attribute") -// subjectValues := flagHelper.GetStringSlice("subject-values", subjectValues, cli.FlagHelperStringSliceOptions{Min: 1}) -// operator := flagHelper.GetRequiredString("operator") - -// m := flagHelper.GetOptionalString("metadata") -// metadata := unMarshalMetadata(m) - -// mapping, err := h.CreateNewSubjectMapping(attrValueId, subjectAttribute, subjectValues, operator, metadata) -// if err != nil { -// cli.ExitWithError("Could not create subject mapping", err) -// } - -// if jsonOutput { -// if output, err := json.MarshalIndent(mapping, "", " "); err != nil { -// cli.ExitWithError("Error marshalling subject mapping", err) -// } else { -// fmt.Println(string(output)) -// } -// return -// } - -// rows := [][]string{ -// {"Id", mapping.Id}, -// {"Subject Attribute", mapping.SubjectAttribute}, -// {"Operator", handlers.GetSubjectMappingOperatorChoiceFromEnum(mapping.Operator)}, -// {"Subject Values", strings.Join(mapping.SubjectValues, ", ")}, -// {"Attribute Value Id", mapping.AttributeValue.Id}, -// } - -// if mdRows := getMetadataRows(mapping.Metadata); mdRows != nil { -// rows = append(rows, mdRows...) -// } - -// cli.PrintSuccessTable(cmd, mapping.Id, -// cli.NewTabular(). -// Rows(rows...)) -// }, -// } - -// policy_subjectMappingDeleteCmd = &cobra.Command{ -// Use: "delete", -// Short: "Delete a subject mapping by id", -// Run: func(cmd *cobra.Command, args []string) { -// h := cli.NewHandler(cmd) -// defer h.Close() - -// flagHelper := cli.NewFlagHelper(cmd) -// id := flagHelper.GetRequiredString("id") - -// sm, err := h.GetSubjectMapping(id) -// if err != nil { -// errMsg := fmt.Sprintf("Could not find subject mapping (%s)", id) -// cli.ExitWithNotFoundError(errMsg, err) -// cli.ExitWithError(errMsg, err) -// } - -// cli.ConfirmDelete("subject mapping", sm.Id) - -// if err := h.DeleteSubjectMapping(id); err != nil { -// errMsg := fmt.Sprintf("Could not delete subject mapping (%s)", id) -// cli.ExitWithNotFoundError(errMsg, err) -// cli.ExitWithError(errMsg, err) -// } - -// // TODO: handle json output once service sends back deleted subject mapping -// cli.PrintSuccessTable(cmd, id, nil) -// }, -// } - -// policy_subjectMappingUpdateCmd = &cobra.Command{ -// Use: "update", -// Short: "Update a subject mapping", -// Run: func(cmd *cobra.Command, args []string) { -// h := cli.NewHandler(cmd) -// defer h.Close() - -// flagHelper := cli.NewFlagHelper(cmd) -// id := flagHelper.GetRequiredString("id") -// attrValueId := flagHelper.GetRequiredString("attribute-value-id") -// subjectAttribute := flagHelper.GetRequiredString("subject-attribute") -// subjectValues := flagHelper.GetStringSlice("subject-values", subjectValues, cli.FlagHelperStringSliceOptions{Min: 1}) -// operator := flagHelper.GetRequiredString("operator") - -// m := flagHelper.GetOptionalString("metadata") -// metadata := unMarshalMetadata(m) - -// if _, err := h.UpdateSubjectMapping( -// id, -// attrValueId, -// subjectAttribute, -// subjectValues, -// operator, -// metadata, -// ); err != nil { -// cli.ExitWithError("Could not update subject mapping", err) -// } - -// // TODO: handle json output once service sends back updated subject mapping -// fmt.Println(cli.SuccessMessage(fmt.Sprintf("Subject mapping id: (%s) updated.", id))) -// }, -// } -// ) - -// func init() { -// policyCmd.AddCommand(policy_subject_mappingsCmd) - -// policy_subject_mappingsCmd.AddCommand(policy_subjectMappingGetCmd) -// policy_subjectMappingGetCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") - -// policy_subject_mappingsCmd.AddCommand(policy_subject_mappingsListCmd) - -// policy_subject_mappingsCmd.AddCommand(policy_subjectMappingCreateCmd) -// policy_subjectMappingCreateCmd.Flags().StringP("attribute-value-id", "a", "", "Id of the attribute value") -// policy_subjectMappingCreateCmd.Flags().StringP("subject-attribute", "s", "", "Subject attribute") -// policy_subjectMappingCreateCmd.Flags().StringSliceVarP(&subjectValues, "subject-values", "v", []string{}, "Subject values") -// policy_subjectMappingCreateCmd.Flags().StringP("operator", "o", "", "Operator") -// policy_subjectMappingCreateCmd.Flags().StringP("metadata", "m", "", "Metadata (optional): labels and description") - -// policy_subject_mappingsCmd.AddCommand(policy_subjectMappingUpdateCmd) -// policy_subjectMappingUpdateCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") -// policy_subjectMappingUpdateCmd.Flags().StringP("attribute-value-id", "a", "", "Id of the attribute value") -// policy_subjectMappingUpdateCmd.Flags().StringP("subject-attribute", "s", "", "Subject attribute") -// policy_subjectMappingUpdateCmd.Flags().StringSliceVarP(&subjectValues, "subject-values", "v", []string{}, "Subject values") -// policy_subjectMappingUpdateCmd.Flags().StringP("operator", "o", "", "Operator: [IN, NOT_IN]") -// policy_subjectMappingUpdateCmd.Flags().StringP("metadata", "m", "", "Metadata (optional): labels and description") - -// policy_subject_mappingsCmd.AddCommand(policy_subjectMappingDeleteCmd) -// policy_subjectMappingDeleteCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") -// } +import ( + "encoding/json" + "fmt" + "strings" + + "github.com/opentdf/tructl/pkg/cli" + "github.com/opentdf/tructl/pkg/handlers" + "github.com/spf13/cobra" +) + +var ( + policy_subject_mappingsCmds = []string{ + policy_subject_mappingCreateCmd.Use, + policy_subject_mappingGetCmd.Use, + policy_subject_mappingsListCmd.Use, + policy_subject_mappingUpdateCmd.Use, + policy_subject_mappingDeleteCmd.Use, + } + + subjectValues []string + + policy_subject_mappingsCmd = &cobra.Command{ + Use: "subject-mappings", + Short: "Manage subject mappings [" + strings.Join(policy_subject_mappingsCmds, ", ") + "]", + Long: ` +Subject Mappings - commands to manage relationships between subjects (PEs, NPEs, etc) and attributes. + +For example: a subject mapping could be created such that the AcmeCorp engineering +team member named "Alice" is "IN" the value "Engineering" for attribute "Teams" in +namespace "acmecorp.com", but is not mapped to the attribute value "Sales" within the +same attribute and namespace. +`, + } + + policy_subject_mappingGetCmd = &cobra.Command{ + Use: "get", + Short: "Get a subject mapping by id", + Run: func(cmd *cobra.Command, args []string) { + h := cli.NewHandler(cmd) + defer h.Close() + + flagHelper := cli.NewFlagHelper(cmd) + id := flagHelper.GetRequiredString("id") + + mapping, err := h.GetSubjectMapping(id) + if err != nil { + errMsg := fmt.Sprintf("Could not find subject mapping (%s)", id) + cli.ExitWithNotFoundError(errMsg, err) + cli.ExitWithError(errMsg, err) + } + + rows := [][]string{ + {"Id", mapping.Id}, + {"Subject Attribute", mapping.SubjectAttribute}, + {"Operator", handlers.GetSubjectMappingOperatorChoiceFromEnum(mapping.Operator)}, + {"Subject Values", strings.Join(mapping.SubjectValues, ", ")}, + } + + if mdRows := getMetadataRows(mapping.Metadata); mdRows != nil { + rows = append(rows, mdRows...) + } + + if !jsonOutput { + cli.PrintSuccessTable(cmd, id, cli.NewTabular().Rows(rows...)) + } else { + if output, err := json.MarshalIndent(mapping, "", " "); err != nil { + cli.ExitWithError("Error marshalling subject mapping", err) + } else { + fmt.Println(string(output)) + } + } + }, + } + + policy_subject_mappingsListCmd = &cobra.Command{ + Use: "list", + Short: "List subject mappings", + Run: func(cmd *cobra.Command, args []string) { + h := cli.NewHandler(cmd) + defer h.Close() + + list, err := h.ListSubjectMappings() + if err != nil { + cli.ExitWithError("Could not get subject mappings", err) + } + + if jsonOutput { + if output, err := json.MarshalIndent(list, "", " "); err != nil { + cli.ExitWithError("Error marshalling subject mappings", err) + } else { + fmt.Println(string(output)) + } + return + } + + t := cli.NewTable().Width(180) + t.Headers("Id", "Subject Attribute", "Operator", "Subject Values", "Attribute Value ID") + for _, sm := range list { + rowCells := []string{ + sm.Id, + sm.SubjectAttribute, + handlers.GetSubjectMappingOperatorChoiceFromEnum(sm.Operator), + strings.Join(sm.SubjectValues, ", "), + sm.AttributeValue.Id, + } + t.Row(rowCells...) + } + cli.PrintSuccessTable(cmd, "", t) + }, + } + + policy_subject_mappingCreateCmd = &cobra.Command{ + Use: "create", + Short: "Create a new subject mapping", + Run: func(cmd *cobra.Command, args []string) { + h := cli.NewHandler(cmd) + defer h.Close() + + flagHelper := cli.NewFlagHelper(cmd) + attrValueId := flagHelper.GetRequiredString("attribute-value-id") + subjectAttribute := flagHelper.GetRequiredString("subject-attribute") + subjectValues := flagHelper.GetStringSlice("subject-values", subjectValues, cli.FlagHelperStringSliceOptions{Min: 1}) + operator := flagHelper.GetRequiredString("operator") + + m := flagHelper.GetOptionalString("metadata") + metadata := unMarshalMetadata(m) + + mapping, err := h.CreateNewSubjectMapping(attrValueId, subjectAttribute, subjectValues, operator, metadata) + if err != nil { + cli.ExitWithError("Could not create subject mapping", err) + } + + if jsonOutput { + if output, err := json.MarshalIndent(mapping, "", " "); err != nil { + cli.ExitWithError("Error marshalling subject mapping", err) + } else { + fmt.Println(string(output)) + } + return + } + + rows := [][]string{ + {"Id", mapping.Id}, + {"Subject Attribute", mapping.SubjectAttribute}, + {"Operator", handlers.GetSubjectMappingOperatorChoiceFromEnum(mapping.Operator)}, + {"Subject Values", strings.Join(mapping.SubjectValues, ", ")}, + {"Attribute Value Id", mapping.AttributeValue.Id}, + } + + if mdRows := getMetadataRows(mapping.Metadata); mdRows != nil { + rows = append(rows, mdRows...) + } + + cli.PrintSuccessTable(cmd, mapping.Id, + cli.NewTabular(). + Rows(rows...)) + }, + } + + policy_subject_mappingDeleteCmd = &cobra.Command{ + Use: "delete", + Short: "Delete a subject mapping by id", + Run: func(cmd *cobra.Command, args []string) { + h := cli.NewHandler(cmd) + defer h.Close() + + flagHelper := cli.NewFlagHelper(cmd) + id := flagHelper.GetRequiredString("id") + + sm, err := h.GetSubjectMapping(id) + if err != nil { + errMsg := fmt.Sprintf("Could not find subject mapping (%s)", id) + cli.ExitWithNotFoundError(errMsg, err) + cli.ExitWithError(errMsg, err) + } + + cli.ConfirmDelete("subject mapping", sm.Id) + + if err := h.DeleteSubjectMapping(id); err != nil { + errMsg := fmt.Sprintf("Could not delete subject mapping (%s)", id) + cli.ExitWithNotFoundError(errMsg, err) + cli.ExitWithError(errMsg, err) + } + + // TODO: handle json output once service sends back deleted subject mapping + cli.PrintSuccessTable(cmd, id, nil) + }, + } + + policy_subject_mappingUpdateCmd = &cobra.Command{ + Use: "update", + Short: "Update a subject mapping", + Run: func(cmd *cobra.Command, args []string) { + h := cli.NewHandler(cmd) + defer h.Close() + + flagHelper := cli.NewFlagHelper(cmd) + id := flagHelper.GetRequiredString("id") + attrValueId := flagHelper.GetRequiredString("attribute-value-id") + subjectAttribute := flagHelper.GetRequiredString("subject-attribute") + subjectValues := flagHelper.GetStringSlice("subject-values", subjectValues, cli.FlagHelperStringSliceOptions{Min: 1}) + operator := flagHelper.GetRequiredString("operator") + + m := flagHelper.GetOptionalString("metadata") + metadata := unMarshalMetadata(m) + + if _, err := h.UpdateSubjectMapping( + id, + attrValueId, + subjectAttribute, + subjectValues, + operator, + metadata, + ); err != nil { + cli.ExitWithError("Could not update subject mapping", err) + } + + // TODO: handle json output once service sends back updated subject mapping + fmt.Println(cli.SuccessMessage(fmt.Sprintf("Subject mapping id: (%s) updated.", id))) + }, + } +) + +func init() { + policyCmd.AddCommand(policy_subject_mappingsCmd) + + policy_subject_mappingsCmd.AddCommand(policy_subject_mappingGetCmd) + policy_subject_mappingGetCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") + + policy_subject_mappingsCmd.AddCommand(policy_subject_mappingsListCmd) + + policy_subject_mappingsCmd.AddCommand(policy_subject_mappingCreateCmd) + policy_subject_mappingCreateCmd.Flags().StringP("attribute-value-id", "a", "", "Id of the attribute value") + policy_subject_mappingCreateCmd.Flags().StringP("subject-attribute", "s", "", "Subject attribute") + policy_subject_mappingCreateCmd.Flags().StringSliceVarP(&subjectValues, "subject-values", "v", []string{}, "Subject values") + policy_subject_mappingCreateCmd.Flags().StringP("operator", "o", "", "Operator") + policy_subject_mappingCreateCmd.Flags().StringP("metadata", "m", "", "Metadata (optional): labels and description") + + policy_subject_mappingsCmd.AddCommand(policy_subject_mappingUpdateCmd) + policy_subject_mappingUpdateCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") + policy_subject_mappingUpdateCmd.Flags().StringP("attribute-value-id", "a", "", "Id of the attribute value") + policy_subject_mappingUpdateCmd.Flags().StringP("subject-attribute", "s", "", "Subject attribute") + policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&subjectValues, "subject-values", "v", []string{}, "Subject values") + policy_subject_mappingUpdateCmd.Flags().StringP("operator", "o", "", "Operator: [IN, NOT_IN]") + policy_subject_mappingUpdateCmd.Flags().StringP("metadata", "m", "", "Metadata (optional): labels and description") + + policy_subject_mappingsCmd.AddCommand(policy_subject_mappingDeleteCmd) + policy_subject_mappingDeleteCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") +} func placeholder() { fmt.Println("This is a placeholder for the policy-subject_mappings.go file, once the subject mappings have been stablized") From 0c170a8070b1310680e8eeede1b25b05a9b18780 Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Wed, 13 Mar 2024 17:07:05 -0400 Subject: [PATCH 04/13] checkpoint --- cmd/policy-subject_mappings.go | 27 ++-- pkg/handlers/subjectmappings.go | 229 ++++++++++++++++---------------- 2 files changed, 122 insertions(+), 134 deletions(-) diff --git a/cmd/policy-subject_mappings.go b/cmd/policy-subject_mappings.go index 5c42a42d..ca11b56a 100644 --- a/cmd/policy-subject_mappings.go +++ b/cmd/policy-subject_mappings.go @@ -6,7 +6,6 @@ import ( "strings" "github.com/opentdf/tructl/pkg/cli" - "github.com/opentdf/tructl/pkg/handlers" "github.com/spf13/cobra" ) @@ -53,9 +52,9 @@ same attribute and namespace. rows := [][]string{ {"Id", mapping.Id}, - {"Subject Attribute", mapping.SubjectAttribute}, - {"Operator", handlers.GetSubjectMappingOperatorChoiceFromEnum(mapping.Operator)}, - {"Subject Values", strings.Join(mapping.SubjectValues, ", ")}, + // {"Subject Attribute", mapping.SubjectAttribute}, + // {"Operator", handlers.GetSubjectMappingOperatorChoiceFromEnum(mapping.Operator)}, + // {"Subject Values", strings.Join(mapping.SubjectValues, ", ")}, } if mdRows := getMetadataRows(mapping.Metadata); mdRows != nil { @@ -100,9 +99,9 @@ same attribute and namespace. for _, sm := range list { rowCells := []string{ sm.Id, - sm.SubjectAttribute, - handlers.GetSubjectMappingOperatorChoiceFromEnum(sm.Operator), - strings.Join(sm.SubjectValues, ", "), + // sm.SubjectAttribute, + // handlers.GetSubjectMappingOperatorChoiceFromEnum(sm.Operator), + // strings.Join(sm.SubjectValues, ", "), sm.AttributeValue.Id, } t.Row(rowCells...) @@ -143,9 +142,9 @@ same attribute and namespace. rows := [][]string{ {"Id", mapping.Id}, - {"Subject Attribute", mapping.SubjectAttribute}, - {"Operator", handlers.GetSubjectMappingOperatorChoiceFromEnum(mapping.Operator)}, - {"Subject Values", strings.Join(mapping.SubjectValues, ", ")}, + // {"Subject Attribute", mapping.SubjectAttribute}, + // {"Operator", handlers.GetSubjectMappingOperatorChoiceFromEnum(mapping.Operator)}, + // {"Subject Values", strings.Join(mapping.SubjectValues, ", ")}, {"Attribute Value Id", mapping.AttributeValue.Id}, } @@ -249,11 +248,3 @@ func init() { policy_subject_mappingsCmd.AddCommand(policy_subject_mappingDeleteCmd) policy_subject_mappingDeleteCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") } - -func placeholder() { - fmt.Println("This is a placeholder for the policy-subject_mappings.go file, once the subject mappings have been stablized") -} - -func main() { - placeholder() -} diff --git a/pkg/handlers/subjectmappings.go b/pkg/handlers/subjectmappings.go index 3c50f857..25059e75 100644 --- a/pkg/handlers/subjectmappings.go +++ b/pkg/handlers/subjectmappings.go @@ -1,118 +1,115 @@ package handlers -// import ( -// "fmt" -// "slices" -// "strings" - -// "github.com/opentdf/platform/protocol/go/common" -// "github.com/opentdf/platform/protocol/go/policy" -// "github.com/opentdf/platform/protocol/go/policy/subjectmapping" -// ) - -// const ( -// SubjectMappingOperatorIn = "IN" -// SubjectMappingOperatorNotIn = "NOT_IN" -// SubjectMappingOperatorUnspecified = "UNSPECIFIED" -// ) - -// var SubjectMappingOperatorEnumChoices = []string{SubjectMappingOperatorIn, SubjectMappingOperatorNotIn, SubjectMappingOperatorUnspecified} - -// func (h Handler) GetSubjectMapping(id string) (*policy.SubjectMapping, error) { -// resp, err := h.sdk.SubjectMapping.GetSubjectMapping(h.ctx, &subjectmapping.GetSubjectMappingRequest{ -// Id: id, -// }) -// if err != nil { -// return nil, err -// } - -// return resp.SubjectMapping, nil -// } - -// func (h Handler) ListSubjectMappings() ([]*policy.SubjectMapping, error) { -// resp, err := h.sdk.SubjectMapping.ListSubjectMappings(h.ctx, &subjectmapping.ListSubjectMappingsRequest{}) -// if err != nil { -// return nil, err -// } - -// return resp.SubjectMappings, nil -// } - -// func (h Handler) CreateNewSubjectMapping(attributeValueId string, subjectAttribute string, subjectValues []string, operator string, metadata *common.MetadataMutable) (*subjectmapping.SubjectMapping, error) { -// if !slices.Contains(SubjectMappingOperatorEnumChoices, operator) { -// return nil, fmt.Errorf("Invalid operator. Must be one of [%s]" + strings.Join(SubjectMappingOperatorEnumChoices, ", ")) -// } - -// resp, err := h.sdk.SubjectMapping.CreateSubjectMapping(h.ctx, &subjectmapping.CreateSubjectMappingRequest{ -// SubjectMapping: &subjectmapping.SubjectMappingCreateUpdate{ -// AttributeValueId: attributeValueId, -// SubjectAttribute: subjectAttribute, -// SubjectValues: subjectValues, -// Operator: GetSubjectMappingOperatorFromChoice(operator), -// Metadata: metadata, -// }, -// }) -// if err != nil { -// return nil, err -// } - -// return resp.SubjectMapping, nil -// } - -// func (h Handler) UpdateSubjectMapping(id string, attributeValueId string, subjectAttribute string, subjectValues []string, operator string, metadata *common.MetadataMutable) (*subjectmapping.SubjectMapping, error) { -// if !slices.Contains(SubjectMappingOperatorEnumChoices, operator) { -// return nil, fmt.Errorf("Invalid operator. Must be one of [%s]" + strings.Join(SubjectMappingOperatorEnumChoices, ", ")) -// } - -// resp, err := h.sdk.SubjectMapping.UpdateSubjectMapping(h.ctx, &subjectmapping.UpdateSubjectMappingRequest{ -// Id: id, -// SubjectMapping: &subjectmapping.SubjectMappingCreateUpdate{ -// AttributeValueId: attributeValueId, -// SubjectAttribute: subjectAttribute, -// SubjectValues: subjectValues, -// Operator: GetSubjectMappingOperatorFromChoice(operator), -// Metadata: metadata, -// }, -// }) -// if err != nil { -// return nil, err -// } -// return resp.SubjectMapping, nil -// } - -// func (h Handler) DeleteSubjectMapping(id string) error { -// _, err := h.sdk.SubjectMapping.DeleteSubjectMapping(h.ctx, &subjectmapping.DeleteSubjectMappingRequest{ -// Id: id, -// }) -// if err != nil { -// return err -// } - -// return nil -// } - -// func GetSubjectMappingOperatorFromChoice(readable string) subjectmapping.SubjectMappingOperatorEnum { -// switch readable { -// case SubjectMappingOperatorIn: -// return subjectmapping.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_IN -// case SubjectMappingOperatorNotIn: -// return subjectmapping.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_NOT_IN -// case SubjectMappingOperatorUnspecified: -// return subjectmapping.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_UNSPECIFIED -// default: -// return subjectmapping.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_UNSPECIFIED -// } -// } - -// func GetSubjectMappingOperatorChoiceFromEnum(enum subjectmapping.SubjectMappingOperatorEnum) string { -// switch enum { -// case subjectmapping.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_IN: -// return SubjectMappingOperatorIn -// case subjectmapping.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_NOT_IN: -// return SubjectMappingOperatorNotIn -// case subjectmapping.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_UNSPECIFIED: -// return SubjectMappingOperatorUnspecified -// default: -// return SubjectMappingOperatorUnspecified -// } -// } +import ( + "fmt" + "slices" + "strings" + + "github.com/opentdf/platform/protocol/go/common" + "github.com/opentdf/platform/protocol/go/policy" + "github.com/opentdf/platform/protocol/go/policy/subjectmapping" +) + +const ( + SubjectMappingOperatorIn = "IN" + SubjectMappingOperatorNotIn = "NOT_IN" + SubjectMappingOperatorUnspecified = "UNSPECIFIED" +) + +var SubjectMappingOperatorEnumChoices = []string{SubjectMappingOperatorIn, SubjectMappingOperatorNotIn, SubjectMappingOperatorUnspecified} + +func (h Handler) GetSubjectMapping(id string) (*policy.SubjectMapping, error) { + resp, err := h.sdk.SubjectMapping.GetSubjectMapping(h.ctx, &subjectmapping.GetSubjectMappingRequest{ + Id: id, + }) + if err != nil { + return nil, err + } + + return resp.SubjectMapping, nil +} + +func (h Handler) ListSubjectMappings() ([]*policy.SubjectMapping, error) { + resp, err := h.sdk.SubjectMapping.ListSubjectMappings(h.ctx, &subjectmapping.ListSubjectMappingsRequest{}) + if err != nil { + return nil, err + } + + return resp.SubjectMappings, nil +} + +func (h Handler) CreateNewSubjectMapping(attributeValueId string, subjectAttribute string, subjectValues []string, operator string, metadata *common.MetadataMutable) (*policy.SubjectMapping, error) { + if !slices.Contains(SubjectMappingOperatorEnumChoices, operator) { + return nil, fmt.Errorf("Invalid operator. Must be one of [%s]" + strings.Join(SubjectMappingOperatorEnumChoices, ", ")) + } + + resp, err := h.sdk.SubjectMapping.CreateSubjectMapping(h.ctx, &subjectmapping.CreateSubjectMappingRequest{ + AttributeValueId: attributeValueId, + // SubjectAttribute: subjectAttribute, + // SubjectValues: subjectValues, + // Operator: GetSubjectMappingOperatorFromChoice(operator), + Metadata: metadata, + }) + if err != nil { + return nil, err + } + + return resp.SubjectMapping, nil +} + +// TODO: verify update behavior +func (h Handler) UpdateSubjectMapping(id string, attributeValueId string, subjectAttribute string, subjectValues []string, operator string, metadata *common.MetadataMutable) (*policy.SubjectMapping, error) { + if !slices.Contains(SubjectMappingOperatorEnumChoices, operator) { + return nil, fmt.Errorf("Invalid operator. Must be one of [%s]" + strings.Join(SubjectMappingOperatorEnumChoices, ", ")) + } + + resp, err := h.sdk.SubjectMapping.UpdateSubjectMapping(h.ctx, &subjectmapping.UpdateSubjectMappingRequest{ + Id: id, + // AttributeValueId: attributeValueId, + // SubjectAttribute: subjectAttribute, + // SubjectValues: subjectValues, + // Operator: GetSubjectMappingOperatorFromChoice(operator), + Metadata: metadata, + }) + if err != nil { + return nil, err + } + return resp.SubjectMapping, nil +} + +func (h Handler) DeleteSubjectMapping(id string) error { + _, err := h.sdk.SubjectMapping.DeleteSubjectMapping(h.ctx, &subjectmapping.DeleteSubjectMappingRequest{ + Id: id, + }) + if err != nil { + return err + } + + return nil +} + +func GetSubjectMappingOperatorFromChoice(readable string) policy.SubjectMappingOperatorEnum { + switch readable { + case SubjectMappingOperatorIn: + return policy.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_IN + case SubjectMappingOperatorNotIn: + return policy.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_NOT_IN + case SubjectMappingOperatorUnspecified: + return policy.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_UNSPECIFIED + default: + return policy.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_UNSPECIFIED + } +} + +func GetSubjectMappingOperatorChoiceFromEnum(enum policy.SubjectMappingOperatorEnum) string { + switch enum { + case policy.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_IN: + return SubjectMappingOperatorIn + case policy.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_NOT_IN: + return SubjectMappingOperatorNotIn + case policy.SubjectMappingOperatorEnum_SUBJECT_MAPPING_OPERATOR_ENUM_UNSPECIFIED: + return SubjectMappingOperatorUnspecified + default: + return SubjectMappingOperatorUnspecified + } +} From 9161765b92e23d66786350574725a8e29e9a255f Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Thu, 14 Mar 2024 15:46:35 -0400 Subject: [PATCH 05/13] add new reusable metadata functionality for create and update, and consume subject mappings RPCs for CRUD --- cmd/dev.go | 56 +++++++++ cmd/policy-attributes.go | 4 +- cmd/policy-subject_mappings.go | 206 +++++++++++++++++++++++++------- go.mod | 22 +--- go.sum | 114 ++---------------- pkg/handlers/subjectmappings.go | 71 ++++------- 6 files changed, 256 insertions(+), 217 deletions(-) diff --git a/cmd/dev.go b/cmd/dev.go index dd549894..d2df8887 100644 --- a/cmd/dev.go +++ b/cmd/dev.go @@ -3,6 +3,7 @@ package cmd import ( "encoding/json" "fmt" + "strings" "github.com/opentdf/platform/protocol/go/common" "github.com/opentdf/tructl/pkg/cli" @@ -75,6 +76,61 @@ func unMarshalMetadata(m string) *common.MetadataMutable { return nil } +func getMetadata(labels []string) *common.MetadataMutable { + var metadata *common.MetadataMutable + if len(labels) > 0 { + metadata.Labels = map[string]string{} + for _, label := range labels { + kv := strings.Split(label, "=") + if len(kv) != 2 { + cli.ExitWithError("Invalid label format", nil) + } + metadata.Labels[kv[0]] = kv[1] + } + return metadata + } + return nil +} + +func processUpdateMetadata(newLabels, updatedLabels []string, getExtendableMetadata func() (*common.Metadata, error)) (*common.MetadataMutable, common.MetadataUpdateEnum) { + var metadata *common.MetadataMutable + behavior := common.MetadataUpdateEnum_METADATA_UPDATE_ENUM_EXTEND + if len(updatedLabels) == 0 { + metadata = getMetadata(newLabels) + } + if len(updatedLabels) > 0 { + behavior = common.MetadataUpdateEnum_METADATA_UPDATE_ENUM_REPLACE + md, _ := getExtendableMetadata() + metadata = mergeMetadata(md.Labels, newLabels, updatedLabels) + } + return metadata, behavior +} + +func mergeMetadata(existing map[string]string, newLabels, replacedLabels []string) *common.MetadataMutable { + merged := map[string]string{} + if existing != nil { + merged = existing + } + for _, label := range newLabels { + kv := strings.Split(label, "=") + if len(kv) != 2 { + cli.ExitWithError("Invalid label format", nil) + } + merged[kv[0]] = kv[1] + } + for _, label := range replacedLabels { + kv := strings.Split(label, "=") + if len(kv) != 2 { + cli.ExitWithError("Invalid label format", nil) + } + merged[kv[0]] = kv[1] + } + + return &common.MetadataMutable{ + Labels: merged, + } +} + func init() { rootCmd.AddCommand(devCmd) devCmd.AddCommand(designCmd) diff --git a/cmd/policy-attributes.go b/cmd/policy-attributes.go index 2f57ad0e..81c043ba 100644 --- a/cmd/policy-attributes.go +++ b/cmd/policy-attributes.go @@ -10,7 +10,9 @@ import ( ) var ( - attrValues []string + attrValues []string + newMetadataLabels []string + updatedMetadataLabels []string policy_attributeCommands = []string{ policy_attributesCreateCmd.Use, diff --git a/cmd/policy-subject_mappings.go b/cmd/policy-subject_mappings.go index ca11b56a..3f4c7743 100644 --- a/cmd/policy-subject_mappings.go +++ b/cmd/policy-subject_mappings.go @@ -5,6 +5,8 @@ import ( "fmt" "strings" + "github.com/opentdf/platform/protocol/go/common" + "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/tructl/pkg/cli" "github.com/spf13/cobra" ) @@ -18,18 +20,29 @@ var ( policy_subject_mappingDeleteCmd.Use, } - subjectValues []string + standardActions []string + customActions []string policy_subject_mappingsCmd = &cobra.Command{ Use: "subject-mappings", Short: "Manage subject mappings [" + strings.Join(policy_subject_mappingsCmds, ", ") + "]", Long: ` -Subject Mappings - commands to manage relationships between subjects (PEs, NPEs, etc) and attributes. +Subject Mappings - relations between Attribute Values and Subject Condition Sets that define the allowed Actions. -For example: a subject mapping could be created such that the AcmeCorp engineering -team member named "Alice" is "IN" the value "Engineering" for attribute "Teams" in -namespace "acmecorp.com", but is not mapped to the attribute value "Sales" within the -same attribute and namespace. +If a User's properties match a Subject Condition Set, the corresponding Subject Mapping provides them a set of allowed Actions +on any Resource (data) containing the mapped Attribute Value. + + Attribute Value <------ Subject Mapping -------> Subject Condition Set + + Subject Mapping: + - Attribute Value: associated Attribute Value that the Subject Mapping Actions are relevant to + - Actions: permitted Actions a Subject can take on Resources containing the Attribute Value + - Subject Condition Set: associated logical structure of external fields and values to match a Subject + +Platform consumption flow: +Subject/User -> IdP/LDAP's External Fields & Values -> SubjectConditionSet -> SubjectMapping w/ Actions -> AttributeValue + +Note: SubjectConditionSets are reusable among SubjectMappings and are available under separate 'policy' commands. `, } @@ -50,11 +63,23 @@ same attribute and namespace. cli.ExitWithError(errMsg, err) } + var actionsJSON []byte + if actionsJSON, err = json.Marshal(mapping.Actions); err != nil { + cli.ExitWithError("Error marshalling subject mapping actions", err) + } + + var subjectSetsJSON []byte + if subjectSetsJSON, err = json.Marshal(mapping.SubjectConditionSet.SubjectSets); err != nil { + cli.ExitWithError("Error marshalling subject condition set", err) + } + rows := [][]string{ {"Id", mapping.Id}, - // {"Subject Attribute", mapping.SubjectAttribute}, - // {"Operator", handlers.GetSubjectMappingOperatorChoiceFromEnum(mapping.Operator)}, - // {"Subject Values", strings.Join(mapping.SubjectValues, ", ")}, + {"Subject AttrVal: Id", mapping.AttributeValue.Id}, + {"Subject AttrVal: Value", mapping.AttributeValue.Value}, + {"Actions", string(actionsJSON)}, + {"Subject Condition Set: Id", mapping.SubjectConditionSet.Id}, + {"Subject Condition Set", string(subjectSetsJSON)}, } if mdRows := getMetadataRows(mapping.Metadata); mdRows != nil { @@ -95,14 +120,25 @@ same attribute and namespace. } t := cli.NewTable().Width(180) - t.Headers("Id", "Subject Attribute", "Operator", "Subject Values", "Attribute Value ID") + t.Headers("Id", "Subject AttrVal: Id", "Subject AttrVal: Value", "Actions", "Subject Condition Set: Id", "Subject Condition Set") for _, sm := range list { + var actionsJSON []byte + if actionsJSON, err = json.Marshal(sm.Actions); err != nil { + cli.ExitWithError("Error marshalling subject mapping actions", err) + } + + var subjectSetsJSON []byte + if subjectSetsJSON, err = json.Marshal(sm.SubjectConditionSet.SubjectSets); err != nil { + cli.ExitWithError("Error marshalling subject condition set", err) + } + rowCells := []string{ sm.Id, - // sm.SubjectAttribute, - // handlers.GetSubjectMappingOperatorChoiceFromEnum(sm.Operator), - // strings.Join(sm.SubjectValues, ", "), sm.AttributeValue.Id, + sm.AttributeValue.Value, + string(actionsJSON), + sm.SubjectConditionSet.Id, + string(subjectSetsJSON), } t.Row(rowCells...) } @@ -119,14 +155,28 @@ same attribute and namespace. flagHelper := cli.NewFlagHelper(cmd) attrValueId := flagHelper.GetRequiredString("attribute-value-id") - subjectAttribute := flagHelper.GetRequiredString("subject-attribute") - subjectValues := flagHelper.GetStringSlice("subject-values", subjectValues, cli.FlagHelperStringSliceOptions{Min: 1}) - operator := flagHelper.GetRequiredString("operator") - - m := flagHelper.GetOptionalString("metadata") - metadata := unMarshalMetadata(m) + standardActions := flagHelper.GetStringSlice("action-standard", standardActions, cli.FlagHelperStringSliceOptions{Min: 0}) + customActions := flagHelper.GetStringSlice("action-custom", customActions, cli.FlagHelperStringSliceOptions{Min: 0}) + existingSCSId := flagHelper.GetOptionalString("subject-condition-set-id") + // TODO: do we need to support creating a SM & SCS simultaneously? If so, it gets more complex. + // newScs := flagHelper.GetOptionalString("new-subject-condition-set") + metadataLabels := flagHelper.GetStringSlice("label", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + + // validations + if len(standardActions) == 0 && len(customActions) == 0 { + cli.ExitWithError("At least one Standard or Custom Action [--action-standard, --action-custom] is required", nil) + } + if len(standardActions) > 0 { + for _, a := range standardActions { + a = strings.ToUpper(a) + if a != "DECRYPT" && a != "TRANSMIT" { + cli.ExitWithError(fmt.Sprintf("Invalid Standard Action: '%s'. Must be one of [ENCRYPT, TRANSMIT].", a), nil) + } + } + } + actions := getFullActionsList(standardActions, customActions) - mapping, err := h.CreateNewSubjectMapping(attrValueId, subjectAttribute, subjectValues, operator, metadata) + mapping, err := h.CreateNewSubjectMapping(attrValueId, actions, existingSCSId, nil, getMetadata(metadataLabels)) if err != nil { cli.ExitWithError("Could not create subject mapping", err) } @@ -140,11 +190,23 @@ same attribute and namespace. return } + var actionsJSON []byte + if actionsJSON, err = json.Marshal(mapping.Actions); err != nil { + cli.ExitWithError("Error marshalling subject mapping actions", err) + } + + var subjectSetsJSON []byte + if subjectSetsJSON, err = json.Marshal(mapping.SubjectConditionSet.SubjectSets); err != nil { + cli.ExitWithError("Error marshalling subject condition set", err) + } + rows := [][]string{ {"Id", mapping.Id}, - // {"Subject Attribute", mapping.SubjectAttribute}, - // {"Operator", handlers.GetSubjectMappingOperatorChoiceFromEnum(mapping.Operator)}, - // {"Subject Values", strings.Join(mapping.SubjectValues, ", ")}, + {"Subject AttrVal: Id", mapping.AttributeValue.Id}, + {"Subject AttrVal: Value", mapping.AttributeValue.Value}, + {"Actions", string(actionsJSON)}, + {"Subject Condition Set: Id", mapping.SubjectConditionSet.Id}, + {"Subject Condition Set", string(subjectSetsJSON)}, {"Attribute Value Id", mapping.AttributeValue.Id}, } @@ -177,7 +239,7 @@ same attribute and namespace. cli.ConfirmDelete("subject mapping", sm.Id) - if err := h.DeleteSubjectMapping(id); err != nil { + if _, err := h.DeleteSubjectMapping(id); err != nil { errMsg := fmt.Sprintf("Could not delete subject mapping (%s)", id) cli.ExitWithNotFoundError(errMsg, err) cli.ExitWithError(errMsg, err) @@ -191,27 +253,49 @@ same attribute and namespace. policy_subject_mappingUpdateCmd = &cobra.Command{ Use: "update", Short: "Update a subject mapping", + Long: ` +Update a Subject Mapping by id. +'Actions' are updated in place, destructively replacing the current set. If you want to add or remove actions, you must provide the +full set of actions on update. `, Run: func(cmd *cobra.Command, args []string) { h := cli.NewHandler(cmd) defer h.Close() flagHelper := cli.NewFlagHelper(cmd) id := flagHelper.GetRequiredString("id") - attrValueId := flagHelper.GetRequiredString("attribute-value-id") - subjectAttribute := flagHelper.GetRequiredString("subject-attribute") - subjectValues := flagHelper.GetStringSlice("subject-values", subjectValues, cli.FlagHelperStringSliceOptions{Min: 1}) - operator := flagHelper.GetRequiredString("operator") - - m := flagHelper.GetOptionalString("metadata") - metadata := unMarshalMetadata(m) + standardActions := flagHelper.GetStringSlice("action-standard", standardActions, cli.FlagHelperStringSliceOptions{Min: 0}) + customActions := flagHelper.GetStringSlice("action-custom", customActions, cli.FlagHelperStringSliceOptions{Min: 0}) + scsId := flagHelper.GetOptionalString("subject-condition-set-id") + newLabels := flagHelper.GetStringSlice("label-new", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + replacedLabels := flagHelper.GetStringSlice("label-replace", updatedMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + + if len(standardActions) > 0 { + for _, a := range standardActions { + a = strings.ToUpper(a) + if a != "DECRYPT" && a != "TRANSMIT" { + cli.ExitWithError(fmt.Sprintf("Invalid Standard Action: '%s'. Must be one of [ENCRYPT, TRANSMIT]. Other actions must be custom.", a), nil) + } + } + } + actions := getFullActionsList(standardActions, customActions) + + metadata, behavior := processUpdateMetadata(newLabels, replacedLabels, func() (*common.Metadata, error) { + sm, err := h.GetSubjectMapping(id) + if err != nil { + errMsg := fmt.Sprintf("Could not find subject mapping (%s)", id) + cli.ExitWithNotFoundError(errMsg, err) + cli.ExitWithError(errMsg, err) + } + return sm.Metadata, nil + }, + ) if _, err := h.UpdateSubjectMapping( id, - attrValueId, - subjectAttribute, - subjectValues, - operator, + scsId, + actions, metadata, + behavior, ); err != nil { cli.ExitWithError("Could not update subject mapping", err) } @@ -222,6 +306,36 @@ same attribute and namespace. } ) +func getSubjectMappingMappingActionEnumFromChoice(readable string) policy.Action_StandardAction { + switch readable { + case "DECRYPT": + return policy.Action_STANDARD_ACTION_DECRYPT + case "TRANSMIT": + return policy.Action_STANDARD_ACTION_TRANSMIT + default: + return policy.Action_STANDARD_ACTION_UNSPECIFIED + } +} + +func getFullActionsList(standardActions, customActions []string) []*policy.Action { + actions := []*policy.Action{} + for _, a := range standardActions { + actions = append(actions, &policy.Action{ + Value: &policy.Action_Standard{ + Standard: getSubjectMappingMappingActionEnumFromChoice(a), + }, + }) + } + for _, a := range customActions { + actions = append(actions, &policy.Action{ + Value: &policy.Action_Custom{ + Custom: a, + }, + }) + } + return actions +} + func init() { policyCmd.AddCommand(policy_subject_mappingsCmd) @@ -231,19 +345,21 @@ func init() { policy_subject_mappingsCmd.AddCommand(policy_subject_mappingsListCmd) policy_subject_mappingsCmd.AddCommand(policy_subject_mappingCreateCmd) - policy_subject_mappingCreateCmd.Flags().StringP("attribute-value-id", "a", "", "Id of the attribute value") - policy_subject_mappingCreateCmd.Flags().StringP("subject-attribute", "s", "", "Subject attribute") - policy_subject_mappingCreateCmd.Flags().StringSliceVarP(&subjectValues, "subject-values", "v", []string{}, "Subject values") - policy_subject_mappingCreateCmd.Flags().StringP("operator", "o", "", "Operator") - policy_subject_mappingCreateCmd.Flags().StringP("metadata", "m", "", "Metadata (optional): labels and description") + policy_subject_mappingCreateCmd.Flags().StringP("attribute-value-id", "a", "", "Id of the mapped Attribute Value") + policy_subject_mappingCreateCmd.Flags().StringSliceVarP(&standardActions, "action-standard", "as", []string{}, "Standard Action: [DECRYPT, TRANSMIT]") + policy_subject_mappingCreateCmd.Flags().StringSliceVarP(&customActions, "action-custom", "ac", []string{}, "Custom Action") + policy_subject_mappingCreateCmd.Flags().StringP("subject-condition-set-id", "scs-id", "", "Pre-existing Subject Condition Set Id") + // TODO: do we need to support creating a SM & SCS simultaneously? If so, it gets more complex. + // policy_subject_mappingCreateCmd.Flags().StringP("new-subject-condition-set", "scs", "", "New Subject Condition Set (optional)") + policy_subject_mappingCreateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label", "l", []string{}, "Optional metadata 'labels' in the format: key=value") policy_subject_mappingsCmd.AddCommand(policy_subject_mappingUpdateCmd) policy_subject_mappingUpdateCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") - policy_subject_mappingUpdateCmd.Flags().StringP("attribute-value-id", "a", "", "Id of the attribute value") - policy_subject_mappingUpdateCmd.Flags().StringP("subject-attribute", "s", "", "Subject attribute") - policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&subjectValues, "subject-values", "v", []string{}, "Subject values") - policy_subject_mappingUpdateCmd.Flags().StringP("operator", "o", "", "Operator: [IN, NOT_IN]") - policy_subject_mappingUpdateCmd.Flags().StringP("metadata", "m", "", "Metadata (optional): labels and description") + policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&standardActions, "action-standard", "as", []string{}, "Standard Action: [DECRYPT, TRANSMIT]. Note: destructively replaces existing Actions.") + policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&customActions, "action-custom", "ac", []string{}, "Custom Action. Note: destructively replaces existing Actions.") + policy_subject_mappingUpdateCmd.Flags().StringP("subject-condition-set-id", "scs-id", "", "Updated Subject Condition Set Id") + policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label-new", "ln", []string{}, "Optional new metadata 'labels' in the format: key=value") + policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&updatedMetadataLabels, "label-replace", "lr", []string{}, "Optional replace of existing metadata 'labels' in the format: key=value") policy_subject_mappingsCmd.AddCommand(policy_subject_mappingDeleteCmd) policy_subject_mappingDeleteCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") diff --git a/go.mod b/go.mod index 73f1a3ac..b2de69fa 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/charmbracelet/bubbles v0.17.2-0.20240108170749-ec883029c8e6 github.com/charmbracelet/bubbletea v0.25.0 github.com/charmbracelet/huh v0.3.0 - github.com/charmbracelet/lipgloss v0.9.1 + github.com/charmbracelet/lipgloss v0.10.0 github.com/muesli/reflow v0.3.0 github.com/opentdf/platform/protocol/go v0.0.0-20240313200110-bcc04e006182 github.com/opentdf/platform/sdk v0.0.0-20240313200110-bcc04e006182 @@ -26,10 +26,8 @@ require ( github.com/catppuccin/go v0.2.0 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/coreos/go-oidc/v3 v3.9.0 // indirect - github.com/creasty/defaults v1.7.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-jose/go-jose/v3 v3.0.3 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect @@ -38,7 +36,6 @@ require ( github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/klauspost/compress v1.17.2 // indirect github.com/lestrrat-go/blackmagic v1.0.2 // indirect @@ -48,30 +45,20 @@ require ( github.com/lestrrat-go/jwx/v2 v2.0.21 // indirect github.com/lestrrat-go/option v1.0.1 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect - github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/termenv v0.15.2 // indirect github.com/opentdf/backend-go v0.1.17 // indirect - github.com/pelletier/go-toml/v2 v2.1.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/rivo/uniseg v0.4.4 // indirect + github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect - github.com/sagikazarmark/locafero v0.4.0 // indirect - github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f // indirect github.com/segmentio/asm v1.2.0 // indirect - github.com/sourcegraph/conc v0.3.0 // indirect - github.com/spf13/afero v1.11.0 // indirect - github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.18.2 // indirect - github.com/subosito/gotenv v1.6.0 // indirect github.com/virtru/access-pdp v1.11.0 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect @@ -86,14 +73,11 @@ require ( golang.org/x/sys v0.18.0 // indirect golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.18.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + gotest.tools/v3 v3.5.1 // indirect ) diff --git a/go.sum b/go.sum index 6ffc3d25..08c1770c 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1 h1:u0olL4yf2p7Tl5jfsAK5keaFi+JFJuv1CDHrbiXkxkk= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1/go.mod h1:tiTMKD8j6Pd/D2WzREoweufjzaJKHZg35f/VGcZ2v3I= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1 h1:0nWhrRcnkgw1kwJ7xibIO8bqfOA7pBzBjGCDBxIHch8= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1/go.mod h1:Tgn5bgL220vkFOI0KPStlcClPeOJzAv4uT+V8JXGUnw= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= @@ -12,6 +10,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= +github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= +github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/adrg/frontmatter v0.2.0 h1:/DgnNe82o03riBd1S+ZDjd43wAmC6W35q67NHeLkPd4= github.com/adrg/frontmatter v0.2.0/go.mod h1:93rQCj3z3ZlwyxxpQioRKC1wDLto4aXHrbqIsnH9wmE= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= @@ -28,8 +28,8 @@ github.com/charmbracelet/bubbletea v0.25.0 h1:bAfwk7jRz7FKFl9RzlIULPkStffg5k6pNt github.com/charmbracelet/bubbletea v0.25.0/go.mod h1:EN3QDR1T5ZdWmdfDzYcqOCAps45+QIJbLOBxmVNWNNg= github.com/charmbracelet/huh v0.3.0 h1:CxPplWkgW2yUTDDG0Z4S5HH8SJOosWHd4LxCvi0XsKE= github.com/charmbracelet/huh v0.3.0/go.mod h1:fujUdKX8tC45CCSaRQdw789O6uaCRwx8l2NDyKfC4jA= -github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1p/u1KWg= -github.com/charmbracelet/lipgloss v0.9.1/go.mod h1:1mPmG4cxScwUQALAAnacHaigiiHB9Pmr+v1VEawJl6I= +github.com/charmbracelet/lipgloss v0.10.0 h1:KWeXFSexGcfahHX+54URiZGkBFazf70JNMtwg/AFW3s= +github.com/charmbracelet/lipgloss v0.10.0/go.mod h1:Wig9DSfvANsxqkRsqj6x87irdy123SR4dOXlKa91ciE= github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY= github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/containerd/containerd v1.7.12 h1:+KQsnv4VnzyxWcfO9mlxxELaoztsDEjOuCMPAuPqgU0= @@ -41,10 +41,7 @@ github.com/coreos/go-oidc/v3 v3.9.0/go.mod h1:rTKz2PYwftcrtoCzV5g5kvfJoWcm0Mk8AF github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creasty/defaults v1.7.0 h1:eNdqZvc5B509z18lD8yc212CAqJNvfT1Jq6L8WowdBA= -github.com/creasty/defaults v1.7.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= @@ -59,10 +56,6 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= -github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA= -github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= github.com/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k= github.com/go-jose/go-jose/v3 v3.0.3/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -80,11 +73,8 @@ github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOW github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= @@ -93,8 +83,6 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= @@ -111,14 +99,10 @@ github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE= github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= -github.com/lestrrat-go/httprc v1.0.4 h1:bAZymwoZQb+Oq8MEbyipag7iSq6YIga8Wj6GOiJGdI8= -github.com/lestrrat-go/httprc v1.0.4/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= github.com/lestrrat-go/httprc v1.0.5 h1:bsTfiH8xaKOJPrg1R+E3iE/AWZr/x0Phj9PBTG/OLUk= github.com/lestrrat-go/httprc v1.0.5/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI= github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= -github.com/lestrrat-go/jwx/v2 v2.0.19 h1:ekv1qEZE6BVct89QA+pRF6+4pCpfVrOnEJnTnT4RXoY= -github.com/lestrrat-go/jwx/v2 v2.0.19/go.mod h1:l3im3coce1lL2cDeAjqmaR+Awx+X8Ih+2k8BuHNJ4CU= github.com/lestrrat-go/jwx/v2 v2.0.21 h1:jAPKupy4uHgrHFEdjVjNkUgoBKtVDgrQPB/h55FHrR0= github.com/lestrrat-go/jwx/v2 v2.0.21/go.mod h1:09mLW8zto6bWL9GbwnqAli+ArLf+5M33QLQPDggkUWM= github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= @@ -138,8 +122,6 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU= github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= @@ -162,22 +144,12 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= -github.com/opentdf/backend-go v0.1.16 h1:t7OD3ShBCeuAZWUKZNYJJBfC01d4X0EL5a6J1UnIdx4= -github.com/opentdf/backend-go v0.1.16/go.mod h1:4RAZ3K19YOJkpxSh4jl6vtjOUkK3H/zqA32LeBf3CDQ= github.com/opentdf/backend-go v0.1.17 h1:RA/9Mj7OKycnvOrkIZTJCsSyROCcioXzzqMUlnCxP48= github.com/opentdf/backend-go v0.1.17/go.mod h1:4RAZ3K19YOJkpxSh4jl6vtjOUkK3H/zqA32LeBf3CDQ= -github.com/opentdf/platform/protocol/go v0.0.0-20240301211102-04107b3757a9 h1:7E2tnDEZjIwHys0gPPs56Emf+sw1dKXmr+Ho/n/jH8M= -github.com/opentdf/platform/protocol/go v0.0.0-20240301211102-04107b3757a9/go.mod h1:O0Wolf3NAhKII0hfDcEPtpsXe/VcUI7Lq/rNqh8I7Wk= github.com/opentdf/platform/protocol/go v0.0.0-20240313200110-bcc04e006182 h1:iBhem3wapJaRI15yZ2Kv60MjikiD0wYbgtZOaWlAdbk= github.com/opentdf/platform/protocol/go v0.0.0-20240313200110-bcc04e006182/go.mod h1:qwJ2OQqNVtucVgkLlZhz6O1I1fxqHTXrl5HVRu9AO4Y= -github.com/opentdf/platform/sdk v0.0.0-20240301211102-04107b3757a9 h1:NY4GcZ5IETFH2NyexuEENgkL79ZiSQNaZhzs9OkozaI= -github.com/opentdf/platform/sdk v0.0.0-20240301211102-04107b3757a9/go.mod h1:ugS04emTB9g96A4sqNjOFVn0Ip4B/VVYQ+eAKD7OFxM= -github.com/opentdf/platform/sdk v0.0.0-20240305152130-b34c2fe9ad70 h1:FjKH+bwYRho7mJqPjX3vFnZu5jv7sjdupPhAI37xYgM= -github.com/opentdf/platform/sdk v0.0.0-20240305152130-b34c2fe9ad70/go.mod h1:secHYA6In0KqYB67IzB6b/GdFciPPSZUsjAXjvWkuU0= github.com/opentdf/platform/sdk v0.0.0-20240313200110-bcc04e006182 h1:zW4WrX92tV8kLJdmPDLBIhq7dJJFxztWvCVxF76inek= github.com/opentdf/platform/sdk v0.0.0-20240313200110-bcc04e006182/go.mod h1:oDdaR1hll4VtRfBuy1g6pE4d7iPgug2pZ6+akzLAyQA= -github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI= -github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -187,15 +159,11 @@ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= -github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= -github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= -github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= -github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f h1:MvTmaQdww/z0Q4wrYjDSCcZ78NoftLQyHBSLW/Cx79Y= github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= @@ -206,29 +174,16 @@ github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFt github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= -github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= -github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= -github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= -github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= -github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= -github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= -github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/testcontainers/testcontainers-go v0.28.0 h1:1HLm9qm+J5VikzFDYhOd+Zw12NtOl+8drH2E8nTY1r8= github.com/testcontainers/testcontainers-go v0.28.0/go.mod h1:COlDpUXbwW3owtpMkEB1zo9gwb1CoKVKlyrVPejF4AU= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= @@ -242,57 +197,36 @@ github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFi github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 h1:x8Z78aZx8cOF0+Kkazoc7lwUNMGy0LrzEMxTm4BbTxg= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0/go.mod h1:62CPTSry9QZtOaSsE3tOzhx6LzDhHnXJ6xHeMNNiM6Q= -go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= -go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= -go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= -go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= -go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= -go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= -go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -301,7 +235,6 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -311,8 +244,6 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= @@ -320,9 +251,6 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= @@ -338,48 +266,32 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= -golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe h1:USL2DhxfgRchafRvt/wYyyQNzwgL7ZiURcozOE/Pkvo= -google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:cc8bqMqtv9gMOr0zHg2Vzff5ULhhL2IXP4sbcn32Dro= -google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 h1:ImUcDPHjTrAqNhlOkSocDLfG9rrNHH7w7uoKWPaWZ8s= -google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7/go.mod h1:/3XmxOjePkvmKrHuBy4zNFw7IzxJXtAgdpXi8Ll990U= -google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 h1:x9PwdEgd11LgK+orcck69WVRo7DezSO4VUMPI4xpc8A= -google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014/go.mod h1:rbHMSEDyoYX62nRVLOCc4Qt1HbsdytAYoVwgjiOhF3I= google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 h1:oqta3O3AnlWbmIE3bFnWbu4bRxZjfbWCp0cKSuZh01E= google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7/go.mod h1:VQW3tUculP/D4B+xVCo+VgSq8As6wA9ZjHl//pmk+6s= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe h1:bQnxqljG/wqi4NTXu2+DJ3n7APcEA882QZ1JvhQAq9o= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 h1:8EeVk1VKMD+GD/neyEHGmz7pFblqPjHoi+PGQIlLx2s= google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= -google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= -google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/go-jose/go-jose.v2 v2.6.2 h1:Rl5+9rA0kG3vsO1qhncMPRT5eHICihAMQYJkD7u/i4M= -gopkg.in/go-jose/go-jose.v2 v2.6.2/go.mod h1:zzZDPkNNw/c9IE7Z9jr11mBZQhKQTMzoEEIoEdZlFBI= gopkg.in/go-jose/go-jose.v2 v2.6.3 h1:nt80fvSDlhKWQgSWyHyy5CfmlQr+asih51R8PTWNKKs= gopkg.in/go-jose/go-jose.v2 v2.6.3/go.mod h1:zzZDPkNNw/c9IE7Z9jr11mBZQhKQTMzoEEIoEdZlFBI= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= +gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= diff --git a/pkg/handlers/subjectmappings.go b/pkg/handlers/subjectmappings.go index 25059e75..522f540f 100644 --- a/pkg/handlers/subjectmappings.go +++ b/pkg/handlers/subjectmappings.go @@ -1,10 +1,6 @@ package handlers import ( - "fmt" - "slices" - "strings" - "github.com/opentdf/platform/protocol/go/common" "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/platform/protocol/go/policy/subjectmapping" @@ -22,70 +18,43 @@ func (h Handler) GetSubjectMapping(id string) (*policy.SubjectMapping, error) { resp, err := h.sdk.SubjectMapping.GetSubjectMapping(h.ctx, &subjectmapping.GetSubjectMappingRequest{ Id: id, }) - if err != nil { - return nil, err - } - - return resp.SubjectMapping, nil + return resp.SubjectMapping, err } func (h Handler) ListSubjectMappings() ([]*policy.SubjectMapping, error) { resp, err := h.sdk.SubjectMapping.ListSubjectMappings(h.ctx, &subjectmapping.ListSubjectMappingsRequest{}) - if err != nil { - return nil, err - } - return resp.SubjectMappings, nil + return resp.SubjectMappings, err } -func (h Handler) CreateNewSubjectMapping(attributeValueId string, subjectAttribute string, subjectValues []string, operator string, metadata *common.MetadataMutable) (*policy.SubjectMapping, error) { - if !slices.Contains(SubjectMappingOperatorEnumChoices, operator) { - return nil, fmt.Errorf("Invalid operator. Must be one of [%s]" + strings.Join(SubjectMappingOperatorEnumChoices, ", ")) - } - +func (h Handler) CreateNewSubjectMapping(attrValId string, actions []*policy.Action, existingSCSId string, newScs *subjectmapping.SubjectConditionSetCreate, m *common.MetadataMutable) (*policy.SubjectMapping, error) { resp, err := h.sdk.SubjectMapping.CreateSubjectMapping(h.ctx, &subjectmapping.CreateSubjectMappingRequest{ - AttributeValueId: attributeValueId, - // SubjectAttribute: subjectAttribute, - // SubjectValues: subjectValues, - // Operator: GetSubjectMappingOperatorFromChoice(operator), - Metadata: metadata, + AttributeValueId: attrValId, + Actions: actions, + ExistingSubjectConditionSetId: existingSCSId, + NewSubjectConditionSet: newScs, + Metadata: m, }) - if err != nil { - return nil, err - } - - return resp.SubjectMapping, nil + return resp.SubjectMapping, err } -// TODO: verify update behavior -func (h Handler) UpdateSubjectMapping(id string, attributeValueId string, subjectAttribute string, subjectValues []string, operator string, metadata *common.MetadataMutable) (*policy.SubjectMapping, error) { - if !slices.Contains(SubjectMappingOperatorEnumChoices, operator) { - return nil, fmt.Errorf("Invalid operator. Must be one of [%s]" + strings.Join(SubjectMappingOperatorEnumChoices, ", ")) - } - +func (h Handler) UpdateSubjectMapping(id string, updatedSCSId string, updatedActions []*policy.Action, metadata *common.MetadataMutable, metadataBehavior common.MetadataUpdateEnum) (*policy.SubjectMapping, error) { resp, err := h.sdk.SubjectMapping.UpdateSubjectMapping(h.ctx, &subjectmapping.UpdateSubjectMappingRequest{ - Id: id, - // AttributeValueId: attributeValueId, - // SubjectAttribute: subjectAttribute, - // SubjectValues: subjectValues, - // Operator: GetSubjectMappingOperatorFromChoice(operator), - Metadata: metadata, + Id: id, + SubjectConditionSetId: updatedSCSId, + Actions: updatedActions, + // TODO: add reusable metadata label flags and drive this? + MetadataUpdateBehavior: metadataBehavior, + Metadata: metadata, }) - if err != nil { - return nil, err - } - return resp.SubjectMapping, nil + return resp.SubjectMapping, err } -func (h Handler) DeleteSubjectMapping(id string) error { - _, err := h.sdk.SubjectMapping.DeleteSubjectMapping(h.ctx, &subjectmapping.DeleteSubjectMappingRequest{ +func (h Handler) DeleteSubjectMapping(id string) (*policy.SubjectMapping, error) { + resp, err := h.sdk.SubjectMapping.DeleteSubjectMapping(h.ctx, &subjectmapping.DeleteSubjectMappingRequest{ Id: id, }) - if err != nil { - return err - } - - return nil + return resp.SubjectMapping, err } func GetSubjectMappingOperatorFromChoice(readable string) policy.SubjectMappingOperatorEnum { From b8283741efa85403fded7f4cc96ff58cc270ceb9 Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Thu, 14 Mar 2024 16:00:13 -0400 Subject: [PATCH 06/13] fix flags for subject mappings --- cmd/policy-subject_mappings.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/policy-subject_mappings.go b/cmd/policy-subject_mappings.go index 3f4c7743..7004d7e0 100644 --- a/cmd/policy-subject_mappings.go +++ b/cmd/policy-subject_mappings.go @@ -346,20 +346,20 @@ func init() { policy_subject_mappingsCmd.AddCommand(policy_subject_mappingCreateCmd) policy_subject_mappingCreateCmd.Flags().StringP("attribute-value-id", "a", "", "Id of the mapped Attribute Value") - policy_subject_mappingCreateCmd.Flags().StringSliceVarP(&standardActions, "action-standard", "as", []string{}, "Standard Action: [DECRYPT, TRANSMIT]") - policy_subject_mappingCreateCmd.Flags().StringSliceVarP(&customActions, "action-custom", "ac", []string{}, "Custom Action") - policy_subject_mappingCreateCmd.Flags().StringP("subject-condition-set-id", "scs-id", "", "Pre-existing Subject Condition Set Id") + policy_subject_mappingCreateCmd.Flags().StringSliceVarP(&standardActions, "action-standard", "s", []string{}, "Standard Action: [DECRYPT, TRANSMIT]") + policy_subject_mappingCreateCmd.Flags().StringSliceVarP(&customActions, "action-custom", "c", []string{}, "Custom Action") + policy_subject_mappingCreateCmd.Flags().String("subject-condition-set-id", "", "Pre-existing Subject Condition Set Id") // TODO: do we need to support creating a SM & SCS simultaneously? If so, it gets more complex. // policy_subject_mappingCreateCmd.Flags().StringP("new-subject-condition-set", "scs", "", "New Subject Condition Set (optional)") policy_subject_mappingCreateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label", "l", []string{}, "Optional metadata 'labels' in the format: key=value") policy_subject_mappingsCmd.AddCommand(policy_subject_mappingUpdateCmd) policy_subject_mappingUpdateCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") - policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&standardActions, "action-standard", "as", []string{}, "Standard Action: [DECRYPT, TRANSMIT]. Note: destructively replaces existing Actions.") - policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&customActions, "action-custom", "ac", []string{}, "Custom Action. Note: destructively replaces existing Actions.") - policy_subject_mappingUpdateCmd.Flags().StringP("subject-condition-set-id", "scs-id", "", "Updated Subject Condition Set Id") - policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label-new", "ln", []string{}, "Optional new metadata 'labels' in the format: key=value") - policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&updatedMetadataLabels, "label-replace", "lr", []string{}, "Optional replace of existing metadata 'labels' in the format: key=value") + policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&standardActions, "action-standard", "s", []string{}, "Standard Action: [DECRYPT, TRANSMIT]. Note: destructively replaces existing Actions.") + policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&customActions, "action-custom", "c", []string{}, "Custom Action. Note: destructively replaces existing Actions.") + policy_subject_mappingUpdateCmd.Flags().String("subject-condition-set-id", "", "Updated Subject Condition Set Id") + policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label-new", "n", []string{}, "Optional new metadata 'labels' in the format: key=value") + policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&updatedMetadataLabels, "label-replace", "r", []string{}, "Optional replace of existing metadata 'labels' in the format: key=value") policy_subject_mappingsCmd.AddCommand(policy_subject_mappingDeleteCmd) policy_subject_mappingDeleteCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") From 9361f354e921fc6811c6c3e27f7eb75910e071a9 Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Thu, 14 Mar 2024 16:22:25 -0400 Subject: [PATCH 07/13] add metadata create and update of labels throughout the CLI --- cmd/policy-attributes.go | 23 ++++++++++++++++++++-- cmd/policy-namespaces.go | 29 +++++++++++++++++++++++----- cmd/policy-resource_mappings.go | 26 ++++++++++++++++++++++--- cmd/policy-subject_condition_sets.go | 2 ++ cmd/policy-subject_mappings.go | 4 +++- pkg/handlers/attribute.go | 11 +++++++---- pkg/handlers/namespaces.go | 12 ++++++++---- pkg/handlers/resourceMappings.go | 14 +++++++++----- 8 files changed, 97 insertions(+), 24 deletions(-) diff --git a/cmd/policy-attributes.go b/cmd/policy-attributes.go index 81c043ba..2e5c889f 100644 --- a/cmd/policy-attributes.go +++ b/cmd/policy-attributes.go @@ -4,11 +4,14 @@ import ( "fmt" "strings" + "github.com/opentdf/platform/protocol/go/common" "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/tructl/pkg/cli" "github.com/spf13/cobra" ) +// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/30] is addressed + var ( attrValues []string newMetadataLabels []string @@ -46,8 +49,9 @@ used to define the access controls based on subject encodings and entity entitle rule := flagHelper.GetRequiredString("rule") values := flagHelper.GetStringSlice("values", attrValues, cli.FlagHelperStringSliceOptions{}) namespace := flagHelper.GetRequiredString("namespace") + metadataLabels := flagHelper.GetStringSlice("label", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) - attr, err := h.CreateAttribute(name, rule, namespace) + attr, err := h.CreateAttribute(name, rule, namespace, getMetadata(metadataLabels)) if err != nil { cli.ExitWithError("Could not create attribute", err) } @@ -202,8 +206,20 @@ used to define the access controls based on subject encodings and entity entitle flagHelper := cli.NewFlagHelper(cmd) id := flagHelper.GetRequiredString("id") + newLabels := flagHelper.GetStringSlice("label-new", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + replacedLabels := flagHelper.GetStringSlice("label-replace", updatedMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) - if _, err := h.UpdateAttribute(id); err != nil { + metadata, behavior := processUpdateMetadata(newLabels, replacedLabels, func() (*common.Metadata, error) { + attr, err := h.GetAttribute(id) + if err != nil { + errMsg := fmt.Sprintf("Could not find attribute (%s)", id) + cli.ExitWithNotFoundError(errMsg, err) + cli.ExitWithError(errMsg, err) + } + return attr.Metadata, nil + }, + ) + if _, err := h.UpdateAttribute(id, metadata, behavior); err != nil { cli.ExitWithError("Could not update attribute", err) } else { fmt.Println(cli.SuccessMessage(fmt.Sprintf("Attribute id: %s updated.", id))) @@ -222,6 +238,7 @@ func init() { policy_attributesCreateCmd.Flags().StringSliceVarP(&attrValues, "values", "v", []string{}, "Values of the attribute") policy_attributesCreateCmd.Flags().StringP("namespace", "s", "", "Namespace of the attribute") policy_attributesCreateCmd.Flags().StringP("description", "d", "", "Description of the attribute") + policy_attributesCreateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label", "l", []string{}, "Labels for the attribute") // Get an attribute policy_attributesCmd.AddCommand(policy_attributeGetCmd) @@ -233,6 +250,8 @@ func init() { // Update an attribute policy_attributesCmd.AddCommand(policy_attributeUpdateCmd) policy_attributeUpdateCmd.Flags().StringP("id", "i", "", "Id of the attribute") + policy_attributeUpdateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label-new", "n", []string{}, "Optional new metadata 'labels' in the format: key=value") + policy_attributeUpdateCmd.Flags().StringSliceVarP(&updatedMetadataLabels, "label-replace", "r", []string{}, "Optional replace of existing metadata 'labels' in the format: key=value. Note: providing one destructively replaces entire set of labels.") // Delete an attribute policy_attributesCmd.AddCommand(policy_attributesDeleteCmd) diff --git a/cmd/policy-namespaces.go b/cmd/policy-namespaces.go index 46a89963..fcd1fe6b 100644 --- a/cmd/policy-namespaces.go +++ b/cmd/policy-namespaces.go @@ -4,10 +4,13 @@ import ( "fmt" "strings" + "github.com/opentdf/platform/protocol/go/common" "github.com/opentdf/tructl/pkg/cli" "github.com/spf13/cobra" ) +// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/30] is addressed + var ( policy_namespacesCommands = []string{ policy_namespacesCreateCmd.Use, @@ -90,8 +93,9 @@ or different attributes tied to each. flagHelper := cli.NewFlagHelper(cmd) name := flagHelper.GetRequiredString("name") + metadataLabels := flagHelper.GetStringSlice("label", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) - created, err := h.CreateNamespace(name) + created, err := h.CreateNamespace(name, getMetadata(metadataLabels)) if err != nil { cli.ExitWithError("Could not create namespace", err) } @@ -151,16 +155,29 @@ or different attributes tied to each. defer h.Close() flagHelper := cli.NewFlagHelper(cmd) - id := flagHelper.GetRequiredString("id") - name := flagHelper.GetRequiredString("name") + newLabels := flagHelper.GetStringSlice("label-new", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + replacedLabels := flagHelper.GetStringSlice("label-replace", updatedMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + + metadata, behavior := processUpdateMetadata(newLabels, replacedLabels, func() (*common.Metadata, error) { + ns, err := h.GetNamespace(id) + if err != nil { + errMsg := fmt.Sprintf("Could not find namespace (%s)", id) + cli.ExitWithNotFoundError(errMsg, err) + cli.ExitWithError(errMsg, err) + } + return ns.Metadata, nil + }, + ) if _, err := h.UpdateNamespace( id, + metadata, + behavior, ); err != nil { cli.ExitWithError("Could not update namespace", err) } - fmt.Println(cli.SuccessMessage(fmt.Sprintf("Namespace id: (%s) updated. Name set to (%s).", id, name))) + fmt.Println(cli.SuccessMessage(fmt.Sprintf("Namespace id: (%s) updated.", id))) }, } ) @@ -175,10 +192,12 @@ func init() { policy_namespacesCmd.AddCommand(policy_namespacesCreateCmd) policy_namespacesCreateCmd.Flags().StringP("name", "n", "", "Name value of the namespace") + policy_namespacesCreateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label", "l", []string{}, "Optional metadata 'labels' in the format: key=value") policy_namespacesCmd.AddCommand(policy_namespaceUpdateCmd) policy_namespaceUpdateCmd.Flags().StringP("id", "i", "", "Id of the namespace") - policy_namespaceUpdateCmd.Flags().StringP("name", "n", "", "Name value of the namespace") + policy_namespaceUpdateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label-new", "n", []string{}, "Optional new metadata 'labels' in the format: key=value") + policy_namespaceUpdateCmd.Flags().StringSliceVarP(&updatedMetadataLabels, "label-replace", "r", []string{}, "Optional replace of existing metadata 'labels' in the format: key=value. Note: providing one destructively replaces entire set of labels.") policy_namespacesCmd.AddCommand(policy_namespaceDeleteCmd) policy_namespaceDeleteCmd.Flags().StringP("id", "i", "", "Id of the namespace") diff --git a/cmd/policy-resource_mappings.go b/cmd/policy-resource_mappings.go index 7722b1df..c0cde184 100644 --- a/cmd/policy-resource_mappings.go +++ b/cmd/policy-resource_mappings.go @@ -5,11 +5,14 @@ import ( "fmt" "strings" + "github.com/opentdf/platform/protocol/go/common" "github.com/opentdf/tructl/docs/man" "github.com/opentdf/tructl/pkg/cli" "github.com/spf13/cobra" ) +// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/30] is addressed + var ( policy_resource_mappingsTerms []string @@ -38,8 +41,9 @@ var ( terms := flagHelper.GetStringSlice("terms", policy_resource_mappingsTerms, cli.FlagHelperStringSliceOptions{ Min: 1, }) + metadataLabels := flagHelper.GetStringSlice("label", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) - resourceMapping, err := h.CreateResourceMapping(attrId, terms) + resourceMapping, err := h.CreateResourceMapping(attrId, terms, getMetadata(metadataLabels)) if err != nil { cli.ExitWithError("Failed to create resource mapping", err) } @@ -110,8 +114,21 @@ var ( id := flagHelper.GetRequiredString("id") attrValueId := flagHelper.GetOptionalString("attribute-value-id") terms := flagHelper.GetStringSlice("terms", policy_resource_mappingsTerms, cli.FlagHelperStringSliceOptions{}) - - resourceMapping, err := h.UpdateResourceMapping(id, attrValueId, terms) + newLabels := flagHelper.GetStringSlice("label-new", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + replacedLabels := flagHelper.GetStringSlice("label-replace", updatedMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + + metadata, behavior := processUpdateMetadata(newLabels, replacedLabels, func() (*common.Metadata, error) { + rm, err := h.GetResourceMapping(id) + if err != nil { + errMsg := fmt.Sprintf("Could not find resource mapping (%s)", id) + cli.ExitWithNotFoundError(errMsg, err) + cli.ExitWithError(errMsg, err) + } + return rm.Metadata, nil + }, + ) + + resourceMapping, err := h.UpdateResourceMapping(id, attrValueId, terms, metadata, behavior) if err != nil { cli.ExitWithError("Failed to update resource mapping", err) } @@ -160,6 +177,7 @@ func init() { policy_resource_mappingsCmd.AddCommand(policy_resource_mappingsCreateCmd) policy_resource_mappingsCreateCmd.Flags().String("attribute-value-id", "", "Attribute Value ID") policy_resource_mappingsCreateCmd.Flags().StringSliceVar(&policy_resource_mappingsTerms, "terms", []string{}, "Synonym terms") + policy_resource_mappingsCreateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label", "l", []string{}, "Optional metadata 'labels' in the format: key=value") policy_resource_mappingsCmd.AddCommand(policy_resource_mappingsGetCmd) policy_resource_mappingsGetCmd.Flags().String("id", "", "Resource Mapping ID") @@ -170,6 +188,8 @@ func init() { policy_resource_mappingsUpdateCmd.Flags().String("id", "", "Resource Mapping ID") policy_resource_mappingsUpdateCmd.Flags().String("attribute-value-id", "", "Attribute Value ID") policy_resource_mappingsUpdateCmd.Flags().StringSliceVar(&policy_resource_mappingsTerms, "terms", []string{}, "Synonym terms") + policy_resource_mappingsUpdateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label-new", "n", []string{}, "Optional metadata 'labels' in the format: key=value") + policy_resource_mappingsUpdateCmd.Flags().StringSliceVarP(&updatedMetadataLabels, "label-replace", "r", []string{}, "Optional metadata 'labels' in the format: key=value. Note: providing one destructively replaces entire set of labels.") policy_resource_mappingsCmd.AddCommand(policy_resource_mappingsDeleteCmd) policy_resource_mappingsDeleteCmd.Flags().String("id", "", "Resource Mapping ID") diff --git a/cmd/policy-subject_condition_sets.go b/cmd/policy-subject_condition_sets.go index 1d619dd0..245bb426 100644 --- a/cmd/policy-subject_condition_sets.go +++ b/cmd/policy-subject_condition_sets.go @@ -1 +1,3 @@ package cmd + +// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/30] is addressed diff --git a/cmd/policy-subject_mappings.go b/cmd/policy-subject_mappings.go index 7004d7e0..33865585 100644 --- a/cmd/policy-subject_mappings.go +++ b/cmd/policy-subject_mappings.go @@ -11,6 +11,8 @@ import ( "github.com/spf13/cobra" ) +// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/30] is addressed + var ( policy_subject_mappingsCmds = []string{ policy_subject_mappingCreateCmd.Use, @@ -359,7 +361,7 @@ func init() { policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&customActions, "action-custom", "c", []string{}, "Custom Action. Note: destructively replaces existing Actions.") policy_subject_mappingUpdateCmd.Flags().String("subject-condition-set-id", "", "Updated Subject Condition Set Id") policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label-new", "n", []string{}, "Optional new metadata 'labels' in the format: key=value") - policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&updatedMetadataLabels, "label-replace", "r", []string{}, "Optional replace of existing metadata 'labels' in the format: key=value") + policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&updatedMetadataLabels, "label-replace", "r", []string{}, "Optional replace of existing metadata 'labels' in the format: key=value. Note: providing one destructively replaces entire set of labels.") policy_subject_mappingsCmd.AddCommand(policy_subject_mappingDeleteCmd) policy_subject_mappingDeleteCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") diff --git a/pkg/handlers/attribute.go b/pkg/handlers/attribute.go index 4a9d4b74..41a5508d 100644 --- a/pkg/handlers/attribute.go +++ b/pkg/handlers/attribute.go @@ -50,7 +50,7 @@ func (h Handler) ListAttributes() ([]*policy.Attribute, error) { } // TODO: allow creation of a value with the attribute simultaneously? -func (h Handler) CreateAttribute(name string, rule string, namespace string) (*policy.Attribute, error) { +func (h Handler) CreateAttribute(name string, rule string, namespace string, metadata *common.MetadataMutable) (*policy.Attribute, error) { r, err := GetAttributeRuleFromReadableString(rule) if err != nil { return nil, err @@ -60,6 +60,7 @@ func (h Handler) CreateAttribute(name string, rule string, namespace string) (*p NamespaceId: namespace, Name: name, Rule: r, + Metadata: metadata, } resp, err := h.sdk.Attributes.CreateAttribute(h.ctx, attrReq) @@ -80,11 +81,13 @@ func (h Handler) CreateAttribute(name string, rule string, namespace string) (*p // TODO: verify updation behavior func (h *Handler) UpdateAttribute( id string, - fns ...func(*common.MetadataMutable) *common.MetadataMutable, + metadata *common.MetadataMutable, + behavior common.MetadataUpdateEnum, ) (*attributes.UpdateAttributeResponse, error) { return h.sdk.Attributes.UpdateAttribute(h.ctx, &attributes.UpdateAttributeRequest{ - Id: id, - Metadata: buildMetadata(&common.MetadataMutable{}, fns...), + Id: id, + Metadata: metadata, + MetadataUpdateBehavior: behavior, }) } diff --git a/pkg/handlers/namespaces.go b/pkg/handlers/namespaces.go index 6e0eb18c..79a04730 100644 --- a/pkg/handlers/namespaces.go +++ b/pkg/handlers/namespaces.go @@ -1,6 +1,7 @@ package handlers import ( + "github.com/opentdf/platform/protocol/go/common" "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/platform/protocol/go/policy/namespaces" ) @@ -25,9 +26,10 @@ func (h Handler) ListNamespaces() ([]*policy.Namespace, error) { return resp.Namespaces, nil } -func (h Handler) CreateNamespace(name string) (*policy.Namespace, error) { +func (h Handler) CreateNamespace(name string, metadata *common.MetadataMutable) (*policy.Namespace, error) { resp, err := h.sdk.Namespaces.CreateNamespace(h.ctx, &namespaces.CreateNamespaceRequest{ - Name: name, + Name: name, + Metadata: metadata, }) if err != nil { return nil, err @@ -37,9 +39,11 @@ func (h Handler) CreateNamespace(name string) (*policy.Namespace, error) { } // TODO: verify updation of metadata -func (h Handler) UpdateNamespace(id string) (*policy.Namespace, error) { +func (h Handler) UpdateNamespace(id string, metadata *common.MetadataMutable, behavior common.MetadataUpdateEnum) (*policy.Namespace, error) { resp, err := h.sdk.Namespaces.UpdateNamespace(h.ctx, &namespaces.UpdateNamespaceRequest{ - Id: id, + Id: id, + Metadata: metadata, + MetadataUpdateBehavior: behavior, }) if err != nil { return nil, err diff --git a/pkg/handlers/resourceMappings.go b/pkg/handlers/resourceMappings.go index 9f241f58..df23eb66 100644 --- a/pkg/handlers/resourceMappings.go +++ b/pkg/handlers/resourceMappings.go @@ -3,6 +3,7 @@ package handlers import ( "context" + "github.com/opentdf/platform/protocol/go/common" "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/platform/protocol/go/policy/resourcemapping" ) @@ -13,10 +14,11 @@ type ResourceMapping struct { Terms []string } -func (h *Handler) CreateResourceMapping(attributeId string, terms []string) (*policy.ResourceMapping, error) { +func (h *Handler) CreateResourceMapping(attributeId string, terms []string, metadata *common.MetadataMutable) (*policy.ResourceMapping, error) { res, err := h.sdk.ResourceMapping.CreateResourceMapping(context.Background(), &resourcemapping.CreateResourceMappingRequest{ AttributeValueId: attributeId, Terms: terms, + Metadata: metadata, }) if err != nil { return nil, err @@ -46,11 +48,13 @@ func (h *Handler) ListResourceMappings() ([]*policy.ResourceMapping, error) { } // TODO: verify updation behavior -func (h *Handler) UpdateResourceMapping(id string, attrValueId string, terms []string) (*policy.ResourceMapping, error) { +func (h *Handler) UpdateResourceMapping(id string, attrValueId string, terms []string, metadata *common.MetadataMutable, behavior common.MetadataUpdateEnum) (*policy.ResourceMapping, error) { res, err := h.sdk.ResourceMapping.UpdateResourceMapping(context.Background(), &resourcemapping.UpdateResourceMappingRequest{ - Id: id, - AttributeValueId: attrValueId, - Terms: terms, + Id: id, + AttributeValueId: attrValueId, + Terms: terms, + Metadata: metadata, + MetadataUpdateBehavior: behavior, }) if err != nil { return nil, err From 73af8e2d77c64ca5ae4e8fdd9f8354fb1f866af2 Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Thu, 14 Mar 2024 16:28:04 -0400 Subject: [PATCH 08/13] remove field not provided back on subject mappings create --- cmd/policy-subject_mappings.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/policy-subject_mappings.go b/cmd/policy-subject_mappings.go index 33865585..ef0c871c 100644 --- a/cmd/policy-subject_mappings.go +++ b/cmd/policy-subject_mappings.go @@ -205,7 +205,6 @@ Note: SubjectConditionSets are reusable among SubjectMappings and are available rows := [][]string{ {"Id", mapping.Id}, {"Subject AttrVal: Id", mapping.AttributeValue.Id}, - {"Subject AttrVal: Value", mapping.AttributeValue.Value}, {"Actions", string(actionsJSON)}, {"Subject Condition Set: Id", mapping.SubjectConditionSet.Id}, {"Subject Condition Set", string(subjectSetsJSON)}, From c3b350fc2c1fbb20cf4c5c6d9945283b7a5996d9 Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Thu, 14 Mar 2024 16:29:05 -0400 Subject: [PATCH 09/13] bump go version --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index b2de69fa..f23dbdee 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/opentdf/tructl -go 1.21.8 +go 1.22 toolchain go1.22.0 From dda1639778856750647869dcbf3c2cb164c5db25 Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Thu, 14 Mar 2024 16:36:24 -0400 Subject: [PATCH 10/13] fix reference to attributes --- tui/form/addAttribute.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tui/form/addAttribute.go b/tui/form/addAttribute.go index 7f31ffa7..f2bb3163 100644 --- a/tui/form/addAttribute.go +++ b/tui/form/addAttribute.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/charmbracelet/huh" - "github.com/opentdf/platform/protocol/go/policy/attributes" + "github.com/opentdf/platform/protocol/go/policy" ) type AttributeDefinition struct { @@ -13,7 +13,7 @@ type AttributeDefinition struct { Description string Labels map[string]string Type string - Rule attributes.AttributeRuleTypeEnum + Rule policy.AttributeRuleTypeEnum Values []string } @@ -40,12 +40,12 @@ func AddAttribute() (AttributeDefinition, error) { Value(&attr.Description), // Select Rule - huh.NewSelect[attributes.AttributeRuleTypeEnum](). + huh.NewSelect[policy.AttributeRuleTypeEnum](). Title("Rule"). Options( - huh.NewOption("All Of", attributes.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ALL_OF), - huh.NewOption("Any Of", attributes.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ANY_OF), - huh.NewOption("Hierarchical", attributes.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_HIERARCHY), + huh.NewOption("All Of", policy.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ALL_OF), + huh.NewOption("Any Of", policy.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_ANY_OF), + huh.NewOption("Hierarchical", policy.AttributeRuleTypeEnum_ATTRIBUTE_RULE_TYPE_ENUM_HIERARCHY), ). Value(&attr.Rule), ), From ae3384d1609bbfc29da815c5c478e6be2e772dba Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Tue, 19 Mar 2024 11:14:08 -0700 Subject: [PATCH 11/13] unify around force-replace-labels behavior in update/create flows --- cmd/dev.go | 40 ++++----------------------------- cmd/policy-attributes.go | 33 +++++++++++---------------- cmd/policy-namespaces.go | 27 ++++++---------------- cmd/policy-resource_mappings.go | 27 ++++++---------------- cmd/policy-subject_mappings.go | 27 ++++++---------------- 5 files changed, 38 insertions(+), 116 deletions(-) diff --git a/cmd/dev.go b/cmd/dev.go index d2df8887..5def200c 100644 --- a/cmd/dev.go +++ b/cmd/dev.go @@ -92,43 +92,11 @@ func getMetadata(labels []string) *common.MetadataMutable { return nil } -func processUpdateMetadata(newLabels, updatedLabels []string, getExtendableMetadata func() (*common.Metadata, error)) (*common.MetadataMutable, common.MetadataUpdateEnum) { - var metadata *common.MetadataMutable - behavior := common.MetadataUpdateEnum_METADATA_UPDATE_ENUM_EXTEND - if len(updatedLabels) == 0 { - metadata = getMetadata(newLabels) - } - if len(updatedLabels) > 0 { - behavior = common.MetadataUpdateEnum_METADATA_UPDATE_ENUM_REPLACE - md, _ := getExtendableMetadata() - metadata = mergeMetadata(md.Labels, newLabels, updatedLabels) - } - return metadata, behavior -} - -func mergeMetadata(existing map[string]string, newLabels, replacedLabels []string) *common.MetadataMutable { - merged := map[string]string{} - if existing != nil { - merged = existing - } - for _, label := range newLabels { - kv := strings.Split(label, "=") - if len(kv) != 2 { - cli.ExitWithError("Invalid label format", nil) - } - merged[kv[0]] = kv[1] - } - for _, label := range replacedLabels { - kv := strings.Split(label, "=") - if len(kv) != 2 { - cli.ExitWithError("Invalid label format", nil) - } - merged[kv[0]] = kv[1] - } - - return &common.MetadataMutable{ - Labels: merged, +func getMetadataUpdateBehavior() common.MetadataUpdateEnum { + if forceReplaceMetadataLabels { + return common.MetadataUpdateEnum_METADATA_UPDATE_ENUM_REPLACE } + return common.MetadataUpdateEnum_METADATA_UPDATE_ENUM_EXTEND } func init() { diff --git a/cmd/policy-attributes.go b/cmd/policy-attributes.go index 2e5c889f..82abd091 100644 --- a/cmd/policy-attributes.go +++ b/cmd/policy-attributes.go @@ -13,9 +13,9 @@ import ( // TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/30] is addressed var ( - attrValues []string - newMetadataLabels []string - updatedMetadataLabels []string + attrValues []string + metadataLabels []string + forceReplaceMetadataLabels bool policy_attributeCommands = []string{ policy_attributesCreateCmd.Use, @@ -49,7 +49,7 @@ used to define the access controls based on subject encodings and entity entitle rule := flagHelper.GetRequiredString("rule") values := flagHelper.GetStringSlice("values", attrValues, cli.FlagHelperStringSliceOptions{}) namespace := flagHelper.GetRequiredString("namespace") - metadataLabels := flagHelper.GetStringSlice("label", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + metadataLabels := flagHelper.GetStringSlice("label", metadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) attr, err := h.CreateAttribute(name, rule, namespace, getMetadata(metadataLabels)) if err != nil { @@ -206,20 +206,13 @@ used to define the access controls based on subject encodings and entity entitle flagHelper := cli.NewFlagHelper(cmd) id := flagHelper.GetRequiredString("id") - newLabels := flagHelper.GetStringSlice("label-new", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) - replacedLabels := flagHelper.GetStringSlice("label-replace", updatedMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + labels := flagHelper.GetStringSlice("label", metadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) - metadata, behavior := processUpdateMetadata(newLabels, replacedLabels, func() (*common.Metadata, error) { - attr, err := h.GetAttribute(id) - if err != nil { - errMsg := fmt.Sprintf("Could not find attribute (%s)", id) - cli.ExitWithNotFoundError(errMsg, err) - cli.ExitWithError(errMsg, err) - } - return attr.Metadata, nil - }, - ) - if _, err := h.UpdateAttribute(id, metadata, behavior); err != nil { + behavior := common.MetadataUpdateEnum_METADATA_UPDATE_ENUM_EXTEND + if forceReplaceMetadataLabels { + behavior = common.MetadataUpdateEnum_METADATA_UPDATE_ENUM_REPLACE + } + if _, err := h.UpdateAttribute(id, getMetadata(labels), behavior); err != nil { cli.ExitWithError("Could not update attribute", err) } else { fmt.Println(cli.SuccessMessage(fmt.Sprintf("Attribute id: %s updated.", id))) @@ -238,7 +231,7 @@ func init() { policy_attributesCreateCmd.Flags().StringSliceVarP(&attrValues, "values", "v", []string{}, "Values of the attribute") policy_attributesCreateCmd.Flags().StringP("namespace", "s", "", "Namespace of the attribute") policy_attributesCreateCmd.Flags().StringP("description", "d", "", "Description of the attribute") - policy_attributesCreateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label", "l", []string{}, "Labels for the attribute") + policy_attributesCreateCmd.Flags().StringSliceVarP(&metadataLabels, "label", "l", []string{}, "Labels for the attribute") // Get an attribute policy_attributesCmd.AddCommand(policy_attributeGetCmd) @@ -250,8 +243,8 @@ func init() { // Update an attribute policy_attributesCmd.AddCommand(policy_attributeUpdateCmd) policy_attributeUpdateCmd.Flags().StringP("id", "i", "", "Id of the attribute") - policy_attributeUpdateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label-new", "n", []string{}, "Optional new metadata 'labels' in the format: key=value") - policy_attributeUpdateCmd.Flags().StringSliceVarP(&updatedMetadataLabels, "label-replace", "r", []string{}, "Optional replace of existing metadata 'labels' in the format: key=value. Note: providing one destructively replaces entire set of labels.") + policy_attributeUpdateCmd.Flags().StringSliceVarP(&metadataLabels, "label", "l", []string{}, "Optional new metadata 'labels' in the format: key=value") + policy_attributeUpdateCmd.Flags().BoolVar(&forceReplaceMetadataLabels, "force-replace-labels", false, "Destructively replace entire set of existing metadata 'labels' with any provided to this command.") // Delete an attribute policy_attributesCmd.AddCommand(policy_attributesDeleteCmd) diff --git a/cmd/policy-namespaces.go b/cmd/policy-namespaces.go index fcd1fe6b..7955b9d2 100644 --- a/cmd/policy-namespaces.go +++ b/cmd/policy-namespaces.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - "github.com/opentdf/platform/protocol/go/common" "github.com/opentdf/tructl/pkg/cli" "github.com/spf13/cobra" ) @@ -93,7 +92,7 @@ or different attributes tied to each. flagHelper := cli.NewFlagHelper(cmd) name := flagHelper.GetRequiredString("name") - metadataLabels := flagHelper.GetStringSlice("label", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + metadataLabels := flagHelper.GetStringSlice("label", metadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) created, err := h.CreateNamespace(name, getMetadata(metadataLabels)) if err != nil { @@ -156,24 +155,12 @@ or different attributes tied to each. flagHelper := cli.NewFlagHelper(cmd) id := flagHelper.GetRequiredString("id") - newLabels := flagHelper.GetStringSlice("label-new", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) - replacedLabels := flagHelper.GetStringSlice("label-replace", updatedMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) - - metadata, behavior := processUpdateMetadata(newLabels, replacedLabels, func() (*common.Metadata, error) { - ns, err := h.GetNamespace(id) - if err != nil { - errMsg := fmt.Sprintf("Could not find namespace (%s)", id) - cli.ExitWithNotFoundError(errMsg, err) - cli.ExitWithError(errMsg, err) - } - return ns.Metadata, nil - }, - ) + labels := flagHelper.GetStringSlice("label", metadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) if _, err := h.UpdateNamespace( id, - metadata, - behavior, + getMetadata(labels), + getMetadataUpdateBehavior(), ); err != nil { cli.ExitWithError("Could not update namespace", err) } @@ -192,12 +179,12 @@ func init() { policy_namespacesCmd.AddCommand(policy_namespacesCreateCmd) policy_namespacesCreateCmd.Flags().StringP("name", "n", "", "Name value of the namespace") - policy_namespacesCreateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label", "l", []string{}, "Optional metadata 'labels' in the format: key=value") + policy_namespacesCreateCmd.Flags().StringSliceVarP(&metadataLabels, "label", "l", []string{}, "Optional metadata 'labels' in the format: key=value") policy_namespacesCmd.AddCommand(policy_namespaceUpdateCmd) policy_namespaceUpdateCmd.Flags().StringP("id", "i", "", "Id of the namespace") - policy_namespaceUpdateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label-new", "n", []string{}, "Optional new metadata 'labels' in the format: key=value") - policy_namespaceUpdateCmd.Flags().StringSliceVarP(&updatedMetadataLabels, "label-replace", "r", []string{}, "Optional replace of existing metadata 'labels' in the format: key=value. Note: providing one destructively replaces entire set of labels.") + policy_namespaceUpdateCmd.Flags().StringSliceVarP(&metadataLabels, "label", "l", []string{}, "Optional new metadata 'labels' in the format: key=value") + policy_namespaceUpdateCmd.Flags().BoolVar(&forceReplaceMetadataLabels, "force-replace-labels", false, "Destructively replace entire set of existing metadata 'labels' with any provided to this command.") policy_namespacesCmd.AddCommand(policy_namespaceDeleteCmd) policy_namespaceDeleteCmd.Flags().StringP("id", "i", "", "Id of the namespace") diff --git a/cmd/policy-resource_mappings.go b/cmd/policy-resource_mappings.go index c0cde184..d054166c 100644 --- a/cmd/policy-resource_mappings.go +++ b/cmd/policy-resource_mappings.go @@ -5,7 +5,6 @@ import ( "fmt" "strings" - "github.com/opentdf/platform/protocol/go/common" "github.com/opentdf/tructl/docs/man" "github.com/opentdf/tructl/pkg/cli" "github.com/spf13/cobra" @@ -41,7 +40,7 @@ var ( terms := flagHelper.GetStringSlice("terms", policy_resource_mappingsTerms, cli.FlagHelperStringSliceOptions{ Min: 1, }) - metadataLabels := flagHelper.GetStringSlice("label", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + metadataLabels := flagHelper.GetStringSlice("label", metadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) resourceMapping, err := h.CreateResourceMapping(attrId, terms, getMetadata(metadataLabels)) if err != nil { @@ -114,21 +113,9 @@ var ( id := flagHelper.GetRequiredString("id") attrValueId := flagHelper.GetOptionalString("attribute-value-id") terms := flagHelper.GetStringSlice("terms", policy_resource_mappingsTerms, cli.FlagHelperStringSliceOptions{}) - newLabels := flagHelper.GetStringSlice("label-new", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) - replacedLabels := flagHelper.GetStringSlice("label-replace", updatedMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) - - metadata, behavior := processUpdateMetadata(newLabels, replacedLabels, func() (*common.Metadata, error) { - rm, err := h.GetResourceMapping(id) - if err != nil { - errMsg := fmt.Sprintf("Could not find resource mapping (%s)", id) - cli.ExitWithNotFoundError(errMsg, err) - cli.ExitWithError(errMsg, err) - } - return rm.Metadata, nil - }, - ) - - resourceMapping, err := h.UpdateResourceMapping(id, attrValueId, terms, metadata, behavior) + labels := flagHelper.GetStringSlice("label", metadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + + resourceMapping, err := h.UpdateResourceMapping(id, attrValueId, terms, getMetadata(labels), getMetadataUpdateBehavior()) if err != nil { cli.ExitWithError("Failed to update resource mapping", err) } @@ -177,7 +164,7 @@ func init() { policy_resource_mappingsCmd.AddCommand(policy_resource_mappingsCreateCmd) policy_resource_mappingsCreateCmd.Flags().String("attribute-value-id", "", "Attribute Value ID") policy_resource_mappingsCreateCmd.Flags().StringSliceVar(&policy_resource_mappingsTerms, "terms", []string{}, "Synonym terms") - policy_resource_mappingsCreateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label", "l", []string{}, "Optional metadata 'labels' in the format: key=value") + policy_resource_mappingsCreateCmd.Flags().StringSliceVarP(&metadataLabels, "label", "l", []string{}, "Optional metadata 'labels' in the format: key=value") policy_resource_mappingsCmd.AddCommand(policy_resource_mappingsGetCmd) policy_resource_mappingsGetCmd.Flags().String("id", "", "Resource Mapping ID") @@ -188,8 +175,8 @@ func init() { policy_resource_mappingsUpdateCmd.Flags().String("id", "", "Resource Mapping ID") policy_resource_mappingsUpdateCmd.Flags().String("attribute-value-id", "", "Attribute Value ID") policy_resource_mappingsUpdateCmd.Flags().StringSliceVar(&policy_resource_mappingsTerms, "terms", []string{}, "Synonym terms") - policy_resource_mappingsUpdateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label-new", "n", []string{}, "Optional metadata 'labels' in the format: key=value") - policy_resource_mappingsUpdateCmd.Flags().StringSliceVarP(&updatedMetadataLabels, "label-replace", "r", []string{}, "Optional metadata 'labels' in the format: key=value. Note: providing one destructively replaces entire set of labels.") + policy_resource_mappingsUpdateCmd.Flags().StringSliceVarP(&metadataLabels, "label", "l", []string{}, "Optional metadata 'labels' in the format: key=value") + policy_resource_mappingsUpdateCmd.Flags().BoolVar(&forceReplaceMetadataLabels, "force-replace-labels", false, "Destructively replace entire set of existing metadata 'labels' with any provided to this command.") policy_resource_mappingsCmd.AddCommand(policy_resource_mappingsDeleteCmd) policy_resource_mappingsDeleteCmd.Flags().String("id", "", "Resource Mapping ID") diff --git a/cmd/policy-subject_mappings.go b/cmd/policy-subject_mappings.go index ef0c871c..c4f4a1c0 100644 --- a/cmd/policy-subject_mappings.go +++ b/cmd/policy-subject_mappings.go @@ -5,7 +5,6 @@ import ( "fmt" "strings" - "github.com/opentdf/platform/protocol/go/common" "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/tructl/pkg/cli" "github.com/spf13/cobra" @@ -162,7 +161,7 @@ Note: SubjectConditionSets are reusable among SubjectMappings and are available existingSCSId := flagHelper.GetOptionalString("subject-condition-set-id") // TODO: do we need to support creating a SM & SCS simultaneously? If so, it gets more complex. // newScs := flagHelper.GetOptionalString("new-subject-condition-set") - metadataLabels := flagHelper.GetStringSlice("label", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + metadataLabels := flagHelper.GetStringSlice("label", metadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) // validations if len(standardActions) == 0 && len(customActions) == 0 { @@ -267,8 +266,7 @@ full set of actions on update. `, standardActions := flagHelper.GetStringSlice("action-standard", standardActions, cli.FlagHelperStringSliceOptions{Min: 0}) customActions := flagHelper.GetStringSlice("action-custom", customActions, cli.FlagHelperStringSliceOptions{Min: 0}) scsId := flagHelper.GetOptionalString("subject-condition-set-id") - newLabels := flagHelper.GetStringSlice("label-new", newMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) - replacedLabels := flagHelper.GetStringSlice("label-replace", updatedMetadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) + labels := flagHelper.GetStringSlice("label", metadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) if len(standardActions) > 0 { for _, a := range standardActions { @@ -280,23 +278,12 @@ full set of actions on update. `, } actions := getFullActionsList(standardActions, customActions) - metadata, behavior := processUpdateMetadata(newLabels, replacedLabels, func() (*common.Metadata, error) { - sm, err := h.GetSubjectMapping(id) - if err != nil { - errMsg := fmt.Sprintf("Could not find subject mapping (%s)", id) - cli.ExitWithNotFoundError(errMsg, err) - cli.ExitWithError(errMsg, err) - } - return sm.Metadata, nil - }, - ) - if _, err := h.UpdateSubjectMapping( id, scsId, actions, - metadata, - behavior, + getMetadata(labels), + getMetadataUpdateBehavior(), ); err != nil { cli.ExitWithError("Could not update subject mapping", err) } @@ -352,15 +339,15 @@ func init() { policy_subject_mappingCreateCmd.Flags().String("subject-condition-set-id", "", "Pre-existing Subject Condition Set Id") // TODO: do we need to support creating a SM & SCS simultaneously? If so, it gets more complex. // policy_subject_mappingCreateCmd.Flags().StringP("new-subject-condition-set", "scs", "", "New Subject Condition Set (optional)") - policy_subject_mappingCreateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label", "l", []string{}, "Optional metadata 'labels' in the format: key=value") + policy_subject_mappingCreateCmd.Flags().StringSliceVarP(&metadataLabels, "label", "l", []string{}, "Optional metadata 'labels' in the format: key=value") policy_subject_mappingsCmd.AddCommand(policy_subject_mappingUpdateCmd) policy_subject_mappingUpdateCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&standardActions, "action-standard", "s", []string{}, "Standard Action: [DECRYPT, TRANSMIT]. Note: destructively replaces existing Actions.") policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&customActions, "action-custom", "c", []string{}, "Custom Action. Note: destructively replaces existing Actions.") policy_subject_mappingUpdateCmd.Flags().String("subject-condition-set-id", "", "Updated Subject Condition Set Id") - policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&newMetadataLabels, "label-new", "n", []string{}, "Optional new metadata 'labels' in the format: key=value") - policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&updatedMetadataLabels, "label-replace", "r", []string{}, "Optional replace of existing metadata 'labels' in the format: key=value. Note: providing one destructively replaces entire set of labels.") + policy_subject_mappingUpdateCmd.Flags().StringSliceVarP(&metadataLabels, "label", "l", []string{}, "Optional new metadata 'labels' in the format: key=value") + policy_subject_mappingUpdateCmd.Flags().BoolVar(&forceReplaceMetadataLabels, "force-replace-labels", false, "Destructively replace entire set of existing metadata 'labels' with any provided to this command.") policy_subject_mappingsCmd.AddCommand(policy_subject_mappingDeleteCmd) policy_subject_mappingDeleteCmd.Flags().StringP("id", "i", "", "Id of the subject mapping") From 267f314c4d8094b837a4724eaf454f95b61c5463 Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Wed, 20 Mar 2024 07:21:56 -0700 Subject: [PATCH 12/13] small cleanuip --- cmd/policy-attributes.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cmd/policy-attributes.go b/cmd/policy-attributes.go index 82abd091..569c975a 100644 --- a/cmd/policy-attributes.go +++ b/cmd/policy-attributes.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - "github.com/opentdf/platform/protocol/go/common" "github.com/opentdf/platform/protocol/go/policy" "github.com/opentdf/tructl/pkg/cli" "github.com/spf13/cobra" @@ -208,11 +207,7 @@ used to define the access controls based on subject encodings and entity entitle id := flagHelper.GetRequiredString("id") labels := flagHelper.GetStringSlice("label", metadataLabels, cli.FlagHelperStringSliceOptions{Min: 0}) - behavior := common.MetadataUpdateEnum_METADATA_UPDATE_ENUM_EXTEND - if forceReplaceMetadataLabels { - behavior = common.MetadataUpdateEnum_METADATA_UPDATE_ENUM_REPLACE - } - if _, err := h.UpdateAttribute(id, getMetadata(labels), behavior); err != nil { + if _, err := h.UpdateAttribute(id, getMetadata(labels), getMetadataUpdateBehavior()); err != nil { cli.ExitWithError("Could not update attribute", err) } else { fmt.Println(cli.SuccessMessage(fmt.Sprintf("Attribute id: %s updated.", id))) From cf9b15a163ef344c6a29a09a3af1894b60be83b8 Mon Sep 17 00:00:00 2001 From: jakedoublev Date: Wed, 20 Mar 2024 10:30:38 -0700 Subject: [PATCH 13/13] fix todo comment --- cmd/policy-attributes.go | 2 +- cmd/policy-namespaces.go | 2 +- cmd/policy-resource_mappings.go | 2 +- cmd/policy-subject_condition_sets.go | 2 -- cmd/policy-subject_mappings.go | 2 +- pkg/handlers/subjectmappings.go | 7 +++---- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/cmd/policy-attributes.go b/cmd/policy-attributes.go index 449d3e8e..c271d901 100644 --- a/cmd/policy-attributes.go +++ b/cmd/policy-attributes.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" ) -// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/30] is addressed +// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/73] is addressed var ( attrValues []string diff --git a/cmd/policy-namespaces.go b/cmd/policy-namespaces.go index de457a21..bd9abafa 100644 --- a/cmd/policy-namespaces.go +++ b/cmd/policy-namespaces.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" ) -// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/30] is addressed +// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/73] is addressed var ( policy_namespacesCommands = []string{ diff --git a/cmd/policy-resource_mappings.go b/cmd/policy-resource_mappings.go index ad588b92..8fe9bc68 100644 --- a/cmd/policy-resource_mappings.go +++ b/cmd/policy-resource_mappings.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" ) -// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/30] is addressed +// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/73] is addressed var ( policy_resource_mappingsTerms []string diff --git a/cmd/policy-subject_condition_sets.go b/cmd/policy-subject_condition_sets.go index 245bb426..1d619dd0 100644 --- a/cmd/policy-subject_condition_sets.go +++ b/cmd/policy-subject_condition_sets.go @@ -1,3 +1 @@ package cmd - -// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/30] is addressed diff --git a/cmd/policy-subject_mappings.go b/cmd/policy-subject_mappings.go index bc89f8ce..ac9077ae 100644 --- a/cmd/policy-subject_mappings.go +++ b/cmd/policy-subject_mappings.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/30] is addressed +// TODO: add metadata to outputs once [https://github.com/opentdf/tructl/issues/73] is addressed var ( policy_subject_mappingsCmds = []string{ diff --git a/pkg/handlers/subjectmappings.go b/pkg/handlers/subjectmappings.go index 522f540f..6123883f 100644 --- a/pkg/handlers/subjectmappings.go +++ b/pkg/handlers/subjectmappings.go @@ -40,10 +40,9 @@ func (h Handler) CreateNewSubjectMapping(attrValId string, actions []*policy.Act func (h Handler) UpdateSubjectMapping(id string, updatedSCSId string, updatedActions []*policy.Action, metadata *common.MetadataMutable, metadataBehavior common.MetadataUpdateEnum) (*policy.SubjectMapping, error) { resp, err := h.sdk.SubjectMapping.UpdateSubjectMapping(h.ctx, &subjectmapping.UpdateSubjectMappingRequest{ - Id: id, - SubjectConditionSetId: updatedSCSId, - Actions: updatedActions, - // TODO: add reusable metadata label flags and drive this? + Id: id, + SubjectConditionSetId: updatedSCSId, + Actions: updatedActions, MetadataUpdateBehavior: metadataBehavior, Metadata: metadata, })