k8s/io/kubernetes/pkg/api/errors.IsAlreadyExists 示例代码

2022-03-03

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

示例1:
etcd_test.go开发语言: Go项目名称: kubernetes代码行数: 1480
254	})
255	if !errors.IsAlreadyExists(err) {
256		t.Errorf("Unexpected error returned: %#v", err)
288	err = registry.ApplyBinding(ctx, &api.Binding{PodID: "foo", Host: "machine"})
289	if !errors.IsAlreadyExists(err) {
290		t.Fatalf("Unexpected error returned: %#v", err)
938	})
939	if !errors.IsAlreadyExists(err) {
940		t.Errorf("expected already exists err, got %#v", err)
1033	})
1034	if !errors.IsAlreadyExists(err) {
1035		t.Errorf("expected already exists err, got %#v", err)
示例2:
machine.go开发语言: Go项目名称: juju代码行数: 1414
916		_, err := m.st.AddNetwork(network)
917		if err != nil && errors.IsAlreadyExists(err) {
918			// Ignore already existing networks.
925		_, err := m.AddNetworkInterface(iface)
926		if err != nil && errors.IsAlreadyExists(err) {
927			// Ignore already existing network interfaces.
1130// this to succeed. If a network interface already exists, the
1131// returned error satisfies errors.IsAlreadyExists.
1132func (m *Machine) AddNetworkInterface(args NetworkInterfaceInfo) (iface *NetworkInterface, err error) {
示例3:
machine.go开发语言: Go项目名称: juju代码行数: 1292
854		_, err := m.st.AddNetwork(network)
855		if err != nil && errors.IsAlreadyExists(err) {
856			// Ignore already existing networks.
863		_, err := m.AddNetworkInterface(iface)
864		if err != nil && errors.IsAlreadyExists(err) {
865			// Ignore already existing network interfaces.
1013// this to succeed. If a network interface already exists, the
1014// returned error satisfies errors.IsAlreadyExists.
1015func (m *Machine) AddNetworkInterface(args NetworkInterfaceInfo) (iface *NetworkInterface, err error) {
示例4:
etcd_test.go开发语言: Go项目名称: ashumeow代码行数: 1482
216	})
217	if !errors.IsAlreadyExists(err) {
218		t.Errorf("Unexpected error returned: %#v", err)
250	err = registry.ApplyBinding(ctx, &api.Binding{PodID: "foo", Host: "machine"})
251	if !errors.IsAlreadyExists(err) {
252		t.Fatalf("Unexpected error returned: %#v", err)
908	})
909	if !errors.IsAlreadyExists(err) {
910		t.Errorf("expected already exists err, got %#v", err)
1003	})
1004	if !errors.IsAlreadyExists(err) {
1005		t.Errorf("expected already exists err, got %#v", err)
示例5:
machine.go开发语言: Go项目名称: aznashwan代码行数: 1415
916		_, err := m.st.AddNetwork(network)
917		if err != nil && errors.IsAlreadyExists(err) {
918			// Ignore already existing networks.
925		_, err := m.AddNetworkInterface(iface)
926		if err != nil && errors.IsAlreadyExists(err) {
927			// Ignore already existing network interfaces.
1130// this to succeed. If a network interface already exists, the
1131// returned error satisfies errors.IsAlreadyExists.
1132func (m *Machine) AddNetworkInterface(args NetworkInterfaceInfo) (iface *NetworkInterface, err error) {
示例6:
state.go开发语言: Go项目名称: juju代码行数: 2123
1447// network with the same name or provider id already exists in state,
1448// an error satisfying errors.IsAlreadyExists is returned.
1449func (st *State) AddNetwork(args NetworkInfo) (n *Network, err error) {
示例7:
service.go开发语言: Go项目名称: juju代码行数: 584
287	err := s.start()
288	if errors.IsAlreadyExists(err) {
289		logger.Debugf("service %q already running", s.Name())
443	err := s.install()
444	if errors.IsAlreadyExists(err) {
445		logger.Debugf("service %q already installed", s.Name())
示例8:
machine.go开发语言: Go项目名称: abentley代码行数: 1372
900		_, err := m.st.AddNetwork(network)
901		if err != nil && errors.IsAlreadyExists(err) {
902			// Ignore already existing networks.
909		_, err := m.AddNetworkInterface(iface)
910		if err != nil && errors.IsAlreadyExists(err) {
911			// Ignore already existing network interfaces.
1093// this to succeed. If a network interface already exists, the
1094// returned error satisfies errors.IsAlreadyExists.
1095func (m *Machine) AddNetworkInterface(args NetworkInterfaceInfo) (iface *NetworkInterface, err error) {
示例9:
machine.go开发语言: Go项目名称: allomov代码行数: 1369
897		_, err := m.st.AddNetwork(network)
898		if err != nil && errors.IsAlreadyExists(err) {
899			// Ignore already existing networks.
906		_, err := m.AddNetworkInterface(iface)
907		if err != nil && errors.IsAlreadyExists(err) {
908			// Ignore already existing network interfaces.
1090// this to succeed. If a network interface already exists, the
1091// returned error satisfies errors.IsAlreadyExists.
1092func (m *Machine) AddNetworkInterface(args NetworkInterfaceInfo) (iface *NetworkInterface, err error) {
示例10:
wrapper.go开发语言: Go项目名称: utils代码行数: 162
86//
87// Any problem (including an existing file, see errors.IsAlreadyExists)
88// results in an error.  If there is an error while storing either the
115// If a file has already been stored an error is returned (see
116// errors.IsAlreadyExists).  Any other failure to add the file also
117// results in an error.

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