-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add secrets / config to a verbs metadata #2999
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package schema | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"google.golang.org/protobuf/proto" | ||
|
||
schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema" | ||
) | ||
|
||
// MetadataConfig represents a metadata block with a list of config items that are used. | ||
// | ||
//protobuf:10,optional | ||
type MetadataConfig struct { | ||
Pos Position `parser:"" protobuf:"1,optional"` | ||
|
||
Config []*Ref `parser:"'+' 'config' @@ (',' @@)*" protobuf:"2"` | ||
} | ||
|
||
var _ Metadata = (*MetadataConfig)(nil) | ||
|
||
func (m *MetadataConfig) Position() Position { return m.Pos } | ||
func (m *MetadataConfig) String() string { | ||
out := &strings.Builder{} | ||
fmt.Fprint(out, "+config ") | ||
w := 6 | ||
for i, config := range m.Config { | ||
if i > 0 { | ||
fmt.Fprint(out, ", ") | ||
w += 2 | ||
} | ||
str := config.String() | ||
if w+len(str) > 70 { | ||
w = 6 | ||
fmt.Fprint(out, "\n ") | ||
} | ||
w += len(str) | ||
fmt.Fprint(out, str) | ||
} | ||
fmt.Fprint(out) | ||
return out.String() | ||
} | ||
|
||
func (m *MetadataConfig) schemaChildren() []Node { | ||
out := make([]Node, 0, len(m.Config)) | ||
for _, ref := range m.Config { | ||
out = append(out, ref) | ||
} | ||
return out | ||
} | ||
func (*MetadataConfig) schemaMetadata() {} | ||
|
||
func (m *MetadataConfig) ToProto() proto.Message { | ||
return &schemapb.MetadataConfig{ | ||
Pos: posToProto(m.Pos), | ||
Config: nodeListToProto[*schemapb.Ref](m.Config), | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package schema | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"google.golang.org/protobuf/proto" | ||
|
||
schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema" | ||
) | ||
|
||
// MetadataSecrets represents a metadata block with a list of config items that are used. | ||
// | ||
//protobuf:11,optional | ||
type MetadataSecrets struct { | ||
Pos Position `parser:"" protobuf:"1,optional"` | ||
|
||
Secrets []*Ref `parser:"'+' 'secrets' @@ (',' @@)*" protobuf:"2"` | ||
} | ||
|
||
var _ Metadata = (*MetadataSecrets)(nil) | ||
|
||
func (m *MetadataSecrets) Position() Position { return m.Pos } | ||
func (m *MetadataSecrets) String() string { | ||
out := &strings.Builder{} | ||
fmt.Fprint(out, "+secrets ") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot to say, there are tests that should be updated to exercise this parsing, in particular TestParserRoundtrip et al and TestProtoRoundTrip. |
||
w := 6 | ||
for i, secret := range m.Secrets { | ||
if i > 0 { | ||
fmt.Fprint(out, ", ") | ||
w += 2 | ||
} | ||
str := secret.String() | ||
if w+len(str) > 70 { | ||
w = 6 | ||
fmt.Fprint(out, "\n ") | ||
} | ||
w += len(str) | ||
fmt.Fprint(out, str) | ||
} | ||
fmt.Fprint(out) | ||
return out.String() | ||
} | ||
|
||
func (m *MetadataSecrets) schemaChildren() []Node { | ||
out := make([]Node, 0, len(m.Secrets)) | ||
for _, ref := range m.Secrets { | ||
out = append(out, ref) | ||
} | ||
return out | ||
} | ||
func (*MetadataSecrets) schemaMetadata() {} | ||
|
||
func (m *MetadataSecrets) ToProto() proto.Message { | ||
return &schemapb.MetadataSecrets{ | ||
Pos: posToProto(m.Pos), | ||
Secrets: nodeListToProto[*schemapb.Ref](m.Secrets), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call.