Skip to content

Commit ba8e262

Browse files
authored
Merge branch 'main' into dependabot/go_modules/dot-github/workflows/dapr-bot/golang.org/x/crypto-0.35.0
2 parents aa7049e + 6dd4349 commit ba8e262

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1010
-439
lines changed

.github/workflows/test-dapr-bot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: Test
1818
runs-on: ubuntu-latest
1919
env:
20-
GOLANGCILINT_VER: v1.61.0
20+
GOLANGCILINT_VER: v1.64.6
2121

2222
steps:
2323
- name: Checkout

.github/workflows/test-on-push.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Test
1212
runs-on: ubuntu-latest
1313
env:
14-
GOLANGCILINT_VER: v1.61.0
14+
GOLANGCILINT_VER: v1.64.6
1515

1616
steps:
1717
- name: Checkout

.github/workflows/test-tooling.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- "macos-latest"
2626
runs-on: ${{ matrix.os }}
2727
env:
28-
GOLANGCILINT_VER: v1.61.0 # Make sure to bump /tools/check-lint-version/main_test.go
28+
GOLANGCILINT_VER: v1.64.6 # Make sure to bump /tools/check-lint-version/main_test.go
2929

3030
steps:
3131
- name: Checkout

.github/workflows/validate_examples.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ jobs:
3838
CHECKOUT_REF: ${{ github.ref }}
3939
outputs:
4040
DAPR_INSTALL_URL: ${{ env.DAPR_INSTALL_URL }}
41-
DAPR_CLI_VER: ${{ steps.outputs.outputs.DAPR_CLI_VER }}
41+
DAPR_CLI_VER: 1.16.0-rc.1
4242
DAPR_CLI_REF: ${{ steps.outputs.outputs.DAPR_CLI_REF }}
43-
DAPR_RUNTIME_VER: ${{ steps.outputs.outputs.DAPR_RUNTIME_VER }}
43+
DAPR_RUNTIME_VER: 1.16.0-rc.3
4444
CHECKOUT_REPO: ${{ steps.outputs.outputs.CHECKOUT_REPO }}
4545
CHECKOUT_REF: ${{ steps.outputs.outputs.CHECKOUT_REF }}
4646
DAPR_REF: ${{ steps.outputs.outputs.DAPR_REF }}
@@ -166,7 +166,7 @@ jobs:
166166
"configuration",
167167
"conversation",
168168
"crypto",
169-
"dist-scheduler",
169+
"jobs",
170170
"grpc-service",
171171
"hello-world",
172172
"pubsub",
@@ -175,6 +175,7 @@ jobs:
175175
"socket",
176176
"workflow",
177177
"workflow-parallel",
178+
"workflow-taskexecutionid"
178179
]
179180
steps:
180181
- name: Check out code onto GOPATH

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ linters:
234234
- lll
235235
- unparam
236236
- wsl
237-
- gomnd
238237
- testpackage
239238
- nestif
240239
- nlreturn
@@ -271,8 +270,6 @@ linters:
271270
- tagalign
272271
- mnd
273272
- canonicalheader
274-
- exportloopref
275-
- execinquery
276273
- err113
277274
- fatcontext
278275
- forbidigo # TODO: Re-enable and remove fmt.println

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ cover: ## Displays test coverage in the client and service packages
3333
lint: check-lint ## Lints the entire project
3434
golangci-lint run --timeout=3m
3535

36+
.PHONY: lint-fix
37+
lint-fix: check-lint ## Lints the entire project
38+
golangci-lint run --timeout=3m --fix
39+
3640
.PHONY: check-lint
3741
check-lint: ## Compares the locally installed linter with the workflow version
3842
cd ./tools/check-lint-version && \

