本文整理匯總了Golang中k8s/io/kubernetes/federation/client/clientset_generated/federation_release_1_5.Clientset.Core方法的典型用法代碼示例。如果您正苦於以下問題:Golang Clientset.Core方法的具體用法?Golang Clientset.Core怎麽用?Golang Clientset.Core使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/federation/client/clientset_generated/federation_release_1_5.Clientset
的用法示例。
在下文中一共展示了Clientset.Core方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: updateSecretOrFail
func updateSecretOrFail(clientset *fedclientset.Clientset, namespace string) *v1.Secret {
if clientset == nil || len(namespace) == 0 {
Fail(fmt.Sprintf("Internal error: invalid parameters passed to updateSecretOrFail: clientset: %v, namespace: %v", clientset, namespace))
}
var newSecret *v1.Secret
for retryCount := 0; retryCount < MaxRetries; retryCount++ {
secret, err := clientset.Core().Secrets(namespace).Get(FederatedSecretName)
if err != nil {
framework.Failf("failed to get secret %q: %v", FederatedSecretName, err)
}
// Update one of the data in the secret.
secret.Data = map[string][]byte{
"key": []byte("value"),
}
newSecret, err = clientset.Core().Secrets(namespace).Update(secret)
if err == nil {
return newSecret
}
if !errors.IsConflict(err) && !errors.IsServerTimeout(err) {
framework.Failf("failed to update secret %q: %v", FederatedSecretName, err)
}
}
framework.Failf("too many retries updating secret %q", FederatedSecretName)
return newSecret
}
示例2: createEventOrFail
func createEventOrFail(clientset *federation_release_1_5.Clientset, namespace string) *v1.Event {
if clientset == nil || len(namespace) == 0 {
Fail(fmt.Sprintf("Internal error: invalid parameters passed to createEventOrFail: clientset: %v, namespace: %v", clientset, namespace))
}
By(fmt.Sprintf("Creating federated event %q in namespace %q", FederationEventName, namespace))
event := &v1.Event{
ObjectMeta: v1.ObjectMeta{
Name: FederationEventName,
Namespace: namespace,
},
InvolvedObject: v1.ObjectReference{
Kind: "Pod",
Name: "pod-name",
Namespace: namespace,
UID: "C934D34AFB20242",
APIVersion: "version",
},
Source: v1.EventSource{
Component: "kubelet",
Host: "kublet.node1",
},
Count: 1,
Type: v1.EventTypeNormal,
}
_, err := clientset.Core().Events(namespace).Create(event)
framework.ExpectNoError(err, "Creating event %q in namespace %q", event.Name, namespace)
By(fmt.Sprintf("Successfully created federated event %q in namespace %q", FederationEventName, namespace))
return event
}
示例3: deleteAllSecretsOrFail
// deleteAllSecretsOrFail deletes all secrets in the given namespace name.
func deleteAllSecretsOrFail(clientset *fedclientset.Clientset, nsName string) {
SecretList, err := clientset.Core().Secrets(nsName).List(v1.ListOptions{})
Expect(err).NotTo(HaveOccurred())
orphanDependents := false
for _, Secret := range SecretList.Items {
deleteSecretOrFail(clientset, nsName, Secret.Name, &orphanDependents)
}
}
示例4: createSecretOrFail
func createSecretOrFail(clientset *fedclientset.Clientset, namespace string) *v1.Secret {
if clientset == nil || len(namespace) == 0 {
Fail(fmt.Sprintf("Internal error: invalid parameters passed to createSecretOrFail: clientset: %v, namespace: %v", clientset, namespace))
}
secret := &v1.Secret{
ObjectMeta: v1.ObjectMeta{
Name: FederatedSecretName,
},
}
By(fmt.Sprintf("Creating secret %q in namespace %q", secret.Name, namespace))
_, err := clientset.Core().Secrets(namespace).Create(secret)
framework.ExpectNoError(err, "Failed to create secret %s", secret.Name)
By(fmt.Sprintf("Successfully created federated secret %q in namespace %q", FederatedSecretName, namespace))
return secret
}
示例5: deleteSecretOrFail
func deleteSecretOrFail(clientset *fedclientset.Clientset, nsName string, secretName string, orphanDependents bool) {
By(fmt.Sprintf("Deleting secret %q in namespace %q", secretName, nsName))
err := clientset.Core().Secrets(nsName).Delete(secretName, &v1.DeleteOptions{OrphanDependents: &orphanDependents})
framework.ExpectNoError(err, "Error deleting secret %q in namespace %q", secretName, nsName)
// Wait for the secret to be deleted.
err = wait.Poll(5*time.Second, wait.ForeverTestTimeout, func() (bool, error) {
_, err := clientset.Core().Secrets(nsName).Get(secretName)
if err != nil && errors.IsNotFound(err) {
return true, nil
}
return false, err
})
if err != nil {
framework.Failf("Error in deleting secret %s: %v", secretName, err)
}
}
示例6: createSecretOrFail
func createSecretOrFail(clientset *fedclientset.Clientset, nsName string) *v1.Secret {
if len(nsName) == 0 {
Fail(fmt.Sprintf("Internal error: invalid parameters passed to createSecretOrFail: namespace: %v", nsName))
}
secret := &v1.Secret{
ObjectMeta: v1.ObjectMeta{
Name: api.SimpleNameGenerator.GenerateName(secretNamePrefix),
Namespace: nsName,
},
}
By(fmt.Sprintf("Creating secret %q in namespace %q", secret.Name, nsName))
_, err := clientset.Core().Secrets(nsName).Create(secret)
framework.ExpectNoError(err, "Failed to create secret %s", secret.Name)
By(fmt.Sprintf("Successfully created federated secret %q in namespace %q", secret.Name, nsName))
return secret
}