-
Notifications
You must be signed in to change notification settings - Fork 190
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
Introduce ack-generate webhooks
sub command
#122
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: A-Hilaly The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
2d48795
to
2dcad55
Compare
Could we hold off on this command until after I propose the metadata configuration? Options such as deprecated versions, etc. will all be available in that configuration file and it will not be necessary to pass them as command line arguments. |
Sure. I will rebase on top of your work once it's available. |
c149eb8
to
78c343c
Compare
pkg/generate/ack/output.go
Outdated
// LoadGenerationMetadata read the generation metadata for a given api version and | ||
// apis path. | ||
func LoadGenerationMetadata(apisPath, apiVersion string) (*GenerationMetadata, error) { | ||
filePath := filepath.Join(apisPath, apiVersion, outputFileName) | ||
b, err := ioutil.ReadFile(filePath) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var generationMetadata GenerationMetadata | ||
err = yaml.Unmarshal(b, &generationMetadata) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &generationMetadata, nil | ||
} | ||
|
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.
@RedbackThomson If you can implement a similar function in your PR, i'm taking it :)
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.
These have been moved to pkg/metadata
d91e0ae
to
a36d4d1
Compare
Need to be rebased, now that #126 is merged |
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.
@a-hilaly wonderful start on this! You will need to make a number of changes, however, in order to properly deal with nested complex types. See inline for an explanation of why your variable-naming schema needs to be adapted.
// elementCopy := make([]*v1alpha2.WebhookFilter, 0, len(element)) | ||
varElementCopy := "element" + "Copy" |
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.
You are going to run into problems with nested list types here, because you will have variable name shadowing in effect. This is why the code generation that sets CR fields from an Output shape (the pkg/generate/code.SetOutput
stuff) generates a variable name that represents the field's numeric index within the Shape. For instance, if I had a Shape like this:
type Bar struct {
Baz string
}
type Foo struct {
Bars []*Bar
}
type MyShape struct {
Foos []*Foo
}
The variable referring to MyShape.Foos.Bars
would be called f0f0
and the iterator over elements in that list of Bar
structs would be called f0f0iter
, with the element variable name of f0f0elem
.
The way you are naming things here means that you would end up producing Go code like this:
elementCopy := make([]*Foo, 0, len(src.Foos))
for _, element := range src.Foos {
fooCopy := &Foo{}
elementCopy := make([]*Bar, 0, len(element.Bars)
for _, element := range element.Bars {
barCopy := &Bar{}
barCopy.Baz = element.Baz
elementCopy = append(elementCopy, barCopy)
}
elementCopy = append(elementCopy, fooCopy)
}
which would be invalid since the variable name elementCopy
is shadowed/hidden by the inner declaration of itself.
) | ||
|
||
memberShape := shape.ValueRef.Shape | ||
varElementCopy := "element" + "Copy" |
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.
same comment as above :) you are going to run into variable naming conflicts.
return out | ||
} | ||
|
||
// storeVariableIn retruns go code that stores a value in a given variable. |
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.
s/retruns go/returns Go
functions This patch introduces a new function that generates conversion functions. It can be used to generate `ConvertTo` and `ConvertFrom` functions.
This patch brings in a new sub command that can be used to generate webhook functions. For now it can only generate conversion webhook functions, but it can be used to generate defaulting and validating functions. This patch also introduces a new function to load existing ack-generate metadata for a given api version.
282df9a
to
3a3f2f0
Compare
/do-not-merge needs-rebase |
Issues go stale after 90d of inactivity. |
Stale issues rot after 30d of inactivity. |
/remove-lifecycle rotten |
Issues go stale after 90d of inactivity. |
/lifecycle frozen |
@a-hilaly: The In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Stale issues rot after 30d of inactivity. |
Rotten issues close after 30d of inactivity. |
@ack-bot: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/reopen |
@a-hilaly: Reopened this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@a-hilaly: The In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@a-hilaly: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Rotten issues close after 30d of inactivity. |
@ack-bot: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Part of aws-controllers-k8s/community#835
This patch brings in a new sub command that can be used to generate
webhook functions. For now it can only generate conversion webhook
functions, but it can be extended to generate defaulting and validating
functions.
This patch also introduces a new function that generates conversion
functions. It can be used to generate
ConvertTo
andConvertFrom
functions.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.