本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/testing/core.NewDeleteAction函数的典型用法代码示例。如果您正苦于以下问题:Golang NewDeleteAction函数的具体用法?Golang NewDeleteAction怎么用?Golang NewDeleteAction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewDeleteAction函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Delete
func (c *FakeNetworkPolicies) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction(networkpoliciesResource, c.ns, name), &extensions.NetworkPolicy{})
return err
}
示例2: Delete
func (c *FakeHorizontalPodAutoscalers) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction("horizontalpodautoscalers", c.ns, name), &v1beta1.HorizontalPodAutoscaler{})
return err
}
示例3: Delete
func (c *FakeJobs) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction(jobsResource, c.ns, name), &v1beta1.Job{})
return err
}
示例4: Delete
func (c *FakeSecrets) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction("secrets", c.ns, name), &api.Secret{})
return err
}
示例5: Delete
func (c *FakeDeployments) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction(deploymentsResource, c.ns, name), &v1beta1.Deployment{})
return err
}
示例6: Delete
func (c *FakePodTemplates) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction("podtemplates", c.ns, name), &api.PodTemplate{})
return err
}
示例7: Delete
func (c *FakeLimitRanges) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction(limitrangesResource, c.ns, name), &v1.LimitRange{})
return err
}
示例8: Delete
func (c *FakePolicyBindings) Delete(name string) error {
_, err := c.Fake.Invokes(core.NewDeleteAction(policyBindingsResource, c.Namespace, name), &authorizationapi.PolicyBinding{})
return err
}
示例9: Delete
func (c *FakeServiceAccounts) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction(serviceaccountsResource, c.ns, name), &api.ServiceAccount{})
return err
}
示例10: TestDockercfgDeletion
func TestDockercfgDeletion(t *testing.T) {
testcases := map[string]struct {
ClientObjects []runtime.Object
DeletedSecret *api.Secret
ExpectedActions []core.Action
}{
"deleted dockercfg secret without serviceaccount": {
DeletedSecret: createdDockercfgSecret(),
ExpectedActions: []core.Action{
core.NewGetAction(unversioned.GroupVersionResource{Resource: "serviceaccounts"}, "default", "default"),
core.NewDeleteAction(unversioned.GroupVersionResource{Resource: "secrets"}, "default", "token-secret-1"),
},
},
"deleted dockercfg secret with serviceaccount with reference": {
ClientObjects: []runtime.Object{serviceAccount(addTokenSecretReference(tokenSecretReferences()), imagePullSecretReferences()), createdDockercfgSecret()},
DeletedSecret: createdDockercfgSecret(),
ExpectedActions: []core.Action{
core.NewGetAction(unversioned.GroupVersionResource{Resource: "serviceaccounts"}, "default", "default"),
core.NewUpdateAction(unversioned.GroupVersionResource{Resource: "serviceaccounts"}, "default", serviceAccount(tokenSecretReferences(), emptyImagePullSecretReferences())),
core.NewDeleteAction(unversioned.GroupVersionResource{Resource: "secrets"}, "default", "token-secret-1"),
},
},
"deleted dockercfg secret with serviceaccount without reference": {
ClientObjects: []runtime.Object{serviceAccount(addTokenSecretReference(tokenSecretReferences()), imagePullSecretReferences()), createdDockercfgSecret()},
DeletedSecret: createdDockercfgSecret(),
ExpectedActions: []core.Action{
core.NewGetAction(unversioned.GroupVersionResource{Resource: "serviceaccounts"}, "default", "default"),
core.NewUpdateAction(unversioned.GroupVersionResource{Resource: "serviceaccounts"}, "default", serviceAccount(tokenSecretReferences(), emptyImagePullSecretReferences())),
core.NewDeleteAction(unversioned.GroupVersionResource{Resource: "secrets"}, "default", "token-secret-1"),
},
},
}
for k, tc := range testcases {
// Re-seed to reset name generation
rand.Seed(1)
client := fake.NewSimpleClientset(tc.ClientObjects...)
controller := NewDockercfgDeletedController(client, DockercfgDeletedControllerOptions{})
if tc.DeletedSecret != nil {
controller.secretDeleted(tc.DeletedSecret)
}
for i, action := range client.Actions() {
if len(tc.ExpectedActions) < i+1 {
t.Errorf("%s: %d unexpected actions: %+v", k, len(client.Actions())-len(tc.ExpectedActions), client.Actions()[i:])
break
}
expectedAction := tc.ExpectedActions[i]
if !reflect.DeepEqual(expectedAction, action) {
t.Errorf("%s: Expected %v, got %v", k, expectedAction, action)
continue
}
}
if len(tc.ExpectedActions) > len(client.Actions()) {
t.Errorf("%s: %d additional expected actions:%+v", k, len(tc.ExpectedActions)-len(client.Actions()), tc.ExpectedActions[len(client.Actions()):])
}
}
}
示例11: Delete
func (c *FakeDaemonSets) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction(daemonsetsResource, c.ns, name), &extensions.DaemonSet{})
return err
}
示例12: Delete
func (c *FakePetSets) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction(petsetsResource, c.ns, name), &apps.PetSet{})
return err
}
示例13: Delete
func (c *FakeEndpoints) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction(endpointsResource, c.ns, name), &v1.Endpoints{})
return err
}
示例14: TestSimpleStop
func TestSimpleStop(t *testing.T) {
tests := []struct {
fake *reaperFake
kind schema.GroupKind
actions []testcore.Action
expectError bool
test string
}{
{
fake: &reaperFake{
Clientset: fake.NewSimpleClientset(pod()),
},
kind: api.Kind("Pod"),
actions: []testcore.Action{
testcore.NewGetAction(api.Resource("pods").WithVersion(""), api.NamespaceDefault, "foo"),
testcore.NewDeleteAction(api.Resource("pods").WithVersion(""), api.NamespaceDefault, "foo"),
},
expectError: false,
test: "stop pod succeeds",
},
{
fake: &reaperFake{
Clientset: fake.NewSimpleClientset(service()),
},
kind: api.Kind("Service"),
actions: []testcore.Action{
testcore.NewGetAction(api.Resource("services").WithVersion(""), api.NamespaceDefault, "foo"),
testcore.NewDeleteAction(api.Resource("services").WithVersion(""), api.NamespaceDefault, "foo"),
},
expectError: false,
test: "stop service succeeds",
},
{
fake: &reaperFake{
Clientset: fake.NewSimpleClientset(),
noSuchPod: true,
},
kind: api.Kind("Pod"),
actions: []testcore.Action{},
expectError: true,
test: "stop pod fails, no pod",
},
{
fake: &reaperFake{
Clientset: fake.NewSimpleClientset(service()),
noDeleteService: true,
},
kind: api.Kind("Service"),
actions: []testcore.Action{
testcore.NewGetAction(api.Resource("services").WithVersion(""), api.NamespaceDefault, "foo"),
},
expectError: true,
test: "stop service fails, can't delete",
},
}
for _, test := range tests {
fake := test.fake
reaper, err := ReaperFor(test.kind, fake)
if err != nil {
t.Errorf("unexpected error: %v (%s)", err, test.test)
}
err = reaper.Stop("default", "foo", 0, nil)
if err != nil && !test.expectError {
t.Errorf("unexpected error: %v (%s)", err, test.test)
}
if err == nil {
if test.expectError {
t.Errorf("unexpected non-error: %v (%s)", err, test.test)
}
}
actions := fake.Actions()
if len(test.actions) != len(actions) {
t.Errorf("unexpected actions: %v; expected %v (%s)", actions, test.actions, test.test)
}
for i, action := range actions {
testAction := test.actions[i]
if action != testAction {
t.Errorf("unexpected action: %#v; expected %v (%s)", action, testAction, test.test)
}
}
}
}
示例15: Delete
func (c *FakeLimitRanges) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(core.NewDeleteAction("limitranges", c.ns, name), &api.LimitRange{})
return err
}