mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
feat(dns): expose service as service-name.cluster-domain if cluster domain reserved
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user