Skip to content

Commit

Permalink
Ref: policeable -> authorizable
Browse files Browse the repository at this point in the history
  • Loading branch information
David Arnold committed Nov 26, 2020
1 parent 809d340 commit 6fdbfee
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions cmd/app_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ var appCommandCmd = &cobra.Command{
├── domain.go // generated domain interface
├── identiy.go // generated identity assertion interface
├── distinguishable.go // generated stub of distinguishable interface (edit & implement!)
├── policeable.go // generated stub of policeable interface (edit & implement!)
├── policeable
├── authorizable.go // generated stub of authorizable interface (edit & implement!)
├── authorizable
│ └── actor.go // implement your actor here
├── distinguishable
│ └── target.go // implement your target here
Expand Down
11 changes: 11 additions & 0 deletions internal/test-svc/app/authorizable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package app

// OffersAuthorizable is an actor that can be policed
// application implements OffersAuthorizable and thereby offers policy adapter and external consumers a common language to reason about a authorizable actor
// TODO: implement OffersAuthorizable
type OffersAuthorizable interface {
// TODO: adapt to your needs

User() string
ElevationToken() string
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package policeable
package authorizable

import (
"github.com/xoe-labs/ddd-gen/internal/test-svc/app"
Expand All @@ -19,5 +19,5 @@ func (a *Actor) ElevationToken() string {
}

var (
_ app.OffersPoliceable = (*Actor)(nil)
_ app.OffersAuthorizable = (*Actor)(nil)
)
2 changes: 1 addition & 1 deletion internal/test-svc/app/command/block_account_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/test-svc/app/command/delete_account_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/test-svc/app/command/increase_balance_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/test-svc/app/command/make_new_account_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/test-svc/app/command/validate_holder_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions internal/test-svc/app/policeable.go

This file was deleted.

2 changes: 1 addition & 1 deletion internal/test-svc/app/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import (
// RequiresPolicer knows to make decisions on access policy
// application requires policy adapter to implement this interface.
type RequiresPolicer interface {
Can(ctx context.Context, p OffersPoliceable, action string, a *account.Account) bool
Can(ctx context.Context, p OffersAuthorizable, action string, a *account.Account) bool
}
14 changes: 7 additions & 7 deletions pkg/gen_app/generator/ifaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func GenIfacePolicer(entity QualId, pkgName string) (f *File, typIdent string) {
Id("Can").Params(
Id("ctx").Qual("context", "Context"),
Id("p").Id(
Policeable,
Authorizable,
),
Id("action").Id("string"),
Id(entityShort).Op("*").Qual(entity.Qual, entity.Id),
Expand Down Expand Up @@ -240,13 +240,13 @@ func GenIfaceDistinguishable(pkgName string) (f *File, typIdent string) {
return f, Distinguishable
}

func GenIfacePoliceable(pkgName string) (f *File, typIdent string) {
func GenIfaceAuthorizable(pkgName string) (f *File, typIdent string) {
f = NewFile(pkgName)
f.Commentf("%s is an actor that can be policed", Policeable)
f.Commentf("application implements %s and thereby offers policy adapter and external consumers a common language to reason about a policeable actor", Policeable)
f.Commentf("TODO: implement %s", Policeable)
f.Commentf("%s is an actor that can be policed", Authorizable)
f.Commentf("application implements %s and thereby offers policy adapter and external consumers a common language to reason about a authorizable actor", Authorizable)
f.Commentf("TODO: implement %s", Authorizable)
f.Type().Id(
Policeable,
Authorizable,
).Interface(
Comment("TODO: adapt to your needs"),
Line(),
Expand All @@ -261,5 +261,5 @@ func GenIfacePoliceable(pkgName string) (f *File, typIdent string) {
Id("string"),
),
)
return f, Policeable
return f, Authorizable
}
2 changes: 1 addition & 1 deletion pkg/gen_app/generator/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const (
DistinguishableMethod = "Identifier"
DistinguishableAsserterMethod = "IsDistinguishable"

Policeable = "OffersPoliceable"
Authorizable = "OffersAuthorizable"
Policer = "RequiresPolicer"
PolicerMethod = "Can"

Expand Down
12 changes: 6 additions & 6 deletions pkg/gen_app/ifaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ func generateIfaces(genPath string, useFactStorage bool, objects *generator.Obje
Id: disTyp,
}

// policeable related interfaces
policeableFile := path.Join(genPath, "policeable.go")
if fileExists(policeableFile) {
if err := os.Remove(policeableFile); err != nil {
// authorizable related interfaces
authorizableFile := path.Join(genPath, "authorizable.go")
if fileExists(authorizableFile) {
if err := os.Remove(authorizableFile); err != nil {
return err
}
}
gpf, polTyp := generator.GenIfacePoliceable(pkgName)
if err := gpf.Save(policeableFile); err != nil {
gpf, polTyp := generator.GenIfaceAuthorizable(pkgName)
if err := gpf.Save(authorizableFile); err != nil {
return err
}
objects.Actor = generator.QualId{
Expand Down

0 comments on commit 6fdbfee

Please sign in to comment.