Skip to content

Commit a871031

Browse files
committed
first iteration
1 parent 6c1155f commit a871031

34 files changed

Lines changed: 977 additions & 400 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.iml
22
.idea
3-
/cac
3+
/cac
4+
/examples/e2e-local/

cmd/pull.go

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package cmd
22

33
import (
4-
"github.com/cloudentity/acp-client-go/clients/hub/models"
4+
"os"
5+
56
"github.com/cloudentity/cac/internal/cac"
67
"github.com/cloudentity/cac/internal/cac/api"
8+
"github.com/cloudentity/cac/internal/cac/utils"
9+
"github.com/pkg/errors"
710
"github.com/spf13/cobra"
811
"golang.org/x/exp/slog"
912
)
@@ -15,7 +18,7 @@ var (
1518
RunE: func(cmd *cobra.Command, args []string) error {
1619
var (
1720
app *cac.Application
18-
data models.Rfc7396PatchOperation
21+
data api.PatchInterface
1922
err error
2023
)
2124

@@ -39,20 +42,43 @@ var (
3942
return err
4043
}
4144

42-
if err = app.Storage.Write(cmd.Context(), data, api.WithWorkspace(rootConfig.Workspace)); err != nil {
43-
return err
45+
if pullConfig.Out == "" {
46+
// default
47+
if err = app.Storage.Write(cmd.Context(), data, api.WithWorkspace(rootConfig.Workspace), api.WithSecrets(pullConfig.WithSecrets)); err != nil {
48+
return err
49+
}
50+
} else {
51+
bts, err := utils.ToYaml(data)
52+
53+
if err != nil {
54+
return errors.Wrap(err, "failed to marshal data to YAML")
55+
}
56+
57+
if pullConfig.Out == "-" {
58+
if _, err = os.Stdout.Write(bts); err != nil {
59+
return errors.Wrap(err, "failed to write diff result to stdout")
60+
}
61+
}
62+
63+
if err = os.WriteFile(pullConfig.Out, bts, 0644); err != nil {
64+
return errors.Wrap(err, "failed to write diff result to file")
65+
}
4466
}
4567

68+
slog.Info("Configuration pulled", "out", pullConfig.Out)
69+
4670
return nil
4771
},
4872
}
4973
pullConfig struct {
5074
WithSecrets bool
5175
Filters []string
76+
Out string
5277
}
5378
)
5479

5580
func init() {
5681
pullCmd.PersistentFlags().BoolVar(&pullConfig.WithSecrets, "with-secrets", false, "Pull secrets")
5782
pullCmd.PersistentFlags().StringSliceVar(&pullConfig.Filters, "filter", []string{}, "Pull only selected resources")
83+
pullCmd.PersistentFlags().StringVar(&pullConfig.Out, "out", "", "Pull output. It can be a file or '-' for stdout")
5884
}

cmd/push.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cmd
22

