pkg/generator: auto-gen for apis/../types.go#37
Merged
hongchaodeng merged 1 commit intooperator-framework:masterfrom Feb 22, 2018
fanminshi:gen_apis_types
Merged
pkg/generator: auto-gen for apis/../types.go#37hongchaodeng merged 1 commit intooperator-framework:masterfrom fanminshi:gen_apis_types
hongchaodeng merged 1 commit intooperator-framework:masterfrom
fanminshi:gen_apis_types
Conversation
Contributor
Author
|
Manual test: func TestGenTypes(t *testing.T) {
buf := &bytes.Buffer{}
if err := renderApisTypes(buf, "PlayService", "v1alpha1"); err != nil {
t.Error(err)
return
}
if err := ioutil.WriteFile("./types.go", buf.Bytes(), 0644); err != nil {
t.Error(err)
}
}Output: package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type PlayServiceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []PlayService `json:"items"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type PlayService struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec PlayServiceSpec `json:"spec"`
Status PlayServiceStatus `json:"status,omitempty"`
}
type PlayServiceSpec struct {
Replica int32 `json:"replica,omitempty"`
// Fills me
}
type PlayServiceStatus struct {
// Fills me
} |
Contributor
Author
Contributor
This would require to distribute the "tmpl" files along with the binary, right? Use this trick: `...` + "`" + `json:"xxx,inline" + "`" |
xiang90
reviewed
Feb 22, 2018
|
|
||
| type {{.Kind}}Status struct { | ||
| // Fills me | ||
| } No newline at end of file |
Contributor
Author
|
|
Contributor
Author
|
Latest Test Output: package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type PlayServiceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []PlayService `json:"items"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type PlayService struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec PlayServiceSpec `json:"spec"`
Status PlayServiceStatus `json:"status,omitempty"`
}
type PlayServiceSpec struct {
Replica int32 `json:"replica,omitempty"`
// Fills me
}
type PlayServiceStatus struct {
// Fills me
} |
Contributor
Author
|
PTAL cc/ @hongchaodeng @hasbro17 |
Contributor
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this pr adds auto-gen for apis/../types.go.