Skip to content

Commit 6ab12cc

Browse files
authored
gofmt (#2136)
1 parent 75225de commit 6ab12cc

22 files changed

+305
-308
lines changed

tavern/app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,10 @@ func NewServer(ctx context.Context, options ...func(*Config)) (*Server, error) {
337337
AllowUnactivated: true,
338338
},
339339
"/auth/rda/approve": tavernhttp.Endpoint{
340-
Handler: tavernhttp.NewRDAApproveHandler(client),
340+
Handler: tavernhttp.NewRDAApproveHandler(client),
341341
},
342342
"/auth/rda/revoke": tavernhttp.Endpoint{
343-
Handler: tavernhttp.NewRDARevokeHandler(client),
343+
Handler: tavernhttp.NewRDARevokeHandler(client),
344344
},
345345
"/api/auth/signout": tavernhttp.Endpoint{
346346
Handler: tavernhttp.NewSignoutHandler(),

tavern/cli/auth/options.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package auth
22

3-
4-
53
type AuthOptions struct {
64
EnvAPIKeyName string
75
CachePath string

tavern/internal/builder/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
// Keys ending in "-bin" use gRPC binary metadata encoding.
2323
mdKeyBuilderCert = "builder-cert-bin"
2424
mdKeyBuilderSignature = "builder-signature-bin"
25-
mdKeyBuilderTimestamp = "builder-timestamp"
25+
mdKeyBuilderTimestamp = "builder-timestamp"
2626

2727
// Maximum age for a timestamp to be considered valid.
2828
maxTimestampAge = 5 * time.Minute

tavern/internal/builder/build_config.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const (
2121

2222
// DefaultTransports is the default transport configuration for a build task.
2323
var DefaultTransports = []builderpb.BuildProfileTransport{{
24-
URI: "http://127.0.0.1:8000",
25-
Interval: 5,
26-
Type: c2pb.Transport_TRANSPORT_GRPC,
24+
URI: "http://127.0.0.1:8000",
25+
Interval: 5,
26+
Type: c2pb.Transport_TRANSPORT_GRPC,
2727
}}
2828

2929
// TargetFormat is an alias for builderpb.TargetFormat.
@@ -50,11 +50,11 @@ type buildKey struct {
5050

5151
// buildCommands maps (target_os, target_format) -> cargo build command.
5252
var buildCommands = map[buildKey]string{
53-
{c2pb.Host_PLATFORM_LINUX, builderpb.TargetFormat_TARGET_FORMAT_BIN}: "cargo build --release --bin imix --target=x86_64-unknown-linux-musl",
54-
{c2pb.Host_PLATFORM_MACOS, builderpb.TargetFormat_TARGET_FORMAT_BIN}: "cargo zigbuild --release --target aarch64-apple-darwin",
55-
{c2pb.Host_PLATFORM_WINDOWS, builderpb.TargetFormat_TARGET_FORMAT_BIN}: "cargo build --release --target=x86_64-pc-windows-gnu",
53+
{c2pb.Host_PLATFORM_LINUX, builderpb.TargetFormat_TARGET_FORMAT_BIN}: "cargo build --release --bin imix --target=x86_64-unknown-linux-musl",
54+
{c2pb.Host_PLATFORM_MACOS, builderpb.TargetFormat_TARGET_FORMAT_BIN}: "cargo zigbuild --release --target aarch64-apple-darwin",
55+
{c2pb.Host_PLATFORM_WINDOWS, builderpb.TargetFormat_TARGET_FORMAT_BIN}: "cargo build --release --target=x86_64-pc-windows-gnu",
5656
{c2pb.Host_PLATFORM_WINDOWS, builderpb.TargetFormat_TARGET_FORMAT_WINDOWS_SERVICE}: "cargo build --release --features win_service --target=x86_64-pc-windows-gnu",
57-
{c2pb.Host_PLATFORM_WINDOWS, builderpb.TargetFormat_TARGET_FORMAT_CDYLIB}: "cargo build --release --lib --target=x86_64-pc-windows-gnu",
57+
{c2pb.Host_PLATFORM_WINDOWS, builderpb.TargetFormat_TARGET_FORMAT_CDYLIB}: "cargo build --release --lib --target=x86_64-pc-windows-gnu",
5858
}
5959

6060
// ValidateTargetFormat checks whether the given format is supported for the given OS.
@@ -101,10 +101,10 @@ func TransportTypeToString(t c2pb.Transport_Type) string {
101101

102102
// ImixTransportConfig represents the transport section of the IMIX configuration.
103103
type ImixTransportConfig struct {
104-
URI string `yaml:"URI"`
105-
Interval int `yaml:"interval"`
106-
Type string `yaml:"type"`
107-
Extra string `yaml:"extra"`
104+
URI string `yaml:"URI"`
105+
Interval int `yaml:"interval"`
106+
Type string `yaml:"type"`
107+
Extra string `yaml:"extra"`
108108
}
109109

110110
// ImixConfig represents the IMIX agent configuration YAML.

tavern/internal/builder/builderpb/enum_build_profile_transport.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import "realm.pub/tavern/internal/c2/c2pb"
44

55
// BuildProfileTransport represents a single transport configuration stored in the BuildTask entity.
66
type BuildProfileTransport struct {
7-
URI string `json:"uri"`
8-
Interval int `json:"interval"`
9-
Type c2pb.Transport_Type `json:"type"`
10-
Extra string `json:"extra,omitempty"`
7+
URI string `json:"uri"`
8+
Interval int `json:"interval"`
9+
Type c2pb.Transport_Type `json:"type"`
10+
Extra string `json:"extra,omitempty"`
1111
}

tavern/internal/builder/client.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const (
3030
maxConcurrentBuilds = 4
3131

3232
maxOutputChSize = 64
33-
maxErrorChSize = 64
33+
maxErrorChSize = 64
3434
)
3535

3636
// builderCredentials implements grpc.PerRPCCredentials for mTLS authentication.
@@ -285,16 +285,16 @@ func executeTask(ctx context.Context, client builderpb.BuilderClient, exec execu
285285
// Run the build through the executor.
286286
// The executor closes both channels when done.
287287
result, buildErr := exec.Build(ctx, executor.BuildSpec{
288-
TaskID: task.Id,
289-
TargetOS: task.TargetOs,
290-
BuildImage: task.BuildImage,
291-
BuildScript: task.BuildScript,
292-
ArtifactPath: task.ArtifactPath,
293-
Env: task.Env,
294-
SetupScript: task.SetupScript,
288+
TaskID: task.Id,
289+
TargetOS: task.TargetOs,
290+
BuildImage: task.BuildImage,
291+
BuildScript: task.BuildScript,
292+
ArtifactPath: task.ArtifactPath,
293+
Env: task.Env,
294+
SetupScript: task.SetupScript,
295295
PreBuildScript: task.PreBuildScript,
296296
PostBuildScript: task.PostBuildScript,
297-
Tomes: tomes,
297+
Tomes: tomes,
298298
}, outputCh, errorCh)
299299

300300
// Wait for the collector goroutine to drain remaining channel data.

tavern/internal/builder/executor/docker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func prepareMountDir(spec BuildSpec) (string, error) {
276276
return tmpDir, fmt.Errorf("writing setup script: %w", err)
277277
}
278278
}
279-
279+
280280
// Write pre-build script.
281281
if spec.PreBuildScript != "" {
282282
if err := os.WriteFile(filepath.Join(scriptsDir, "1_pre_build.sh"), []byte(spec.PreBuildScript), 0o755); err != nil {

tavern/internal/builder/integration_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ func TestBuilderE2E(t *testing.T) {
176176
SetBuildImage("golang:1.21").
177177
SetDescription("An explicit profile").
178178
SetTransports([]builderpb.BuildProfileTransport{{
179-
URI: "https://callback.example.com",
180-
Interval: 10,
181-
Type: c2pb.Transport_TRANSPORT_GRPC,
179+
URI: "https://callback.example.com",
180+
Interval: 10,
181+
Type: c2pb.Transport_TRANSPORT_GRPC,
182182
}}).
183183
SaveX(ctx)
184184

tavern/internal/builder/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (s *Server) ClaimBuildTasks(ctx context.Context, req *builderpb.ClaimBuildT
108108

109109
// Derive the IMIX config YAML from the build task's stored transports.
110110
profile, err := claimedTask.Profile(ctx)
111-
if err != nil || profile == nil{
111+
if err != nil || profile == nil {
112112
return nil, status.Errorf(codes.Internal, "failed to load build profile task %d: %v", taskID, err)
113113
}
114114
transports := profile.Transports

tavern/internal/c2/api_fetch_asset_test.go

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package c2_test
33
import (
44
"bytes"
55
"context"
6+
"crypto/rand"
67
"errors"
78
"fmt"
89
"io"
910
"testing"
10-
"crypto/rand"
1111

1212
_ "github.com/mattn/go-sqlite3"
1313
"github.com/stretchr/testify/assert"
@@ -16,14 +16,14 @@ import (
1616
"google.golang.org/grpc/status"
1717
"realm.pub/tavern/internal/c2/c2pb"
1818
"realm.pub/tavern/internal/c2/c2test"
19-
"realm.pub/tavern/internal/ent"
19+
"realm.pub/tavern/internal/ent"
2020
)
2121

2222
func TestFetchAsset(t *testing.T) {
2323
// Setup Dependencies
2424
client, graph, close, token := c2test.New(t)
2525
defer close()
26-
ctx := context.Background()
26+
ctx := context.Background()
2727

2828
// Test Cases
2929
type testCase struct {
@@ -59,31 +59,31 @@ func TestFetchAsset(t *testing.T) {
5959

6060
testHandler := func(t *testing.T, tc testCase) {
6161
// Create Asset
62-
var a *ent.Asset
63-
if tc.fileSize > 0 {
64-
// Generate Random Content
65-
data := make([]byte, tc.fileSize)
66-
_, err := rand.Read(data)
67-
require.NoError(t, err)
62+
var a *ent.Asset
63+
if tc.fileSize > 0 {
64+
// Generate Random Content
65+
data := make([]byte, tc.fileSize)
66+
_, err := rand.Read(data)
67+
require.NoError(t, err)
6868

69-
a = graph.Asset.Create().
70-
SetName(tc.fileName).
71-
SetContent(data).
72-
SaveX(ctx)
73-
}
69+
a = graph.Asset.Create().
70+
SetName(tc.fileName).
71+
SetContent(data).
72+
SaveX(ctx)
73+
}
7474

7575
// Ensure request contains JWT
7676
if tc.req.Context == nil {
7777
tc.req.Context = &c2pb.FetchAssetRequest_TaskContext{
7878
TaskContext: &c2pb.TaskContext{Jwt: token},
7979
}
8080
} else {
81-
switch c := tc.req.Context.(type) {
82-
case *c2pb.FetchAssetRequest_TaskContext:
83-
c.TaskContext.Jwt = token
84-
case *c2pb.FetchAssetRequest_ShellTaskContext:
85-
c.ShellTaskContext.Jwt = token
86-
}
81+
switch c := tc.req.Context.(type) {
82+
case *c2pb.FetchAssetRequest_TaskContext:
83+
c.TaskContext.Jwt = token
84+
case *c2pb.FetchAssetRequest_ShellTaskContext:
85+
c.ShellTaskContext.Jwt = token
86+
}
8787
}
8888

8989
// Send Request
@@ -99,36 +99,36 @@ func TestFetchAsset(t *testing.T) {
9999
break
100100
}
101101

102-
if err != nil {
103-
st, ok := status.FromError(err)
104-
require.True(t, ok)
105-
// Check Status
106-
require.Equal(t, tc.wantCode.String(), st.Code().String())
107-
if st.Code() != codes.OK {
108-
// Do not continue if we expected error code
109-
return
110-
}
111-
}
102+
if err != nil {
103+
st, ok := status.FromError(err)
104+
require.True(t, ok)
105+
// Check Status
106+
require.Equal(t, tc.wantCode.String(), st.Code().String())
107+
if st.Code() != codes.OK {
108+
// Do not continue if we expected error code
109+
return
110+
}
111+
}
112112

113113
// Write Chunk
114114
if resp != nil {
115-
_, err = buf.Write(resp.Chunk)
116-
require.NoError(t, err)
117-
}
115+
_, err = buf.Write(resp.Chunk)
116+
require.NoError(t, err)
117+
}
118118
}
119119

120120
// Assert Content
121-
if a != nil {
122-
assert.Equal(t, a.Content, buf.Bytes())
121+
if a != nil {
122+
assert.Equal(t, a.Content, buf.Bytes())
123123

124-
// Assert Headers
125-
metadata, err := stream.Header()
126-
require.NoError(t, err)
127-
require.Len(t, metadata.Get("sha3-256-checksum"), 1)
128-
assert.Equal(t, a.Hash, metadata.Get("sha3-256-checksum")[0])
129-
require.Len(t, metadata.Get("file-size"), 1)
130-
assert.Equal(t, fmt.Sprintf("%d", a.Size), metadata.Get("file-size")[0])
131-
}
124+
// Assert Headers
125+
metadata, err := stream.Header()
126+
require.NoError(t, err)
127+
require.Len(t, metadata.Get("sha3-256-checksum"), 1)
128+
assert.Equal(t, a.Hash, metadata.Get("sha3-256-checksum")[0])
129+
require.Len(t, metadata.Get("file-size"), 1)
130+
assert.Equal(t, fmt.Sprintf("%d", a.Size), metadata.Get("file-size")[0])
131+
}
132132
}
133133

134134
// Run Tests

0 commit comments

Comments
 (0)