generated from cybozu-go/neco-template
-
Notifications
You must be signed in to change notification settings - Fork 6
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 #136 from erikgb/switch-hub-version
chore: make v2 API the new conversion hub
- Loading branch information
Showing
14 changed files
with
167 additions
and
167 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
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
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,4 +1,4 @@ | ||
// +kubebuilder:object:generate=true | ||
// +groupName=accurate.cybozu.com | ||
// +k8s:conversion-gen=github.com/cybozu-go/accurate/api/accurate/v2alpha1 | ||
// +k8s:conversion-gen=github.com/cybozu-go/accurate/api/accurate/v2 | ||
package v1 |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,4 +1,3 @@ | ||
// +kubebuilder:object:generate=true | ||
// +groupName=accurate.cybozu.com | ||
// +k8s:conversion-gen=github.com/cybozu-go/accurate/api/accurate/v2alpha1 | ||
package v2 |
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
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,43 +1,4 @@ | ||
package v2 | ||
|
||
import ( | ||
accuratev2alpha1 "github.com/cybozu-go/accurate/api/accurate/v2alpha1" | ||
"github.com/go-logr/logr" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/conversion" | ||
) | ||
|
||
// ConvertTo converts this SubNamespace to the Hub version (v2alpha1). | ||
func (src *SubNamespace) ConvertTo(dstRaw conversion.Hub) error { | ||
dst := dstRaw.(*accuratev2alpha1.SubNamespace) | ||
|
||
logger := getConversionLogger(src).WithValues( | ||
"source", SchemeGroupVersion.Version, | ||
"destination", accuratev2alpha1.SchemeGroupVersion.Version, | ||
) | ||
logger.V(5).Info("converting") | ||
|
||
return Convert_v2_SubNamespace_To_v2alpha1_SubNamespace(src, dst, nil) | ||
} | ||
|
||
// ConvertFrom converts from the Hub version (v2alpha1) to this version. | ||
func (dst *SubNamespace) ConvertFrom(srcRaw conversion.Hub) error { | ||
src := srcRaw.(*accuratev2alpha1.SubNamespace) | ||
|
||
logger := getConversionLogger(src).WithValues( | ||
"source", accuratev2alpha1.SchemeGroupVersion.Version, | ||
"destination", SchemeGroupVersion.Version, | ||
) | ||
logger.V(5).Info("converting") | ||
|
||
return Convert_v2alpha1_SubNamespace_To_v2_SubNamespace(src, dst, nil) | ||
} | ||
|
||
func getConversionLogger(obj client.Object) logr.Logger { | ||
return ctrl.Log.WithName("conversion").WithValues( | ||
"kind", "SubNamespace", | ||
"namespace", obj.GetNamespace(), | ||
"name", obj.GetName(), | ||
) | ||
} | ||
// Hub marks this SubNamespace version as a conversion hub. | ||
func (*SubNamespace) Hub() {} |
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
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,3 +1,4 @@ | ||
// +kubebuilder:object:generate=true | ||
// +groupName=accurate.cybozu.com | ||
// +k8s:conversion-gen=github.com/cybozu-go/accurate/api/accurate/v2 | ||
package v2alpha1 |
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
Oops, something went wrong.