Skip to content

Commit

Permalink
[Release 1.14] Cherry Pick of 3470 - Azure Auth for all Redis Compone…
Browse files Browse the repository at this point in the history
…nts (#3471)

Signed-off-by: Bernd Verst <github@bernd.dev>
  • Loading branch information
berndverst authored Jul 2, 2024
1 parent 128691d commit 273bea1
Show file tree
Hide file tree
Showing 25 changed files with 273 additions and 66 deletions.
4 changes: 1 addition & 3 deletions .build-tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/dapr/components-contrib/build-tools

go 1.22.0

toolchain go1.22.2
go 1.22.4

require (
github.com/dapr/components-contrib v0.0.0
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/components-contrib-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
GOOS: ${{ matrix.target_os }}
GOARCH: ${{ matrix.target_arch }}
GOPROXY: https://proxy.golang.org
GOLANGCI_LINT_VER: "v1.55.2"
GOLANGCI_LINT_VER: "v1.59.1"
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
Expand Down Expand Up @@ -143,10 +143,11 @@ jobs:
run: make check-component-metadata-schema-diff
- name: Run golangci-lint
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux' && steps.skip_check.outputs.should_skip != 'true'
uses: golangci/golangci-lint-action@v3.2.0
uses: golangci/golangci-lint-action@v6.0.1
with:
version: ${{ env.GOLANGCI_LINT_VER }}
skip-cache: true
only-new-issues: true
args: --timeout 15m
- name: Run go mod tidy check diff
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux' && steps.skip_check.outputs.should_skip != 'true'
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/components-contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
GOOS: linux
GOARCH: amd64
GOPROXY: https://proxy.golang.org
GOLANGCI_LINT_VER: "v1.55.2"
GOLANGCI_LINT_VER: "v1.59.1"
steps:
- name: Check out code into the Go module directory
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
Expand Down Expand Up @@ -62,10 +62,11 @@ jobs:
run: make check-component-metadata
- name: Run golangci-lint
if: steps.skip_check.outputs.should_skip != 'true'
uses: golangci/golangci-lint-action@v3.4.0
uses: golangci/golangci-lint-action@v6.0.1
with:
version: ${{ env.GOLANGCI_LINT_VER }}
skip-cache: true
only-new-issues: true
args: --timeout 15m
- name: Run go mod tidy check diff
if: steps.skip_check.outputs.should_skip != 'true'
Expand Down
28 changes: 9 additions & 19 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ run:
# default value is empty list, but next dirs are always skipped independently
# from this option's value:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs:
issues.exclude-dirs:
- ^vendor$

# which files to skip: they will be analyzed, but issues from them
Expand All @@ -37,7 +37,7 @@ run:
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
format: tab
formats: tab

# print lines of code with issue, default is true
print-issued-lines: true
Expand Down Expand Up @@ -71,9 +71,6 @@ linters-settings:
statements: 40

govet:
# report about shadowed variables
check-shadowing: true

# settings per analyzer
settings:
printf: # analyzer name, run `go tool vet help` to see all analyzers
Expand All @@ -86,6 +83,7 @@ linters-settings:
# enable or disable analyzers by name
enable:
- atomicalign
- shadow
enable-all: false
disable:
- shadow
Expand All @@ -106,9 +104,6 @@ linters-settings:
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
dupl:
# tokens count to trigger issue, 150 by default
threshold: 100
Expand All @@ -121,6 +116,10 @@ linters-settings:
rules:
main:
deny:
- pkg: "github.com/golang-jwt/jwt/v5"
desc: "must use github.com/lestrrat-go/jwx/v2/jwt"
- pkg: "github.com/golang-jwt/jwt/v4"
desc: "must use github.com/lestrrat-go/jwx/v2/jwt"
- pkg: "github.com/Sirupsen/logrus"
desc: "must use github.com/dapr/kit/logger"
- pkg: "github.com/agrea/ptr"
Expand Down Expand Up @@ -277,28 +276,24 @@ linters:
- gocyclo
- gocognit
- godox
- interfacer
- lll
- maligned
- scopelint
- unparam
- wsl
- mnd
- gomnd
- testpackage
- goerr113
- err113
- nestif
- nlreturn
- exhaustive
- exhaustruct
- noctx
- gci
- golint
- tparallel
- paralleltest
- wrapcheck
- tagliatelle
- ireturn
- exhaustivestruct
- errchkjson
- contextcheck
- gomoddirectives
Expand All @@ -307,7 +302,6 @@ linters:
- varnamelen
- errorlint
- forcetypeassert
- ifshort
- maintidx
- nilnil
- predeclared
Expand All @@ -320,10 +314,6 @@ linters:
- asasalint
- rowserrcheck
- sqlclosecheck
- structcheck
- deadcode
- nosnakecase
- varcheck
- goconst
- tagalign
- inamedparam
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export GH_LINT_VERSION := $(shell grep 'GOLANGCI_LINT_VER:' .github/workflows/co
ifeq (,$(LINTER_BINARY))
INSTALLED_LINT_VERSION := "v0.0.0"
else
INSTALLED_LINT_VERSION=v$(shell $(LINTER_BINARY) version | grep -Eo '([0-9]+\.)+[0-9]+' - || "")
INSTALLED_LINT_VERSION=v$(shell $(LINTER_BINARY) version | grep -Eo '([0-9]+\.)+[0-9]+' - | head -1 || "")
endif

# Build tools
Expand Down Expand Up @@ -249,4 +249,4 @@ prettier-format:
################################################################################
.PHONY: conf-tests
conf-tests:
CGO_ENABLED=$(CGO) go test -v -tags=conftests -count=1 ./tests/conformance
CGO_ENABLED=$(CGO) go test -v -tags=conftests -count=1 ./tests/conformance
15 changes: 15 additions & 0 deletions bindings/redis/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,18 @@ metadata:
"-1" disables idle timeout check.
default: "5m"
example: "10m"
builtinAuthenticationProfiles:
- name: "azuread"
metadata:
- name: useEntraID
required: false
default: "false"
example: "true"
type: bool
description: |
If set, enables authentication to Azure Cache for Redis using Microsoft EntraID. The Redis server must explicitly enable EntraID authentication. Note that
Azure Cache for Redis also requires the use of TLS, so `enableTLS` should be set. No username or password should be set.
- name: enableTLS
required: true
description: Must be set to true if using EntraID
example: "true"
2 changes: 1 addition & 1 deletion bindings/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewRedis(logger logger.Logger) bindings.OutputBinding {

// Init performs metadata parsing and connection creation.
func (r *Redis) Init(ctx context.Context, meta bindings.Metadata) (err error) {
r.client, r.clientSettings, err = rediscomponent.ParseClientFromProperties(meta.Properties, metadata.BindingType)
r.client, r.clientSettings, err = rediscomponent.ParseClientFromProperties(meta.Properties, metadata.BindingType, ctx, &r.logger)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/redis/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestInvokeDelete(t *testing.T) {

rgetRep, err := c.DoRead(context.Background(), "GET", testKey)
assert.Equal(t, redis.Nil, err)
assert.Equal(t, nil, rgetRep)
assert.Nil(t, rgetRep)
}

func TestCreateExpire(t *testing.T) {
Expand Down
Loading

0 comments on commit 273bea1

Please sign in to comment.