33
import (
4-
"github.com/cloudentity/acp-client-go/clients/hub/models"
54
"github.com/cloudentity/cac/internal/cac"
65
"github.com/cloudentity/cac/internal/cac/api"
76
"github.com/cloudentity/cac/internal/cac/storage"
@@ -17,7 +16,7 @@ var (
1716
RunE: func(cmd *cobra.Command, args []string) error {
1817
var (
1918
app *cac.Application
20-
data models.Rfc7396PatchOperation
19+
data api.PatchInterface
2120
err error
2221
)
2322

@@ -34,7 +33,7 @@ var (
3433
}
3534

3635
if !pushConfig.NoLocalValidate {
37-
if err = app.Validator.Validate(&data); err != nil {
36+
if err = app.Validator.Validate(data); err != nil {
3837
return errors.Wrap(err, "failed to validate configuration")
3938
}
4039
}

go.mod

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module github.com/cloudentity/cac
22

3-
go 1.22
3+
go 1.23.0
44

5-
toolchain go1.22.0
5+
toolchain go1.24.3
66

77
require (
88
github.com/Masterminds/sprig/v3 v3.2.3
9-
github.com/cloudentity/acp-client-go v0.0.0-20241209151610-14608290c460
9+
github.com/cloudentity/acp-client-go v0.0.0-20250530113034-a2fab50491c3
1010
github.com/corvus-ch/zbase32 v1.0.0
1111
github.com/go-json-experiment/json v0.0.0-20240524174822-2d9f40f7385b
1212
github.com/go-openapi/strfmt v0.22.0
@@ -17,7 +17,7 @@ require (
1717
github.com/pkg/errors v0.9.1
1818
github.com/spf13/cobra v1.8.0
1919
github.com/spf13/viper v1.18.2
20-
github.com/stretchr/testify v1.8.4
20+
github.com/stretchr/testify v1.10.0
2121
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
2222
)
2323

@@ -28,6 +28,7 @@ require (
2828
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2929
github.com/fatih/color v1.14.1 // indirect
3030
github.com/fsnotify/fsnotify v1.7.0 // indirect
31+
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
3132
github.com/go-logr/logr v1.4.1 // indirect
3233
github.com/go-logr/stdr v1.2.2 // indirect
3334
github.com/go-openapi/analysis v0.22.2 // indirect
@@ -69,16 +70,15 @@ require (
6970
go.opentelemetry.io/otel/metric v1.22.0 // indirect
7071
go.opentelemetry.io/otel/trace v1.22.0 // indirect
7172
go.uber.org/multierr v1.11.0 // indirect
72-
golang.org/x/crypto v0.18.0 // indirect
73+
golang.org/x/crypto v0.35.0 // indirect
7374
golang.org/x/oauth2 v0.16.0 // indirect
74-
golang.org/x/sync v0.6.0 // indirect
75-
golang.org/x/sys v0.16.0 // indirect
76-
golang.org/x/text v0.14.0 // indirect
75+
golang.org/x/sync v0.11.0 // indirect
76+
golang.org/x/sys v0.30.0 // indirect
77+
golang.org/x/text v0.22.0 // indirect
7778
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
7879
google.golang.org/appengine v1.6.8 // indirect
7980
google.golang.org/protobuf v1.33.0 // indirect
8081
gopkg.in/corvus-ch/zbase32.v1 v1.0.0 // indirect
8182
gopkg.in/ini.v1 v1.67.0 // indirect
82-
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
8383
gopkg.in/yaml.v3 v3.0.1 // indirect
8484
)

go.sum

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj
77
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
88
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
99
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
10-
github.com/cloudentity/acp-client-go v0.0.0-20241209151610-14608290c460 h1:ViagTxoPaC+H0R1QrjnTlXGuqR9PT4VZAI7o8v3c2KU=
11-
github.com/cloudentity/acp-client-go v0.0.0-20241209151610-14608290c460/go.mod h1:dTHIsfs5YtDOH2CgeoHFlhfnnU1X+ohn+TIU30WlWQQ=
10+
github.com/cloudentity/acp-client-go v0.0.0-20250530113034-a2fab50491c3 h1:uOLP0y8JkhUF5NHFhi9r8BxblcH/Q2Of35y06GpFaFA=
11+
github.com/cloudentity/acp-client-go v0.0.0-20250530113034-a2fab50491c3/go.mod h1:bDN2WQOAcMuBO9eQc1Le3zgyQ0RdsIcwVg3U+lR9Pgg=
1212
github.com/corvus-ch/zbase32 v1.0.0 h1:pDV0qZ1g+HYA8P0PbULsgUg/tZue1FIjsZ7r7h4nZeU=
1313
github.com/corvus-ch/zbase32 v1.0.0/go.mod h1:A7KLRecF1tysURyoqiJBvMJFmt/ccqkRdDTLjlQeVsU=
1414
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
@@ -22,6 +22,8 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk
2222
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
2323
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
2424
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
25+
github.com/go-jose/go-jose/v4 v4.0.5 h1:M6T8+mKZl/+fNNuFHvGIzDz7BTLQPIounk/b9dw3AaE=
26+
github.com/go-jose/go-jose/v4 v4.0.5/go.mod h1:s3P1lRrkT8igV8D9OjyL4WRyHvjB6a4JSllnOrmmBOA=
2527
github.com/go-json-experiment/json v0.0.0-20240524174822-2d9f40f7385b h1:IM96IiRXFcd7l+mU8Sys9pcggoBLbH/dEgzOESrS8F8=
2628
github.com/go-json-experiment/json v0.0.0-20240524174822-2d9f40f7385b/go.mod h1:uDEMZSTQMj7V6Lxdrx4ZwchmHEGdICbjuY+GQd7j9LM=
2729
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
@@ -150,8 +152,9 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
150152
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
151153
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
152154
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
153-
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
154155
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
156+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
157+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
155158
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
156159
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
157160
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
@@ -175,8 +178,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
175178
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
176179
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
177180
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
178-
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
179-
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
181+
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
182+
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
180183
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
181184
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
182185
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
@@ -189,8 +192,8 @@ golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ=
189192
golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o=
190193
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
191194
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
192-
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
193-
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
195+
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
196+
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
194197
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
195198
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
196199
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -200,8 +203,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
200203
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
201204
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
202205
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
203-
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
204-
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
206+
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
207+
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
205208
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
206209
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
207210
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
@@ -212,8 +215,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
212215
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
213216
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
214217
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
215-
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
216-
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
218+
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
219+
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
217220
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
218221
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
219222
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
@@ -234,8 +237,6 @@ gopkg.in/corvus-ch/zbase32.v1 v1.0.0 h1:K4u1NprbDNvKPczKfHLbwdOWHTZ0zfv2ow71H1nR
234237
gopkg.in/corvus-ch/zbase32.v1 v1.0.0/go.mod h1:T3oKkPOm4AV/bNXCNFUxRmlE9RUyBz/DSo0nK9U+c0Y=
235238
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
236239
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
237-
gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI=
238-
gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
239240
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
240241
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
241242
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/cac/api/model.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package api
2+
3+
import (
4+
"github.com/cloudentity/acp-client-go/clients/hub/models"
5+
smodels "github.com/cloudentity/acp-client-go/clients/system/models"
6+
"github.com/imdario/mergo"
7+
)
8+
9+
type ServerExtensions struct {
10+
Secrets map[string]*smodels.Secret `json:"secrets,omitempty"`
11+
}
12+
13+
type TenantExtensions struct {
14+
Servers map[string]ServerExtensions `json:"servers,omitempty"`
15+
}
16+
17+
func (te *TenantExtensions) GetServerExtensions(serverID string) *ServerExtensions {
18+
if te.Servers == nil {
19+
return nil
20+
}
21+
22+
if ext, ok := te.Servers[serverID]; ok {
23+
return &ext
24+
}
25+
26+
return nil
27+
}
28+
29+
type Patch[T any] struct {
30+
Data models.Rfc7396PatchOperation `json:"data,omitempty"`
31+
Ext *T `json:"ext,omitempty"`
32+
}
33+
34+
type PatchInterface interface {
35+
GetData() models.Rfc7396PatchOperation
36+
GetExtensions() any
37+
Merge(other PatchInterface) error
38+
}
39+
40+
type ServerPatch Patch[ServerExtensions]
41+
42+
func (sp *ServerPatch) GetData() models.Rfc7396PatchOperation {
43+
return sp.Data
44+
}
45+
func (tp *ServerPatch) GetExtensions() any {
46+
return tp.Ext
47+
}
48+
func (sp *ServerPatch) Merge(other PatchInterface) error {
49+
if err := mergo.Merge(&sp.Data, other.GetData(), mergo.WithOverride); err != nil {
50+
return err
51+
}
52+
53+
if err := mergo.Merge(sp.Ext, other.GetExtensions(), mergo.WithOverride); err != nil {
54+
return err
55+
}
56+
57+
return nil
58+
}
59+
60+
type TenantPatch Patch[TenantExtensions]
61+
62+
func (tp *TenantPatch) GetData() models.Rfc7396PatchOperation {
63+
return tp.Data
64+
}
65+
func (tp *TenantPatch) GetExtensions() any {
66+
return tp.Ext
67+
}
68+
func (sp *TenantPatch) Merge(other PatchInterface) error {
69+
if err := mergo.Merge(&sp.Data, other.GetData(), mergo.WithOverride); err != nil {
70+
return err
71+
}
72+
73+
if err := mergo.Merge(sp.Ext, other.GetExtensions(), mergo.WithOverride); err != nil {
74+
return err
75+
}
76+
77+
return nil
78+
}

internal/cac/api/source.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package api
33
import (
44
"context"
55
"errors"
6-
"github.com/cloudentity/acp-client-go/clients/hub/models"
76
)
87

98
type SourceType string
@@ -37,17 +36,12 @@ type Options struct {
3736
type SourceOpt func(*Options)
3837

3938
type Source interface {
40-
Read(ctx context.Context, opts ...SourceOpt) (models.Rfc7396PatchOperation, error)
41-
Write(ctx context.Context, data models.Rfc7396PatchOperation, opts ...SourceOpt) error
39+
Read(ctx context.Context, opts ...SourceOpt) (PatchInterface, error)
40+
Write(ctx context.Context, data PatchInterface, opts ...SourceOpt) error
4241

4342
String() string
4443
}
4544

46-
type Mapper[T any] interface {
47-
FromPatchToModel(patch models.Rfc7396PatchOperation) (*T, error)
48-
FromModelToPatch(*T) (models.Rfc7396PatchOperation, error)
49-
}
50-
5145
func WithSecrets(secrets bool) SourceOpt {
5246
return func(o *Options) {
5347
o.Secrets = secrets

internal/cac/app.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
package cac
22

33
import (
4+
"strings"
5+
46
"github.com/cloudentity/cac/internal/cac/api"
57
"github.com/cloudentity/cac/internal/cac/client"
68
"github.com/cloudentity/cac/internal/cac/config"
79
"github.com/cloudentity/cac/internal/cac/data"
810
"github.com/cloudentity/cac/internal/cac/logging"
911
"github.com/cloudentity/cac/internal/cac/storage"
1012
"golang.org/x/exp/slog"
11-
"strings"
1213
)
1314

1415
type Application struct {
15-
Config *config.Configuration
16-
RootConfig *config.RootConfiguration
17-
Client api.Source
18-
Storage storage.Storage
19-
Validator data.ValidatorApi
16+
Config *config.Configuration
17+
RootConfig *config.RootConfiguration
18+
Client api.Source
19+
Storage storage.Storage
20+
Validator data.ValidatorApi
2021
}
2122

2223
func InitApp(configPath string, profile string, tenant bool) (app *Application, err error) {

0 commit comments

Comments
 (0)