-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Remove unnecessary custom conversion functions #77346
Remove unnecessary custom conversion functions #77346
Conversation
@@ -357,88 +357,6 @@ func Convert_v1_Secret_To_core_Secret(in *v1.Secret, out *core.Secret, s convers | |||
return nil | |||
} | |||
|
|||
func Convert_core_SecurityContext_To_v1_SecurityContext(in *core.SecurityContext, out *v1.SecurityContext, s conversion.Scope) error { |
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.
compare with autogenerated function:
kubernetes/pkg/apis/core/v1/zz_generated.conversion.go
Lines 6816 to 6827 in c3e8a43
func autoConvert_core_SecurityContext_To_v1_SecurityContext(in *core.SecurityContext, out *v1.SecurityContext, s conversion.Scope) error { | |
out.Capabilities = (*v1.Capabilities)(unsafe.Pointer(in.Capabilities)) | |
out.Privileged = (*bool)(unsafe.Pointer(in.Privileged)) | |
out.SELinuxOptions = (*v1.SELinuxOptions)(unsafe.Pointer(in.SELinuxOptions)) | |
out.RunAsUser = (*int64)(unsafe.Pointer(in.RunAsUser)) | |
out.RunAsGroup = (*int64)(unsafe.Pointer(in.RunAsGroup)) | |
out.RunAsNonRoot = (*bool)(unsafe.Pointer(in.RunAsNonRoot)) | |
out.ReadOnlyRootFilesystem = (*bool)(unsafe.Pointer(in.ReadOnlyRootFilesystem)) | |
out.AllowPrivilegeEscalation = (*bool)(unsafe.Pointer(in.AllowPrivilegeEscalation)) | |
out.ProcMount = (*v1.ProcMountType)(unsafe.Pointer(in.ProcMount)) | |
return nil | |
} |
(the Convert_... functions being called were the autogenerated ones)
return nil | ||
} | ||
|
||
func Convert_core_PodSecurityContext_To_v1_PodSecurityContext(in *core.PodSecurityContext, out *v1.PodSecurityContext, s conversion.Scope) error { |
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.
compare with autogenerated function:
kubernetes/pkg/apis/core/v1/zz_generated.conversion.go
Lines 5524 to 5537 in c3e8a43
func autoConvert_core_PodSecurityContext_To_v1_PodSecurityContext(in *core.PodSecurityContext, out *v1.PodSecurityContext, s conversion.Scope) error { | |
// INFO: in.HostNetwork opted out of conversion generation | |
// INFO: in.HostPID opted out of conversion generation | |
// INFO: in.HostIPC opted out of conversion generation | |
// INFO: in.ShareProcessNamespace opted out of conversion generation | |
out.SELinuxOptions = (*v1.SELinuxOptions)(unsafe.Pointer(in.SELinuxOptions)) | |
out.RunAsUser = (*int64)(unsafe.Pointer(in.RunAsUser)) | |
out.RunAsGroup = (*int64)(unsafe.Pointer(in.RunAsGroup)) | |
out.RunAsNonRoot = (*bool)(unsafe.Pointer(in.RunAsNonRoot)) | |
out.SupplementalGroups = *(*[]int64)(unsafe.Pointer(&in.SupplementalGroups)) | |
out.FSGroup = (*int64)(unsafe.Pointer(in.FSGroup)) | |
out.Sysctls = *(*[]v1.Sysctl)(unsafe.Pointer(&in.Sysctls)) | |
return nil | |
} |
(the Convert_... functions being called were the autogenerated ones)
return nil | ||
} | ||
|
||
func Convert_v1_PodSecurityContext_To_core_PodSecurityContext(in *v1.PodSecurityContext, out *core.PodSecurityContext, s conversion.Scope) error { |
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.
compare with autogenerated function:
kubernetes/pkg/apis/core/v1/zz_generated.conversion.go
Lines 5513 to 5522 in c3e8a43
func autoConvert_v1_PodSecurityContext_To_core_PodSecurityContext(in *v1.PodSecurityContext, out *core.PodSecurityContext, s conversion.Scope) error { | |
out.SELinuxOptions = (*core.SELinuxOptions)(unsafe.Pointer(in.SELinuxOptions)) | |
out.RunAsUser = (*int64)(unsafe.Pointer(in.RunAsUser)) | |
out.RunAsGroup = (*int64)(unsafe.Pointer(in.RunAsGroup)) | |
out.RunAsNonRoot = (*bool)(unsafe.Pointer(in.RunAsNonRoot)) | |
out.SupplementalGroups = *(*[]int64)(unsafe.Pointer(&in.SupplementalGroups)) | |
out.FSGroup = (*int64)(unsafe.Pointer(in.FSGroup)) | |
out.Sysctls = *(*[]core.Sysctl)(unsafe.Pointer(&in.Sysctls)) | |
return nil | |
} |
(the Convert_... functions being called were the autogenerated ones)
} else { | ||
out.SecurityContext = nil | ||
} | ||
out.SecurityContext = (*core.SecurityContext)(unsafe.Pointer(in.SecurityContext)) |
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.
not defining a custom function means this can collapse to a direct memory copy
} else { | ||
out.SecurityContext = nil | ||
} | ||
out.SecurityContext = (*v1.SecurityContext)(unsafe.Pointer(in.SecurityContext)) |
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.
ditto on direct memory copy
/priority backlog |
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, smarterclayton 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 |
/kind cleanup
What this PR does / why we need it:
Several custom conversion functions around pod and container security context structs were not required.
Dropping this streamlines addition of new fields to these structs, since the auto-generated conversion will automatically add copies for the new fields, instead of having to manually update the custom functions
Resolves unit test failures in #77147
Does this PR introduce a user-facing change?:
/sig api-machinery
/cc @sttts