Skip to content

Commit

Permalink
try to format everything
Browse files Browse the repository at this point in the history
  • Loading branch information
fearful-symmetry committed Mar 7, 2023
1 parent a654a41 commit 53dcdd0
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 59 deletions.
13 changes: 6 additions & 7 deletions dev-tools/mage/gotest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ var gotestHelperMode = os.Getenv(envGoTestHelper) == "1"
// TestGoTest_CaptureOutput sets the `GOTEST_WANT_HELPER` environment variable when it executes the tests.
// each test helper must check if it is driven by this function or not:
//
// func TestGoTest_Helper_X(t *testing.T) {
// if !gotestHelperMode {
// return
// }
//
// // sample test
// }
// func TestGoTest_Helper_X(t *testing.T) {
// if !gotestHelperMode {
// return
// }
//
// // sample test
// }
func TestGoTest_CaptureOutput(t *testing.T) {
errNonZero := "go test returned a non-zero value"
makeArgs := func(test string) GoTestArgs {
Expand Down
11 changes: 7 additions & 4 deletions dev-tools/mage/keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,19 @@ var (
// GetAppleSigningInfo returns the signing identities used for code signing
// apps and installers.
//
// Environment Variables
// # Environment Variables
//
// APPLE_SIGNING_ENABLED - Must be set to true to enable signing. Defaults to
// false.
//
// false.
//
// APPLE_SIGNING_IDENTITY_INSTALLER - filter for selecting the signing identity
// for installers.
//
// for installers.
//
// APPLE_SIGNING_IDENTITY_APP - filter for selecting the signing identity
// for apps.
//
// for apps.
func GetAppleSigningInfo() (*AppleSigningInfo, error) {
appleSigningInfoOnce.Do(func() {
appleSigningInfoValue, appleSigningInfoErr = getAppleSigningInfo()
Expand Down
23 changes: 13 additions & 10 deletions internal/pkg/agent/application/filters/stream_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ func StreamChecker(log *logger.Logger, ast *transpiler.AST) error {

// The only two requirement are that it has only characters allowed in an Elasticsearch index name
// Index names must meet the following criteria:
// Not longer than 100 bytes
// Lowercase only
// Cannot include \, /, *, ?, ", <, >, |, ` ` (space character), ,, #
//
// Not longer than 100 bytes
// Lowercase only
// Cannot include \, /, *, ?, ", <, >, |, ` ` (space character), ,, #
func matchesNamespaceContraints(namespace string) bool {
// length restriction is in bytes, not characters
if len(namespace) <= 0 || len(namespace) > 100 {
Expand All @@ -165,10 +166,11 @@ func matchesNamespaceContraints(namespace string) bool {
}

// matchesTypeConstraints fails for following rules. As type is first element of resulting index prefix restrictions need to be applied.
// Not longer than 20 bytes
// Lowercase only
// Cannot start with -, _, +
// Cannot include \, /, *, ?, ", <, >, |, ` ` (space character), ,, #
//
// Not longer than 20 bytes
// Lowercase only
// Cannot start with -, _, +
// Cannot include \, /, *, ?, ", <, >, |, ` ` (space character), ,, #
func matchesTypeConstraints(dsType string) bool {
// length restriction is in bytes, not characters
if len(dsType) <= 0 || len(dsType) > 20 {
Expand All @@ -183,9 +185,10 @@ func matchesTypeConstraints(dsType string) bool {
}

// matchesDatasetConstraints fails for following rules
// Not longer than 100 bytes
// Lowercase only
// Cannot include \, /, *, ?, ", <, >, |, ` ` (space character), ,, #
//
// Not longer than 100 bytes
// Lowercase only
// Cannot include \, /, *, ?, ", <, >, |, ` ` (space character), ,, #
func matchesDatasetConstraints(dataset string) bool {
// length restriction is in bytes, not characters
if len(dataset) <= 0 || len(dataset) > 100 {
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/agent/application/reexec/reexec_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
// Windows does not support the ability to execute over the same PID and memory. Depending on the execution context
// different scenarios need to occur.
//
// * Services.msc - A new child process is spawned that waits for the service to stop, then restarts it and the
// current process just exits.
// - Services.msc - A new child process is spawned that waits for the service to stop, then restarts it and the
// current process just exits.
//
// * Sub-process - As a sub-process a new child is spawned and the current process just exits.
func reexec(log *logger.Logger, executable string, argOverrides ...string) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/control/v2/cproto/control_v2.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion internal/pkg/agent/errors/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

//nolint:errorlint,errcheck // Postpone the change here until we refactor error handling.
// Package errors provides a small api to manage hierarchy of errors.
//
//nolint:errorlint,errcheck // Postpone the change here until we refactor error handling.
package errors

import (
Expand Down
22 changes: 12 additions & 10 deletions internal/pkg/fleetapi/ack_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ type AckEvent struct {
// AckRequest consists of multiple actions acked to fleet ui.
// POST /agents/{agentId}/acks
// Authorization: ApiKey {AgentAccessApiKey}
// {
// "action_ids": ["id1"]
// }
//
// {
// "action_ids": ["id1"]
// }
type AckRequest struct {
Events []AckEvent `json:"events"`
}
Expand All @@ -61,13 +62,14 @@ type AckResponseItem struct {

// AckResponse is the response send back from the server.
// 200
// {
// "action": "acks"
// "items": [
// {"status": 200},
// {"status": 404},
// ]
// }
//
// {
// "action": "acks"
// "items": [
// {"status": 200},
// {"status": 404},
// ]
// }
type AckResponse struct {
Action string `json:"action"`
Errors bool `json:"errors,omitempty"` // indicates that some of the events in the ack request failed
Expand Down
44 changes: 23 additions & 21 deletions internal/pkg/fleetapi/enroll_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ func (p EnrollType) MarshalJSON() ([]byte, error) {
//
// Example:
// POST /api/fleet/agents/enroll
// {
// "type": "PERMANENT",
// "metadata": {
// "local": { "os": "macos"},
// "user_provided": { "region": "us-east"}
// }
// }
//
// {
// "type": "PERMANENT",
// "metadata": {
// "local": { "os": "macos"},
// "user_provided": { "region": "us-east"}
// }
// }
type EnrollRequest struct {
EnrollAPIKey string `json:"-"`
Type EnrollType `json:"type"`
Expand Down Expand Up @@ -116,20 +117,21 @@ func (e *EnrollRequest) Validate() error {
// EnrollResponse is the data received after enrolling an Agent into fleet.
//
// Example:
// {
// "action": "created",
// "item": {
// "id": "a4937110-e53e-11e9-934f-47a8e38a522c",
// "active": true,
// "policy_id": "default",
// "type": "PERMANENT",
// "enrolled_at": "2019-10-02T18:01:22.337Z",
// "user_provided_metadata": {},
// "local_metadata": {},
// "actions": [],
// "access_api_key": "API_KEY"
// }
// }
//
// {
// "action": "created",
// "item": {
// "id": "a4937110-e53e-11e9-934f-47a8e38a522c",
// "active": true,
// "policy_id": "default",
// "type": "PERMANENT",
// "enrolled_at": "2019-10-02T18:01:22.337Z",
// "user_provided_metadata": {},
// "local_metadata": {},
// "actions": [],
// "access_api_key": "API_KEY"
// }
// }
type EnrollResponse struct {
Action string `json:"action"`
Item EnrollItemResponse `json:"item"`
Expand Down
7 changes: 4 additions & 3 deletions internal/pkg/remote/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,10 @@ func newClient(
}

// sortClients sort the clients according to the following priority:
// - never used
// - without errors, last used first when more than one does not have errors
// - last errored.
// - never used
// - without errors, last used first when more than one does not have errors
// - last errored.
//
// It also removes the last error after retryOnBadConnTimeout has elapsed.
func (c *Client) sortClients() {
now := time.Now().UTC()
Expand Down

0 comments on commit 53dcdd0

Please sign in to comment.