Skip to content

Commit 1de89b6

Browse files
raviciousgzdunek
andauthored
VNet in Connect: Send notification about bg item if not already enabled (gravitational#44219)
* Make serviceStatus public * Print to stdout when VNet is ready * Use executable name instead of saying "current executable" This error bubbles up to the UI in Connect. In that context, "the current executable" is ambiguous. * Send notification about bg item if not already enabled * Adjust notification copy Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com> --------- Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com>
1 parent 372d5db commit 1de89b6

File tree

12 files changed

+621
-77
lines changed

12 files changed

+621
-77
lines changed

gen/proto/go/teleport/lib/teleterm/vnet/v1/vnet_service.pb.go

+258-47
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/proto/go/teleport/lib/teleterm/vnet/v1/vnet_service_grpc.pb.go

+45-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/proto/ts/teleport/lib/teleterm/vnet/v1/vnet_service_pb.client.ts

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/proto/ts/teleport/lib/teleterm/vnet/v1/vnet_service_pb.grpc-server.ts

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/proto/ts/teleport/lib/teleterm/vnet/v1/vnet_service_pb.ts

+123-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Teleport
2+
// Copyright (C) 2024 Gravitational, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
//go:build vnetdaemon
18+
// +build vnetdaemon
19+
20+
package vnet
21+
22+
import (
23+
"context"
24+
"os"
25+
26+
"github.com/gravitational/trace"
27+
28+
api "github.com/gravitational/teleport/gen/proto/go/teleport/lib/teleterm/vnet/v1"
29+
"github.com/gravitational/teleport/lib/vnet"
30+
vnetdaemon "github.com/gravitational/teleport/lib/vnet/daemon"
31+
)
32+
33+
func (s *Service) GetBackgroundItemStatus(ctx context.Context, req *api.GetBackgroundItemStatusRequest) (*api.GetBackgroundItemStatusResponse, error) {
34+
if os.Getenv(vnet.EnvFeatureFlag) != "yes" {
35+
return nil, trace.NotImplemented("tsh was built with VNet daemon support, but the feature flag is not enabled")
36+
}
37+
38+
status, err := vnetdaemon.DaemonStatus()
39+
if err != nil {
40+
return nil, trace.Wrap(err)
41+
}
42+
43+
return &api.GetBackgroundItemStatusResponse{
44+
Status: backgroundItemStatusFromServiceStatus(status),
45+
}, nil
46+
}
47+
48+
func backgroundItemStatusFromServiceStatus(status vnetdaemon.ServiceStatus) api.BackgroundItemStatus {
49+
switch status {
50+
case vnetdaemon.ServiceStatusNotRegistered:
51+
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_NOT_REGISTERED
52+
case vnetdaemon.ServiceStatusEnabled:
53+
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_ENABLED
54+
case vnetdaemon.ServiceStatusRequiresApproval:
55+
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_REQUIRES_APPROVAL
56+
case vnetdaemon.ServiceStatusNotFound:
57+
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_NOT_FOUND
58+
default:
59+
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_UNSPECIFIED
60+
}
61+
}

0 commit comments

Comments
 (0)