Skip to content

Commit dbde71a

Browse files
authored
refactor(acl): migrate to shared ACL client and add GetObject handler (#322)
**Because** - The ACL client implementation was duplicated across multiple backend services - OpenFGA cache configuration needs to be explicit for consistent behavior - The `GetObject` API endpoint was missing from the handler - Resource ID generation utilities were duplicated and should use the shared library - Pipeline release operations needed to handle OUTPUT_ONLY slug field correctly **This commit** - Refactors `pkg/acl/acl.go` to use the shared ACL client from `github.com/instill-ai/x/acl`, reducing ~350 lines of duplicate OpenFGA client logic - Adds OpenFGA cache configuration in `config/config.yaml` with `enabled: false` and `ttl: 60` - Adds cache configuration struct to `config/config.go` to support the new OpenFGA cache settings - Implements `GetObject` handler in `pkg/handler/object.go` for retrieving object details by AIP-compliant name - Adds `GetObjectByID` method to `pkg/service/object.go` for service-layer object lookup - Refactors `pkg/utils/utils.go` to use shared `resource.GenerateResourceID` from x package instead of duplicated base62 encoding logic - Updates `pkg/pipeline/release.go` to handle OUTPUT_ONLY `Slug` field: - Removes setting `Slug` on Pipeline creation (server-generated from DisplayName) - Lists releases to find existing by slug instead of direct ID lookup - Adds `DisplayName` field to PipelineRelease - Updates various handlers and workers to align with refactored ACL client interface - Updates dependencies: - `protogen-go`: updated to latest alpha with flattened packages - `x`: updated to latest with shared ACL client and resource utilities
1 parent 487d4f7 commit dbde71a

File tree

26 files changed

+313
-567
lines changed

26 files changed

+313
-567
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
go-version: ${{ env.GOLANG_VERSION }}
2323
cache: false
2424
- name: golangci-lint
25-
uses: golangci/golangci-lint-action@v8
25+
uses: golangci/golangci-lint-action@v9
2626
with:
2727
version: v2.8.0
2828
args: --timeout=10m

config/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ type OpenFGAConfig struct {
5454
Port int `koanf:"port"`
5555
ReplicationTimeFrame int `koanf:"replicationtimeframe"` // in seconds
5656
} `koanf:"replica"`
57+
Cache struct {
58+
Enabled bool `koanf:"enabled"` // Enable permission caching
59+
TTL int `koanf:"ttl"` // Cache TTL in seconds (default: 60)
60+
} `koanf:"cache"`
5761
}
5862

5963
// ServerConfig defines HTTP server configurations

config/config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ registry:
8080
openfga:
8181
host: openfga
8282
port: 8081
83+
cache:
84+
enabled: false
85+
ttl: 60 # Permission cache TTL in seconds
8386
minio:
8487
host: minio
8588
port: 9000

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ require (
1313
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
1414
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1
1515
github.com/iancoleman/strcase v0.3.0
16-
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20260118041154-8f06ba4d527d
17-
github.com/instill-ai/x v0.10.1-alpha.0.20260118004501-5221537d0a1d
16+
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20260122065215-c32ea2feec1f
17+
github.com/instill-ai/x v0.10.1-alpha.0.20260122090555-bea4f728b22c
1818
github.com/knadh/koanf v1.5.0
1919
github.com/mennanov/fieldmask-utils v1.1.2
2020
github.com/milvus-io/milvus/client/v2 v2.6.1

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,10 @@ github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSAS
419419
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
420420
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
421421
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
422-
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20260118041154-8f06ba4d527d h1:nQTNxSL0sakFtObb6tnZqXcB/LF1dqGFoaRfX5ywDfA=
423-
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20260118041154-8f06ba4d527d/go.mod h1:bCnBosofpaUxKBuTTJM3/I3thAK37kvfBnKByjnLsl4=
424-
github.com/instill-ai/x v0.10.1-alpha.0.20260118004501-5221537d0a1d h1:YUOzft7m56Jj+FUohdmn36d8gFnDcDo/tO2ij1zrzhw=
425-
github.com/instill-ai/x v0.10.1-alpha.0.20260118004501-5221537d0a1d/go.mod h1:NZwVnFLteR6JvV35pCYOOO75YMzTABefbrBC6YWDF/E=
422+
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20260122065215-c32ea2feec1f h1:Ypnhf9ywdC2z8YLtSZytFZJjlDYH7sNDpfNv1Ul8Zpw=
423+
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20260122065215-c32ea2feec1f/go.mod h1:bCnBosofpaUxKBuTTJM3/I3thAK37kvfBnKByjnLsl4=
424+
github.com/instill-ai/x v0.10.1-alpha.0.20260122090555-bea4f728b22c h1:9Z3NbM6Elzh1zlOGc7PKNP52vQPuM3pwxuj2Zsoh+aE=
425+
github.com/instill-ai/x v0.10.1-alpha.0.20260122090555-bea4f728b22c/go.mod h1:/xG0LMh43kyyK9jXGtV/JGd5p9GVcreSZ6GRGVbALEU=
426426
github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI=
427427
github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0=
428428
github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk=

0 commit comments

Comments
 (0)