mirror of
https://github.com/psviderski/uncloud.git
synced 2026-10-08 14:14:52 +00:00
feat: add uc dns set
This allows manual setting of the cluster's domain name. I use this to
make the local cluster admin aware that this has been done.
(and then manually update the external dns)
```
% uc dns set ctrl.u.science.ru.nl
Set cluster domain: ctrl.u.science.ru.nl
Deploy the Caddy reverse proxy service ('uc caddy deploy') to enable internet access to your services via the reserved or your custom domain.
% uc dns show
ctrl.u.science.ru.nl
% uc dns set ctrl.u.science.ru.nl
Error: domain already reserved
% uc dns release
Released cluster domain: ctrl.u.science.ru.nl
```
See: #37
Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
1 parent
db55df64a2
commit
cec3c75a10
6 files changed
+797
-35
No files matched your search
@@ -112,6 +112,35 @@ func (c *Cluster) ReleaseDomain(ctx context.Context, _ *emptypb.Empty) (*pb.Doma
|
||||
return &pb.Domain{Name: domain.Name}, nil
|
||||
}
|
||||
|
||||
func (c *Cluster) SetDomain(ctx context.Context, req *pb.SetDomainRequest) (*pb.Domain, error) {
|
||||
if err := c.checkReady(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := c.storedDomain(ctx); err == nil {
|
||||
return nil, status.Errorf(codes.AlreadyExists, "domain already reserved")
|
||||
} else {
|
||||
if s := status.Convert(err); s.Code() != codes.NotFound {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
domain := uncloudDNSDomain{
|
||||
Endpoint: "",
|
||||
Name: req.Name,
|
||||
Token: "",
|
||||
}
|
||||
domainJSON, err := json.Marshal(domain)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "marshal set domain for store: %v", err)
|
||||
}
|
||||
if err = c.store.Put(ctx, uncloudDNSKey, domainJSON); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "store set domain: %v", err)
|
||||
}
|
||||
|
||||
return &pb.Domain{Name: req.Name}, nil
|
||||
}
|
||||
|
||||
func (c *Cluster) CreateDomainRecords(
|
||||
ctx context.Context, req *pb.CreateDomainRecordsRequest,
|
||||
) (*pb.CreateDomainRecordsResponse, error) {
|
||||
|
||||
Reference in new issue
Block a user