adapter

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright 2020 The OpenYurt Authors. Copyright 2019 The Kruise Authors. Licensed 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. @CHANGELOG OpenYurt Authors: change Adapter interface

Copyright 2021 The OpenYurt Authors. Copyright 2019 The Kruise Authors. Licensed 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.

Copyright 2021 The OpenYurt Authors. Licensed 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

This section is empty.

Variables

This section is empty.

Functions

func CreateNewPatchedObject

func CreateNewPatchedObject(patchInfo *runtime.RawExtension, set metav1.Object, newPatched metav1.Object) error

func PoolHasPatch

func PoolHasPatch(poolConfig *appsv1alpha1.Pool, set metav1.Object) bool

func StrategicMergeByPatches

func StrategicMergeByPatches(oldobj interface{}, patch *runtime.RawExtension, newPatched interface{}) error

Types

type Adapter

type Adapter interface {
	// NewResourceObject creates a empty pool object.
	NewResourceObject() runtime.Object
	// NewResourceListObject creates a empty pool list object.
	NewResourceListObject() runtime.Object
	// GetStatusObservedGeneration returns the observed generation of the pool.
	GetStatusObservedGeneration(pool metav1.Object) int64
	// GetDetails returns the replicas information of the pool status.
	GetDetails(pool metav1.Object) (replicasInfo ReplicasInfo, err error)
	// GetAvailableStatus returns the available condition status of the workload
	GetAvailableStatus(set metav1.Object) (conditionStatus corev1.ConditionStatus, err error)
	// GetPoolFailure returns failure information of the pool.
	GetPoolFailure() *string
	// ApplyPoolTemplate updates the pool to the latest revision.
	ApplyPoolTemplate(yas *alpha1.YurtAppSet, poolName, revision string, replicas int32, pool runtime.Object) error
	// IsExpected checks the pool is the expected revision or not.
	// If not, YurtAppSet will call ApplyPoolTemplate to update it.
	IsExpected(pool metav1.Object, revision string) bool
	// PostUpdate does some works after pool updated
	PostUpdate(yas *alpha1.YurtAppSet, pool runtime.Object, revision string) error
}

type DeploymentAdapter

type DeploymentAdapter struct {
	client.Client
	Scheme *runtime.Scheme
}

func (*DeploymentAdapter) ApplyPoolTemplate

func (a *DeploymentAdapter) ApplyPoolTemplate(yas *alpha1.YurtAppSet, poolName, revision string,
	replicas int32, obj runtime.Object) error

ApplyPoolTemplate updates the pool to the latest revision, depending on the DeploymentTemplate.

func (*DeploymentAdapter) GetAvailableStatus

func (a *DeploymentAdapter) GetAvailableStatus(obj metav1.Object) (conditionStatus corev1.ConditionStatus, err error)

GetAvailableStatus returns the available condition status of the workload

func (*DeploymentAdapter) GetDetails

func (a *DeploymentAdapter) GetDetails(obj metav1.Object) (ReplicasInfo, error)

GetDetails returns the replicas detail the pool needs.

func (*DeploymentAdapter) GetPoolFailure

func (a *DeploymentAdapter) GetPoolFailure() *string

GetPoolFailure returns the failure information of the pool. Deployment has no condition.

func (*DeploymentAdapter) GetStatusObservedGeneration

func (a *DeploymentAdapter) GetStatusObservedGeneration(obj metav1.Object) int64

GetStatusObservedGeneration returns the observed generation of the pool.

func (*DeploymentAdapter) IsExpected

func (a *DeploymentAdapter) IsExpected(obj metav1.Object, revision string) bool

IsExpected checks the pool is the expected revision or not. The revision label can tell the current pool revision.

func (*DeploymentAdapter) NewResourceListObject

func (a *DeploymentAdapter) NewResourceListObject() runtime.Object

NewResourceListObject creates a empty DeploymentList object.

func (*DeploymentAdapter) NewResourceObject

func (a *DeploymentAdapter) NewResourceObject() runtime.Object

NewResourceObject creates a empty Deployment object.

func (*DeploymentAdapter) PostUpdate

func (a *DeploymentAdapter) PostUpdate(yas *alpha1.YurtAppSet, obj runtime.Object, revision string) error

PostUpdate does some works after pool updated. Deployment will implement this method to clean stuck pods.

type ReplicasInfo

type ReplicasInfo struct {
	Replicas      int32
	ReadyReplicas int32
}

Jump to

Keyboard shortcuts

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