actor/runtime/actor_runtime_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func TestRegisterActorFactoryAndInvokeMethod(t *testing.T) {
4848
mockServer.EXPECT().RegisterActorImplFactory(gomock.Any())
4949
rt.RegisterActorFactory(actorMock.ActorImplFactory)
5050

51+
//nolint:usetesting
5152
mockServer.EXPECT().InvokeMethod(context.Background(), "mockActorID", "Invoke", []byte("param")).Return([]byte("response"), actorErr.Success)
5253
rspData, err := rt.InvokeActorMethod("testActorType", "mockActorID", "Invoke", []byte("param"))
5354

@@ -89,6 +90,7 @@ func TestInvokeReminder(t *testing.T) {
8990
mockServer.EXPECT().RegisterActorImplFactory(gomock.Any())
9091
rt.RegisterActorFactory(actorMock.ActorImplFactory)
9192

93+
//nolint:usetesting
9294
mockServer.EXPECT().InvokeReminder(context.Background(), "mockActorID", "mockReminder", []byte("param")).Return(actorErr.Success)
9395
err = rt.InvokeReminder("testActorType", "mockActorID", "mockReminder", []byte("param"))
9496

@@ -109,6 +111,7 @@ func TestInvokeTimer(t *testing.T) {
109111
mockServer.EXPECT().RegisterActorImplFactory(gomock.Any())
110112
rt.RegisterActorFactory(actorMock.ActorImplFactory)
111113

114+
//nolint:usetesting
112115
mockServer.EXPECT().InvokeTimer(context.Background(), "mockActorID", "mockTimer", []byte("param")).Return(actorErr.Success)
113116
err = rt.InvokeTimer("testActorType", "mockActorID", "mockTimer", []byte("param"))
114117

client/actor_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ limitations under the License.
1414
package client
1515

1616
import (
17-
"context"
1817
"testing"
1918

2019
"github.com/stretchr/testify/require"
@@ -25,7 +24,7 @@ import (
2524
const testActorType = "test"
2625

2726
func TestInvokeActor(t *testing.T) {
28-
ctx := context.Background()
27+
ctx := t.Context()
2928
in := &InvokeActorRequest{
3029
ActorID: "fn",
3130
Method: "mockMethod",
@@ -74,7 +73,7 @@ func TestInvokeActor(t *testing.T) {
7473
}
7574

7675
func TestRegisterActorReminder(t *testing.T) {
77-
ctx := context.Background()
76+
ctx := t.Context()
7877
in := &RegisterActorReminderRequest{
7978
ActorID: "fn",
8079
Data: []byte(`{hello}`),
@@ -137,7 +136,7 @@ func TestRegisterActorReminder(t *testing.T) {
137136
}
138137

139138
func TestRegisterActorTimer(t *testing.T) {
140-
ctx := context.Background()
139+
ctx := t.Context()
141140
in := &RegisterActorTimerRequest{
142141
ActorID: "fn",
143142
Data: []byte(`{hello}`),
@@ -215,7 +214,7 @@ func TestRegisterActorTimer(t *testing.T) {
215214
}
216215

217216
func TestUnregisterActorReminder(t *testing.T) {
218-
ctx := context.Background()
217+
ctx := t.Context()
219218
in := &UnregisterActorReminderRequest{
220219
ActorID: "fn",
221220
ActorType: testActorType,
@@ -260,7 +259,7 @@ func TestUnregisterActorReminder(t *testing.T) {
260259
}
261260

262261
func TestUnregisterActorTimer(t *testing.T) {
263-
ctx := context.Background()
262+
ctx := t.Context()
264263
in := &UnregisterActorTimerRequest{
265264
ActorID: "fn",
266265
ActorType: testActorType,

client/binding_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ limitations under the License.
1414
package client
1515

1616
import (
17-
"context"
1817
"testing"
1918

2019
"github.com/stretchr/testify/require"
@@ -25,7 +24,7 @@ import (
2524
// go test -timeout 30s ./client -count 1 -run ^TestInvokeBinding$
2625

2726
func TestInvokeBinding(t *testing.T) {
28-
ctx := context.Background()
27+
ctx := t.Context()
2928
in := &InvokeBindingRequest{
3029
Name: "test",
3130
Operation: "fn",

client/client.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func NewClientWithAddressContext(ctx context.Context, address string) (client Cl
355355
return nil, fmt.Errorf("error parsing address '%s': %w", address, err)
356356
}
357357

358-
at := &authToken{}
358+
at := newAuthToken()
359359

360360
opts := []grpc.DialOption{
361361
grpc.WithUserAgent(userAgent()),
@@ -404,7 +404,7 @@ func NewClientWithSocket(socket string) (client Client, err error) {
404404
if socket == "" {
405405
return nil, errors.New("nil socket")
406406
}
407-
at := &authToken{}
407+
at := newAuthToken()
408408
logger.Printf("dapr client initializing for: %s", socket)
409409
addr := "unix://" + socket
410410
conn, err := grpc.Dial( //nolint:staticcheck
@@ -421,11 +421,6 @@ func NewClientWithSocket(socket string) (client Client, err error) {
421421
}
422422

423423
func newClientWithConnection(conn *grpc.ClientConn, authToken *authToken) Client {
424-
apiToken := os.Getenv(apiTokenEnvVarName)
425-
if apiToken != "" {
426-
logger.Println("client uses API token")
427-
authToken.set(apiToken)
428-
}
429424
return &GRPCClient{
430425
connection: conn,
431426
protoClient: pb.NewDaprClient(conn),
@@ -435,14 +430,26 @@ func newClientWithConnection(conn *grpc.ClientConn, authToken *authToken) Client
435430

436431
// NewClientWithConnection instantiates Dapr client using specific connection.
437432
func NewClientWithConnection(conn *grpc.ClientConn) Client {
438-
return newClientWithConnection(conn, &authToken{})
433+
return newClientWithConnection(conn, newAuthToken())
439434
}
440435

436+
// NOTE: authToken must be created using newAuthToken()
437+
// it is crucial to correctly initialize the dapr client with the API token from the environment variable
441438
type authToken struct {
442439
mu sync.RWMutex
443440
authToken string
444441
}
445442

443+
func newAuthToken() *authToken {
444+
apiToken := os.Getenv(apiTokenEnvVarName)
445+
if apiToken != "" {
446+
logger.Println("API Token loaded from the environment variable")
447+
}
448+
return &authToken{
449+
authToken: apiToken,
450+
}
451+
}
452+
446453
func (a *authToken) get() string {
447454
a.mu.RLock()
448455
defer a.mu.RUnlock()

0 commit comments

Comments
 (0)