-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from Jefftree/defaulter
Update defaulter-gen to support +default annotation
- Loading branch information
Showing
10 changed files
with
881 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
TOOL=defaulter-gen | ||
|
||
.PHONY : gen test verify git_verify_clean git_verify_no_change | ||
test: | ||
go test ./_output_tests/marker/... | ||
|
||
gen: | ||
@go build -o /tmp/$(TOOL) | ||
@PKGS=$$(cd _output_tests; go list ./... | paste -sd' ' -); \ | ||
/tmp/$(TOOL) --logtostderr --v=4 -i $$(echo $$PKGS | sed 's/ /,/g') -O zz_generated | ||
|
||
git_verify_clean: | ||
@if ! git diff --quiet HEAD; then \ | ||
echo "FAIL: git client is not clean"; \ | ||
false; \ | ||
fi | ||
@go build -o /tmp/$(TOOL) | ||
@PKGS=$$(cd _output_tests; go list ./... | paste -sd' ' -); \ | ||
/tmp/$(TOOL) --logtostderr --v=4 -i $$(echo $$PKGS | sed 's/ /,/g') -O zz_generated | ||
|
||
git_verify_no_change: | ||
@if ! git diff --quiet HEAD; then \ | ||
echo "FAIL: output files changed"; \ | ||
git diff; \ | ||
false; \ | ||
fi | ||
|
||
verify: git_verify_clean gen git_verify_no_change |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package marker | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime" | ||
) | ||
|
||
func addDefaultingFuncs(scheme *runtime.Scheme) error { | ||
return RegisterDefaults(scheme) | ||
} | ||
|
||
func SetDefaults_DefaultedWithFunction(obj *DefaultedWithFunction) { | ||
if obj.S1 == "" { | ||
obj.S1 = "default_function" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// +k8s:defaulter-gen=TypeMeta | ||
|
||
// This is a test package. | ||
package marker // import "k8s.io/gengo/examples/defaulter-gen/_output_tests/marker" |
67 changes: 67 additions & 0 deletions
67
examples/defaulter-gen/_output_tests/marker/fake_deepcopy_conversion.go
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package marker | ||
|
||
import ( | ||
runtime "k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
func (in *Defaulted) DeepCopy() *Defaulted { | ||
if in == nil { | ||
return nil | ||
} | ||
out := new(Defaulted) | ||
in.DeepCopyInto(out) | ||
return out | ||
} | ||
|
||
func (in *Defaulted) DeepCopyInto(out *Defaulted) { | ||
*out = *in | ||
return | ||
} | ||
|
||
func (in *Defaulted) DeepCopyObject() runtime.Object { | ||
if c := in.DeepCopy(); c != nil { | ||
return c | ||
} | ||
return nil | ||
} | ||
|
||
func (in *DefaultedWithFunction) DeepCopy() *DefaultedWithFunction { | ||
if in == nil { | ||
return nil | ||
} | ||
out := new(DefaultedWithFunction) | ||
in.DeepCopyInto(out) | ||
return out | ||
} | ||
|
||
func (in *DefaultedWithFunction) DeepCopyInto(out *DefaultedWithFunction) { | ||
*out = *in | ||
return | ||
} | ||
|
||
func (in *DefaultedWithFunction) DeepCopyObject() runtime.Object { | ||
if c := in.DeepCopy(); c != nil { | ||
return c | ||
} | ||
return nil | ||
} | ||
|
||
func (obj *Defaulted) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind } | ||
func (obj *DefaultedWithFunction) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind } |
Oops, something went wrong.