mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-21 13:23:03 +01:00
* test(kubernetes): use testcontainers for test
* fix(kubernetes): get state properly reports the workload as down when scaled to 0
* refactor(kubernetes): split provider in multiple files
* refactor(provider): use Instance prefix for actions
* test(testcontainers): use provider.PullImage
* squash
* Revert "test(testcontainers): use provider.PullImage"
This reverts commit 6f958c48a5.
* test: add random generator thread safety
23 lines
786 B
Go
23 lines
786 B
Go
package kubernetes
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/sablierapp/sablier/app/instance"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
)
|
|
|
|
func (p *KubernetesProvider) DeploymentInspect(ctx context.Context, config ParsedName) (instance.State, error) {
|
|
d, err := p.Client.AppsV1().Deployments(config.Namespace).Get(ctx, config.Name, metav1.GetOptions{})
|
|
if err != nil {
|
|
return instance.State{}, fmt.Errorf("error getting deployment: %w", err)
|
|
}
|
|
|
|
// TODO: Should add option to set ready as soon as one replica is ready
|
|
if *d.Spec.Replicas != 0 && *d.Spec.Replicas == d.Status.ReadyReplicas {
|
|
return instance.ReadyInstanceState(config.Original, config.Replicas), nil
|
|
}
|
|
|
|
return instance.NotReadyInstanceState(config.Original, d.Status.ReadyReplicas, config.Replicas), nil
|
|
}
|