feat(dns): expose service as service-name.cluster-domain if cluster domain reserved

This commit is contained in:
Pavel Sviderski
2025-02-26 21:10:21 +10:00
parent 4cc68e3133
commit a5f6ec4a68
5 changed files with 148 additions and 34 deletions
+2 -4
View File
@@ -7,8 +7,6 @@ import (
"github.com/charmbracelet/huh"
"github.com/docker/compose/v2/pkg/progress"
"github.com/spf13/cobra"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"maps"
"slices"
"strings"
@@ -175,8 +173,8 @@ func deploy(ctx context.Context, uncli *cli.CLI, opts deployOptions) error {
}
fmt.Println()
if _, err = clusterClient.GetDomain(ctx, nil); err != nil {
if status.Convert(err).Code() == codes.NotFound {
if _, err = clusterClient.GetDomain(ctx); err != nil {
if errors.Is(err, client.ErrNotFound) {
fmt.Println("Skipping DNS records update as no cluster domain is reserved (see 'uc dns').")
return nil
}
+6 -8
View File
@@ -5,10 +5,8 @@ import (
"errors"
"fmt"
"github.com/spf13/cobra"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
"uncloud/internal/cli"
"uncloud/internal/cli/client"
)
type showOptions struct {
@@ -36,20 +34,20 @@ func NewShowCommand() *cobra.Command {
}
func show(ctx context.Context, uncli *cli.CLI, opts showOptions) error {
client, err := uncli.ConnectCluster(ctx, opts.cluster)
clusterClient, err := uncli.ConnectCluster(ctx, opts.cluster)
if err != nil {
return fmt.Errorf("connect to cluster: %w", err)
}
defer client.Close()
defer clusterClient.Close()
domain, err := client.GetDomain(ctx, &emptypb.Empty{})
domain, err := clusterClient.GetDomain(ctx)
if err != nil {
if status.Convert(err).Code() == codes.NotFound {
if errors.Is(err, client.ErrNotFound) {
return errors.New("no domain reserved")
}
return err
}
fmt.Println(domain.Name)
fmt.Println(domain)
return nil
}