ShortURL: Use UpdateStatus client (#111170)

This commit is contained in:
Ryan McKinley
2025-10-30 15:57:03 +03:00
committed by GitHub
parent f185377c68
commit d303746ff9
12 changed files with 250 additions and 130 deletions
+10 -4
View File
@@ -30,11 +30,12 @@ var (
func New(cfg app.Config) (app.App, error) {
cfg.KubeConfig.APIPath = "apis"
client, err := k8s.NewClientRegistry(cfg.KubeConfig, k8s.DefaultClientConfig()).
tmp, err := k8s.NewClientRegistry(cfg.KubeConfig, k8s.DefaultClientConfig()).
ClientFor(shorturlv1alpha1.ShortURLKind())
if err != nil {
return nil, fmt.Errorf("unable to create client")
}
client := shorturlv1alpha1.NewShortURLClient(tmp)
simpleConfig := simple.AppConfig{
Name: "shorturl",
@@ -81,8 +82,8 @@ func New(cfg app.Config) (app.App, error) {
Name: req.ResourceIdentifier.Name,
}
info := &shorturlv1alpha1.ShortURL{}
if err := client.GetInto(ctx, id, info); err != nil {
info, err := client.Get(ctx, id)
if err != nil {
return err
}
@@ -93,7 +94,12 @@ func New(cfg app.Config) (app.App, error) {
if err != nil {
logging.FromContext(ctx).Warn("unable to create background identity", "err", err)
} else {
_, _ = client.Update(ctx, id, info, resource.UpdateOptions{})
_, err = client.UpdateStatus(ctx, id, info.Status, resource.UpdateOptions{
ResourceVersion: info.ResourceVersion,
})
if err != nil {
logging.FromContext(ctx).Warn("unable to update status", "err", err)
}
}
}()