Skip to content
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

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

stuartwdouglas
Copy link
Collaborator

fixes: #1083

This just adds them for JVM languages for now, as the go implementation will change when they move to an injection model.

@stuartwdouglas stuartwdouglas requested review from a team and alecthomas as code owners October 4, 2024 06:23
@stuartwdouglas stuartwdouglas requested review from a team, tomdaffurn and wesbillman and removed request for a team October 4, 2024 06:23
This was referenced Oct 4, 2024
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks Stuart.

@@ -130,6 +130,7 @@ func genErrorf(pos token.Pos, format string, args ...any) error {

var tmpl = template.Must(template.New("proto").
Parse(`
// THIS FILE IS GENERATED; DO NOT MODIFY
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.

func (m *MetadataConfig) Position() Position { return m.Pos }
func (m *MetadataConfig) String() string {
out := &strings.Builder{}
fmt.Fprint(out, "+calls ")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fmt.Fprint(out, "+calls ")
fmt.Fprint(out, "+config ")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, sorry, this PR is mostly just copypasta from from the calls metadata.

out := &strings.Builder{}
fmt.Fprint(out, "+calls ")
w := 6
for i, call := range m.Config {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/call/config/g

func (m *MetadataSecrets) Position() Position { return m.Pos }
func (m *MetadataSecrets) String() string {
out := &strings.Builder{}
fmt.Fprint(out, "+calls ")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fmt.Fprint(out, "+calls ")
fmt.Fprint(out, "+secrets ")

type MetadataSecrets struct {
Pos Position `parser:"" protobuf:"1,optional"`

Secrets []*Ref `parser:"'+' 'config' @@ (',' @@)*" protobuf:"2"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Secrets []*Ref `parser:"'+' 'config' @@ (',' @@)*" protobuf:"2"`
Secrets []*Ref `parser:"'+' 'secrets' @@ (',' @@)*" protobuf:"2"`

out := &strings.Builder{}
fmt.Fprint(out, "+calls ")
w := 6
for i, call := range m.Secrets {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/call/ref/g

@@ -341,8 +341,11 @@ func ValidateModule(module *Module) error {

case *Data:
for _, md := range n.Metadata {
if md, ok := md.(*MetadataCalls); ok {
switch md.(type) {
case *MetadataCalls, *MetadataSecrets, *MetadataConfig:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should have some kind of mapping for this instead...a map of which metadata types are valid on which schema node types.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, there are definitely gaps in the current logic, I don't think it is high priority though.

func (m *MetadataSecrets) Position() Position { return m.Pos }
func (m *MetadataSecrets) String() string {
out := &strings.Builder{}
fmt.Fprint(out, "+secrets ")
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

@stuartwdouglas stuartwdouglas merged commit b2aca81 into main Oct 7, 2024
95 checks passed
@stuartwdouglas stuartwdouglas deleted the stuartwdouglas/1083 branch October 7, 2024 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config/secret references should be part of a verb's metadata
2 participants