utils

package
v1.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	ConditionType        = "ResourcesAvailable"
	CommonSuccessMessage = "Sync Successfully"

	// Component is used for event component
	Component = "ApisixIngress"
	// ResourceSynced is used when a resource is synced successfully
	ResourceSynced = "ResourcesSynced"
	// MessageResourceSynced is used to specify controller
	MessageResourceSynced = "%s synced successfully"
	// ResourceSyncAborted is used when a resource synced failed
	ResourceSyncAborted = "ResourceSyncAborted"
	// MessageResourceFailed is used to report error
	MessageResourceFailed = "%s synced failed, with error: %s"
)

Variables

This section is empty.

Functions

func CoreV1ToNetworkV1LB

CoreV1ToNetworkV1LB convert []corev1.LoadBalancerIngress to []networkingv1.IngressLoadBalancerIngress

func CoreV1ToNetworkV1beta1LB

func CoreV1ToNetworkV1beta1LB(lbips []corev1.LoadBalancerIngress) []networkingv1beta1.IngressLoadBalancerIngress

CoreV1ToNetworkV1beta1LB convert []corev1.LoadBalancerIngress to []networkingv1beta1.IngressLoadBalancerIngress

func DiffGlobalRules

func DiffGlobalRules(olds, news []*apisixv1.GlobalRule) (added, updated, deleted []*apisixv1.GlobalRule)

func DiffPluginConfigs

func DiffPluginConfigs(olds, news []*apisixv1.PluginConfig) (added, updated, deleted []*apisixv1.PluginConfig)

func DiffPluginMetadatas

func DiffPluginMetadatas(olds, news []*apisixv1.PluginMetadata) (added, updated, deleted []*apisixv1.PluginMetadata)

func DiffRoutes

func DiffRoutes(olds, news []*apisixv1.Route) (added, updated, deleted []*apisixv1.Route)

func DiffSSL

func DiffSSL(olds, news []*apisixv1.Ssl) (added, updated, deleted []*apisixv1.Ssl)

func DiffStreamRoutes

func DiffStreamRoutes(olds, news []*apisixv1.StreamRoute) (added, updated, deleted []*apisixv1.StreamRoute)

func DiffUpstreams

func DiffUpstreams(olds, news []*apisixv1.Upstream) (added, updated, deleted []*apisixv1.Upstream)

func Difference

func Difference(a, b []string) []string

Difference returns elements only in a Duplicated elements are considered as same element

func Equal

func Equal(a, b []string) bool

func IngressLBStatusIPs

func IngressLBStatusIPs(ingressPublishService string, ingressStatusAddress []string, svcLister listerscorev1.ServiceLister) ([]corev1.LoadBalancerIngress, error)

IngressLBStatusIPs organizes the available addresses

func IngressPublishAddresses

func IngressPublishAddresses(ingressPublishService string, ingressStatusAddress []string, svcLister listerscorev1.ServiceLister) ([]string, error)

IngressPublishAddresses get addressed used to expose Ingress

func InsertKeyInMap added in v1.8.1

func InsertKeyInMap(key string, value interface{}, dest map[string]interface{})

InsertKeyInMap takes a dot separated string and recursively goes inside the destination to fill the value

func IsHostnameMatch

func IsHostnameMatch(listener, route string) bool

IsHostnameMatch follow GatewayAPI specification to match listenr and route hostname. FYI: https://github.com/kubernetes-sigs/gateway-api/blob/a596211672a5aed54881862dc87c8c1cad9c7bd8/apis/v1beta1/gateway_types.go#L154

func MatchCRDsIngressClass

func MatchCRDsIngressClass(resourceIngressClassName string, configIngressClass string) bool

func PtrOf

func PtrOf[T any](v T) *T

func RecorderEvent

func RecorderEvent(recorder record.EventRecorder, object runtime.Object, eventtype, reason string, err error)

RecorderEvent recorder events for resources

func RecorderEventS

func RecorderEventS(recorder record.EventRecorder, object runtime.Object, eventtype, reason string, msg string)

RecorderEventS recorder events for resources

func ReverseString

func ReverseString(s string) string

func SchemeToPort

func SchemeToPort(schema string) int

SchemeToPort scheme converts to the default port ref https://github.com/apache/apisix/blob/c5fc10d9355a0c177a7532f01c77745ff0639a7f/apisix/upstream.lua#L167-L172

func SyncManifests

func SyncManifests(ctx context.Context, apisix apisix.APISIX, clusterName string, added, updated, deleted *Manifest, shouldCompare bool) error

Due to dependency, delete priority should be last shouldCompare only affects Create event since periodic synchronization is considered as Add event

func TruncateString

func TruncateString(s string, max int) string

func VerifyConditions

func VerifyConditions(conditions *[]metav1.Condition, newCondition metav1.Condition) bool

VerifyConditions verify conditions to decide whether to update status

func VerifyGeneration

func VerifyGeneration(conditions *[]metav1.Condition, newCondition metav1.Condition) bool

VerifyGeneration verify generation to decide whether to update status

Types

type Manifest

type Manifest struct {
	Routes          []*apisixv1.Route
	Upstreams       []*apisixv1.Upstream
	StreamRoutes    []*apisixv1.StreamRoute
	SSLs            []*apisixv1.Ssl
	PluginConfigs   []*apisixv1.PluginConfig
	PluginMetadatas []*apisixv1.PluginMetadata
	GlobalRules     []*apisixv1.GlobalRule
}

func (*Manifest) Diff

func (m *Manifest) Diff(om *Manifest) (added, updated, deleted *Manifest)

type ParallelExecutor

type ParallelExecutor struct {
	// contains filtered or unexported fields
}

func (*ParallelExecutor) Add

func (exec *ParallelExecutor) Add(handler func())

func (*ParallelExecutor) AddE

func (exec *ParallelExecutor) AddE(handler func() error)

func (*ParallelExecutor) Errors

func (exec *ParallelExecutor) Errors() []error

func (*ParallelExecutor) Wait

func (exec *ParallelExecutor) Wait()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL