Skip to content

[dev] Run gofmt after Go 1.19 upgrade #11958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions components/common-go/baseserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions components/common-go/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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{}

Expand Down
1 change: 1 addition & 0 deletions components/ee/agent-smith/cmd/testtarget/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func main() {
}

// don't inline to produce an elf entry
//
//go:noinline
func agentSmithTestTarget() {
fmt.Println("something")
Expand Down
4 changes: 3 additions & 1 deletion components/gitpod-cli/cmd/credential-helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions components/gitpod-protocol/go/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
Expand Down
38 changes: 20 additions & 18 deletions components/ide/jetbrains/image/status/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
7 changes: 7 additions & 0 deletions components/licensor/typescript/ee/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions components/proxy/plugins/logif/caddyfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (
// UnmarshalCaddyfile sets up the module form Caddyfile tokens.
//
// Syntax:
// if {
// "<expression>"
// } [<encoder>]
//
// if {
// "<expression>"
// } [<encoder>]
//
// The <expression> must be on a single line.
// Refer to `lang.Lang` for its syntax.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,4 @@ func (n *noBufferWriter) Write(p []byte) (written int, err error) {
}

return
}
}
2 changes: 1 addition & 1 deletion components/registry-facade/ca-updater/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion components/workspacekit/cmd/rings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
10 changes: 6 additions & 4 deletions components/ws-daemon/pkg/cpulimit/cpulimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion components/ws-daemon/pkg/iws/iws.go
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,8 @@ func (wbs *InWorkspaceServiceServer) WriteIDMapping(ctx context.Context, req *ap
//
// <container-cgorup> 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 {
Expand Down
18 changes: 11 additions & 7 deletions components/ws-manager/pkg/clock/clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ 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
// running backwards. Also, this implementation is naively synchronised using a simple mutex.
//
// 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)
Expand All @@ -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()) },
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions components/ws-manager/pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading