Files
sablier/pkg/provider/kubernetes/deployment_inspect.go
Alexis Couvreur fca9c79289 refactor: reorganize code structure (#556)
* refactor: rename providers to Provider

* refactor folders

* fix build cmd

* fix build cmd

* fix build cmd

* fix cmd start
2025-03-10 14:11:40 -04:00

23 lines
784 B
Go

package kubernetes
import (
"context"
"fmt"
"github.com/sablierapp/sablier/pkg/sablier"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func (p *Provider) DeploymentInspect(ctx context.Context, config ParsedName) (sablier.InstanceInfo, error) {
d, err := p.Client.AppsV1().Deployments(config.Namespace).Get(ctx, config.Name, metav1.GetOptions{})
if err != nil {
return sablier.InstanceInfo{}, 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 sablier.ReadyInstanceState(config.Original, config.Replicas), nil
}
return sablier.NotReadyInstanceState(config.Original, d.Status.ReadyReplicas, config.Replicas), nil
}