Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Create minimial v1a2 to v1a1 converters #1162

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions incubator/hnc/api/v1alpha1/hierarchy_types_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ func (src *HierarchyConfiguration) ConvertTo(dstRaw conversion.Hub) error {
return nil
}

// We don't need a conversion from v1alpha2 to v1alpha1. because we will never
// serve both versions. We serve v1alpha1 in 0.5 and v1alpha2 in 0.6. Upgrading
// from 0.5 to 0.6 only needs one-way conversion. Downgrading is not supported.
// Thus we keep an empty ConvertFrom just to implement Convertible.
// We don't need a conversion from v1alpha2 to v1alpha1. because we will never serve both versions.
// However, the apiserver appears to ask for v1alpha1 even if there are no other clients and
// complains if the metadata changes, so simply copy the metadata but nothing else.
func (dst *HierarchyConfiguration) ConvertFrom(srcRaw conversion.Hub) error {
// We wanted to return errors.New("not supported") here considering this
// function should never be called, but in reality this error log is populated
// constantly even when all the HNC reconcilers and validators are disabled.
// To not pollute the logs, we decide to return nil here.
src := srcRaw.(*v1a2.HierarchyConfiguration)
dst.ObjectMeta = src.ObjectMeta
return nil
}
13 changes: 5 additions & 8 deletions incubator/hnc/api/v1alpha1/hnc_config_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,11 @@ func (src *HNCConfiguration) ConvertTo(dstRaw conversion.Hub) error {
return nil
}

// We don't need a conversion from v1alpha2 to v1alpha1. because we will never
// serve both versions. We serve v1alpha1 in 0.5 and v1alpha2 in 0.6. Upgrading
// from 0.5 to 0.6 only needs one-way conversion. Downgrading is not supported.
// Thus we keep an empty ConvertFrom just to implement Convertible.
// We don't need a conversion from v1alpha2 to v1alpha1. because we will never serve both versions.
// However, the apiserver appears to ask for v1alpha1 even if there are no other clients and
// complains if the metadata changes, so simply copy the metadata but nothing else.
func (dst *HNCConfiguration) ConvertFrom(srcRaw conversion.Hub) error {
// We wanted to return errors.New("not supported") here considering this
// function should never be called, but in reality this error log is populated
// constantly even when all the HNC reconcilers and validators are disabled.
// To not pollute the logs, we decide to return nil here.
src := srcRaw.(*v1a2.HNCConfiguration)
dst.ObjectMeta = src.ObjectMeta
return nil
}
13 changes: 5 additions & 8 deletions incubator/hnc/api/v1alpha1/subnamespace_anchor_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@ func (src *SubnamespaceAnchor) ConvertTo(dstRaw conversion.Hub) error {
return nil
}

// We don't need a conversion from v1alpha2 to v1alpha1. because we will never
// serve both versions. We serve v1alpha1 in 0.5 and v1alpha2 in 0.6. Upgrading
// from 0.5 to 0.6 only needs one-way conversion. Downgrading is not supported.
// Thus we keep an empty ConvertFrom just to implement Convertible.
// We don't need a conversion from v1alpha2 to v1alpha1. because we will never serve both versions.
// However, the apiserver appears to ask for v1alpha1 even if there are no other clients and
// complains if the metadata changes, so simply copy the metadata but nothing else.
func (dst *SubnamespaceAnchor) ConvertFrom(srcRaw conversion.Hub) error {
// We wanted to return errors.New("not supported") here considering this
// function should never be called, but in reality this error log is populated
// constantly even when all the HNC reconcilers and validators are disabled.
// To not pollute the logs, we decide to return nil here.
src := srcRaw.(*v1a2.SubnamespaceAnchor)
dst.ObjectMeta = src.ObjectMeta
return nil
}