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

feature request: opt-out fieldmask behaviour in patch #839

Closed
glerchundi opened this issue Jan 7, 2019 · 2 comments
Closed

feature request: opt-out fieldmask behaviour in patch #839

glerchundi opened this issue Jan 7, 2019 · 2 comments

Comments

@glerchundi
Copy link
Contributor

I would like to get rid of this fieldmask related thingy on generated code because we're already generating this on another step.

Would you be open to opt-out this by hinting the generator so that it can exclude that piece from generated code?

WDYT?

/cc @razamiDev @johanbrandhorst

In case you were interested we're generating a metadata code based on proto extensions that define which field is 'updateable' and which isn't (by default it's updateable).

message AccessPoint {
    string name = 1 [(myorg.updatable) = false];

    // Display name.
    string display_name = 2;
}

This would generate:

[...]
var _AccessPoint_Updateables = []string{
	"display_name",
}

var _AccessPoint_Updateables_Lookup = map[string]bool{
	"name": false,
	"display_name": true,
}

func (m *AccessPoint) Updateables() []string {
	return _AccessPoint_Updateables
}

func (m *AccessPoint) IsUpdateable(path string) bool {
	updateable, ok := _AccessPoint_Updateables_Lookup[path]
	if !ok {
		return true
	}

	return updateable
}
[...]
@johanbrandhorst
Copy link
Collaborator

Sure that seems reasonable, I guess it would have to be a runtime parameter?

On another note, it seems the official advice for disallowing updates is to mark the field "Output only" in a comment. This is not enforced in code, of course.

@glerchundi
Copy link
Contributor Author

Sure that seems reasonable, I guess it would have to be a runtime parameter?

If you don't mind I prefer to avoid the generated code.

On another note, it seems the official advice for disallowing updates is to mark the field "Output only" in a comment. This is not enforced in code, of course.

Yeah, but we found some (very) rare cases where fields that aren't going to be outputted but can be updated. For example an Account where the password is never printed to the outside but is considered as updateable.

Thanks anyway!

adasari pushed a commit to adasari/grpc-gateway that referenced this issue Apr 9, 2020
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

No branches or pull requests

2 participants