diff --git a/components/common-go/baseserver/server.go b/components/common-go/baseserver/server.go index 598f0fd96dce56..d510ac9ca86725 100644 --- a/components/common-go/baseserver/server.go +++ b/components/common-go/baseserver/server.go @@ -61,18 +61,18 @@ func New(name string, opts ...Option) (*Server, error) { // Server implements graceful shutdown making it suitable for usage in integration tests. See server_test.go. // // Server is composed of the following: -// * Debug server which serves observability and debug endpoints -// - /metrics for Prometheus metrics -// - /pprof for Golang profiler -// - /ready for kubernetes readiness check -// - /live for kubernetes liveness check -// * (optional) gRPC server with standard interceptors and configuration -// - Started when baseserver is configured WithGRPCPort (port is non-negative) -// - Use Server.GRPC() to get access to the underlying grpc.Server and register services -// * (optional) HTTP server -// - Currently does not come with any standard HTTP middlewares -// - Started when baseserver is configured WithHTTPPort (port is non-negative) -// - Use Server.HTTPMux() to get access to the root handler and register your endpoints +// - Debug server which serves observability and debug endpoints +// - /metrics for Prometheus metrics +// - /pprof for Golang profiler +// - /ready for kubernetes readiness check +// - /live for kubernetes liveness check +// - (optional) gRPC server with standard interceptors and configuration +// - Started when baseserver is configured WithGRPCPort (port is non-negative) +// - Use Server.GRPC() to get access to the underlying grpc.Server and register services +// - (optional) HTTP server +// - Currently does not come with any standard HTTP middlewares +// - Started when baseserver is configured WithHTTPPort (port is non-negative) +// - Use Server.HTTPMux() to get access to the root handler and register your endpoints type Server struct { // Name is the name of this server, used for logging context Name string diff --git a/components/common-go/log/log.go b/components/common-go/log/log.go index ca2d714e2ea441..25420db09f6bcf 100644 --- a/components/common-go/log/log.go +++ b/components/common-go/log/log.go @@ -31,7 +31,8 @@ const ( // OWI builds a structure meant for logrus which contains the owner, workspace and instance. // Beware that this refers to the terminology outside of wsman which maps like: -// owner = owner, workspace = metaID, instance = workspaceID +// +// owner = owner, workspace = metaID, instance = workspaceID func OWI(owner, workspace, instance string) log.Fields { return log.Fields{ OwnerField: owner, @@ -42,7 +43,8 @@ func OWI(owner, workspace, instance string) log.Fields { // LogContext builds a structure meant for logrus which contains the owner, workspace and instance. // Beware that this refers to the terminology outside of wsman which maps like: -// owner = owner, workspace = metaID, instance = workspaceID +// +// owner = owner, workspace = metaID, instance = workspaceID func LogContext(owner, workspace, instance, project, team string) log.Fields { logFields := log.Fields{} diff --git a/components/ee/agent-smith/cmd/testtarget/main.go b/components/ee/agent-smith/cmd/testtarget/main.go index ccd61e9595bd31..4e30616ef77e34 100644 --- a/components/ee/agent-smith/cmd/testtarget/main.go +++ b/components/ee/agent-smith/cmd/testtarget/main.go @@ -15,6 +15,7 @@ func main() { } // don't inline to produce an elf entry +// //go:noinline func agentSmithTestTarget() { fmt.Println("something") diff --git a/components/gitpod-cli/cmd/credential-helper.go b/components/gitpod-cli/cmd/credential-helper.go index b9283f5dac05b7..aaec6bd8fe4f85 100644 --- a/components/gitpod-cli/cmd/credential-helper.go +++ b/components/gitpod-cli/cmd/credential-helper.go @@ -230,9 +230,11 @@ func walkProcessTree(pid int, fn pidCallbackFn) error { // - Private npm package // - Create a private git repository for an npm package e.g https://github.com/jeanp413/test-private-package // - Start a workspace, then run `npm install github:jeanp413/test-private-package` with and without permissions in the dashboard +// // - Private npm package no access // - Open this workspace https://github.com/jeanp413/test-gp-bug and run `npm install` -// - Observe NO notification with this message appears `Unknown repository '' Please grant the necessary permissions.` +// - Observe NO notification with this message appears `Unknown repository ” Please grant the necessary permissions.` +// // - Clone private repo without permission // - Start a workspace, then run `git clone 'https://gitlab.ebizmarts.com/ebizmarts/magento2-pos-api-request.git`, you should see a prompt ask your username and password, instead of `'gp credential-helper' told us to quit` func init() { diff --git a/components/gitpod-protocol/go/websocket.go b/components/gitpod-protocol/go/websocket.go index a16ff443d329cb..191a0e11dc191e 100644 --- a/components/gitpod-protocol/go/websocket.go +++ b/components/gitpod-protocol/go/websocket.go @@ -39,7 +39,7 @@ var ( pingPeriod = (pongWait * 9) / 10 ) -//NewWebsocketConnection converts a websocket.Conn into a net.Conn +// NewWebsocketConnection converts a websocket.Conn into a net.Conn func NewWebsocketConnection(ctx context.Context, websocketConn *websocket.Conn, onStale func(staleErr error)) (*WebsocketConnection, error) { ctx, cancel := context.WithCancel(ctx) c := &WebsocketConnection{ @@ -90,8 +90,8 @@ func (c *WebsocketConnection) Wait() error { return c.closeErr } -//Read is not threadsafe though thats okay since there -//should never be more than one reader +// Read is not threadsafe though thats okay since there +// should never be more than one reader func (c *WebsocketConnection) Read(dst []byte) (int, error) { ldst := len(dst) //use buffer or read new message diff --git a/components/ide/jetbrains/image/status/main.go b/components/ide/jetbrains/image/status/main.go index 3b2c435bcbad24..d266bfb8486c97 100644 --- a/components/ide/jetbrains/image/status/main.go +++ b/components/ide/jetbrains/image/status/main.go @@ -379,24 +379,26 @@ func updateVMOptions(config *gitpod.GitpodConfig, alias string, content string) return strings.Join(vmoptions, "\n") + "\n" } -/** -{ - "buildNumber" : "221.4994.44", - "customProperties" : [ ], - "dataDirectoryName" : "IntelliJIdea2022.1", - "launch" : [ { - "javaExecutablePath" : "jbr/bin/java", - "launcherPath" : "bin/idea.sh", - "os" : "Linux", - "startupWmClass" : "jetbrains-idea", - "vmOptionsFilePath" : "bin/idea64.vmoptions" - } ], - "name" : "IntelliJ IDEA", - "productCode" : "IU", - "svgIconPath" : "bin/idea.svg", - "version" : "2022.1", - "versionSuffix" : "EAP" -} +/* +* + + { + "buildNumber" : "221.4994.44", + "customProperties" : [ ], + "dataDirectoryName" : "IntelliJIdea2022.1", + "launch" : [ { + "javaExecutablePath" : "jbr/bin/java", + "launcherPath" : "bin/idea.sh", + "os" : "Linux", + "startupWmClass" : "jetbrains-idea", + "vmOptionsFilePath" : "bin/idea64.vmoptions" + } ], + "name" : "IntelliJ IDEA", + "productCode" : "IU", + "svgIconPath" : "bin/idea.svg", + "version" : "2022.1", + "versionSuffix" : "EAP" + } */ type ProductInfo struct { Version string `json:"version"` diff --git a/components/licensor/typescript/ee/main.go b/components/licensor/typescript/ee/main.go index 3cef8af627d5a0..ed7fab4a8dcebd 100644 --- a/components/licensor/typescript/ee/main.go +++ b/components/licensor/typescript/ee/main.go @@ -20,6 +20,7 @@ var ( ) // Init initializes the global license evaluator from an environment variable +// //export Init func Init(key *C.char, domain *C.char) (id int) { id = nextID @@ -36,6 +37,7 @@ func Init(key *C.char, domain *C.char) (id int) { } // GetLicenseData returns the info about license for the admin dashboard +// //export GetLicenseData func GetLicenseData(id int) (licData *C.char, ok bool) { e, ok := instances[id] @@ -54,6 +56,7 @@ func GetLicenseData(id int) (licData *C.char, ok bool) { } // Validate returns false if the license isn't valid and a message explaining why that is. +// //export Validate func Validate(id int) (msg *C.char, valid bool) { e, ok := instances[id] @@ -66,6 +69,7 @@ func Validate(id int) (msg *C.char, valid bool) { } // Enabled returns true if a license enables a feature +// //export Enabled func Enabled(id int, feature *C.char, seats int) (enabled, ok bool) { e, ok := instances[id] @@ -77,6 +81,7 @@ func Enabled(id int, feature *C.char, seats int) (enabled, ok bool) { } // HasEnoughSeats returns true if the license supports at least the given number of seats. +// //export HasEnoughSeats func HasEnoughSeats(id int, seats int) (permitted, ok bool) { e, ok := instances[id] @@ -88,6 +93,7 @@ func HasEnoughSeats(id int, seats int) (permitted, ok bool) { } // Inspect returns the license information this evaluator holds. +// //export Inspect func Inspect(id int) (lic *C.char, ok bool) { e, ok := instances[id] @@ -105,6 +111,7 @@ func Inspect(id int) (lic *C.char, ok bool) { } // Dispose removes/disposes an instance formerly created using Init. If the id does not exist, nothing happens. +// //export Dispose func Dispose(id int) { delete(instances, id) diff --git a/components/proxy/plugins/logif/caddyfile.go b/components/proxy/plugins/logif/caddyfile.go index 7bd628faaaa722..1b604bcdb05e50 100644 --- a/components/proxy/plugins/logif/caddyfile.go +++ b/components/proxy/plugins/logif/caddyfile.go @@ -13,9 +13,10 @@ import ( // UnmarshalCaddyfile sets up the module form Caddyfile tokens. // // Syntax: -// if { -// "" -// } [] +// +// if { +// "" +// } [] // // The must be on a single line. // Refer to `lang.Lang` for its syntax. diff --git a/components/proxy/plugins/workspacedownload/workspace_download.go b/components/proxy/plugins/workspacedownload/workspace_download.go index dd58c6441de459..1aff50960b1cda 100644 --- a/components/proxy/plugins/workspacedownload/workspace_download.go +++ b/components/proxy/plugins/workspacedownload/workspace_download.go @@ -171,4 +171,4 @@ func (n *noBufferWriter) Write(p []byte) (written int, err error) { } return -} \ No newline at end of file +} diff --git a/components/registry-facade/ca-updater/Dockerfile b/components/registry-facade/ca-updater/Dockerfile index 3ca00f09670871..37084d9c7ab03d 100644 --- a/components/registry-facade/ca-updater/Dockerfile +++ b/components/registry-facade/ca-updater/Dockerfile @@ -2,7 +2,7 @@ # Licensed under the GNU Affero General Public License (AGPL). # See License-AGPL.txt in the project root for license information. -FROM ubuntu:21.04 +FROM ubuntu:22.04 COPY install-packages /usr/bin diff --git a/components/workspacekit/cmd/rings.go b/components/workspacekit/cmd/rings.go index 296d64ef1fb246..21dc8fabb2c6c7 100644 --- a/components/workspacekit/cmd/rings.go +++ b/components/workspacekit/cmd/rings.go @@ -623,7 +623,8 @@ var ( // That's how configMaps and secrets behave in Kubernetes. // // Note/Caveat: configMap or secret volumes with a subPath do not behave as described above and will not be recognised by this function. -// in those cases you'll want to use GITPOD_WORKSPACEKIT_BIND_MOUNTS to explicitely list those paths. +// +// in those cases you'll want to use GITPOD_WORKSPACEKIT_BIND_MOUNTS to explicitely list those paths. func findBindMountCandidates(procMounts io.Reader, readlink func(path string) (dest string, err error)) (mounts []string, err error) { scanner := bufio.NewScanner(procMounts) for scanner.Scan() { diff --git a/components/ws-daemon/pkg/cpulimit/cpulimit.go b/components/ws-daemon/pkg/cpulimit/cpulimit.go index 2152dec76e60a3..2cb15fbaa8e811 100644 --- a/components/ws-daemon/pkg/cpulimit/cpulimit.go +++ b/components/ws-daemon/pkg/cpulimit/cpulimit.go @@ -274,10 +274,12 @@ type Bucket struct { // BucketLimiter limits CPU use based on different "pots of CPU time". // The current limit is decided by the current bucket which is taken in order. // For example: -// buckets = [ { Budget: 50, Limit: 20 }, { Budget: 20, Limit: 10 }, { Budget: 0, Limit: 5 } ] -// budgetSpent = totalBudget - budgetLeft == 65 -// then the current limit is 10, because we have spent all our budget from bucket 0, and are currently -// spending from the second bucket. +// +// buckets = [ { Budget: 50, Limit: 20 }, { Budget: 20, Limit: 10 }, { Budget: 0, Limit: 5 } ] +// budgetSpent = totalBudget - budgetLeft == 65 +// then the current limit is 10, because we have spent all our budget from bucket 0, and are currently +// spending from the second bucket. +// // The last bucket's Budget is always ignored and becomes the default limit if all other // buckets are used up. // If the list of buckets is empty, this limiter limits to zero. diff --git a/components/ws-daemon/pkg/iws/iws.go b/components/ws-daemon/pkg/iws/iws.go index 645cb859868031..fa16c08e1c88a3 100644 --- a/components/ws-daemon/pkg/iws/iws.go +++ b/components/ws-daemon/pkg/iws/iws.go @@ -934,7 +934,8 @@ func (wbs *InWorkspaceServiceServer) WriteIDMapping(ctx context.Context, req *ap // // drwxr-xr-x 3 root root // └── workspace drwxr-xr-x 5 gitpodUid gitpodGid -// └── user drwxr-xr-x 5 gitpodUid gitpodGid +// +// └── user drwxr-xr-x 5 gitpodUid gitpodGid func (wbs *InWorkspaceServiceServer) EvacuateCGroup(ctx context.Context, req *api.EvacuateCGroupRequest) (*api.EvacuateCGroupResponse, error) { unified, err := cgroups.IsUnifiedCgroupSetup() if err != nil { diff --git a/components/ws-manager/pkg/clock/clock.go b/components/ws-manager/pkg/clock/clock.go index b3d688cedf0540..cf1ec4cf6fa032 100644 --- a/components/ws-manager/pkg/clock/clock.go +++ b/components/ws-manager/pkg/clock/clock.go @@ -12,9 +12,10 @@ import ( ) // This clock roughly implements a Hybrid Logical Clock (HLC) as described in -// Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases -// Kulkarni et al. -// https://cse.buffalo.edu/tech-reports/2014-04.pdf +// +// Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases +// Kulkarni et al. +// https://cse.buffalo.edu/tech-reports/2014-04.pdf // // This implementation is very much geared towards single process use, yet still // protects us from the funny bits of physical wall time, e.g. clock skew or time @@ -22,7 +23,8 @@ import ( // // In the future, if we ever make ws-manager properly distributed, we might want // to take inspiration from cockroachDB's implementation: -// https://github.com/cockroachdb/cockroach/blob/master/pkg/util/hlc/hlc.go +// +// https://github.com/cockroachdb/cockroach/blob/master/pkg/util/hlc/hlc.go type HLC struct { physicalTime func() uint64 backwardsFlowReporter func(diff uint64) @@ -37,8 +39,9 @@ type HLC struct { // System takes the wall time from the actual system time. // Beware: when using the clock wall time, it's a good idea to wait out -// the maximum expected real wall time skew, e.g. as imposed by -// NTP. time.Sleep(2*time.Second) should be enough in most cases. +// +// the maximum expected real wall time skew, e.g. as imposed by +// NTP. time.Sleep(2*time.Second) should be enough in most cases. func System() *HLC { return &HLC{ physicalTime: func() uint64 { return uint64(time.Now().Unix()) }, @@ -59,7 +62,8 @@ const ( // ReportBackwardsTime registers a reporter which gets called when the wall time // does not increase monotonously. // Beware: this function is not synchronised with Tick() and must not be called -// concurrently. +// +// concurrently. func (c *HLC) ReportBackwardsTime(r func(diff uint64)) { c.backwardsFlowReporter = r } diff --git a/components/ws-manager/pkg/manager/internal/workpool/workpool.go b/components/ws-manager/pkg/manager/internal/workpool/workpool.go index 2c8246bff5530e..883da0fe5b381a 100644 --- a/components/ws-manager/pkg/manager/internal/workpool/workpool.go +++ b/components/ws-manager/pkg/manager/internal/workpool/workpool.go @@ -30,7 +30,6 @@ import ( // Why not use kubernetes/client-go/workqueue? // We have different requirements than the workqueue. The Kubernetes workqueue cares about the order/ // execution of single items. We care about the order of several items grouped by some factor. -// type EventWorkerPool struct { WorkOn func(watch.Event) diff --git a/components/ws-manager/pkg/manager/manager.go b/components/ws-manager/pkg/manager/manager.go index 4eee65d47d0d66..372c32d33da7c3 100644 --- a/components/ws-manager/pkg/manager/manager.go +++ b/components/ws-manager/pkg/manager/manager.go @@ -863,6 +863,7 @@ func (m *Manager) findWorkspacePod(ctx context.Context, workspaceID string) (*co } // getPodID computes the pod ID from a workpace ID +// //nolint:unused,deadcode func getPodID(workspaceType, workspaceID string) string { return fmt.Sprintf("%s-%s", strings.TrimSpace(strings.ToLower(workspaceType)), strings.TrimSpace(workspaceID)) diff --git a/dev/gpctl/cmd/workspaces-watch.go b/dev/gpctl/cmd/workspaces-watch.go index 68b858c12fdcd5..e37111a84c9ecf 100644 --- a/dev/gpctl/cmd/workspaces-watch.go +++ b/dev/gpctl/cmd/workspaces-watch.go @@ -8,68 +8,69 @@ package cmd var defaultTemplate = `{{.Id}} {{.Phase}}: {{.Message}}{{"\n"}}` // clientStartCmd starts a new workspace -var clientWatchCmd = &cobra.Command{ - Use: "watch", - Short: "observe for workspace status changes", - Run: func(cmd *cobra.Command, args []string) { - tpl := template.New("tpl") - tpl, err := tpl.Parse(defaultTemplate) - if err != nil { - log.WithError(err).Fatal("cannot parse template") - } - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - conn, client, err := getWorkspacesClient(ctx) - if err != nil { - log.WithError(err).Fatal("cannot connect") - } - defer conn.Close() + var clientWatchCmd = &cobra.Command{ + Use: "watch", + Short: "observe for workspace status changes", + Run: func(cmd *cobra.Command, args []string) { + tpl := template.New("tpl") + tpl, err := tpl.Parse(defaultTemplate) + if err != nil { + log.WithError(err).Fatal("cannot parse template") + } - sub, err := client.Subscribe(ctx, &api.SubscribeRequest{}) - if err != nil { - log.WithError(err).Fatal("cannot subscribe") - } - rcvChan := make(chan *api.WorkspaceStatus) - go func() { - for { - update, err := sub.Recv() - if err != nil { - if err != io.EOF { - log.WithError(err).Warn("error while receiving updates") + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + conn, client, err := getWorkspacesClient(ctx) + if err != nil { + log.WithError(err).Fatal("cannot connect") + } + defer conn.Close() + + sub, err := client.Subscribe(ctx, &api.SubscribeRequest{}) + if err != nil { + log.WithError(err).Fatal("cannot subscribe") + } + rcvChan := make(chan *api.WorkspaceStatus) + go func() { + for { + update, err := sub.Recv() + if err != nil { + if err != io.EOF { + log.WithError(err).Warn("error while receiving updates") + } + + return } - return - } + sts, ok := update.Payload.(*api.SubscribeResponse_Status) + if !ok { + continue + } - sts, ok := update.Payload.(*api.SubscribeResponse_Status) - if !ok { - continue + rcvChan <- sts.Status } + }() - rcvChan <- sts.Status - } - }() - - // run until we're told to stop - sigChan := make(chan os.Signal, 1) - signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM) - log.Info("Listening for status updates. Stop with SIGINT or CTRL+C") + // run until we're told to stop + sigChan := make(chan os.Signal, 1) + signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM) + log.Info("Listening for status updates. Stop with SIGINT or CTRL+C") - for { - select { - case <-sigChan: - log.Info("Received SIGINT - shutting down") - return - case sts := <-rcvChan: - err = tpl.Execute(os.Stdout, sts) - if err != nil { - log.WithError(err).WithField("status", sts).Info("status update") + for { + select { + case <-sigChan: + log.Info("Received SIGINT - shutting down") + return + case sts := <-rcvChan: + err = tpl.Execute(os.Stdout, sts) + if err != nil { + log.WithError(err).WithField("status", sts).Info("status update") + } } } - } - }, -} + }, + } */ func init() { // TODO: re-enable this once we're not talking over messagebus anymore diff --git a/dev/preview/previewctl/pkg/preview/preview.go b/dev/preview/previewctl/pkg/preview/preview.go index da42fe80bbadb9..96cc041e9835a5 100644 --- a/dev/preview/previewctl/pkg/preview/preview.go +++ b/dev/preview/previewctl/pkg/preview/preview.go @@ -127,7 +127,6 @@ func (p *Preview) InstallContext(wait bool, timeout time.Duration) error { // // Preview environments are considered the same if they are based on the same underlying // branch and the VM hasn't changed. -// func (p *Preview) Same(newPreview *Preview) bool { sameBranch := p.branch == newPreview.branch if !sameBranch { diff --git a/operations/observability/mixins/tools.go b/operations/observability/mixins/tools.go index e10a040facec5c..8602a194ac6c64 100644 --- a/operations/observability/mixins/tools.go +++ b/operations/observability/mixins/tools.go @@ -2,7 +2,8 @@ // Licensed under the GNU Affero General Public License (AGPL). // See License-AGPL.txt in the project root for license information. -//+build tools +//go:build tools +// +build tools // Package tools tracks dependencies for tools that used in the build process. // See https://github.com/golang/go/wiki/Modules @@ -12,4 +13,4 @@ import ( _ "github.com/google/go-jsonnet/cmd/jsonnet" _ "github.com/google/go-jsonnet/cmd/jsonnetfmt" _ "github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb" -) \ No newline at end of file +) diff --git a/test/tests/workspace/git_test.go b/test/tests/workspace/git_test.go index 2d3d2b9a1006ad..68b0226de7ddab 100644 --- a/test/tests/workspace/git_test.go +++ b/test/tests/workspace/git_test.go @@ -19,7 +19,6 @@ import ( "github.com/gitpod-io/gitpod/test/pkg/integration/common" ) -// type GitTest struct { Skip bool Name string