k8s/io/kubernetes/pkg/api.Secret 示例代码

2022-03-03

以下示例是关于golang中包含api.Secret用法的示例代码,想了解api.Secret的具体用法?api.Secret怎么用?api.Secret使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。

示例1:
rest.go开发语言: Go项目名称: kubernetes代码行数: 163
46func (rs *REST) Create(ctx api.Context, obj runtime.Object) (runtime.Object, error) {
47	secret, ok := obj.(*api.Secret)
48	if !ok {
73func (rs *REST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, bool, error) {
74	secret, ok := obj.(*api.Secret)
75	if !ok {
87
88	editSecret := oldObj.(*api.Secret)
89
114	}
115	_, ok := obj.(*api.Secret)
116	if !ok {
128	}
129	secret, ok := obj.(*api.Secret)
130	if !ok {
示例2:
secrets.go开发语言: Go项目名称: kubernetes代码行数: 141
32type SecretsInterface interface {
33	Create(secret *api.Secret) (*api.Secret, error)
34	Update(secret *api.Secret) (*api.Secret, error)
35	Delete(name string) error
36	List(label, field labels.Selector) (*api.SecretList, error)
37	Get(name string) (*api.Secret, error)
54
55func (s *secrets) Create(secret *api.Secret) (*api.Secret, error) {
56	if s.namespace != "" && secret.Namespace != s.namespace {
59
60	result := &api.Secret{}
61	err := s.client.Post().
123
124func (s *secrets) Update(secret *api.Secret) (result *api.Secret, err error) {
125	result = &api.Secret{}
示例3:
secrets.go开发语言: Go项目名称: kubernetes代码行数: 167
46
47		secret := &api.Secret{
48			ObjectMeta: api.ObjectMeta{
84						Source: api.VolumeSource{
85							Secret: &api.SecretVolumeSource{
86								Target: api.ObjectReference{
示例4:
rest_test.go开发语言: Go项目名称: kubernetes代码行数: 213
39
40func testSecret(name string) *api.Secret {
41	return &api.Secret{
48		},
49		Type: api.SecretTypeOpaque,
50	}
55		ctx    api.Context
56		secret *api.Secret
57		valid  bool
117	}
118	updatedSecret := updatedObj.(*api.Secret)
119	if updatedSecret.Name != "foo" {
166	expect := labels.Set{
167		"type": string(api.SecretTypeOpaque),
168	}
示例5:
validation.go开发语言: Go项目名称: kubernetes代码行数: 938
311
312func validateSecretVolumeSource(secretSource *api.SecretVolumeSource) errs.ValidationErrorList {
313	allErrs := errs.ValidationErrorList{}
855// ValidateSecret tests if required fields in the Secret are set.
856func ValidateSecret(secret *api.Secret) errs.ValidationErrorList {
857	allErrs := errs.ValidationErrorList{}
示例6:
fake_secrets.go开发语言: Go项目名称: kubernetes代码行数: 61
31
32func (c *FakeSecrets) List(labels, fields labels.Selector) (*api.SecretList, error) {
33	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-secrets"})
36
37func (c *FakeSecrets) Get(name string) (*api.Secret, error) {
38	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "get-secret", Value: name})
39	return api.Scheme.CopyOrDie(&c.Fake.Secret).(*api.Secret), nil
40}
41
42func (c *FakeSecrets) Create(secret *api.Secret) (*api.Secret, error) {
43	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "create-secret", Value: secret})
46
47func (c *FakeSecrets) Update(secret *api.Secret) (*api.Secret, error) {
48	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "update-secret", Value: secret})
示例7:
secrets.go开发语言: Go项目名称: kubernetes代码行数: 110
44
45		secret := &api.Secret{
46			ObjectMeta: api.ObjectMeta{
77						VolumeSource: api.VolumeSource{
78							Secret: &api.SecretVolumeSource{
79								SecretName: name,
示例8:
secret_test.go开发语言: Go项目名称: kubernetes代码行数: 150
83	ns := "ns"
84	s := api.Secret{
85		ObjectMeta: api.ObjectMeta{
108					VolumeSource: api.VolumeSource{
109						Secret: &api.SecretVolumeSource{
110							SecretName: "secret",
示例9:
assignments.go开发语言: Go项目名称: docker代码行数: 339
112
113	var secrets []*api.SecretReference
114	container := t.Spec.GetContainer()
171				Item: &api.Assignment_Secret{
172					Secret: &api.Secret{ID: resourceRef.ResourceID},
173				},
195
196	var secrets []*api.SecretReference
197	if container != nil {
205			Item: &api.Assignment_Secret{
206				Secret: &api.Secret{ID: secretID},
207			},
316// driver responds with one or if the payload does not pass validation.
317func (a *assignmentSet) secret(readTx store.ReadTx, task *api.Task, secretID string) (*api.Secret, bool, error) {
318	secret := store.GetSecret(readTx, secretID)
示例10:
secret.go开发语言: Go项目名称: docker代码行数: 263
18// assumes spec is not nil
19func secretFromSecretSpec(spec *api.SecretSpec) *api.Secret {
20	return &api.Secret{
35
36	var secret *api.Secret
37	s.store.View(func(tx store.ReadTx) {
56	}
57	var secret *api.Secret
58	err := s.store.Update(func(tx store.Tx) error {
100	var (
101		secrets     []*api.Secret
102		respSecrets []*api.Secret
243
244func validateSecretSpec(spec *api.SecretSpec) error {
245	if spec == nil {

本文地址:https://www.itbaoku.cn/snippets/415677.html