Skip to Content
Kubernetes编程
book

Kubernetes编程

by Michael Hausenblas, Stefan Schimanski
June 2021
Intermediate to advanced
335 pages
5h 50m
Chinese
China Electric Power Press Ltd.
Content preview from Kubernetes编程
220
8
客户端已被废弃并将逐渐消失。在未来,即使是
API
服务器里的代码也会用
一个外部版本的客户端来实现。
8.4.5
转换
转换用于将某个版本的对象转成另一个版本。转换是通过转换函数实现的,
转换函数可以是自己手写的(按惯例是放在
pkg/apis/
group-name
/version/
conversion.go
文件中),也可以是通过
conversion-gen
自动生成的(按惯例
是放在
pkg/apis/
group-name
/
version
/zz_generated.conversion.go
文件中)。
转换函数通过
Scheme
(参考“
3.5.4 Scheme
”)的
Convert()
函数来调用,
传入源对象和目标对象:
func (s *Scheme) Convert(in, out interface{}, context interface{}) error
context
的描述如下
:
// ...an optional field that callers may use to pass info to conversion functions.
它只在极特殊的场景里使用,大部分情况下传
nil
即可。本章后续的内容中
我们会关注于转换函数部分,这会涉及在转换函数里访问
context
为了完成实际的转换逻辑,
Scheme
需要知道所有的
Golang API
类型、它们
GroupVersionKind
,以及不同
GroupVersionKind
之间的转换函数。为了做
到这些,
conversion-gen ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley
Python机器学习案例精解

Python机器学习案例精解

Posts & Telecom Press, Yuxi (Hayden) Liu
软件开发实践:项目驱动式的Java开发指南

软件开发实践:项目驱动式的Java开发指南

Raoul-Gabriel Urma, Richard Warburton

Publisher Resources

ISBN: 9787519854799