diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..9cc652d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,37 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: Bug +--- + +## Describe the bug + +A clear and concise description of what the bug is. + +## To Reproduce + +Steps to reproduce the behavior: + +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +## Expected behavior + +A clear and concise description of what you expected to happen. + +## Screenshots + +If applicable, add screenshots to help explain your problem. + +## Application + +Please complete the following information: + +- badaas version [X.X.X] or commit hash + +## Additional context + +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/user_story.md b/.github/ISSUE_TEMPLATE/user_story.md new file mode 100644 index 0000000..1112fab --- /dev/null +++ b/.github/ISSUE_TEMPLATE/user_story.md @@ -0,0 +1,39 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: User Story, To be verify +--- + +## Description + +**As a** `[roles impacted]`, + +**I want** `[clear context and goals]` + +**so that** `[result of this story]`. + +## Acceptance Criteria + + **Scenario** | `[the name for the behavior that will be described]` + ------------ | ------------------------------------------------- + **Given** | `[the beginning state of the scenario]` + **When** | `[specific action that the user makes]` + **Then** | `[the outcome of the action in “When”]` + **And** | `[used to continue any of three previous statements]` + +### Constraints + +`[Put all others constraints here, like list of acceptances values or other]` + +## Resources + +`[Put all your resources here, like mockups, diagrams or other here]` + +## Notes + +`[Some complementary notes if necessary]` + +## Links + +`[Only use by the team, to link this feature with epic, technical tasks or bugs]` diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..fbb06c0 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1 @@ +:information_source: Don't forget to modify the changelog.md before merging this branch. \ No newline at end of file diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..05cc270 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,77 @@ +name: CI +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + branch-naming-rules: + name: Check branch name + runs-on: ubuntu-latest + steps: + - uses: deepakputhraya/action-branch-name@master + with: + regex: '^(feature|bugfix|improvement|library|prerelease|release|hotfix|poc)\/[a-z0-9_.-]+$' + allowed_prefixes: 'feature,bugfix,improvement,library,prerelease,release,hotfix,poc' + ignore: main,dev + min_length: 5 + max_length: 50 + + check-style: + name: Code style + needs: [branch-naming-rules] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-go@v3 + with: + go-version: '^1.18' + cache: true + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + skip-cache: true + skip-pkg-cache: true + skip-build-cache: true + + unit-tests: + name: Unit tests + needs: [branch-naming-rules] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-go@v3 + with: + go-version: '^1.18' + cache: true + - name: Run unit tests + run: go test ./... -coverprofile=coverage_unit.out -v + - uses: actions/upload-artifact@v3 + with: + name: coverage_unit + path: coverage_unit.out + + sonarcloud: + name: SonarCloud + needs: [unit-tests, check-style] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Download unit tests line coverage report + uses: actions/download-artifact@v3 + with: + name: coverage_unit + path: coverage_unit.out + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6ead366 --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +vendor/ + +# Go workspace file +go.work + +# vscode conf +.vscode + +# binary output +badaas-cli + +# test results +cmd/gen/conditions/*_conditions.go +cmd/gen/conditions/tests/**/badaas-orm.go \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..9bf38e5 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,238 @@ +# based on +# - https://github.com/istio/common-files/blob/master/files/common/config/.golangci.yml +# - https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322 + +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + deadline: 3m + # which dirs to skip: they won't be analyzed; + # can use regexp here: generated.*, regexp is applied on full path; + # 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: + - mocks$ + # which files to skip: they will be analyzed, but issues from them + # won't be reported. Default value is empty list, but there is + # no need to include all autogenerated files, we confidently recognize + # autogenerated files. + # skip-files: + # - ".*\\.pb\\.go" + # - ".*\\.gen\\.go" + +linters: + enable-all: true + disable: + - dogsled # [sometimes necessary] checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) + - exhaustruct # [make it easier to construct structs] checks if all structure fields are initialized + - gochecknoglobals # [we use them] checks that no global variables exist + - gochecknoinits # [we use them] checks that no init functions are present in Go code + - godot # [not necessary] checks if comments end in a period + - godox # [we use them] detects FIXME, TODO and other comment keywords + - ireturn # [useful for mocks generation] accept interfaces, return concrete types + - nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity + - nonamedreturns # [are util sometimes] reports all named returns + - paralleltest # [too many false positives] detects missing usage of t.Parallel() method in your Go test + - testpackage # [doesn't allow white box tests] makes you use a separate _test package + - thelper # [not the expected result by us] detects golang test helpers without t.Helper() call and checks the consistency of test helpers + - varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope + # deprecated + - deadcode # [deprecated, replaced by unused] finds unused code + - exhaustivestruct # [deprecated, replaced by exhaustruct] checks if all struct's fields are initialized + - golint # [deprecated, replaced by revive] golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes + - ifshort # [deprecated] checks that your code uses short syntax for if-statements whenever possible + - interfacer # [deprecated] suggests narrower interface types + - maligned # [deprecated, replaced by govet fieldalignment] detects Go structs that would take less memory if their fields were sorted + - nosnakecase # [deprecated, replaced by revive var-naming] detects snake case of variable naming and function name + - scopelint # [deprecated, replaced by exportloopref] checks for unpinned variables in go programs + - structcheck # [deprecated, replaced by unused] finds unused struct fields + - varcheck # [deprecated, replaced by unused] finds unused global variables and constants + # can be util in the future for better errors + - goerr113 # [too strict] checks the errors handling expressions + - wrapcheck # [too strict] checks that errors returned from external packages are wrapped + fast: false + +# All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml +linters-settings: + cyclop: + # The maximal code complexity to report. + # Default: 10 + max-complexity: 20 + # The maximal average package complexity. + # If it's higher than 0.0 (float) the check is enabled + # Default: 0.0 + package-average: 0.0 + depguard: + rules: + main: + deny: + - pkg: "github.com/gogo/protobuf" + desc: gogo/protobuf is deprecated, use golang/protobuf + errcheck: + # report about not checking of errors in type assetions: `a := b.(MyStruct)`; + # default is false: such cases aren't reported by default. + check-type-assertions: true + # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; + # default is false: such cases aren't reported by default. + check-blank: false + exhaustive: + # Program elements to check for exhaustiveness. + # Default: [ switch ] + check: + - switch + - map + funlen: + # Checks the number of lines in a function. + # If lower than 0, disable the check. + # Default: 60 + lines: 80 + # Checks the number of statements in a function. + # If lower than 0, disable the check. + # Default: 40 + statements: 40 + gci: + sections: + - standard # Captures all standard packages if they do not match another section. + - default # Contains all imports that could not be matched to another section type. + - prefix(github.com/ditrit/) # Groups all imports with the specified Prefix. + gocritic: + # Settings passed to gocritic. + # The settings key is the name of a supported gocritic checker. + # The list of supported checkers can be find in https://go-critic.github.io/overview. + settings: + captLocal: + # Whether to restrict checker to params only. + # Default: true + paramsOnly: false + underef: + # Whether to skip (*x).method() calls where x is a pointer receiver. + # Default: true + skipRecvDeref: false + goimports: + # put imports beginning with prefix after 3rd-party packages; + # it's a comma-separated list of prefixes + local-prefixes: github.com/ditrit + gomodguard: + blocked: + # List of blocked modules. + # Default: [] + modules: + - github.com/golang/protobuf: + recommendations: + - google.golang.org/protobuf + reason: "see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules" + - github.com/satori/go.uuid: + recommendations: + - github.com/google/uuid + reason: "satori's package is not maintained" + - github.com/gofrs/uuid: + recommendations: + - github.com/google/uuid + reason: "gofrs' package is not go module" + govet: + # Enable all analyzers. + # Default: false + enable-all: true + # Disable analyzers by name. + # Run `go tool vet help` to see all analyzers. + # Default: [] + disable: + - fieldalignment # too strict + # Settings per analyzer. + settings: + shadow: + # Whether to be strict about shadowing; can be noisy. + # Default: false + strict: false + lll: + # max line length, lines longer will be reported. Default is 120. + # '\t' is counted as 1 character by default, and can be changed with the tab-width option + line-length: 160 + # tab width in spaces. Default to 1. + tab-width: 1 + misspell: + # Correct spellings using locale preferences for US or UK. + # Default is to use a neutral variety of English. + # Setting locale to US will correct the British spelling of 'colour' to 'color'. + locale: US + ignore-words: + - cancelled + nolintlint: + # Exclude following linters from requiring an explanation. + # Default: [] + allow-no-explanation: [ funlen, gocognit, lll ] + # Enable to require an explanation of nonzero length after each nolint directive. + # Default: false + require-explanation: true + # Enable to require nolint directives to mention the specific linter being suppressed. + # Default: false + require-specific: true + rowserrcheck: + # database/sql is always checked + # Default: [] + packages: + - github.com/jmoiron/sqlx + unparam: + # call graph construction algorithm (cha, rta). In general, use cha for libraries, + # and rta for programs with main packages. Default is cha. + algo: cha + # Inspect exported functions, default is false. Set to true if no external program/library imports your code. + # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: + # if it's called for subdir of a project it can't find external interfaces. All text editor integrations + # with golangci-lint call it on a directory with the changed file. + check-exported: false + unused: + # treat code as a program (not a library) and report unused exported identifiers; default is false. + # XXX: if you enable this setting, unused will report a lot of false-positives in text editors: + # if it's called for subdir of a project it can't find funcs usages. All text editor integrations + # with golangci-lint call it on a directory with the changed file. + check-exported: false + tenv: + # The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures. + # Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked. + # Default: false + all: true + gosec: + config: + # Globals are applicable to all rules. + global: + # If true, ignore #nosec in comments (and an alternative as well). + # Default: false + nosec: true + # Audit mode enables addition checks that for normal code analysis might be too nosy. + # Default: false + audit: true + +issues: + # List of regexps of issue texts to exclude, empty list by default. + # But independently from this option we use default exclude patterns, + # it can be disabled by `exclude-use-default: false`. To list all + # excluded by default patterns execute `golangci-lint run --help` + exclude: + - composite literal uses unkeyed fields + exclude-rules: + # Exclude some linters from running on test files. + - path: _test\.go$|^testintegration/|^test_e2e/ + linters: + - errcheck + - forcetypeassert + - funlen + - goconst + - noctx + - gomnd + # We need to use the deprecated module since the jsonpb replacement is not backwards compatible. + - linters: + - staticcheck + text: "SA1019: package github.com/golang/protobuf/jsonpb" + - linters: + - staticcheck + text: 'SA1019: "github.com/golang/protobuf/jsonpb"' + # Independently from option `exclude` we use default exclude patterns, + # it can be disabled by this option. To list all + # excluded by default patterns execute `golangci-lint run --help`. + # Default value for this option is true. + exclude-use-default: true + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. + max-per-linter: 0 + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. + max-same-issues: 0 \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..74e762f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,73 @@ +# Contribute to the development of badaas + +- [Local compilation](#local-compilation) +- [Tests](#tests) + - [Unit tests](#unit-tests) +- [Git](#git) + - [Branch naming policy](#branch-naming-policy) + - [Default branch](#default-branch) + - [How to release](#how-to-release) + +## Local compilation + +You can make modifications to the badaas-cli source code and compile it locally with: + +```bash +go build . +``` + +You can then run the badaas-cli executable directly or add a link in your $GOPATH to run it from a project: + +```bash +ln -sf badaas-cli $GOPATH/bin/badaas-cli +``` + +## Tests + +### Unit tests + +We use the standard test suite in combination with [github.com/stretchr/testify](https://github.com/stretchr/testify) to do our unit testing. + +To run them, please run: + +```sh +make test_unit +``` + +## Git + +### Branch naming policy + +`[BRANCH_TYPE]/[BRANCH_NAME]` + +- `BRANCH_TYPE` is a prefix to describe the purpose of the branch. + Accepted prefixes are: + - `feature`, used for feature development + - `bugfix`, used for bug fix + - `improvement`, used for refactor + - `library`, used for updating library + - `prerelease`, used for preparing the branch for the release + - `release`, used for releasing project + - `hotfix`, used for applying a hotfix on main + - `poc`, used for proof of concept +- `BRANCH_NAME` is managed by this regex: `[a-z0-9._-]` (`_` is used as space character). + +### Default branch + +The default branch is `main`. Direct commit on it is forbidden. The only way to update the application is through pull request. + +Release tag are only done on the `main` branch. + +### How to release + +We use [Semantic Versioning](https://semver.org/spec/v2.0.0.html) as guideline for the version management. + +Steps to release: + +- Create a new branch labeled `release/vX.Y.Z` from the latest `main`. +- Improve the version number in `changelog.md`. +- Verify the content of the `changelog.md`. +- Commit the modifications with the label `Release version X.Y.Z`. +- Create a pull request on github for this branch into `main`. +- Once the pull request validated and merged, tag the `main` branch with `vX.Y.Z`. +- After the tag is pushed, make the release on the tag in GitHub. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4152766 --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +lint: + golangci-lint run + +test_unit: clean_test_unit_results + go test ./... -v + +clean_test_unit_results: + rm -f cmd/gen/conditions/*_conditions.go + rm -f cmd/gen/conditions/tests/**/badaas-orm.go + +.PHONY: test_unit \ No newline at end of file diff --git a/README.md b/README.md index 0b83cad..e933bcb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,84 @@ -# badaas-cli -Command line tools to generate the files required to run a badaas application +# badaas-cli + +`badaas-cli` is the command line tool that makes it possible to configure and run a badaas application. + +- [Install with go install](#install-with-go-install) +- [Build from sources](#build-from-sources) +- [Commands](#commands) + - [badaas-cli gen docker](#badaas-cli-gen-docker) + - [badaas-cli gen conditions](#badaas-cli-gen-conditions) +- [Contributing](#contributing) +- [License](#license) + +## Install with go install + +For simply installing it, use: + +```bash +go install github.com/ditrit/badaas-cli +``` + +Or you can build it from sources. + +## Build from sources + +Get the sources of the project, either by visiting the [releases](https://github.com/ditrit/badaas/releases) page and downloading an archive or clone the main branch (please be aware that is it not a stable version). + +To build the project: + +- [Install go](https://go.dev/dl/#go1.18.4) v1.18 +- Install project dependencies + + ```bash + go get + ``` + +- Run build command + + ```bash + go build . + ``` + +Well done, you have a binary `badaas-cli` at the root of the project. + +## Commands + +You can see the available commands by running: + +```bash +badaas-cli help +``` + +For more information about the functionality provided and how to use each command use: + +```bash +badaas-cli help [command] +``` + +### badaas-cli gen docker + +gen docker is the command you can use to generate the files and configurations necessary for your project to use badaas in a simple way. + +`gen docker` will generate the docker and configuration files needed to run the application in the `badaas/docker` and `badaas/config` folders respectively. + +All these files can be modified in case you need different values than those provided by default. For more information about the configuration head to [configuration docs](github.com/ditrit/badaas/configuration.md). + +A Makefile will be generated for the execution of a badaas server, with the command: + +```bash +make badaas_run +``` + +### badaas-cli gen conditions + +gen conditions is the command you can use to generate conditions to query your objects using badaas-orm. For each BaDaaS Model found in the input packages a file containing all possible Conditions on that object will be generated, allowing you to use badaas-orm. + +Its use is recommended through `go generate`. To see an example of how to do it click [here](https://github.com/ditrit/badaa-orm-example/blob/main/standalone/conditions/orm.go). + +## Contributing + +See [this section](./CONTRIBUTING.md). + +## License + +badaas-cli is Licensed under the [Mozilla Public License Version 2.0](./LICENSE). diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..67a76d1 --- /dev/null +++ b/changelog.md @@ -0,0 +1,18 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) + +## [Unreleased] + +### Added + +- Add generation of docker and configuration files +- Add gen conditions to generate the conditions for the badaas' compilable query system. +- Add support for operators in condition generation. +- Add preload conditions generation. +- Add support for dynamic operators. + +[unreleased]: https://github.com/ditrit/badaas-cli/blob/main/changelog.md#unreleased \ No newline at end of file diff --git a/cmd/gen/conditions/codeGenerator.go b/cmd/gen/conditions/codeGenerator.go new file mode 100644 index 0000000..7671dc3 --- /dev/null +++ b/cmd/gen/conditions/codeGenerator.go @@ -0,0 +1,6 @@ +package conditions + +type CodeGenerator[T any] interface { + Into(file *File) error + ForEachField(file *File, fields []Field) []T +} diff --git a/cmd/gen/conditions/condition.go b/cmd/gen/conditions/condition.go new file mode 100644 index 0000000..dd41ee8 --- /dev/null +++ b/cmd/gen/conditions/condition.go @@ -0,0 +1,394 @@ +package conditions + +import ( + "go/types" + + "github.com/dave/jennifer/jen" + "github.com/ettle/strcase" + + "github.com/ditrit/badaas-cli/cmd/log" +) + +const ( + // badaas/orm + badaasORMFieldIs = "FieldIs" + badaasORMBoolFieldIs = "BoolFieldIs" + badaasORMStringFieldIs = "StringFieldIs" + // badaas/orm/condition + conditionPath = badaasORMPath + "/condition" + badaasORMCondition = "Condition" + badaasORMJoinCondition = "JoinCondition" + badaasORMNewJoinCondition = "NewJoinCondition" + badaasORMNewCollectionPreload = "NewCollectionPreloadCondition" + badaasORMNewPreloadCondition = "NewPreloadCondition" + // badaas/orm/query + queryPath = badaasORMPath + "/query" + badaasORMFieldIdentifier = "FieldIdentifier" + // badaas/orm/model + modelPath = badaasORMPath + "/model" + uIntID = "UIntID" + uuid = "UUID" + uuidModel = "UUIDModel" + uIntModel = "UIntModel" +) + +const preloadMethod = "Preload" + +type Condition struct { + FieldName string + FieldType *jen.Statement + FieldDefinition *jen.Statement + ConditionMethod *jen.Statement + PreloadRelationName string + PreloadRelationMethod *jen.Statement + param *JenParam + destPkg string + modelType string +} + +func NewCondition(destPkg string, objectType Type, field Field) *Condition { + condition := &Condition{ + FieldName: field.CompleteName(), + param: NewJenParam(), + destPkg: destPkg, + modelType: getConditionsModelType(objectType.Name()), + } + condition.generate(objectType, field) + + return condition +} + +// Generate the condition between the object and the field +func (condition *Condition) generate(objectType Type, field Field) { + switch fieldType := field.GetType().(type) { + case *types.Basic: + // the field is a basic type (string, int, etc) + // adapt param to that type and generate a WhereCondition + condition.param.ToBasicKind(fieldType) + condition.generateWhere( + objectType, + field, + ) + case *types.Named: + // the field is a named type (user defined structs) + condition.generateForNamedType( + objectType, + field, + ) + case *types.Pointer: + // the field is a pointer + condition.generate( + objectType, + field.ChangeType(fieldType.Elem()), + ) + case *types.Slice: + // the field is a slice + // adapt param to slice and + // generate code for the type of the elements of the slice + condition.param.ToSlice() + condition.generateForSlice( + objectType, + field.ChangeType(fieldType.Elem()), + ) + default: + log.Logger.Debugf("struct field type not handled: %T", fieldType) + } +} + +// Generate condition between the object and the field when the field is a slice +func (condition *Condition) generateForSlice(objectType Type, field Field) { + switch elemType := field.GetType().(type) { + case *types.Basic: + // slice of basic types ([]string, []int, etc.) + // the only one supported directly by gorm is []byte + // but the others can be used after configuration in some dbs + condition.generate( + objectType, + field, + ) + case *types.Named: + // slice of named types (user defined types) + _, err := field.Type.BadaasModelStruct() + if err == nil { + // field is a Badaas Model + condition.generateCollectionPreload(objectType, field) + } + case *types.Pointer: + // slice of pointers, generate code for a slice of the pointed type + condition.generateForSlice( + objectType, + field.ChangeType(elemType.Elem()), + ) + default: + log.Logger.Debugf("struct field list elem type not handled: %T", elemType) + } +} + +// Generate condition between object and field when the field is a named type (user defined struct) +func (condition *Condition) generateForNamedType(objectType Type, field Field) { + _, err := field.Type.BadaasModelStruct() + + switch { + case err == nil: + // field is a badaas model + condition.generateForBadaasModel(objectType, field) + case field.Type.IsSQLNullableType(): + // field is a sql nullable type (sql.NullBool, sql.NullInt, etc.) + condition.param.SQLToBasicType(field.Type) + condition.generateWhere( + objectType, + field, + ) + case field.Type.IsGormCustomType() || field.TypeString() == "time.Time" || field.IsModelID(): + // field is a Gorm Custom type (implements Scanner and Valuer interfaces) + // or a named type supported by gorm (time.Time) + // or a badaas-orm id (uuid or uintid) + condition.param.ToCustomType(condition.destPkg, field.Type) + condition.generateWhere( + objectType, + field, + ) + default: + log.Logger.Debugf("struct field type not handled: %s", field.TypeString()) + } +} + +// Generate condition between object and field when the field is a Badaas Model +func (condition *Condition) generateForBadaasModel(objectType Type, field Field) { + _, err := objectType.GetFK(field) + if err == nil { + // has the fk -> belongsTo relation + condition.generateJoinWithFK( + objectType, + field, + ) + } else { + // has not the fk -> hasOne relation + condition.generateJoinWithoutFK( + objectType, + field, + ) + } +} + +// Generate a WhereCondition between object and field +func (condition *Condition) generateWhere(objectType Type, field Field) { + objectTypeQual := jen.Qual( + getRelativePackagePath(condition.destPkg, objectType), + objectType.Name(), + ) + + conditionName := getConditionName(field) + "Is" + log.Logger.Debugf("Generated %q", conditionName) + + condition.createFieldIdentifier( + objectType.Name(), field, + ) + + fieldIs := jen.Qual( + badaasORMPath, badaasORMFieldIs, + ).Types( + objectTypeQual, + condition.param.GenericType(), + ) + + fieldIsCreationValues := jen.Dict{ + jen.Id("FieldID"): jen.Id(condition.modelType).Dot(field.CompleteName()), + } + + if condition.param.isString { + fieldIsCreationValues = jen.Dict{ + jen.Id("FieldIs"): fieldIs.Clone().Values(fieldIsCreationValues), + } + fieldIs = jen.Qual( + badaasORMPath, badaasORMStringFieldIs, + ).Types(objectTypeQual) + } else if condition.param.isBool { + fieldIsCreationValues = jen.Dict{ + jen.Id("FieldIs"): fieldIs.Clone().Values(fieldIsCreationValues), + } + fieldIs = jen.Qual( + badaasORMPath, badaasORMBoolFieldIs, + ).Types(objectTypeQual) + } + + condition.ConditionMethod = createMethod(condition.modelType, conditionName).Params().Add( + fieldIs, + ).Block( + jen.Return(fieldIs.Clone().Values(fieldIsCreationValues)), + ) +} + +func createMethod(typeName, methodName string) *jen.Statement { + return jen.Func().Params( + jen.Id(typeName).Id(typeName), + ).Id(methodName) +} + +// create a variable containing the definition of the field identifier +// to use it in the where condition and in the preload condition +func (condition *Condition) createFieldIdentifier(objectName string, field Field) { + fieldIdentifierValues := jen.Dict{ + jen.Id("ModelType"): jen.Id(getObjectTypeName(objectName)), + jen.Id("Field"): jen.Lit(field.Name), + } + + columnName := field.getColumnName() + + if columnName != "" { + fieldIdentifierValues[jen.Id("Column")] = jen.Lit(columnName) + } + + columnPrefix := field.ColumnPrefix + if columnPrefix != "" { + fieldIdentifierValues[jen.Id("ColumnPrefix")] = jen.Lit(columnPrefix) + } + + condition.FieldType = jen.Id(condition.FieldName).Qual( + queryPath, badaasORMFieldIdentifier, + ).Types( + condition.param.GenericType(), + ) + + condition.FieldDefinition = jen.Qual( + queryPath, badaasORMFieldIdentifier, + ).Types( + condition.param.GenericType(), + ).Values(fieldIdentifierValues) +} + +// Generate a JoinCondition between the object and field's object +// when object has a foreign key to the field's object +func (condition *Condition) generateJoinWithFK(objectType Type, field Field) { + condition.generateJoin( + objectType, + field, + field.getFKAttribute(), + field.getFKReferencesAttribute(), + ) +} + +// Generate a JoinCondition between the object and field's object +// when object has not a foreign key to the field's object +// (so the field's object has it) +func (condition *Condition) generateJoinWithoutFK(objectType Type, field Field) { + condition.generateJoin( + objectType, + field, + field.getFKReferencesAttribute(), + field.getRelatedTypeFKAttribute(objectType.Name()), + ) +} + +// Generate a JoinCondition +func (condition *Condition) generateJoin(objectType Type, field Field, t1Field, t2Field string) { + t1 := jen.Qual( + getRelativePackagePath(condition.destPkg, objectType), + objectType.Name(), + ) + + t2 := jen.Qual( + getRelativePackagePath(condition.destPkg, field.Type), + field.TypeName(), + ) + + conditionName := getConditionName(field) + log.Logger.Debugf("Generated %q", conditionName) + + ormT1IJoinCondition := jen.Qual( + conditionPath, badaasORMJoinCondition, + ).Types(t1) + ormT2Condition := jen.Qual( + conditionPath, badaasORMCondition, + ).Types(t2) + ormJoinCondition := jen.Qual( + conditionPath, badaasORMNewJoinCondition, + ).Types( + t1, t2, + ) + + condition.ConditionMethod = createMethod(condition.modelType, conditionName).Params( + jen.Id("conditions").Op("...").Add(ormT2Condition), + ).Add( + ormT1IJoinCondition, + ).Block( + jen.Return( + ormJoinCondition.Call( + jen.Id("conditions"), + jen.Lit(field.Name), + jen.Lit(t1Field), + jen.Id(condition.modelType).Dot(preloadMethod).Call(), + jen.Lit(t2Field), + ), + ), + ) + + // preload for the relation + condition.setPreloadRelationName(field) + + condition.PreloadRelationMethod = createMethod(condition.modelType, condition.PreloadRelationName).Params().Add( + ormT1IJoinCondition, + ).Block( + jen.Return(jen.Id(condition.modelType).Dot(conditionName).Call( + jen.Id(field.TypeName()).Dot(preloadMethod).Call(), + )), + ) +} + +func (condition *Condition) setPreloadRelationName(field Field) { + condition.PreloadRelationName = "Preload" + field.Name +} + +func (condition *Condition) generateCollectionPreload(objectType Type, field Field) { + t1 := jen.Qual( + getRelativePackagePath(condition.destPkg, objectType), + objectType.Name(), + ) + + t2 := jen.Qual( + getRelativePackagePath(condition.destPkg, field.Type), + field.TypeName(), + ) + + ormT1Condition := jen.Qual( + conditionPath, badaasORMCondition, + ).Types(t1) + ormT2IJoinCondition := jen.Qual( + conditionPath, badaasORMJoinCondition, + ).Types(t2) + ormNewCollectionPreload := jen.Qual( + conditionPath, badaasORMNewCollectionPreload, + ).Types( + t1, t2, + ) + + condition.setPreloadRelationName(field) + + condition.PreloadRelationMethod = createMethod(condition.modelType, condition.PreloadRelationName).Params( + jen.Id("nestedPreloads").Op("...").Add(ormT2IJoinCondition), + ).Add( + ormT1Condition, + ).Block( + jen.Return( + ormNewCollectionPreload.Call( + jen.Lit(field.Name), + jen.Id("nestedPreloads"), + ), + ), + ) +} + +// Generate condition names +func getConditionName(field Field) string { + return strcase.ToPascal(field.NamePrefix) + strcase.ToPascal(field.Name) +} + +// Avoid importing the same package as the destination one +func getRelativePackagePath(destPkg string, typeV Type) string { + srcPkg := typeV.Pkg() + if srcPkg == nil || srcPkg.Name() == destPkg { + return "" + } + + return srcPkg.Path() +} diff --git a/cmd/gen/conditions/conditionsGenerator.go b/cmd/gen/conditions/conditionsGenerator.go new file mode 100644 index 0000000..8467190 --- /dev/null +++ b/cmd/gen/conditions/conditionsGenerator.go @@ -0,0 +1,191 @@ +package conditions + +import ( + "fmt" + "go/types" + + "github.com/dave/jennifer/jen" + "github.com/ettle/strcase" + + "github.com/ditrit/badaas-cli/cmd/log" +) + +//nolint:revive // name is correct +type ConditionsGenerator struct { + object types.Object + objectType Type +} + +func NewConditionsGenerator(object types.Object) *ConditionsGenerator { + return &ConditionsGenerator{ + object: object, + objectType: Type{object.Type()}, + } +} + +// Add conditions for an object in the file +func (cg ConditionsGenerator) Into(file *File) error { + fields, err := getFields(cg.objectType) + if err != nil { + return err + } + + log.Logger.Infof("Generating conditions for type %q in %s", cg.object.Name(), file.name) + + // Add one condition for each field of the object + conditions := cg.ForEachField(file, fields) + + objectName := cg.object.Name() + objectQual := jen.Qual( + getRelativePackagePath(file.destPkg, cg.objectType), + cg.objectType.Name(), + ) + + fieldIdentifiers := []jen.Code{} + relationPreloads := []jen.Code{} + + addReflectTypeDefinition(file, objectName, objectQual) + + conditionsModelType := getConditionsModelType(objectName) + conditionsModelAttributesDef := []jen.Code{} + conditionsModelAttributesIns := jen.Dict{} + + for _, condition := range conditions { + file.Add(condition.ConditionMethod) + + // add all field names to the list of fields of the preload condition + if condition.FieldDefinition != nil { + conditionsModelAttributesDef = append(conditionsModelAttributesDef, condition.FieldType) + conditionsModelAttributesIns[jen.Id(condition.FieldName)] = condition.FieldDefinition + fieldIdentifiers = append( + fieldIdentifiers, + jen.Id(conditionsModelType).Dot(condition.FieldName), + ) + } + + // add the preload to the list of all possible preloads + if condition.PreloadRelationMethod != nil { + file.Add(condition.PreloadRelationMethod) + relationPreloads = append( + relationPreloads, + jen.Id(conditionsModelType).Dot(condition.PreloadRelationName).Call(), + ) + } + } + + addConditionsModelDefinition(file, conditionsModelType, conditionsModelAttributesDef) + addConditionsModelInstantiation(file, objectName, conditionsModelType, conditionsModelAttributesIns) + addPreloadMethod(file, objectName, objectQual, conditionsModelType, fieldIdentifiers) + addPreloadRelationsMethod(file, objectName, objectQual, conditionsModelType, relationPreloads) + + return nil +} + +func addPreloadRelationsMethod(file *File, objectName string, objectQual *jen.Statement, conditionsModelType string, relationPreloads []jen.Code) { + if len(relationPreloads) > 0 { + condition := jen.Index().Add(jen.Qual( + conditionPath, badaasORMCondition, + )).Types( + objectQual, + ) + + file.Add( + jen.Comment(fmt.Sprintf("PreloadRelations allows preloading all the %s's relation when doing a query", objectName)), + createMethod(conditionsModelType, "PreloadRelations").Params().Add(condition).Block( + jen.Return( + condition.Clone().Values(relationPreloads...), + ), + ), + ) + } +} + +func addPreloadMethod(file *File, objectName string, objectQual *jen.Statement, conditionsModelType string, fieldIdentifiers []jen.Code) { + file.Add( + jen.Comment(fmt.Sprintf("Preload allows preloading the %s when doing a query", objectName)), + createMethod(conditionsModelType, preloadMethod).Params().Add( + jen.Qual( + conditionPath, badaasORMCondition, + ).Types( + objectQual, + ), + ).Block( + jen.Return( + jen.Qual( + conditionPath, badaasORMNewPreloadCondition, + ).Types( + objectQual, + ).Call(fieldIdentifiers...), + ), + ), + ) +} + +func addConditionsModelInstantiation(file *File, objectName, conditionsModelType string, conditionsModelAttributes jen.Dict) { + file.Add( + jen.Var().Id( + objectName, + ).Op("=").Add( + jen.Id(conditionsModelType).Values( + conditionsModelAttributes, + ), + ), + ) +} + +func addConditionsModelDefinition(file *File, conditionsModelType string, conditionsModelAttributes []jen.Code) { + file.Add( + jen.Type().Id( + conditionsModelType, + ).Struct( + conditionsModelAttributes..., + ), + ) +} + +func addReflectTypeDefinition(file *File, objectName string, objectQual *jen.Statement) { + file.Add( + jen.Var().Id( + getObjectTypeName(objectName), + ).Op("=").Add( + jen.Qual( + "reflect", + "TypeOf", + ).Call(jen.Op("*").New(objectQual)), + ), + ) +} + +func getConditionsModelType(objectName string) string { + return strcase.ToCamel(objectName) + "Conditions" +} + +func getObjectTypeName(objectType string) string { + return strcase.ToCamel(objectType) + "Type" +} + +// Generate the conditions for each of the object's fields +func (cg ConditionsGenerator) ForEachField(file *File, fields []Field) []Condition { + conditions := []Condition{} + + for _, field := range fields { + log.Logger.Debugf("Generating condition for field %q", field.Name) + + if field.Embedded { + conditions = append( + conditions, + generateForEmbeddedField[Condition]( + file, + field, + cg, + )..., + ) + } else { + conditions = append(conditions, *NewCondition( + file.destPkg, cg.objectType, field, + )) + } + } + + return conditions +} diff --git a/cmd/gen/conditions/embeddedField.go b/cmd/gen/conditions/embeddedField.go new file mode 100644 index 0000000..fa507b7 --- /dev/null +++ b/cmd/gen/conditions/embeddedField.go @@ -0,0 +1,34 @@ +package conditions + +import ( + "errors" + "go/types" + + "github.com/elliotchance/pie/v2" +) + +// Generate conditions for a embedded field using the "generator" +// it will generate a condition for each of the field of the embedded field's type +func generateForEmbeddedField[T any](file *File, field Field, generator CodeGenerator[T]) []T { + embeddedStructType, ok := field.Type.Underlying().(*types.Struct) + if !ok { + panic(errors.New("unreachable! embedded objects are always structs")) + } + + fields, err := getStructFields(embeddedStructType) + if err != nil { + // embedded field's type has not fields + return []T{} + } + + if !isBaseModel(field.TypeString()) { + fields = pie.Map(fields, func(embeddedField Field) Field { + embeddedField.ColumnPrefix = field.Tags.getEmbeddedPrefix() + embeddedField.NamePrefix = field.Name + + return embeddedField + }) + } + + return generator.ForEachField(file, fields) +} diff --git a/cmd/gen/conditions/field.go b/cmd/gen/conditions/field.go new file mode 100644 index 0000000..3c6e652 --- /dev/null +++ b/cmd/gen/conditions/field.go @@ -0,0 +1,139 @@ +package conditions + +import ( + "errors" + "go/types" + + "github.com/elliotchance/pie/v2" +) + +// badaas/orm/baseModels.go +var modelIDs = []string{ + modelPath + "." + uIntID, + modelPath + "." + uuid, +} + +type Field struct { + Name string + NamePrefix string + Type Type + Embedded bool + Tags GormTags + ColumnPrefix string +} + +func (field Field) CompleteName() string { + return field.NamePrefix + field.Name +} + +func (field Field) IsModelID() bool { + return pie.Contains(modelIDs, field.TypeString()) +} + +// Get the name of the column where the data for a field will be saved +func (field Field) getColumnName() string { + columnTag, isPresent := field.Tags[columnTagName] + if isPresent { + // field has a gorm column tag, so the name of the column will be that tag + return columnTag + } + + return "" +} + +// Get name of the attribute of the object that is a foreign key to the field's object +func (field Field) getFKAttribute() string { + foreignKeyTag, isPresent := field.Tags[foreignKeyTagName] + if isPresent { + // field has a foreign key tag, so the name will be that tag + return foreignKeyTag + } + + // gorm default + return field.Name + "ID" +} + +// Get name of the attribute of the field's object that is references by the foreign key +func (field Field) getFKReferencesAttribute() string { + referencesTag, isPresent := field.Tags[referencesTagName] + if isPresent { + // field has a references tag, so the name will be that tag + return referencesTag + } + + // gorm default + return "ID" +} + +// Get name of the attribute of field's object that is a foreign key to the object +func (field Field) getRelatedTypeFKAttribute(structName string) string { + foreignKeyTag, isPresent := field.Tags[foreignKeyTagName] + if isPresent { + // field has a foreign key tag, so the name will that tag + return foreignKeyTag + } + + // gorm default + return structName + "ID" +} + +func (field Field) GetType() types.Type { + return field.Type.Type +} + +// Get field's type full string (pkg + name) +func (field Field) TypeString() string { + return field.Type.String() +} + +// Get field's type name +func (field Field) TypeName() string { + return field.Type.Name() +} + +// Create a new field with the same name and tags but a different type +func (field Field) ChangeType(newType types.Type) Field { + return Field{ + Name: field.Name, + Type: Type{newType}, + Tags: field.Tags, + } +} + +// Get fields of a Badaas model +// Returns error is objectType is not a Badaas model +func getFields(objectType Type) ([]Field, error) { + // The underlying type has to be a struct and a Badaas Model + // (ignore const, var, func, etc.) + structType, err := objectType.BadaasModelStruct() + if err != nil { + return nil, err + } + + return getStructFields(structType) +} + +// Get fields of a struct +// Returns errors if the struct has not fields +func getStructFields(structType *types.Struct) ([]Field, error) { + numFields := structType.NumFields() + if numFields == 0 { + return nil, errors.New("struct has 0 fields") + } + + fields := []Field{} + + // Iterate over struct fields + for i := 0; i < numFields; i++ { + fieldObject := structType.Field(i) + gormTags := getGormTags(structType.Tag(i)) + fields = append(fields, Field{ + Name: fieldObject.Name(), + Type: Type{fieldObject.Type()}, + Embedded: fieldObject.Embedded() || gormTags.hasEmbedded(), + Tags: gormTags, + }) + } + + return fields, nil +} diff --git a/cmd/gen/conditions/file.go b/cmd/gen/conditions/file.go new file mode 100644 index 0000000..2e461db --- /dev/null +++ b/cmd/gen/conditions/file.go @@ -0,0 +1,47 @@ +package conditions + +import ( + "github.com/dave/jennifer/jen" + + "github.com/ditrit/badaas-cli/cmd/version" +) + +type File struct { + destPkg string + jenFile *jen.File + name string + codesAdded bool +} + +func NewFile(destPkg, name string) *File { + // Start a new file in destination package + f := jen.NewFile(destPkg) + + // Add a package comment, so IDEs detect files as generated + f.PackageComment("Code generated by badaas-cli v" + version.Version + ", DO NOT EDIT.") + + return &File{ + destPkg: destPkg, + name: name, + jenFile: f, + } +} + +func (file *File) Add(codes ...jen.Code) { + if len(codes) > 0 { + file.codesAdded = true + } + + for _, code := range codes { + file.jenFile.Add(code) + } +} + +// Write generated file +func (file File) Save() error { + if file.codesAdded { + return file.jenFile.Save(file.name) + } + + return nil +} diff --git a/cmd/gen/conditions/gormTag.go b/cmd/gen/conditions/gormTag.go new file mode 100644 index 0000000..80cde89 --- /dev/null +++ b/cmd/gen/conditions/gormTag.go @@ -0,0 +1,61 @@ +package conditions + +import ( + "strings" + + "github.com/fatih/structtag" +) + +type GormTag string + +const ( + embeddedTagName GormTag = "embedded" + embeddedPrefixTagName GormTag = "embeddedPrefix" + columnTagName GormTag = "column" + foreignKeyTagName GormTag = "foreignKey" + referencesTagName GormTag = "references" +) + +type GormTags map[GormTag]string + +func (tags GormTags) getEmbeddedPrefix() string { + embeddedPrefix, isPresent := tags[embeddedPrefixTagName] + if !isPresent { + return "" + } + + return embeddedPrefix +} + +func (tags GormTags) hasEmbedded() bool { + _, isPresent := tags[embeddedTagName] + return isPresent +} + +func getGormTags(tag string) GormTags { + tagMap := GormTags{} + + allTags, err := structtag.Parse(tag) + if err != nil { + return tagMap + } + + gormTag, err := allTags.Get("gorm") + if err != nil { + return tagMap + } + + gormTags := strings.Split(gormTag.Name, ";") + for _, tag := range gormTags { + splitted := strings.Split(tag, ":") + tagName := GormTag(splitted[0]) + + if len(splitted) == 1 { + tagMap[tagName] = "" + } else { + tagMap[tagName] = splitted[1] + } + } + + return tagMap +} diff --git a/cmd/gen/conditions/jenParam.go b/cmd/gen/conditions/jenParam.go new file mode 100644 index 0000000..5506c47 --- /dev/null +++ b/cmd/gen/conditions/jenParam.go @@ -0,0 +1,122 @@ +package conditions + +import ( + "errors" + "go/types" + + "github.com/dave/jennifer/jen" +) + +type JenParam struct { + internalType *jen.Statement + isBool bool + isString bool + isSlice bool +} + +func NewJenParam() *JenParam { + return &JenParam{ + internalType: &jen.Statement{}, + } +} + +func (param JenParam) GenericType() *jen.Statement { + return param.internalType +} + +func (param *JenParam) ToBasicKind(basicType *types.Basic) { + switch basicType.Kind() { + case types.Bool: + param.ToBool() + case types.Int: + param.internalType.Int() + case types.Int8: + param.internalType.Int8() + case types.Int16: + param.internalType.Int16() + case types.Int32: + param.internalType.Int32() + case types.Int64: + param.internalType.Int64() + case types.Uint: + param.internalType.Uint() + case types.Uint8: + param.internalType.Uint8() + case types.Uint16: + param.internalType.Uint16() + case types.Uint32: + param.internalType.Uint32() + case types.Uint64: + param.internalType.Uint64() + case types.Uintptr: + param.internalType.Uintptr() + case types.Float32: + param.internalType.Float32() + case types.Float64: + param.internalType.Float64() + case types.Complex64: + param.internalType.Complex64() + case types.Complex128: + param.internalType.Complex128() + case types.String: + param.ToString() + case types.Invalid, types.UnsafePointer, + types.UntypedBool, types.UntypedInt, + types.UntypedRune, types.UntypedFloat, + types.UntypedComplex, types.UntypedString, + types.UntypedNil: + panic(errors.New("unreachable! untyped types can't be inside a struct")) + } +} + +func (param *JenParam) ToSlice() { + param.isSlice = true + param.internalType.Index() +} + +func (param JenParam) ToCustomType(destPkg string, typeV Type) { + param.internalType.Qual( + getRelativePackagePath(destPkg, typeV), + typeV.Name(), + ) +} + +func (param *JenParam) SQLToBasicType(typeV Type) { + switch typeV.String() { + case nullString: + param.ToString() + case nullInt64: + param.internalType.Int64() + case nullInt32: + param.internalType.Int32() + case nullInt16: + param.internalType.Int16() + case nullByte: + param.internalType.Int8() + case nullFloat64: + param.internalType.Float64() + case nullBool: + param.ToBool() + case nullTime, deletedAt: + param.internalType.Qual( + "time", + "Time", + ) + } +} + +func (param *JenParam) ToBool() { + if !param.isSlice { + param.isBool = true + } + + param.internalType.Bool() +} + +func (param *JenParam) ToString() { + if !param.isSlice { + param.isString = true + } + + param.internalType.String() +} diff --git a/cmd/gen/conditions/main.go b/cmd/gen/conditions/main.go new file mode 100644 index 0000000..c7234cd --- /dev/null +++ b/cmd/gen/conditions/main.go @@ -0,0 +1,131 @@ +package conditions + +import ( + "errors" + "fmt" + "go/types" + "os" + "path/filepath" + + "github.com/ettle/strcase" + "github.com/spf13/cobra" + "github.com/spf13/viper" + "golang.org/x/tools/go/packages" + + "github.com/ditrit/badaas-cli/cmd/log" + "github.com/ditrit/verdeter" +) + +var GenConditionsCmd = verdeter.BuildVerdeterCommand(verdeter.VerdeterConfig{ + Use: "conditions", + Short: "Generate conditions to query your objects using badaas-orm", + Long: `gen is the command you can use to generate the files and configurations necessary for your project to use BadAss in a simple way.`, + Run: generateConditions, + Args: cobra.MinimumNArgs(1), +}) + +const ( + DestPackageKey = "dest_package" + badaasORMPath = "github.com/ditrit/badaas/orm" +) + +func init() { + err := GenConditionsCmd.LKey( + DestPackageKey, verdeter.IsStr, "d", + "Destination package (not used if ran with go generate)", + ) + if err != nil { + panic(err) + } +} + +// GenConditionsCmd Run func +func generateConditions(_ *cobra.Command, args []string) { + log.SetLevel() + // Inspect package and use type checker to infer imported types + pkgs := loadPackages(args) + + // Get the package of the file with go:generate comment or in command params + destPkg := os.Getenv("GOPACKAGE") + if destPkg == "" { + destPkg = viper.GetString(DestPackageKey) + if destPkg == "" { + panic(errors.New("config --dest_package or use go generate")) + } + } + + // Generate conditions for each package + for i, pkg := range pkgs { + generateConditionsForPkg(destPkg, args[i], pkg) + } +} + +// Generates a file with conditions for each Badaas model in the package +func generateConditionsForPkg(destPkg string, pkgPath string, pkg *packages.Package) { + log.Logger.Infof("Generating conditions for types in package %q", pkg.Types.Name()) + + relationGettersFile := NewFile(pkg.Types.Name(), filepath.Join(pkgPath, "badaas-orm.go")) + + for _, name := range pkg.Types.Scope().Names() { + object := getObject(pkg, name) + if object != nil { + generateConditionsForObject(destPkg, object) + _ = NewRelationGettersGenerator(object).Into(relationGettersFile) + } + } + + err := relationGettersFile.Save() + if err != nil { + panic(err) + } +} + +func generateConditionsForObject(destPkg string, object types.Object) { + file := NewFile( + destPkg, + strcase.ToSnake(object.Name())+"_conditions.go", + ) + + err := NewConditionsGenerator(object).Into(file) + if err != nil { + // object is not a Badaas model, do not generate conditions + return + } + + err = file.Save() + if err != nil { + panic(err) + } +} + +// Load package information from paths +func loadPackages(paths []string) []*packages.Package { + cfg := &packages.Config{Mode: packages.NeedTypes} + + pkgs, err := packages.Load(cfg, paths...) + if err != nil { + panic(fmt.Errorf("loading packages for inspection: %w", err)) + } + + // print compilation errors of source packages + packages.PrintErrors(pkgs) + + return pkgs +} + +// Get object by name in the package +func getObject(pkg *packages.Package, name string) types.Object { + obj := pkg.Types.Scope().Lookup(name) + if obj == nil { + panic(fmt.Errorf("%s not found in declared types of %s", + name, pkg)) + } + + // Generate only if it is a declared type + object, ok := obj.(*types.TypeName) + if !ok { + return nil + } + + return object +} diff --git a/cmd/gen/conditions/main_test.go b/cmd/gen/conditions/main_test.go new file mode 100644 index 0000000..c00374c --- /dev/null +++ b/cmd/gen/conditions/main_test.go @@ -0,0 +1,233 @@ +package conditions + +import ( + "bytes" + "io" + "os" + "testing" + + "github.com/spf13/viper" + "gotest.tools/assert" + + "github.com/ditrit/badaas-cli/cmd/testutils" +) + +const chunkSize = 100000 + +func TestUIntModel(t *testing.T) { + doTest(t, "./tests/uintmodel", []Comparison{ + {Have: "uint_model_conditions.go", Expected: "./tests/results/uintmodel.go"}, + }) + testutils.CheckFileNotExists(t, "./tests/uintmodel/badaas-orm.go") +} + +func TestUUIDModel(t *testing.T) { + doTest(t, "./tests/uuidmodel", []Comparison{ + {Have: "uuid_model_conditions.go", Expected: "./tests/results/uuidmodel.go"}, + }) + testutils.CheckFileNotExists(t, "./tests/uuidmodel/badaas-orm.go") +} + +func TestBasicTypes(t *testing.T) { + doTest(t, "./tests/basictypes", []Comparison{ + {Have: "basic_types_conditions.go", Expected: "./tests/results/basictypes.go"}, + }) + testutils.CheckFileNotExists(t, "./tests/basictypes/badaas-orm.go") +} + +func TestBasicPointers(t *testing.T) { + doTest(t, "./tests/basicpointers", []Comparison{ + {Have: "basic_pointers_conditions.go", Expected: "./tests/results/basicpointers.go"}, + }) + testutils.CheckFileNotExists(t, "./tests/basicpointers/badaas-orm.go") +} + +func TestBasicSlices(t *testing.T) { + doTest(t, "./tests/basicslices", []Comparison{ + {Have: "basic_slices_conditions.go", Expected: "./tests/results/basicslices.go"}, + }) + testutils.CheckFileNotExists(t, "./tests/basicslices/badaas-orm.go") +} + +func TestBasicSlicesPointer(t *testing.T) { + doTest(t, "./tests/basicslicespointer", []Comparison{ + {Have: "basic_slices_pointer_conditions.go", Expected: "./tests/results/basicslicespointer.go"}, + }) + testutils.CheckFileNotExists(t, "./tests/basicslicespointer/badaas-orm.go") +} + +func TestGoEmbedded(t *testing.T) { + doTest(t, "./tests/goembedded", []Comparison{ + {Have: "go_embedded_conditions.go", Expected: "./tests/results/goembedded.go"}, + }) + testutils.CheckFileNotExists(t, "./tests/goembedded/badaas-orm.go") +} + +func TestGormEmbedded(t *testing.T) { + doTest(t, "./tests/gormembedded", []Comparison{ + {Have: "gorm_embedded_conditions.go", Expected: "./tests/results/gormembedded.go"}, + }) + testutils.CheckFileNotExists(t, "./tests/gormembedded/badaas-orm.go") +} + +func TestCustomType(t *testing.T) { + doTest(t, "./tests/customtype", []Comparison{ + {Have: "custom_type_conditions.go", Expected: "./tests/results/customtype.go"}, + }) + testutils.CheckFileNotExists(t, "./tests/customtype/badaas-orm.go") +} + +func TestColumnDefinition(t *testing.T) { + doTest(t, "./tests/columndefinition", []Comparison{ + {Have: "column_definition_conditions.go", Expected: "./tests/results/columndefinition.go"}, + }) + testutils.CheckFileNotExists(t, "./tests/columndefinition/badaas-orm.go") +} + +func TestNullableTypes(t *testing.T) { + doTest(t, "./tests/nullabletypes", []Comparison{ + {Have: "nullable_types_conditions.go", Expected: "./tests/results/nullabletypes.go"}, + }) + testutils.CheckFileNotExists(t, "./tests/nullabletypes/badaas-orm.go") +} + +func TestBelongsTo(t *testing.T) { + doTest(t, "./tests/belongsto", []Comparison{ + {Have: "owner_conditions.go", Expected: "./tests/results/belongsto_owner.go"}, + {Have: "owned_conditions.go", Expected: "./tests/results/belongsto_owned.go"}, + {Have: "./tests/belongsto/badaas-orm.go", Expected: "./tests/belongsto/badaas-orm_result.go"}, + }) +} + +func TestHasOne(t *testing.T) { + doTest(t, "./tests/hasone", []Comparison{ + {Have: "country_conditions.go", Expected: "./tests/results/hasone_country.go"}, + {Have: "city_conditions.go", Expected: "./tests/results/hasone_city.go"}, + {Have: "./tests/hasone/badaas-orm.go", Expected: "./tests/hasone/badaas-orm_result.go"}, + }) +} + +func TestHasMany(t *testing.T) { + doTest(t, "./tests/hasmany", []Comparison{ + {Have: "company_conditions.go", Expected: "./tests/results/hasmany_company.go"}, + {Have: "seller_conditions.go", Expected: "./tests/results/hasmany_seller.go"}, + {Have: "./tests/hasmany/badaas-orm.go", Expected: "./tests/hasmany/badaas-orm_result.go"}, + }) +} + +func TestHasManyWithPointers(t *testing.T) { + doTest(t, "./tests/hasmanywithpointers", []Comparison{ + {Have: "company_with_pointers_conditions.go", Expected: "./tests/results/hasmanywithpointers_company.go"}, + {Have: "seller_in_pointers_conditions.go", Expected: "./tests/results/hasmanywithpointers_seller.go"}, + {Have: "./tests/hasmanywithpointers/badaas-orm.go", Expected: "./tests/hasmanywithpointers/badaas-orm_result.go"}, + }) +} + +func TestSelfReferential(t *testing.T) { + doTest(t, "./tests/selfreferential", []Comparison{ + {Have: "employee_conditions.go", Expected: "./tests/results/selfreferential.go"}, + {Have: "./tests/selfreferential/badaas-orm.go", Expected: "./tests/selfreferential/badaas-orm_result.go"}, + }) +} + +func TestMultiplePackage(t *testing.T) { + doTest(t, "./tests/multiplepackage/package1", []Comparison{ + {Have: "package1_conditions.go", Expected: "./tests/results/multiplepackage_package1.go"}, + {Have: "./tests/multiplepackage/package1/badaas-orm.go", Expected: "./tests/multiplepackage/package1/badaas-orm_result.go"}, + }) + doTest(t, "./tests/multiplepackage/package2", []Comparison{ + {Have: "package2_conditions.go", Expected: "./tests/results/multiplepackage_package2.go"}, + }) +} + +func TestOverrideForeignKey(t *testing.T) { + doTest(t, "./tests/overrideforeignkey", []Comparison{ + {Have: "bicycle_conditions.go", Expected: "./tests/results/overrideforeignkey_bicycle.go"}, + {Have: "person_conditions.go", Expected: "./tests/results/overrideforeignkey_person.go"}, + {Have: "./tests/overrideforeignkey/badaas-orm.go", Expected: "./tests/overrideforeignkey/badaas-orm_result.go"}, + }) +} + +func TestOverrideReferences(t *testing.T) { + doTest(t, "./tests/overridereferences", []Comparison{ + {Have: "phone_conditions.go", Expected: "./tests/results/overridereferences_phone.go"}, + {Have: "brand_conditions.go", Expected: "./tests/results/overridereferences_brand.go"}, + {Have: "./tests/overridereferences/badaas-orm.go", Expected: "./tests/overridereferences/badaas-orm_result.go"}, + }) +} + +func TestOverrideForeignKeyInverse(t *testing.T) { + doTest(t, "./tests/overrideforeignkeyinverse", []Comparison{ + {Have: "user_conditions.go", Expected: "./tests/results/overrideforeignkeyinverse_user.go"}, + {Have: "credit_card_conditions.go", Expected: "./tests/results/overrideforeignkeyinverse_credit_card.go"}, + {Have: "./tests/overrideforeignkeyinverse/badaas-orm.go", Expected: "./tests/overrideforeignkeyinverse/badaas-orm_result.go"}, + }) +} + +func TestOverrideReferencesInverse(t *testing.T) { + doTest(t, "./tests/overridereferencesinverse", []Comparison{ + {Have: "computer_conditions.go", Expected: "./tests/results/overridereferencesinverse_computer.go"}, + {Have: "processor_conditions.go", Expected: "./tests/results/overridereferencesinverse_processor.go"}, + {Have: "./tests/overridereferencesinverse/badaas-orm.go", Expected: "./tests/overridereferencesinverse/badaas-orm_result.go"}, + }) +} + +type Comparison struct { + Have string + Expected string +} + +func doTest(t *testing.T, sourcePkg string, comparisons []Comparison) { + viper.Set(DestPackageKey, "conditions") + generateConditions(nil, []string{sourcePkg}) + + for _, comparison := range comparisons { + checkFilesEqual(t, comparison.Have, comparison.Expected) + } +} + +func checkFilesEqual(t *testing.T, file1, file2 string) { + stat1 := testutils.CheckFileExists(t, file1) + stat2 := testutils.CheckFileExists(t, file2) + + // do inputs at least have the same size? + assert.Equal(t, stat1.Size(), stat2.Size(), "File lens are not equal") + + // long way: compare contents + f1, err := os.Open(file1) + if err != nil { + t.Error(err) + } + defer f1.Close() + + f2, err := os.Open(file2) + if err != nil { + t.Error(err) + } + defer f2.Close() + + b1 := make([]byte, chunkSize) + b2 := make([]byte, chunkSize) + + for { + n1, err1 := io.ReadFull(f1, b1) + n2, err2 := io.ReadFull(f2, b2) + + assert.Assert(t, bytes.Equal(b1[:n1], b2[:n2])) + + if (err1 == io.EOF && err2 == io.EOF) || (err1 == io.ErrUnexpectedEOF && err2 == io.ErrUnexpectedEOF) { + break + } + + // some other error, like a dropped network connection or a bad transfer + if err1 != nil { + t.Error(err1) + } + + if err2 != nil { + t.Error(err2) + } + } + + testutils.RemoveFile(file1) +} diff --git a/cmd/gen/conditions/relationGettersGenerator.go b/cmd/gen/conditions/relationGettersGenerator.go new file mode 100644 index 0000000..82e34e3 --- /dev/null +++ b/cmd/gen/conditions/relationGettersGenerator.go @@ -0,0 +1,226 @@ +package conditions + +import ( + "go/types" + + "github.com/dave/jennifer/jen" + "github.com/ettle/strcase" + + "github.com/ditrit/badaas-cli/cmd/log" +) + +const ( + // badaas/orm/preload + preloadPath = badaasORMPath + "/preload" + badaasORMVerifyStructLoaded = "VerifyStructLoaded" + badaasORMVerifyPointerLoaded = "VerifyPointerLoaded" + badaasORMVerifyPointerWithIDLoaded = "VerifyPointerWithIDLoaded" + badaasORMVerifyCollectionLoaded = "VerifyCollectionLoaded" +) + +type RelationGettersGenerator struct { + object types.Object + objectType Type +} + +func NewRelationGettersGenerator(object types.Object) *RelationGettersGenerator { + return &RelationGettersGenerator{ + object: object, + objectType: Type{object.Type()}, + } +} + +// Add conditions for an object in the file +func (generator RelationGettersGenerator) Into(file *File) error { + fields, err := getFields(generator.objectType) + if err != nil { + return err + } + + log.Logger.Infof("Generating relation getters for type %q in %s", generator.object.Name(), file.name) + + file.Add(generator.ForEachField(file, fields)...) + + return nil +} + +func (generator RelationGettersGenerator) ForEachField(file *File, fields []Field) []jen.Code { + relationGetters := []jen.Code{} + + for _, field := range fields { + if field.Embedded { + relationGetters = append( + relationGetters, + generateForEmbeddedField[jen.Code]( + file, + field, + generator, + )..., + ) + } else { + getterForField := generator.generateForField(field) + if getterForField != nil { + relationGetters = append(relationGetters, getterForField) + } + } + } + + return relationGetters +} + +func (generator RelationGettersGenerator) generateForField(field Field) jen.Code { + switch fieldType := field.GetType().(type) { + case *types.Named: + // the field is a named type (user defined structs) + _, err := field.Type.BadaasModelStruct() + if err == nil { + log.Logger.Debugf("Generating relation getter for type %q and field %s", generator.object.Name(), field.Name) + // field is a badaas Model + return generator.verifyStruct(field) + } + case *types.Pointer: + // the field is a pointer + return generator.generateForPointer(field.ChangeType(fieldType.Elem())) + default: + log.Logger.Debugf("struct field type not handled: %T", fieldType) + } + + return nil +} + +func (generator RelationGettersGenerator) generateForPointer(field Field) jen.Code { + switch fieldType := field.GetType().(type) { + case *types.Named: + _, err := field.Type.BadaasModelStruct() + if err == nil { + // field is a pointer to Badaas Model + fk, err := generator.objectType.GetFK(field) + if err != nil { + log.Logger.Debugf("unhandled: field is a pointer and object not has the fk: %s", field.Type) + return nil + } + + log.Logger.Debugf("Generating relation getter for type %q and field %s", generator.object.Name(), field.Name) + + switch fk.GetType().(type) { + case *types.Named: + if fk.IsModelID() { + return generator.verifyPointerWithID(field) + } + case *types.Pointer: + // the fk is a pointer + return generator.verifyPointer(field) + } + } + case *types.Slice: + return generator.generateForSlicePointer( + field.ChangeType(fieldType.Elem()), + nil, + ) + } + + return nil +} + +func (generator RelationGettersGenerator) generateForSlicePointer(field Field, fieldTypePrefix *jen.Statement) jen.Code { + switch fieldType := field.GetType().(type) { + case *types.Named: + _, err := field.Type.BadaasModelStruct() + if err == nil { + // field is a pointer to a slice of badaas Model + return generator.verifyCollection(field, fieldTypePrefix) + } + case *types.Pointer: + return generator.generateForSlicePointer( + field.ChangeType(fieldType.Elem()), + jen.Op("*"), + ) + } + + return nil +} + +func getGetterName(field Field) string { + return "Get" + strcase.ToPascal(field.Name) +} + +func (generator RelationGettersGenerator) verifyStruct(field Field) *jen.Statement { + return generator.verifyCommon( + field, + badaasORMVerifyStructLoaded, + jen.Op("*"), + nil, + jen.Op("&").Id("m").Op(".").Id(field.Name), + ) +} + +func (generator RelationGettersGenerator) verifyPointer(field Field) *jen.Statement { + return generator.verifyPointerCommon(field, badaasORMVerifyPointerLoaded) +} + +func (generator RelationGettersGenerator) verifyPointerWithID(field Field) *jen.Statement { + return generator.verifyPointerCommon(field, badaasORMVerifyPointerWithIDLoaded) +} + +func (generator RelationGettersGenerator) verifyCollection(field Field, fieldTypePrefix *jen.Statement) jen.Code { + return generator.verifyCommon( + field, + badaasORMVerifyCollectionLoaded, + jen.Index(), + fieldTypePrefix, + jen.Id("m").Op(".").Id(field.Name), + ) +} + +func (generator RelationGettersGenerator) verifyPointerCommon(field Field, verifyFunc string) *jen.Statement { + return generator.verifyCommon( + field, + verifyFunc, + jen.Op("*"), + nil, + jen.Id("m").Op(".").Id(field.Name+"ID"), + jen.Id("m").Op(".").Id(field.Name), + ) +} + +func (generator RelationGettersGenerator) verifyCommon( + field Field, + verifyFunc string, + returnType *jen.Statement, + fieldTypePrefix *jen.Statement, + callParams ...jen.Code, +) *jen.Statement { + fieldType := jen.Qual( + getRelativePackagePath( + generator.object.Pkg().Name(), + field.Type, + ), + field.TypeName(), + ) + + if fieldTypePrefix != nil { + fieldType = fieldTypePrefix.Add(fieldType) + } + + return jen.Func().Parens( + jen.Id("m").Id(generator.object.Name()), + ).Id(getGetterName(field)).Params().Add( + jen.Parens( + jen.List( + returnType.Add(fieldType), + jen.Id("error"), + ), + ), + ).Block( + jen.Return( + jen.Qual( + preloadPath, + verifyFunc, + ).Types( + fieldType, + ).Call( + callParams..., + ), + ), + ) +} diff --git a/cmd/gen/conditions/tests/basicpointers/basicpointers.go b/cmd/gen/conditions/tests/basicpointers/basicpointers.go new file mode 100644 index 0000000..f5e4430 --- /dev/null +++ b/cmd/gen/conditions/tests/basicpointers/basicpointers.go @@ -0,0 +1,26 @@ +package basicpointers + +import "github.com/ditrit/badaas/orm/model" + +type BasicPointers struct { + model.UUIDModel + + Bool *bool + Int *int + Int8 *int8 + Int16 *int16 + Int32 *int32 + Int64 *int64 + UInt *uint + UInt8 *uint8 + UInt16 *uint16 + UInt32 *uint32 + UInt64 *uint64 + UIntptr *uintptr + Float32 *float32 + Float64 *float64 + Complex64 *complex64 + Complex128 *complex128 + String *string + Byte *byte +} diff --git a/cmd/gen/conditions/tests/basicslices/basicslices.go b/cmd/gen/conditions/tests/basicslices/basicslices.go new file mode 100644 index 0000000..eedf58b --- /dev/null +++ b/cmd/gen/conditions/tests/basicslices/basicslices.go @@ -0,0 +1,26 @@ +package basicslices + +import "github.com/ditrit/badaas/orm/model" + +type BasicSlices struct { + model.UUIDModel + + Bool []bool + Int []int + Int8 []int8 + Int16 []int16 + Int32 []int32 + Int64 []int64 + UInt []uint + UInt8 []uint8 + UInt16 []uint16 + UInt32 []uint32 + UInt64 []uint64 + UIntptr []uintptr + Float32 []float32 + Float64 []float64 + Complex64 []complex64 + Complex128 []complex128 + String []string + Byte []byte +} diff --git a/cmd/gen/conditions/tests/basicslicespointer/basicslicespointer.go b/cmd/gen/conditions/tests/basicslicespointer/basicslicespointer.go new file mode 100644 index 0000000..e5a9af6 --- /dev/null +++ b/cmd/gen/conditions/tests/basicslicespointer/basicslicespointer.go @@ -0,0 +1,26 @@ +package basicslicespointer + +import "github.com/ditrit/badaas/orm/model" + +type BasicSlicesPointer struct { + model.UUIDModel + + Bool []*bool + Int []*int + Int8 []*int8 + Int16 []*int16 + Int32 []*int32 + Int64 []*int64 + UInt []*uint + UInt8 []*uint8 + UInt16 []*uint16 + UInt32 []*uint32 + UInt64 []*uint64 + UIntptr []*uintptr + Float32 []*float32 + Float64 []*float64 + Complex64 []*complex64 + Complex128 []*complex128 + String []*string + Byte []*byte +} diff --git a/cmd/gen/conditions/tests/basictypes/basictypes.go b/cmd/gen/conditions/tests/basictypes/basictypes.go new file mode 100644 index 0000000..cbdc1d6 --- /dev/null +++ b/cmd/gen/conditions/tests/basictypes/basictypes.go @@ -0,0 +1,26 @@ +package basictypes + +import "github.com/ditrit/badaas/orm/model" + +type BasicTypes struct { + model.UUIDModel + + Bool bool + Int int + Int8 int8 + Int16 int16 + Int32 int32 + Int64 int64 + UInt uint + UInt8 uint8 + UInt16 uint16 + UInt32 uint32 + UInt64 uint64 + UIntptr uintptr + Float32 float32 + Float64 float64 + Complex64 complex64 + Complex128 complex128 + String string + Byte byte +} diff --git a/cmd/gen/conditions/tests/belongsto/badaas-orm_result.go b/cmd/gen/conditions/tests/belongsto/badaas-orm_result.go new file mode 100644 index 0000000..a41a5ec --- /dev/null +++ b/cmd/gen/conditions/tests/belongsto/badaas-orm_result.go @@ -0,0 +1,8 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package belongsto + +import preload "github.com/ditrit/badaas/orm/preload" + +func (m Owned) GetOwner() (*Owner, error) { + return preload.VerifyStructLoaded[Owner](&m.Owner) +} diff --git a/cmd/gen/conditions/tests/belongsto/belongsto.go b/cmd/gen/conditions/tests/belongsto/belongsto.go new file mode 100644 index 0000000..ce239b6 --- /dev/null +++ b/cmd/gen/conditions/tests/belongsto/belongsto.go @@ -0,0 +1,16 @@ +package belongsto + +import ( + "github.com/ditrit/badaas/orm/model" +) + +type Owner struct { + model.UUIDModel +} +type Owned struct { + model.UUIDModel + + // Owned belongsTo Owner (Owned 0..* -> 1 Owner) + Owner Owner + OwnerID model.UUID +} diff --git a/cmd/gen/conditions/tests/columndefinition/columndefinition.go b/cmd/gen/conditions/tests/columndefinition/columndefinition.go new file mode 100644 index 0000000..0403a5a --- /dev/null +++ b/cmd/gen/conditions/tests/columndefinition/columndefinition.go @@ -0,0 +1,9 @@ +package columndefinition + +import "github.com/ditrit/badaas/orm/model" + +type ColumnDefinition struct { + model.UUIDModel + + String string `gorm:"column:string_something_else"` +} diff --git a/cmd/gen/conditions/tests/customtype/customtype.go b/cmd/gen/conditions/tests/customtype/customtype.go new file mode 100644 index 0000000..063f159 --- /dev/null +++ b/cmd/gen/conditions/tests/customtype/customtype.go @@ -0,0 +1,44 @@ +package customtype + +import ( + "database/sql/driver" + "fmt" + "strings" + + "github.com/ditrit/badaas/orm/model" +) + +type MultiString []string + +func (s *MultiString) Scan(src interface{}) error { + switch typedSrc := src.(type) { + case string: + *s = strings.Split(typedSrc, ",") + return nil + case []byte: + str := string(typedSrc) + *s = strings.Split(str, ",") + + return nil + default: + return fmt.Errorf("failed to scan multistring field - source is not a string, is %T", src) + } +} + +func (s MultiString) Value() (driver.Value, error) { + if len(s) == 0 { + return nil, nil + } + + return strings.Join(s, ","), nil +} + +func (MultiString) GormDataType() string { + return "text" +} + +type CustomType struct { + model.UUIDModel + + Custom MultiString +} diff --git a/cmd/gen/conditions/tests/goembedded/goembedded.go b/cmd/gen/conditions/tests/goembedded/goembedded.go new file mode 100644 index 0000000..7503543 --- /dev/null +++ b/cmd/gen/conditions/tests/goembedded/goembedded.go @@ -0,0 +1,14 @@ +package goembedded + +import "github.com/ditrit/badaas/orm/model" + +type ToBeEmbedded struct { + Int int +} + +type GoEmbedded struct { + model.UIntModel + + Int int + ToBeEmbedded +} diff --git a/cmd/gen/conditions/tests/gormembedded/gormembedded.go b/cmd/gen/conditions/tests/gormembedded/gormembedded.go new file mode 100644 index 0000000..c39eb41 --- /dev/null +++ b/cmd/gen/conditions/tests/gormembedded/gormembedded.go @@ -0,0 +1,15 @@ +package gormembedded + +import "github.com/ditrit/badaas/orm/model" + +type ToBeGormEmbedded struct { + Int int +} + +type GormEmbedded struct { + model.UIntModel + + Int int + GormEmbedded ToBeGormEmbedded `gorm:"embedded;embeddedPrefix:gorm_embedded_"` + GormEmbeddedNoPrefix ToBeGormEmbedded `gorm:"embedded"` +} diff --git a/cmd/gen/conditions/tests/hasmany/badaas-orm_result.go b/cmd/gen/conditions/tests/hasmany/badaas-orm_result.go new file mode 100644 index 0000000..d912fd3 --- /dev/null +++ b/cmd/gen/conditions/tests/hasmany/badaas-orm_result.go @@ -0,0 +1,11 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package hasmany + +import preload "github.com/ditrit/badaas/orm/preload" + +func (m Company) GetSellers() ([]Seller, error) { + return preload.VerifyCollectionLoaded[Seller](m.Sellers) +} +func (m Seller) GetCompany() (*Company, error) { + return preload.VerifyPointerLoaded[Company](m.CompanyID, m.Company) +} diff --git a/cmd/gen/conditions/tests/hasmany/hasmany.go b/cmd/gen/conditions/tests/hasmany/hasmany.go new file mode 100644 index 0000000..c677e73 --- /dev/null +++ b/cmd/gen/conditions/tests/hasmany/hasmany.go @@ -0,0 +1,18 @@ +package hasmany + +import ( + "github.com/ditrit/badaas/orm/model" +) + +type Company struct { + model.UUIDModel + + Sellers *[]Seller // Company HasMany Sellers (Company 0..1 -> 0..* Seller) +} + +type Seller struct { + model.UUIDModel + + Company *Company + CompanyID *model.UUID // Company HasMany Sellers (Company 0..1 -> 0..* Seller) +} diff --git a/cmd/gen/conditions/tests/hasmanywithpointers/badaas-orm_result.go b/cmd/gen/conditions/tests/hasmanywithpointers/badaas-orm_result.go new file mode 100644 index 0000000..d869dac --- /dev/null +++ b/cmd/gen/conditions/tests/hasmanywithpointers/badaas-orm_result.go @@ -0,0 +1,11 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package hasmanywithpointers + +import preload "github.com/ditrit/badaas/orm/preload" + +func (m CompanyWithPointers) GetSellers() ([]*SellerInPointers, error) { + return preload.VerifyCollectionLoaded[*SellerInPointers](m.Sellers) +} +func (m SellerInPointers) GetCompany() (*CompanyWithPointers, error) { + return preload.VerifyPointerLoaded[CompanyWithPointers](m.CompanyID, m.Company) +} diff --git a/cmd/gen/conditions/tests/hasmanywithpointers/hasmanywithpointers.go b/cmd/gen/conditions/tests/hasmanywithpointers/hasmanywithpointers.go new file mode 100644 index 0000000..568c16a --- /dev/null +++ b/cmd/gen/conditions/tests/hasmanywithpointers/hasmanywithpointers.go @@ -0,0 +1,18 @@ +package hasmanywithpointers + +import ( + "github.com/ditrit/badaas/orm/model" +) + +type CompanyWithPointers struct { + model.UUIDModel + + Sellers *[]*SellerInPointers // CompanyWithPointers HasMany SellerInPointers +} + +type SellerInPointers struct { + model.UUIDModel + + Company *CompanyWithPointers + CompanyID *model.UUID // Company HasMany Seller +} diff --git a/cmd/gen/conditions/tests/hasone/badaas-orm_result.go b/cmd/gen/conditions/tests/hasone/badaas-orm_result.go new file mode 100644 index 0000000..2c64298 --- /dev/null +++ b/cmd/gen/conditions/tests/hasone/badaas-orm_result.go @@ -0,0 +1,11 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package hasone + +import preload "github.com/ditrit/badaas/orm/preload" + +func (m City) GetCountry() (*Country, error) { + return preload.VerifyPointerWithIDLoaded[Country](m.CountryID, m.Country) +} +func (m Country) GetCapital() (*City, error) { + return preload.VerifyStructLoaded[City](&m.Capital) +} diff --git a/cmd/gen/conditions/tests/hasone/hasone.go b/cmd/gen/conditions/tests/hasone/hasone.go new file mode 100644 index 0000000..9df541f --- /dev/null +++ b/cmd/gen/conditions/tests/hasone/hasone.go @@ -0,0 +1,18 @@ +package hasone + +import ( + "github.com/ditrit/badaas/orm/model" +) + +type Country struct { + model.UUIDModel + + Capital City // Country HasOne City (Country 1 -> 1 City) +} + +type City struct { + model.UUIDModel + + Country *Country + CountryID model.UUID // Country HasOne City (Country 1 -> 1 City) +} diff --git a/cmd/gen/conditions/tests/multiplepackage/package1/badaas-orm_result.go b/cmd/gen/conditions/tests/multiplepackage/package1/badaas-orm_result.go new file mode 100644 index 0000000..f587899 --- /dev/null +++ b/cmd/gen/conditions/tests/multiplepackage/package1/badaas-orm_result.go @@ -0,0 +1,11 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package package1 + +import ( + package2 "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/multiplepackage/package2" + preload "github.com/ditrit/badaas/orm/preload" +) + +func (m Package1) GetPackage2() (*package2.Package2, error) { + return preload.VerifyStructLoaded[package2.Package2](&m.Package2) +} diff --git a/cmd/gen/conditions/tests/multiplepackage/package1/package1.go b/cmd/gen/conditions/tests/multiplepackage/package1/package1.go new file mode 100644 index 0000000..3e417f3 --- /dev/null +++ b/cmd/gen/conditions/tests/multiplepackage/package1/package1.go @@ -0,0 +1,12 @@ +package package1 + +import ( + "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/multiplepackage/package2" + "github.com/ditrit/badaas/orm/model" +) + +type Package1 struct { + model.UUIDModel + + Package2 package2.Package2 // Package1 HasOne Package2 (Package1 1 -> 1 Package2) +} diff --git a/cmd/gen/conditions/tests/multiplepackage/package2/package2.go b/cmd/gen/conditions/tests/multiplepackage/package2/package2.go new file mode 100644 index 0000000..78f9fd0 --- /dev/null +++ b/cmd/gen/conditions/tests/multiplepackage/package2/package2.go @@ -0,0 +1,11 @@ +package package2 + +import ( + "github.com/ditrit/badaas/orm/model" +) + +type Package2 struct { + model.UUIDModel + + Package1ID model.UUID // Package1 HasOne Package2 (Package1 1 -> 1 Package2) +} diff --git a/cmd/gen/conditions/tests/nullabletypes/nullabletypes.go b/cmd/gen/conditions/tests/nullabletypes/nullabletypes.go new file mode 100644 index 0000000..0639535 --- /dev/null +++ b/cmd/gen/conditions/tests/nullabletypes/nullabletypes.go @@ -0,0 +1,20 @@ +package nullabletypes + +import ( + "database/sql" + + "github.com/ditrit/badaas/orm/model" +) + +type NullableTypes struct { + model.UUIDModel + + String sql.NullString + Int64 sql.NullInt64 + Int32 sql.NullInt32 + Int16 sql.NullInt16 + Byte sql.NullByte + Float64 sql.NullFloat64 + Bool sql.NullBool + Time sql.NullTime +} diff --git a/cmd/gen/conditions/tests/overrideforeignkey/badaas-orm_result.go b/cmd/gen/conditions/tests/overrideforeignkey/badaas-orm_result.go new file mode 100644 index 0000000..ff732bb --- /dev/null +++ b/cmd/gen/conditions/tests/overrideforeignkey/badaas-orm_result.go @@ -0,0 +1,8 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package overrideforeignkey + +import preload "github.com/ditrit/badaas/orm/preload" + +func (m Bicycle) GetOwner() (*Person, error) { + return preload.VerifyStructLoaded[Person](&m.Owner) +} diff --git a/cmd/gen/conditions/tests/overrideforeignkey/overrideforeignkey.go b/cmd/gen/conditions/tests/overrideforeignkey/overrideforeignkey.go new file mode 100644 index 0000000..af3dfa9 --- /dev/null +++ b/cmd/gen/conditions/tests/overrideforeignkey/overrideforeignkey.go @@ -0,0 +1,15 @@ +package overrideforeignkey + +import "github.com/ditrit/badaas/orm/model" + +type Person struct { + model.UUIDModel +} + +type Bicycle struct { + model.UUIDModel + + // Bicycle BelongsTo Person (Bicycle 0..* -> 1 Person) + Owner Person `gorm:"foreignKey:OwnerSomethingID"` + OwnerSomethingID string +} diff --git a/cmd/gen/conditions/tests/overrideforeignkeyinverse/badaas-orm_result.go b/cmd/gen/conditions/tests/overrideforeignkeyinverse/badaas-orm_result.go new file mode 100644 index 0000000..8a20eec --- /dev/null +++ b/cmd/gen/conditions/tests/overrideforeignkeyinverse/badaas-orm_result.go @@ -0,0 +1,8 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package overrideforeignkeyinverse + +import preload "github.com/ditrit/badaas/orm/preload" + +func (m User) GetCreditCard() (*CreditCard, error) { + return preload.VerifyStructLoaded[CreditCard](&m.CreditCard) +} diff --git a/cmd/gen/conditions/tests/overrideforeignkeyinverse/overrideforeignkeyinverse.go b/cmd/gen/conditions/tests/overrideforeignkeyinverse/overrideforeignkeyinverse.go new file mode 100644 index 0000000..d810267 --- /dev/null +++ b/cmd/gen/conditions/tests/overrideforeignkeyinverse/overrideforeignkeyinverse.go @@ -0,0 +1,15 @@ +package overrideforeignkeyinverse + +import ( + "github.com/ditrit/badaas/orm/model" +) + +type User struct { + model.UUIDModel + CreditCard CreditCard `gorm:"foreignKey:UserReference"` +} + +type CreditCard struct { + model.UUIDModel + UserReference model.UUID +} diff --git a/cmd/gen/conditions/tests/overridereferences/badaas-orm_result.go b/cmd/gen/conditions/tests/overridereferences/badaas-orm_result.go new file mode 100644 index 0000000..7968a96 --- /dev/null +++ b/cmd/gen/conditions/tests/overridereferences/badaas-orm_result.go @@ -0,0 +1,8 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package overridereferences + +import preload "github.com/ditrit/badaas/orm/preload" + +func (m Phone) GetBrand() (*Brand, error) { + return preload.VerifyStructLoaded[Brand](&m.Brand) +} diff --git a/cmd/gen/conditions/tests/overridereferences/overridereferences.go b/cmd/gen/conditions/tests/overridereferences/overridereferences.go new file mode 100644 index 0000000..1c90a95 --- /dev/null +++ b/cmd/gen/conditions/tests/overridereferences/overridereferences.go @@ -0,0 +1,17 @@ +package overridereferences + +import "github.com/ditrit/badaas/orm/model" + +type Brand struct { + model.UUIDModel + + Name string `gorm:"unique;type:VARCHAR(255)"` +} + +type Phone struct { + model.UUIDModel + + // Bicycle BelongsTo Person (Bicycle 0..* -> 1 Person) + Brand Brand `gorm:"references:Name;foreignKey:BrandName"` + BrandName string +} diff --git a/cmd/gen/conditions/tests/overridereferencesinverse/badaas-orm_result.go b/cmd/gen/conditions/tests/overridereferencesinverse/badaas-orm_result.go new file mode 100644 index 0000000..ec11aad --- /dev/null +++ b/cmd/gen/conditions/tests/overridereferencesinverse/badaas-orm_result.go @@ -0,0 +1,8 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package overridereferencesinverse + +import preload "github.com/ditrit/badaas/orm/preload" + +func (m Computer) GetProcessor() (*Processor, error) { + return preload.VerifyStructLoaded[Processor](&m.Processor) +} diff --git a/cmd/gen/conditions/tests/overridereferencesinverse/overridereferencesinverse.go b/cmd/gen/conditions/tests/overridereferencesinverse/overridereferencesinverse.go new file mode 100644 index 0000000..d090d32 --- /dev/null +++ b/cmd/gen/conditions/tests/overridereferencesinverse/overridereferencesinverse.go @@ -0,0 +1,14 @@ +package overridereferencesinverse + +import "github.com/ditrit/badaas/orm/model" + +type Computer struct { + model.UUIDModel + Name string + Processor Processor `gorm:"foreignKey:ComputerName;references:Name"` +} + +type Processor struct { + model.UUIDModel + ComputerName string +} diff --git a/cmd/gen/conditions/tests/results/basicpointers.go b/cmd/gen/conditions/tests/results/basicpointers.go new file mode 100644 index 0000000..1178511 --- /dev/null +++ b/cmd/gen/conditions/tests/results/basicpointers.go @@ -0,0 +1,202 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + basicpointers "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/basicpointers" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var basicPointersType = reflect.TypeOf(*new(basicpointers.BasicPointers)) + +func (basicPointersConditions basicPointersConditions) IdIs() orm.FieldIs[basicpointers.BasicPointers, model.UUID] { + return orm.FieldIs[basicpointers.BasicPointers, model.UUID]{FieldID: basicPointersConditions.ID} +} +func (basicPointersConditions basicPointersConditions) CreatedAtIs() orm.FieldIs[basicpointers.BasicPointers, time.Time] { + return orm.FieldIs[basicpointers.BasicPointers, time.Time]{FieldID: basicPointersConditions.CreatedAt} +} +func (basicPointersConditions basicPointersConditions) UpdatedAtIs() orm.FieldIs[basicpointers.BasicPointers, time.Time] { + return orm.FieldIs[basicpointers.BasicPointers, time.Time]{FieldID: basicPointersConditions.UpdatedAt} +} +func (basicPointersConditions basicPointersConditions) DeletedAtIs() orm.FieldIs[basicpointers.BasicPointers, time.Time] { + return orm.FieldIs[basicpointers.BasicPointers, time.Time]{FieldID: basicPointersConditions.DeletedAt} +} +func (basicPointersConditions basicPointersConditions) BoolIs() orm.BoolFieldIs[basicpointers.BasicPointers] { + return orm.BoolFieldIs[basicpointers.BasicPointers]{FieldIs: orm.FieldIs[basicpointers.BasicPointers, bool]{FieldID: basicPointersConditions.Bool}} +} +func (basicPointersConditions basicPointersConditions) IntIs() orm.FieldIs[basicpointers.BasicPointers, int] { + return orm.FieldIs[basicpointers.BasicPointers, int]{FieldID: basicPointersConditions.Int} +} +func (basicPointersConditions basicPointersConditions) Int8Is() orm.FieldIs[basicpointers.BasicPointers, int8] { + return orm.FieldIs[basicpointers.BasicPointers, int8]{FieldID: basicPointersConditions.Int8} +} +func (basicPointersConditions basicPointersConditions) Int16Is() orm.FieldIs[basicpointers.BasicPointers, int16] { + return orm.FieldIs[basicpointers.BasicPointers, int16]{FieldID: basicPointersConditions.Int16} +} +func (basicPointersConditions basicPointersConditions) Int32Is() orm.FieldIs[basicpointers.BasicPointers, int32] { + return orm.FieldIs[basicpointers.BasicPointers, int32]{FieldID: basicPointersConditions.Int32} +} +func (basicPointersConditions basicPointersConditions) Int64Is() orm.FieldIs[basicpointers.BasicPointers, int64] { + return orm.FieldIs[basicpointers.BasicPointers, int64]{FieldID: basicPointersConditions.Int64} +} +func (basicPointersConditions basicPointersConditions) UIntIs() orm.FieldIs[basicpointers.BasicPointers, uint] { + return orm.FieldIs[basicpointers.BasicPointers, uint]{FieldID: basicPointersConditions.UInt} +} +func (basicPointersConditions basicPointersConditions) UInt8Is() orm.FieldIs[basicpointers.BasicPointers, uint8] { + return orm.FieldIs[basicpointers.BasicPointers, uint8]{FieldID: basicPointersConditions.UInt8} +} +func (basicPointersConditions basicPointersConditions) UInt16Is() orm.FieldIs[basicpointers.BasicPointers, uint16] { + return orm.FieldIs[basicpointers.BasicPointers, uint16]{FieldID: basicPointersConditions.UInt16} +} +func (basicPointersConditions basicPointersConditions) UInt32Is() orm.FieldIs[basicpointers.BasicPointers, uint32] { + return orm.FieldIs[basicpointers.BasicPointers, uint32]{FieldID: basicPointersConditions.UInt32} +} +func (basicPointersConditions basicPointersConditions) UInt64Is() orm.FieldIs[basicpointers.BasicPointers, uint64] { + return orm.FieldIs[basicpointers.BasicPointers, uint64]{FieldID: basicPointersConditions.UInt64} +} +func (basicPointersConditions basicPointersConditions) UIntptrIs() orm.FieldIs[basicpointers.BasicPointers, uintptr] { + return orm.FieldIs[basicpointers.BasicPointers, uintptr]{FieldID: basicPointersConditions.UIntptr} +} +func (basicPointersConditions basicPointersConditions) Float32Is() orm.FieldIs[basicpointers.BasicPointers, float32] { + return orm.FieldIs[basicpointers.BasicPointers, float32]{FieldID: basicPointersConditions.Float32} +} +func (basicPointersConditions basicPointersConditions) Float64Is() orm.FieldIs[basicpointers.BasicPointers, float64] { + return orm.FieldIs[basicpointers.BasicPointers, float64]{FieldID: basicPointersConditions.Float64} +} +func (basicPointersConditions basicPointersConditions) Complex64Is() orm.FieldIs[basicpointers.BasicPointers, complex64] { + return orm.FieldIs[basicpointers.BasicPointers, complex64]{FieldID: basicPointersConditions.Complex64} +} +func (basicPointersConditions basicPointersConditions) Complex128Is() orm.FieldIs[basicpointers.BasicPointers, complex128] { + return orm.FieldIs[basicpointers.BasicPointers, complex128]{FieldID: basicPointersConditions.Complex128} +} +func (basicPointersConditions basicPointersConditions) StringIs() orm.StringFieldIs[basicpointers.BasicPointers] { + return orm.StringFieldIs[basicpointers.BasicPointers]{FieldIs: orm.FieldIs[basicpointers.BasicPointers, string]{FieldID: basicPointersConditions.String}} +} +func (basicPointersConditions basicPointersConditions) ByteIs() orm.FieldIs[basicpointers.BasicPointers, uint8] { + return orm.FieldIs[basicpointers.BasicPointers, uint8]{FieldID: basicPointersConditions.Byte} +} + +type basicPointersConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + Bool query.FieldIdentifier[bool] + Int query.FieldIdentifier[int] + Int8 query.FieldIdentifier[int8] + Int16 query.FieldIdentifier[int16] + Int32 query.FieldIdentifier[int32] + Int64 query.FieldIdentifier[int64] + UInt query.FieldIdentifier[uint] + UInt8 query.FieldIdentifier[uint8] + UInt16 query.FieldIdentifier[uint16] + UInt32 query.FieldIdentifier[uint32] + UInt64 query.FieldIdentifier[uint64] + UIntptr query.FieldIdentifier[uintptr] + Float32 query.FieldIdentifier[float32] + Float64 query.FieldIdentifier[float64] + Complex64 query.FieldIdentifier[complex64] + Complex128 query.FieldIdentifier[complex128] + String query.FieldIdentifier[string] + Byte query.FieldIdentifier[uint8] +} + +var BasicPointers = basicPointersConditions{ + Bool: query.FieldIdentifier[bool]{ + Field: "Bool", + ModelType: basicPointersType, + }, + Byte: query.FieldIdentifier[uint8]{ + Field: "Byte", + ModelType: basicPointersType, + }, + Complex128: query.FieldIdentifier[complex128]{ + Field: "Complex128", + ModelType: basicPointersType, + }, + Complex64: query.FieldIdentifier[complex64]{ + Field: "Complex64", + ModelType: basicPointersType, + }, + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: basicPointersType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: basicPointersType, + }, + Float32: query.FieldIdentifier[float32]{ + Field: "Float32", + ModelType: basicPointersType, + }, + Float64: query.FieldIdentifier[float64]{ + Field: "Float64", + ModelType: basicPointersType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: basicPointersType, + }, + Int: query.FieldIdentifier[int]{ + Field: "Int", + ModelType: basicPointersType, + }, + Int16: query.FieldIdentifier[int16]{ + Field: "Int16", + ModelType: basicPointersType, + }, + Int32: query.FieldIdentifier[int32]{ + Field: "Int32", + ModelType: basicPointersType, + }, + Int64: query.FieldIdentifier[int64]{ + Field: "Int64", + ModelType: basicPointersType, + }, + Int8: query.FieldIdentifier[int8]{ + Field: "Int8", + ModelType: basicPointersType, + }, + String: query.FieldIdentifier[string]{ + Field: "String", + ModelType: basicPointersType, + }, + UInt: query.FieldIdentifier[uint]{ + Field: "UInt", + ModelType: basicPointersType, + }, + UInt16: query.FieldIdentifier[uint16]{ + Field: "UInt16", + ModelType: basicPointersType, + }, + UInt32: query.FieldIdentifier[uint32]{ + Field: "UInt32", + ModelType: basicPointersType, + }, + UInt64: query.FieldIdentifier[uint64]{ + Field: "UInt64", + ModelType: basicPointersType, + }, + UInt8: query.FieldIdentifier[uint8]{ + Field: "UInt8", + ModelType: basicPointersType, + }, + UIntptr: query.FieldIdentifier[uintptr]{ + Field: "UIntptr", + ModelType: basicPointersType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: basicPointersType, + }, +} + +// Preload allows preloading the BasicPointers when doing a query +func (basicPointersConditions basicPointersConditions) Preload() condition.Condition[basicpointers.BasicPointers] { + return condition.NewPreloadCondition[basicpointers.BasicPointers](basicPointersConditions.ID, basicPointersConditions.CreatedAt, basicPointersConditions.UpdatedAt, basicPointersConditions.DeletedAt, basicPointersConditions.Bool, basicPointersConditions.Int, basicPointersConditions.Int8, basicPointersConditions.Int16, basicPointersConditions.Int32, basicPointersConditions.Int64, basicPointersConditions.UInt, basicPointersConditions.UInt8, basicPointersConditions.UInt16, basicPointersConditions.UInt32, basicPointersConditions.UInt64, basicPointersConditions.UIntptr, basicPointersConditions.Float32, basicPointersConditions.Float64, basicPointersConditions.Complex64, basicPointersConditions.Complex128, basicPointersConditions.String, basicPointersConditions.Byte) +} diff --git a/cmd/gen/conditions/tests/results/basicslices.go b/cmd/gen/conditions/tests/results/basicslices.go new file mode 100644 index 0000000..c25f8e7 --- /dev/null +++ b/cmd/gen/conditions/tests/results/basicslices.go @@ -0,0 +1,202 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + basicslices "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/basicslices" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var basicSlicesType = reflect.TypeOf(*new(basicslices.BasicSlices)) + +func (basicSlicesConditions basicSlicesConditions) IdIs() orm.FieldIs[basicslices.BasicSlices, model.UUID] { + return orm.FieldIs[basicslices.BasicSlices, model.UUID]{FieldID: basicSlicesConditions.ID} +} +func (basicSlicesConditions basicSlicesConditions) CreatedAtIs() orm.FieldIs[basicslices.BasicSlices, time.Time] { + return orm.FieldIs[basicslices.BasicSlices, time.Time]{FieldID: basicSlicesConditions.CreatedAt} +} +func (basicSlicesConditions basicSlicesConditions) UpdatedAtIs() orm.FieldIs[basicslices.BasicSlices, time.Time] { + return orm.FieldIs[basicslices.BasicSlices, time.Time]{FieldID: basicSlicesConditions.UpdatedAt} +} +func (basicSlicesConditions basicSlicesConditions) DeletedAtIs() orm.FieldIs[basicslices.BasicSlices, time.Time] { + return orm.FieldIs[basicslices.BasicSlices, time.Time]{FieldID: basicSlicesConditions.DeletedAt} +} +func (basicSlicesConditions basicSlicesConditions) BoolIs() orm.FieldIs[basicslices.BasicSlices, []bool] { + return orm.FieldIs[basicslices.BasicSlices, []bool]{FieldID: basicSlicesConditions.Bool} +} +func (basicSlicesConditions basicSlicesConditions) IntIs() orm.FieldIs[basicslices.BasicSlices, []int] { + return orm.FieldIs[basicslices.BasicSlices, []int]{FieldID: basicSlicesConditions.Int} +} +func (basicSlicesConditions basicSlicesConditions) Int8Is() orm.FieldIs[basicslices.BasicSlices, []int8] { + return orm.FieldIs[basicslices.BasicSlices, []int8]{FieldID: basicSlicesConditions.Int8} +} +func (basicSlicesConditions basicSlicesConditions) Int16Is() orm.FieldIs[basicslices.BasicSlices, []int16] { + return orm.FieldIs[basicslices.BasicSlices, []int16]{FieldID: basicSlicesConditions.Int16} +} +func (basicSlicesConditions basicSlicesConditions) Int32Is() orm.FieldIs[basicslices.BasicSlices, []int32] { + return orm.FieldIs[basicslices.BasicSlices, []int32]{FieldID: basicSlicesConditions.Int32} +} +func (basicSlicesConditions basicSlicesConditions) Int64Is() orm.FieldIs[basicslices.BasicSlices, []int64] { + return orm.FieldIs[basicslices.BasicSlices, []int64]{FieldID: basicSlicesConditions.Int64} +} +func (basicSlicesConditions basicSlicesConditions) UIntIs() orm.FieldIs[basicslices.BasicSlices, []uint] { + return orm.FieldIs[basicslices.BasicSlices, []uint]{FieldID: basicSlicesConditions.UInt} +} +func (basicSlicesConditions basicSlicesConditions) UInt8Is() orm.FieldIs[basicslices.BasicSlices, []uint8] { + return orm.FieldIs[basicslices.BasicSlices, []uint8]{FieldID: basicSlicesConditions.UInt8} +} +func (basicSlicesConditions basicSlicesConditions) UInt16Is() orm.FieldIs[basicslices.BasicSlices, []uint16] { + return orm.FieldIs[basicslices.BasicSlices, []uint16]{FieldID: basicSlicesConditions.UInt16} +} +func (basicSlicesConditions basicSlicesConditions) UInt32Is() orm.FieldIs[basicslices.BasicSlices, []uint32] { + return orm.FieldIs[basicslices.BasicSlices, []uint32]{FieldID: basicSlicesConditions.UInt32} +} +func (basicSlicesConditions basicSlicesConditions) UInt64Is() orm.FieldIs[basicslices.BasicSlices, []uint64] { + return orm.FieldIs[basicslices.BasicSlices, []uint64]{FieldID: basicSlicesConditions.UInt64} +} +func (basicSlicesConditions basicSlicesConditions) UIntptrIs() orm.FieldIs[basicslices.BasicSlices, []uintptr] { + return orm.FieldIs[basicslices.BasicSlices, []uintptr]{FieldID: basicSlicesConditions.UIntptr} +} +func (basicSlicesConditions basicSlicesConditions) Float32Is() orm.FieldIs[basicslices.BasicSlices, []float32] { + return orm.FieldIs[basicslices.BasicSlices, []float32]{FieldID: basicSlicesConditions.Float32} +} +func (basicSlicesConditions basicSlicesConditions) Float64Is() orm.FieldIs[basicslices.BasicSlices, []float64] { + return orm.FieldIs[basicslices.BasicSlices, []float64]{FieldID: basicSlicesConditions.Float64} +} +func (basicSlicesConditions basicSlicesConditions) Complex64Is() orm.FieldIs[basicslices.BasicSlices, []complex64] { + return orm.FieldIs[basicslices.BasicSlices, []complex64]{FieldID: basicSlicesConditions.Complex64} +} +func (basicSlicesConditions basicSlicesConditions) Complex128Is() orm.FieldIs[basicslices.BasicSlices, []complex128] { + return orm.FieldIs[basicslices.BasicSlices, []complex128]{FieldID: basicSlicesConditions.Complex128} +} +func (basicSlicesConditions basicSlicesConditions) StringIs() orm.FieldIs[basicslices.BasicSlices, []string] { + return orm.FieldIs[basicslices.BasicSlices, []string]{FieldID: basicSlicesConditions.String} +} +func (basicSlicesConditions basicSlicesConditions) ByteIs() orm.FieldIs[basicslices.BasicSlices, []uint8] { + return orm.FieldIs[basicslices.BasicSlices, []uint8]{FieldID: basicSlicesConditions.Byte} +} + +type basicSlicesConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + Bool query.FieldIdentifier[[]bool] + Int query.FieldIdentifier[[]int] + Int8 query.FieldIdentifier[[]int8] + Int16 query.FieldIdentifier[[]int16] + Int32 query.FieldIdentifier[[]int32] + Int64 query.FieldIdentifier[[]int64] + UInt query.FieldIdentifier[[]uint] + UInt8 query.FieldIdentifier[[]uint8] + UInt16 query.FieldIdentifier[[]uint16] + UInt32 query.FieldIdentifier[[]uint32] + UInt64 query.FieldIdentifier[[]uint64] + UIntptr query.FieldIdentifier[[]uintptr] + Float32 query.FieldIdentifier[[]float32] + Float64 query.FieldIdentifier[[]float64] + Complex64 query.FieldIdentifier[[]complex64] + Complex128 query.FieldIdentifier[[]complex128] + String query.FieldIdentifier[[]string] + Byte query.FieldIdentifier[[]uint8] +} + +var BasicSlices = basicSlicesConditions{ + Bool: query.FieldIdentifier[[]bool]{ + Field: "Bool", + ModelType: basicSlicesType, + }, + Byte: query.FieldIdentifier[[]uint8]{ + Field: "Byte", + ModelType: basicSlicesType, + }, + Complex128: query.FieldIdentifier[[]complex128]{ + Field: "Complex128", + ModelType: basicSlicesType, + }, + Complex64: query.FieldIdentifier[[]complex64]{ + Field: "Complex64", + ModelType: basicSlicesType, + }, + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: basicSlicesType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: basicSlicesType, + }, + Float32: query.FieldIdentifier[[]float32]{ + Field: "Float32", + ModelType: basicSlicesType, + }, + Float64: query.FieldIdentifier[[]float64]{ + Field: "Float64", + ModelType: basicSlicesType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: basicSlicesType, + }, + Int: query.FieldIdentifier[[]int]{ + Field: "Int", + ModelType: basicSlicesType, + }, + Int16: query.FieldIdentifier[[]int16]{ + Field: "Int16", + ModelType: basicSlicesType, + }, + Int32: query.FieldIdentifier[[]int32]{ + Field: "Int32", + ModelType: basicSlicesType, + }, + Int64: query.FieldIdentifier[[]int64]{ + Field: "Int64", + ModelType: basicSlicesType, + }, + Int8: query.FieldIdentifier[[]int8]{ + Field: "Int8", + ModelType: basicSlicesType, + }, + String: query.FieldIdentifier[[]string]{ + Field: "String", + ModelType: basicSlicesType, + }, + UInt: query.FieldIdentifier[[]uint]{ + Field: "UInt", + ModelType: basicSlicesType, + }, + UInt16: query.FieldIdentifier[[]uint16]{ + Field: "UInt16", + ModelType: basicSlicesType, + }, + UInt32: query.FieldIdentifier[[]uint32]{ + Field: "UInt32", + ModelType: basicSlicesType, + }, + UInt64: query.FieldIdentifier[[]uint64]{ + Field: "UInt64", + ModelType: basicSlicesType, + }, + UInt8: query.FieldIdentifier[[]uint8]{ + Field: "UInt8", + ModelType: basicSlicesType, + }, + UIntptr: query.FieldIdentifier[[]uintptr]{ + Field: "UIntptr", + ModelType: basicSlicesType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: basicSlicesType, + }, +} + +// Preload allows preloading the BasicSlices when doing a query +func (basicSlicesConditions basicSlicesConditions) Preload() condition.Condition[basicslices.BasicSlices] { + return condition.NewPreloadCondition[basicslices.BasicSlices](basicSlicesConditions.ID, basicSlicesConditions.CreatedAt, basicSlicesConditions.UpdatedAt, basicSlicesConditions.DeletedAt, basicSlicesConditions.Bool, basicSlicesConditions.Int, basicSlicesConditions.Int8, basicSlicesConditions.Int16, basicSlicesConditions.Int32, basicSlicesConditions.Int64, basicSlicesConditions.UInt, basicSlicesConditions.UInt8, basicSlicesConditions.UInt16, basicSlicesConditions.UInt32, basicSlicesConditions.UInt64, basicSlicesConditions.UIntptr, basicSlicesConditions.Float32, basicSlicesConditions.Float64, basicSlicesConditions.Complex64, basicSlicesConditions.Complex128, basicSlicesConditions.String, basicSlicesConditions.Byte) +} diff --git a/cmd/gen/conditions/tests/results/basicslicespointer.go b/cmd/gen/conditions/tests/results/basicslicespointer.go new file mode 100644 index 0000000..2ea71d4 --- /dev/null +++ b/cmd/gen/conditions/tests/results/basicslicespointer.go @@ -0,0 +1,202 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + basicslicespointer "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/basicslicespointer" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var basicSlicesPointerType = reflect.TypeOf(*new(basicslicespointer.BasicSlicesPointer)) + +func (basicSlicesPointerConditions basicSlicesPointerConditions) IdIs() orm.FieldIs[basicslicespointer.BasicSlicesPointer, model.UUID] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, model.UUID]{FieldID: basicSlicesPointerConditions.ID} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) CreatedAtIs() orm.FieldIs[basicslicespointer.BasicSlicesPointer, time.Time] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, time.Time]{FieldID: basicSlicesPointerConditions.CreatedAt} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) UpdatedAtIs() orm.FieldIs[basicslicespointer.BasicSlicesPointer, time.Time] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, time.Time]{FieldID: basicSlicesPointerConditions.UpdatedAt} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) DeletedAtIs() orm.FieldIs[basicslicespointer.BasicSlicesPointer, time.Time] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, time.Time]{FieldID: basicSlicesPointerConditions.DeletedAt} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) BoolIs() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []bool] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []bool]{FieldID: basicSlicesPointerConditions.Bool} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) IntIs() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []int] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []int]{FieldID: basicSlicesPointerConditions.Int} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) Int8Is() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []int8] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []int8]{FieldID: basicSlicesPointerConditions.Int8} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) Int16Is() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []int16] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []int16]{FieldID: basicSlicesPointerConditions.Int16} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) Int32Is() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []int32] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []int32]{FieldID: basicSlicesPointerConditions.Int32} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) Int64Is() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []int64] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []int64]{FieldID: basicSlicesPointerConditions.Int64} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) UIntIs() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uint] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uint]{FieldID: basicSlicesPointerConditions.UInt} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) UInt8Is() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uint8] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uint8]{FieldID: basicSlicesPointerConditions.UInt8} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) UInt16Is() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uint16] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uint16]{FieldID: basicSlicesPointerConditions.UInt16} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) UInt32Is() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uint32] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uint32]{FieldID: basicSlicesPointerConditions.UInt32} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) UInt64Is() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uint64] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uint64]{FieldID: basicSlicesPointerConditions.UInt64} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) UIntptrIs() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uintptr] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uintptr]{FieldID: basicSlicesPointerConditions.UIntptr} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) Float32Is() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []float32] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []float32]{FieldID: basicSlicesPointerConditions.Float32} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) Float64Is() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []float64] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []float64]{FieldID: basicSlicesPointerConditions.Float64} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) Complex64Is() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []complex64] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []complex64]{FieldID: basicSlicesPointerConditions.Complex64} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) Complex128Is() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []complex128] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []complex128]{FieldID: basicSlicesPointerConditions.Complex128} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) StringIs() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []string] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []string]{FieldID: basicSlicesPointerConditions.String} +} +func (basicSlicesPointerConditions basicSlicesPointerConditions) ByteIs() orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uint8] { + return orm.FieldIs[basicslicespointer.BasicSlicesPointer, []uint8]{FieldID: basicSlicesPointerConditions.Byte} +} + +type basicSlicesPointerConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + Bool query.FieldIdentifier[[]bool] + Int query.FieldIdentifier[[]int] + Int8 query.FieldIdentifier[[]int8] + Int16 query.FieldIdentifier[[]int16] + Int32 query.FieldIdentifier[[]int32] + Int64 query.FieldIdentifier[[]int64] + UInt query.FieldIdentifier[[]uint] + UInt8 query.FieldIdentifier[[]uint8] + UInt16 query.FieldIdentifier[[]uint16] + UInt32 query.FieldIdentifier[[]uint32] + UInt64 query.FieldIdentifier[[]uint64] + UIntptr query.FieldIdentifier[[]uintptr] + Float32 query.FieldIdentifier[[]float32] + Float64 query.FieldIdentifier[[]float64] + Complex64 query.FieldIdentifier[[]complex64] + Complex128 query.FieldIdentifier[[]complex128] + String query.FieldIdentifier[[]string] + Byte query.FieldIdentifier[[]uint8] +} + +var BasicSlicesPointer = basicSlicesPointerConditions{ + Bool: query.FieldIdentifier[[]bool]{ + Field: "Bool", + ModelType: basicSlicesPointerType, + }, + Byte: query.FieldIdentifier[[]uint8]{ + Field: "Byte", + ModelType: basicSlicesPointerType, + }, + Complex128: query.FieldIdentifier[[]complex128]{ + Field: "Complex128", + ModelType: basicSlicesPointerType, + }, + Complex64: query.FieldIdentifier[[]complex64]{ + Field: "Complex64", + ModelType: basicSlicesPointerType, + }, + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: basicSlicesPointerType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: basicSlicesPointerType, + }, + Float32: query.FieldIdentifier[[]float32]{ + Field: "Float32", + ModelType: basicSlicesPointerType, + }, + Float64: query.FieldIdentifier[[]float64]{ + Field: "Float64", + ModelType: basicSlicesPointerType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: basicSlicesPointerType, + }, + Int: query.FieldIdentifier[[]int]{ + Field: "Int", + ModelType: basicSlicesPointerType, + }, + Int16: query.FieldIdentifier[[]int16]{ + Field: "Int16", + ModelType: basicSlicesPointerType, + }, + Int32: query.FieldIdentifier[[]int32]{ + Field: "Int32", + ModelType: basicSlicesPointerType, + }, + Int64: query.FieldIdentifier[[]int64]{ + Field: "Int64", + ModelType: basicSlicesPointerType, + }, + Int8: query.FieldIdentifier[[]int8]{ + Field: "Int8", + ModelType: basicSlicesPointerType, + }, + String: query.FieldIdentifier[[]string]{ + Field: "String", + ModelType: basicSlicesPointerType, + }, + UInt: query.FieldIdentifier[[]uint]{ + Field: "UInt", + ModelType: basicSlicesPointerType, + }, + UInt16: query.FieldIdentifier[[]uint16]{ + Field: "UInt16", + ModelType: basicSlicesPointerType, + }, + UInt32: query.FieldIdentifier[[]uint32]{ + Field: "UInt32", + ModelType: basicSlicesPointerType, + }, + UInt64: query.FieldIdentifier[[]uint64]{ + Field: "UInt64", + ModelType: basicSlicesPointerType, + }, + UInt8: query.FieldIdentifier[[]uint8]{ + Field: "UInt8", + ModelType: basicSlicesPointerType, + }, + UIntptr: query.FieldIdentifier[[]uintptr]{ + Field: "UIntptr", + ModelType: basicSlicesPointerType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: basicSlicesPointerType, + }, +} + +// Preload allows preloading the BasicSlicesPointer when doing a query +func (basicSlicesPointerConditions basicSlicesPointerConditions) Preload() condition.Condition[basicslicespointer.BasicSlicesPointer] { + return condition.NewPreloadCondition[basicslicespointer.BasicSlicesPointer](basicSlicesPointerConditions.ID, basicSlicesPointerConditions.CreatedAt, basicSlicesPointerConditions.UpdatedAt, basicSlicesPointerConditions.DeletedAt, basicSlicesPointerConditions.Bool, basicSlicesPointerConditions.Int, basicSlicesPointerConditions.Int8, basicSlicesPointerConditions.Int16, basicSlicesPointerConditions.Int32, basicSlicesPointerConditions.Int64, basicSlicesPointerConditions.UInt, basicSlicesPointerConditions.UInt8, basicSlicesPointerConditions.UInt16, basicSlicesPointerConditions.UInt32, basicSlicesPointerConditions.UInt64, basicSlicesPointerConditions.UIntptr, basicSlicesPointerConditions.Float32, basicSlicesPointerConditions.Float64, basicSlicesPointerConditions.Complex64, basicSlicesPointerConditions.Complex128, basicSlicesPointerConditions.String, basicSlicesPointerConditions.Byte) +} diff --git a/cmd/gen/conditions/tests/results/basictypes.go b/cmd/gen/conditions/tests/results/basictypes.go new file mode 100644 index 0000000..f673166 --- /dev/null +++ b/cmd/gen/conditions/tests/results/basictypes.go @@ -0,0 +1,202 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + basictypes "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/basictypes" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var basicTypesType = reflect.TypeOf(*new(basictypes.BasicTypes)) + +func (basicTypesConditions basicTypesConditions) IdIs() orm.FieldIs[basictypes.BasicTypes, model.UUID] { + return orm.FieldIs[basictypes.BasicTypes, model.UUID]{FieldID: basicTypesConditions.ID} +} +func (basicTypesConditions basicTypesConditions) CreatedAtIs() orm.FieldIs[basictypes.BasicTypes, time.Time] { + return orm.FieldIs[basictypes.BasicTypes, time.Time]{FieldID: basicTypesConditions.CreatedAt} +} +func (basicTypesConditions basicTypesConditions) UpdatedAtIs() orm.FieldIs[basictypes.BasicTypes, time.Time] { + return orm.FieldIs[basictypes.BasicTypes, time.Time]{FieldID: basicTypesConditions.UpdatedAt} +} +func (basicTypesConditions basicTypesConditions) DeletedAtIs() orm.FieldIs[basictypes.BasicTypes, time.Time] { + return orm.FieldIs[basictypes.BasicTypes, time.Time]{FieldID: basicTypesConditions.DeletedAt} +} +func (basicTypesConditions basicTypesConditions) BoolIs() orm.BoolFieldIs[basictypes.BasicTypes] { + return orm.BoolFieldIs[basictypes.BasicTypes]{FieldIs: orm.FieldIs[basictypes.BasicTypes, bool]{FieldID: basicTypesConditions.Bool}} +} +func (basicTypesConditions basicTypesConditions) IntIs() orm.FieldIs[basictypes.BasicTypes, int] { + return orm.FieldIs[basictypes.BasicTypes, int]{FieldID: basicTypesConditions.Int} +} +func (basicTypesConditions basicTypesConditions) Int8Is() orm.FieldIs[basictypes.BasicTypes, int8] { + return orm.FieldIs[basictypes.BasicTypes, int8]{FieldID: basicTypesConditions.Int8} +} +func (basicTypesConditions basicTypesConditions) Int16Is() orm.FieldIs[basictypes.BasicTypes, int16] { + return orm.FieldIs[basictypes.BasicTypes, int16]{FieldID: basicTypesConditions.Int16} +} +func (basicTypesConditions basicTypesConditions) Int32Is() orm.FieldIs[basictypes.BasicTypes, int32] { + return orm.FieldIs[basictypes.BasicTypes, int32]{FieldID: basicTypesConditions.Int32} +} +func (basicTypesConditions basicTypesConditions) Int64Is() orm.FieldIs[basictypes.BasicTypes, int64] { + return orm.FieldIs[basictypes.BasicTypes, int64]{FieldID: basicTypesConditions.Int64} +} +func (basicTypesConditions basicTypesConditions) UIntIs() orm.FieldIs[basictypes.BasicTypes, uint] { + return orm.FieldIs[basictypes.BasicTypes, uint]{FieldID: basicTypesConditions.UInt} +} +func (basicTypesConditions basicTypesConditions) UInt8Is() orm.FieldIs[basictypes.BasicTypes, uint8] { + return orm.FieldIs[basictypes.BasicTypes, uint8]{FieldID: basicTypesConditions.UInt8} +} +func (basicTypesConditions basicTypesConditions) UInt16Is() orm.FieldIs[basictypes.BasicTypes, uint16] { + return orm.FieldIs[basictypes.BasicTypes, uint16]{FieldID: basicTypesConditions.UInt16} +} +func (basicTypesConditions basicTypesConditions) UInt32Is() orm.FieldIs[basictypes.BasicTypes, uint32] { + return orm.FieldIs[basictypes.BasicTypes, uint32]{FieldID: basicTypesConditions.UInt32} +} +func (basicTypesConditions basicTypesConditions) UInt64Is() orm.FieldIs[basictypes.BasicTypes, uint64] { + return orm.FieldIs[basictypes.BasicTypes, uint64]{FieldID: basicTypesConditions.UInt64} +} +func (basicTypesConditions basicTypesConditions) UIntptrIs() orm.FieldIs[basictypes.BasicTypes, uintptr] { + return orm.FieldIs[basictypes.BasicTypes, uintptr]{FieldID: basicTypesConditions.UIntptr} +} +func (basicTypesConditions basicTypesConditions) Float32Is() orm.FieldIs[basictypes.BasicTypes, float32] { + return orm.FieldIs[basictypes.BasicTypes, float32]{FieldID: basicTypesConditions.Float32} +} +func (basicTypesConditions basicTypesConditions) Float64Is() orm.FieldIs[basictypes.BasicTypes, float64] { + return orm.FieldIs[basictypes.BasicTypes, float64]{FieldID: basicTypesConditions.Float64} +} +func (basicTypesConditions basicTypesConditions) Complex64Is() orm.FieldIs[basictypes.BasicTypes, complex64] { + return orm.FieldIs[basictypes.BasicTypes, complex64]{FieldID: basicTypesConditions.Complex64} +} +func (basicTypesConditions basicTypesConditions) Complex128Is() orm.FieldIs[basictypes.BasicTypes, complex128] { + return orm.FieldIs[basictypes.BasicTypes, complex128]{FieldID: basicTypesConditions.Complex128} +} +func (basicTypesConditions basicTypesConditions) StringIs() orm.StringFieldIs[basictypes.BasicTypes] { + return orm.StringFieldIs[basictypes.BasicTypes]{FieldIs: orm.FieldIs[basictypes.BasicTypes, string]{FieldID: basicTypesConditions.String}} +} +func (basicTypesConditions basicTypesConditions) ByteIs() orm.FieldIs[basictypes.BasicTypes, uint8] { + return orm.FieldIs[basictypes.BasicTypes, uint8]{FieldID: basicTypesConditions.Byte} +} + +type basicTypesConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + Bool query.FieldIdentifier[bool] + Int query.FieldIdentifier[int] + Int8 query.FieldIdentifier[int8] + Int16 query.FieldIdentifier[int16] + Int32 query.FieldIdentifier[int32] + Int64 query.FieldIdentifier[int64] + UInt query.FieldIdentifier[uint] + UInt8 query.FieldIdentifier[uint8] + UInt16 query.FieldIdentifier[uint16] + UInt32 query.FieldIdentifier[uint32] + UInt64 query.FieldIdentifier[uint64] + UIntptr query.FieldIdentifier[uintptr] + Float32 query.FieldIdentifier[float32] + Float64 query.FieldIdentifier[float64] + Complex64 query.FieldIdentifier[complex64] + Complex128 query.FieldIdentifier[complex128] + String query.FieldIdentifier[string] + Byte query.FieldIdentifier[uint8] +} + +var BasicTypes = basicTypesConditions{ + Bool: query.FieldIdentifier[bool]{ + Field: "Bool", + ModelType: basicTypesType, + }, + Byte: query.FieldIdentifier[uint8]{ + Field: "Byte", + ModelType: basicTypesType, + }, + Complex128: query.FieldIdentifier[complex128]{ + Field: "Complex128", + ModelType: basicTypesType, + }, + Complex64: query.FieldIdentifier[complex64]{ + Field: "Complex64", + ModelType: basicTypesType, + }, + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: basicTypesType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: basicTypesType, + }, + Float32: query.FieldIdentifier[float32]{ + Field: "Float32", + ModelType: basicTypesType, + }, + Float64: query.FieldIdentifier[float64]{ + Field: "Float64", + ModelType: basicTypesType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: basicTypesType, + }, + Int: query.FieldIdentifier[int]{ + Field: "Int", + ModelType: basicTypesType, + }, + Int16: query.FieldIdentifier[int16]{ + Field: "Int16", + ModelType: basicTypesType, + }, + Int32: query.FieldIdentifier[int32]{ + Field: "Int32", + ModelType: basicTypesType, + }, + Int64: query.FieldIdentifier[int64]{ + Field: "Int64", + ModelType: basicTypesType, + }, + Int8: query.FieldIdentifier[int8]{ + Field: "Int8", + ModelType: basicTypesType, + }, + String: query.FieldIdentifier[string]{ + Field: "String", + ModelType: basicTypesType, + }, + UInt: query.FieldIdentifier[uint]{ + Field: "UInt", + ModelType: basicTypesType, + }, + UInt16: query.FieldIdentifier[uint16]{ + Field: "UInt16", + ModelType: basicTypesType, + }, + UInt32: query.FieldIdentifier[uint32]{ + Field: "UInt32", + ModelType: basicTypesType, + }, + UInt64: query.FieldIdentifier[uint64]{ + Field: "UInt64", + ModelType: basicTypesType, + }, + UInt8: query.FieldIdentifier[uint8]{ + Field: "UInt8", + ModelType: basicTypesType, + }, + UIntptr: query.FieldIdentifier[uintptr]{ + Field: "UIntptr", + ModelType: basicTypesType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: basicTypesType, + }, +} + +// Preload allows preloading the BasicTypes when doing a query +func (basicTypesConditions basicTypesConditions) Preload() condition.Condition[basictypes.BasicTypes] { + return condition.NewPreloadCondition[basictypes.BasicTypes](basicTypesConditions.ID, basicTypesConditions.CreatedAt, basicTypesConditions.UpdatedAt, basicTypesConditions.DeletedAt, basicTypesConditions.Bool, basicTypesConditions.Int, basicTypesConditions.Int8, basicTypesConditions.Int16, basicTypesConditions.Int32, basicTypesConditions.Int64, basicTypesConditions.UInt, basicTypesConditions.UInt8, basicTypesConditions.UInt16, basicTypesConditions.UInt32, basicTypesConditions.UInt64, basicTypesConditions.UIntptr, basicTypesConditions.Float32, basicTypesConditions.Float64, basicTypesConditions.Complex64, basicTypesConditions.Complex128, basicTypesConditions.String, basicTypesConditions.Byte) +} diff --git a/cmd/gen/conditions/tests/results/belongsto_owned.go b/cmd/gen/conditions/tests/results/belongsto_owned.go new file mode 100644 index 0000000..3324cf8 --- /dev/null +++ b/cmd/gen/conditions/tests/results/belongsto_owned.go @@ -0,0 +1,77 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + belongsto "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/belongsto" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var ownedType = reflect.TypeOf(*new(belongsto.Owned)) + +func (ownedConditions ownedConditions) IdIs() orm.FieldIs[belongsto.Owned, model.UUID] { + return orm.FieldIs[belongsto.Owned, model.UUID]{FieldID: ownedConditions.ID} +} +func (ownedConditions ownedConditions) CreatedAtIs() orm.FieldIs[belongsto.Owned, time.Time] { + return orm.FieldIs[belongsto.Owned, time.Time]{FieldID: ownedConditions.CreatedAt} +} +func (ownedConditions ownedConditions) UpdatedAtIs() orm.FieldIs[belongsto.Owned, time.Time] { + return orm.FieldIs[belongsto.Owned, time.Time]{FieldID: ownedConditions.UpdatedAt} +} +func (ownedConditions ownedConditions) DeletedAtIs() orm.FieldIs[belongsto.Owned, time.Time] { + return orm.FieldIs[belongsto.Owned, time.Time]{FieldID: ownedConditions.DeletedAt} +} +func (ownedConditions ownedConditions) Owner(conditions ...condition.Condition[belongsto.Owner]) condition.JoinCondition[belongsto.Owned] { + return condition.NewJoinCondition[belongsto.Owned, belongsto.Owner](conditions, "Owner", "OwnerID", ownedConditions.Preload(), "ID") +} +func (ownedConditions ownedConditions) PreloadOwner() condition.JoinCondition[belongsto.Owned] { + return ownedConditions.Owner(Owner.Preload()) +} +func (ownedConditions ownedConditions) OwnerIdIs() orm.FieldIs[belongsto.Owned, model.UUID] { + return orm.FieldIs[belongsto.Owned, model.UUID]{FieldID: ownedConditions.OwnerID} +} + +type ownedConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + OwnerID query.FieldIdentifier[model.UUID] +} + +var Owned = ownedConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: ownedType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: ownedType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: ownedType, + }, + OwnerID: query.FieldIdentifier[model.UUID]{ + Field: "OwnerID", + ModelType: ownedType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: ownedType, + }, +} + +// Preload allows preloading the Owned when doing a query +func (ownedConditions ownedConditions) Preload() condition.Condition[belongsto.Owned] { + return condition.NewPreloadCondition[belongsto.Owned](ownedConditions.ID, ownedConditions.CreatedAt, ownedConditions.UpdatedAt, ownedConditions.DeletedAt, ownedConditions.OwnerID) +} + +// PreloadRelations allows preloading all the Owned's relation when doing a query +func (ownedConditions ownedConditions) PreloadRelations() []condition.Condition[belongsto.Owned] { + return []condition.Condition[belongsto.Owned]{ownedConditions.PreloadOwner()} +} diff --git a/cmd/gen/conditions/tests/results/belongsto_owner.go b/cmd/gen/conditions/tests/results/belongsto_owner.go new file mode 100644 index 0000000..d72e70c --- /dev/null +++ b/cmd/gen/conditions/tests/results/belongsto_owner.go @@ -0,0 +1,58 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + belongsto "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/belongsto" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var ownerType = reflect.TypeOf(*new(belongsto.Owner)) + +func (ownerConditions ownerConditions) IdIs() orm.FieldIs[belongsto.Owner, model.UUID] { + return orm.FieldIs[belongsto.Owner, model.UUID]{FieldID: ownerConditions.ID} +} +func (ownerConditions ownerConditions) CreatedAtIs() orm.FieldIs[belongsto.Owner, time.Time] { + return orm.FieldIs[belongsto.Owner, time.Time]{FieldID: ownerConditions.CreatedAt} +} +func (ownerConditions ownerConditions) UpdatedAtIs() orm.FieldIs[belongsto.Owner, time.Time] { + return orm.FieldIs[belongsto.Owner, time.Time]{FieldID: ownerConditions.UpdatedAt} +} +func (ownerConditions ownerConditions) DeletedAtIs() orm.FieldIs[belongsto.Owner, time.Time] { + return orm.FieldIs[belongsto.Owner, time.Time]{FieldID: ownerConditions.DeletedAt} +} + +type ownerConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] +} + +var Owner = ownerConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: ownerType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: ownerType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: ownerType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: ownerType, + }, +} + +// Preload allows preloading the Owner when doing a query +func (ownerConditions ownerConditions) Preload() condition.Condition[belongsto.Owner] { + return condition.NewPreloadCondition[belongsto.Owner](ownerConditions.ID, ownerConditions.CreatedAt, ownerConditions.UpdatedAt, ownerConditions.DeletedAt) +} diff --git a/cmd/gen/conditions/tests/results/columndefinition.go b/cmd/gen/conditions/tests/results/columndefinition.go new file mode 100644 index 0000000..18dcaed --- /dev/null +++ b/cmd/gen/conditions/tests/results/columndefinition.go @@ -0,0 +1,67 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + columndefinition "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/columndefinition" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var columnDefinitionType = reflect.TypeOf(*new(columndefinition.ColumnDefinition)) + +func (columnDefinitionConditions columnDefinitionConditions) IdIs() orm.FieldIs[columndefinition.ColumnDefinition, model.UUID] { + return orm.FieldIs[columndefinition.ColumnDefinition, model.UUID]{FieldID: columnDefinitionConditions.ID} +} +func (columnDefinitionConditions columnDefinitionConditions) CreatedAtIs() orm.FieldIs[columndefinition.ColumnDefinition, time.Time] { + return orm.FieldIs[columndefinition.ColumnDefinition, time.Time]{FieldID: columnDefinitionConditions.CreatedAt} +} +func (columnDefinitionConditions columnDefinitionConditions) UpdatedAtIs() orm.FieldIs[columndefinition.ColumnDefinition, time.Time] { + return orm.FieldIs[columndefinition.ColumnDefinition, time.Time]{FieldID: columnDefinitionConditions.UpdatedAt} +} +func (columnDefinitionConditions columnDefinitionConditions) DeletedAtIs() orm.FieldIs[columndefinition.ColumnDefinition, time.Time] { + return orm.FieldIs[columndefinition.ColumnDefinition, time.Time]{FieldID: columnDefinitionConditions.DeletedAt} +} +func (columnDefinitionConditions columnDefinitionConditions) StringIs() orm.StringFieldIs[columndefinition.ColumnDefinition] { + return orm.StringFieldIs[columndefinition.ColumnDefinition]{FieldIs: orm.FieldIs[columndefinition.ColumnDefinition, string]{FieldID: columnDefinitionConditions.String}} +} + +type columnDefinitionConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + String query.FieldIdentifier[string] +} + +var ColumnDefinition = columnDefinitionConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: columnDefinitionType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: columnDefinitionType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: columnDefinitionType, + }, + String: query.FieldIdentifier[string]{ + Column: "string_something_else", + Field: "String", + ModelType: columnDefinitionType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: columnDefinitionType, + }, +} + +// Preload allows preloading the ColumnDefinition when doing a query +func (columnDefinitionConditions columnDefinitionConditions) Preload() condition.Condition[columndefinition.ColumnDefinition] { + return condition.NewPreloadCondition[columndefinition.ColumnDefinition](columnDefinitionConditions.ID, columnDefinitionConditions.CreatedAt, columnDefinitionConditions.UpdatedAt, columnDefinitionConditions.DeletedAt, columnDefinitionConditions.String) +} diff --git a/cmd/gen/conditions/tests/results/customtype.go b/cmd/gen/conditions/tests/results/customtype.go new file mode 100644 index 0000000..a338f00 --- /dev/null +++ b/cmd/gen/conditions/tests/results/customtype.go @@ -0,0 +1,66 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + customtype "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/customtype" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var customTypeType = reflect.TypeOf(*new(customtype.CustomType)) + +func (customTypeConditions customTypeConditions) IdIs() orm.FieldIs[customtype.CustomType, model.UUID] { + return orm.FieldIs[customtype.CustomType, model.UUID]{FieldID: customTypeConditions.ID} +} +func (customTypeConditions customTypeConditions) CreatedAtIs() orm.FieldIs[customtype.CustomType, time.Time] { + return orm.FieldIs[customtype.CustomType, time.Time]{FieldID: customTypeConditions.CreatedAt} +} +func (customTypeConditions customTypeConditions) UpdatedAtIs() orm.FieldIs[customtype.CustomType, time.Time] { + return orm.FieldIs[customtype.CustomType, time.Time]{FieldID: customTypeConditions.UpdatedAt} +} +func (customTypeConditions customTypeConditions) DeletedAtIs() orm.FieldIs[customtype.CustomType, time.Time] { + return orm.FieldIs[customtype.CustomType, time.Time]{FieldID: customTypeConditions.DeletedAt} +} +func (customTypeConditions customTypeConditions) CustomIs() orm.FieldIs[customtype.CustomType, customtype.MultiString] { + return orm.FieldIs[customtype.CustomType, customtype.MultiString]{FieldID: customTypeConditions.Custom} +} + +type customTypeConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + Custom query.FieldIdentifier[customtype.MultiString] +} + +var CustomType = customTypeConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: customTypeType, + }, + Custom: query.FieldIdentifier[customtype.MultiString]{ + Field: "Custom", + ModelType: customTypeType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: customTypeType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: customTypeType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: customTypeType, + }, +} + +// Preload allows preloading the CustomType when doing a query +func (customTypeConditions customTypeConditions) Preload() condition.Condition[customtype.CustomType] { + return condition.NewPreloadCondition[customtype.CustomType](customTypeConditions.ID, customTypeConditions.CreatedAt, customTypeConditions.UpdatedAt, customTypeConditions.DeletedAt, customTypeConditions.Custom) +} diff --git a/cmd/gen/conditions/tests/results/goembedded.go b/cmd/gen/conditions/tests/results/goembedded.go new file mode 100644 index 0000000..a08a18e --- /dev/null +++ b/cmd/gen/conditions/tests/results/goembedded.go @@ -0,0 +1,74 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + goembedded "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/goembedded" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var goEmbeddedType = reflect.TypeOf(*new(goembedded.GoEmbedded)) + +func (goEmbeddedConditions goEmbeddedConditions) IdIs() orm.FieldIs[goembedded.GoEmbedded, model.UIntID] { + return orm.FieldIs[goembedded.GoEmbedded, model.UIntID]{FieldID: goEmbeddedConditions.ID} +} +func (goEmbeddedConditions goEmbeddedConditions) CreatedAtIs() orm.FieldIs[goembedded.GoEmbedded, time.Time] { + return orm.FieldIs[goembedded.GoEmbedded, time.Time]{FieldID: goEmbeddedConditions.CreatedAt} +} +func (goEmbeddedConditions goEmbeddedConditions) UpdatedAtIs() orm.FieldIs[goembedded.GoEmbedded, time.Time] { + return orm.FieldIs[goembedded.GoEmbedded, time.Time]{FieldID: goEmbeddedConditions.UpdatedAt} +} +func (goEmbeddedConditions goEmbeddedConditions) DeletedAtIs() orm.FieldIs[goembedded.GoEmbedded, time.Time] { + return orm.FieldIs[goembedded.GoEmbedded, time.Time]{FieldID: goEmbeddedConditions.DeletedAt} +} +func (goEmbeddedConditions goEmbeddedConditions) IntIs() orm.FieldIs[goembedded.GoEmbedded, int] { + return orm.FieldIs[goembedded.GoEmbedded, int]{FieldID: goEmbeddedConditions.Int} +} +func (goEmbeddedConditions goEmbeddedConditions) ToBeEmbeddedIntIs() orm.FieldIs[goembedded.GoEmbedded, int] { + return orm.FieldIs[goembedded.GoEmbedded, int]{FieldID: goEmbeddedConditions.ToBeEmbeddedInt} +} + +type goEmbeddedConditions struct { + ID query.FieldIdentifier[model.UIntID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + Int query.FieldIdentifier[int] + ToBeEmbeddedInt query.FieldIdentifier[int] +} + +var GoEmbedded = goEmbeddedConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: goEmbeddedType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: goEmbeddedType, + }, + ID: query.FieldIdentifier[model.UIntID]{ + Field: "ID", + ModelType: goEmbeddedType, + }, + Int: query.FieldIdentifier[int]{ + Field: "Int", + ModelType: goEmbeddedType, + }, + ToBeEmbeddedInt: query.FieldIdentifier[int]{ + Field: "Int", + ModelType: goEmbeddedType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: goEmbeddedType, + }, +} + +// Preload allows preloading the GoEmbedded when doing a query +func (goEmbeddedConditions goEmbeddedConditions) Preload() condition.Condition[goembedded.GoEmbedded] { + return condition.NewPreloadCondition[goembedded.GoEmbedded](goEmbeddedConditions.ID, goEmbeddedConditions.CreatedAt, goEmbeddedConditions.UpdatedAt, goEmbeddedConditions.DeletedAt, goEmbeddedConditions.Int, goEmbeddedConditions.ToBeEmbeddedInt) +} diff --git a/cmd/gen/conditions/tests/results/gormembedded.go b/cmd/gen/conditions/tests/results/gormembedded.go new file mode 100644 index 0000000..cc22aef --- /dev/null +++ b/cmd/gen/conditions/tests/results/gormembedded.go @@ -0,0 +1,83 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + gormembedded "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/gormembedded" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var gormEmbeddedType = reflect.TypeOf(*new(gormembedded.GormEmbedded)) + +func (gormEmbeddedConditions gormEmbeddedConditions) IdIs() orm.FieldIs[gormembedded.GormEmbedded, model.UIntID] { + return orm.FieldIs[gormembedded.GormEmbedded, model.UIntID]{FieldID: gormEmbeddedConditions.ID} +} +func (gormEmbeddedConditions gormEmbeddedConditions) CreatedAtIs() orm.FieldIs[gormembedded.GormEmbedded, time.Time] { + return orm.FieldIs[gormembedded.GormEmbedded, time.Time]{FieldID: gormEmbeddedConditions.CreatedAt} +} +func (gormEmbeddedConditions gormEmbeddedConditions) UpdatedAtIs() orm.FieldIs[gormembedded.GormEmbedded, time.Time] { + return orm.FieldIs[gormembedded.GormEmbedded, time.Time]{FieldID: gormEmbeddedConditions.UpdatedAt} +} +func (gormEmbeddedConditions gormEmbeddedConditions) DeletedAtIs() orm.FieldIs[gormembedded.GormEmbedded, time.Time] { + return orm.FieldIs[gormembedded.GormEmbedded, time.Time]{FieldID: gormEmbeddedConditions.DeletedAt} +} +func (gormEmbeddedConditions gormEmbeddedConditions) IntIs() orm.FieldIs[gormembedded.GormEmbedded, int] { + return orm.FieldIs[gormembedded.GormEmbedded, int]{FieldID: gormEmbeddedConditions.Int} +} +func (gormEmbeddedConditions gormEmbeddedConditions) GormEmbeddedIntIs() orm.FieldIs[gormembedded.GormEmbedded, int] { + return orm.FieldIs[gormembedded.GormEmbedded, int]{FieldID: gormEmbeddedConditions.GormEmbeddedInt} +} +func (gormEmbeddedConditions gormEmbeddedConditions) GormEmbeddedNoPrefixIntIs() orm.FieldIs[gormembedded.GormEmbedded, int] { + return orm.FieldIs[gormembedded.GormEmbedded, int]{FieldID: gormEmbeddedConditions.GormEmbeddedNoPrefixInt} +} + +type gormEmbeddedConditions struct { + ID query.FieldIdentifier[model.UIntID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + Int query.FieldIdentifier[int] + GormEmbeddedInt query.FieldIdentifier[int] + GormEmbeddedNoPrefixInt query.FieldIdentifier[int] +} + +var GormEmbedded = gormEmbeddedConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: gormEmbeddedType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: gormEmbeddedType, + }, + GormEmbeddedInt: query.FieldIdentifier[int]{ + ColumnPrefix: "gorm_embedded_", + Field: "Int", + ModelType: gormEmbeddedType, + }, + GormEmbeddedNoPrefixInt: query.FieldIdentifier[int]{ + Field: "Int", + ModelType: gormEmbeddedType, + }, + ID: query.FieldIdentifier[model.UIntID]{ + Field: "ID", + ModelType: gormEmbeddedType, + }, + Int: query.FieldIdentifier[int]{ + Field: "Int", + ModelType: gormEmbeddedType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: gormEmbeddedType, + }, +} + +// Preload allows preloading the GormEmbedded when doing a query +func (gormEmbeddedConditions gormEmbeddedConditions) Preload() condition.Condition[gormembedded.GormEmbedded] { + return condition.NewPreloadCondition[gormembedded.GormEmbedded](gormEmbeddedConditions.ID, gormEmbeddedConditions.CreatedAt, gormEmbeddedConditions.UpdatedAt, gormEmbeddedConditions.DeletedAt, gormEmbeddedConditions.Int, gormEmbeddedConditions.GormEmbeddedInt, gormEmbeddedConditions.GormEmbeddedNoPrefixInt) +} diff --git a/cmd/gen/conditions/tests/results/hasmany_company.go b/cmd/gen/conditions/tests/results/hasmany_company.go new file mode 100644 index 0000000..921217e --- /dev/null +++ b/cmd/gen/conditions/tests/results/hasmany_company.go @@ -0,0 +1,66 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + hasmany "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/hasmany" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var companyType = reflect.TypeOf(*new(hasmany.Company)) + +func (companyConditions companyConditions) IdIs() orm.FieldIs[hasmany.Company, model.UUID] { + return orm.FieldIs[hasmany.Company, model.UUID]{FieldID: companyConditions.ID} +} +func (companyConditions companyConditions) CreatedAtIs() orm.FieldIs[hasmany.Company, time.Time] { + return orm.FieldIs[hasmany.Company, time.Time]{FieldID: companyConditions.CreatedAt} +} +func (companyConditions companyConditions) UpdatedAtIs() orm.FieldIs[hasmany.Company, time.Time] { + return orm.FieldIs[hasmany.Company, time.Time]{FieldID: companyConditions.UpdatedAt} +} +func (companyConditions companyConditions) DeletedAtIs() orm.FieldIs[hasmany.Company, time.Time] { + return orm.FieldIs[hasmany.Company, time.Time]{FieldID: companyConditions.DeletedAt} +} +func (companyConditions companyConditions) PreloadSellers(nestedPreloads ...condition.JoinCondition[hasmany.Seller]) condition.Condition[hasmany.Company] { + return condition.NewCollectionPreloadCondition[hasmany.Company, hasmany.Seller]("Sellers", nestedPreloads) +} + +type companyConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] +} + +var Company = companyConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: companyType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: companyType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: companyType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: companyType, + }, +} + +// Preload allows preloading the Company when doing a query +func (companyConditions companyConditions) Preload() condition.Condition[hasmany.Company] { + return condition.NewPreloadCondition[hasmany.Company](companyConditions.ID, companyConditions.CreatedAt, companyConditions.UpdatedAt, companyConditions.DeletedAt) +} + +// PreloadRelations allows preloading all the Company's relation when doing a query +func (companyConditions companyConditions) PreloadRelations() []condition.Condition[hasmany.Company] { + return []condition.Condition[hasmany.Company]{companyConditions.PreloadSellers()} +} diff --git a/cmd/gen/conditions/tests/results/hasmany_seller.go b/cmd/gen/conditions/tests/results/hasmany_seller.go new file mode 100644 index 0000000..39e0b06 --- /dev/null +++ b/cmd/gen/conditions/tests/results/hasmany_seller.go @@ -0,0 +1,77 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + hasmany "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/hasmany" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var sellerType = reflect.TypeOf(*new(hasmany.Seller)) + +func (sellerConditions sellerConditions) IdIs() orm.FieldIs[hasmany.Seller, model.UUID] { + return orm.FieldIs[hasmany.Seller, model.UUID]{FieldID: sellerConditions.ID} +} +func (sellerConditions sellerConditions) CreatedAtIs() orm.FieldIs[hasmany.Seller, time.Time] { + return orm.FieldIs[hasmany.Seller, time.Time]{FieldID: sellerConditions.CreatedAt} +} +func (sellerConditions sellerConditions) UpdatedAtIs() orm.FieldIs[hasmany.Seller, time.Time] { + return orm.FieldIs[hasmany.Seller, time.Time]{FieldID: sellerConditions.UpdatedAt} +} +func (sellerConditions sellerConditions) DeletedAtIs() orm.FieldIs[hasmany.Seller, time.Time] { + return orm.FieldIs[hasmany.Seller, time.Time]{FieldID: sellerConditions.DeletedAt} +} +func (sellerConditions sellerConditions) Company(conditions ...condition.Condition[hasmany.Company]) condition.JoinCondition[hasmany.Seller] { + return condition.NewJoinCondition[hasmany.Seller, hasmany.Company](conditions, "Company", "CompanyID", sellerConditions.Preload(), "ID") +} +func (sellerConditions sellerConditions) PreloadCompany() condition.JoinCondition[hasmany.Seller] { + return sellerConditions.Company(Company.Preload()) +} +func (sellerConditions sellerConditions) CompanyIdIs() orm.FieldIs[hasmany.Seller, model.UUID] { + return orm.FieldIs[hasmany.Seller, model.UUID]{FieldID: sellerConditions.CompanyID} +} + +type sellerConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + CompanyID query.FieldIdentifier[model.UUID] +} + +var Seller = sellerConditions{ + CompanyID: query.FieldIdentifier[model.UUID]{ + Field: "CompanyID", + ModelType: sellerType, + }, + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: sellerType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: sellerType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: sellerType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: sellerType, + }, +} + +// Preload allows preloading the Seller when doing a query +func (sellerConditions sellerConditions) Preload() condition.Condition[hasmany.Seller] { + return condition.NewPreloadCondition[hasmany.Seller](sellerConditions.ID, sellerConditions.CreatedAt, sellerConditions.UpdatedAt, sellerConditions.DeletedAt, sellerConditions.CompanyID) +} + +// PreloadRelations allows preloading all the Seller's relation when doing a query +func (sellerConditions sellerConditions) PreloadRelations() []condition.Condition[hasmany.Seller] { + return []condition.Condition[hasmany.Seller]{sellerConditions.PreloadCompany()} +} diff --git a/cmd/gen/conditions/tests/results/hasmanywithpointers_company.go b/cmd/gen/conditions/tests/results/hasmanywithpointers_company.go new file mode 100644 index 0000000..1840cc2 --- /dev/null +++ b/cmd/gen/conditions/tests/results/hasmanywithpointers_company.go @@ -0,0 +1,66 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + hasmanywithpointers "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/hasmanywithpointers" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var companyWithPointersType = reflect.TypeOf(*new(hasmanywithpointers.CompanyWithPointers)) + +func (companyWithPointersConditions companyWithPointersConditions) IdIs() orm.FieldIs[hasmanywithpointers.CompanyWithPointers, model.UUID] { + return orm.FieldIs[hasmanywithpointers.CompanyWithPointers, model.UUID]{FieldID: companyWithPointersConditions.ID} +} +func (companyWithPointersConditions companyWithPointersConditions) CreatedAtIs() orm.FieldIs[hasmanywithpointers.CompanyWithPointers, time.Time] { + return orm.FieldIs[hasmanywithpointers.CompanyWithPointers, time.Time]{FieldID: companyWithPointersConditions.CreatedAt} +} +func (companyWithPointersConditions companyWithPointersConditions) UpdatedAtIs() orm.FieldIs[hasmanywithpointers.CompanyWithPointers, time.Time] { + return orm.FieldIs[hasmanywithpointers.CompanyWithPointers, time.Time]{FieldID: companyWithPointersConditions.UpdatedAt} +} +func (companyWithPointersConditions companyWithPointersConditions) DeletedAtIs() orm.FieldIs[hasmanywithpointers.CompanyWithPointers, time.Time] { + return orm.FieldIs[hasmanywithpointers.CompanyWithPointers, time.Time]{FieldID: companyWithPointersConditions.DeletedAt} +} +func (companyWithPointersConditions companyWithPointersConditions) PreloadSellers(nestedPreloads ...condition.JoinCondition[hasmanywithpointers.SellerInPointers]) condition.Condition[hasmanywithpointers.CompanyWithPointers] { + return condition.NewCollectionPreloadCondition[hasmanywithpointers.CompanyWithPointers, hasmanywithpointers.SellerInPointers]("Sellers", nestedPreloads) +} + +type companyWithPointersConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] +} + +var CompanyWithPointers = companyWithPointersConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: companyWithPointersType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: companyWithPointersType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: companyWithPointersType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: companyWithPointersType, + }, +} + +// Preload allows preloading the CompanyWithPointers when doing a query +func (companyWithPointersConditions companyWithPointersConditions) Preload() condition.Condition[hasmanywithpointers.CompanyWithPointers] { + return condition.NewPreloadCondition[hasmanywithpointers.CompanyWithPointers](companyWithPointersConditions.ID, companyWithPointersConditions.CreatedAt, companyWithPointersConditions.UpdatedAt, companyWithPointersConditions.DeletedAt) +} + +// PreloadRelations allows preloading all the CompanyWithPointers's relation when doing a query +func (companyWithPointersConditions companyWithPointersConditions) PreloadRelations() []condition.Condition[hasmanywithpointers.CompanyWithPointers] { + return []condition.Condition[hasmanywithpointers.CompanyWithPointers]{companyWithPointersConditions.PreloadSellers()} +} diff --git a/cmd/gen/conditions/tests/results/hasmanywithpointers_seller.go b/cmd/gen/conditions/tests/results/hasmanywithpointers_seller.go new file mode 100644 index 0000000..fc34564 --- /dev/null +++ b/cmd/gen/conditions/tests/results/hasmanywithpointers_seller.go @@ -0,0 +1,77 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + hasmanywithpointers "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/hasmanywithpointers" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var sellerInPointersType = reflect.TypeOf(*new(hasmanywithpointers.SellerInPointers)) + +func (sellerInPointersConditions sellerInPointersConditions) IdIs() orm.FieldIs[hasmanywithpointers.SellerInPointers, model.UUID] { + return orm.FieldIs[hasmanywithpointers.SellerInPointers, model.UUID]{FieldID: sellerInPointersConditions.ID} +} +func (sellerInPointersConditions sellerInPointersConditions) CreatedAtIs() orm.FieldIs[hasmanywithpointers.SellerInPointers, time.Time] { + return orm.FieldIs[hasmanywithpointers.SellerInPointers, time.Time]{FieldID: sellerInPointersConditions.CreatedAt} +} +func (sellerInPointersConditions sellerInPointersConditions) UpdatedAtIs() orm.FieldIs[hasmanywithpointers.SellerInPointers, time.Time] { + return orm.FieldIs[hasmanywithpointers.SellerInPointers, time.Time]{FieldID: sellerInPointersConditions.UpdatedAt} +} +func (sellerInPointersConditions sellerInPointersConditions) DeletedAtIs() orm.FieldIs[hasmanywithpointers.SellerInPointers, time.Time] { + return orm.FieldIs[hasmanywithpointers.SellerInPointers, time.Time]{FieldID: sellerInPointersConditions.DeletedAt} +} +func (sellerInPointersConditions sellerInPointersConditions) Company(conditions ...condition.Condition[hasmanywithpointers.CompanyWithPointers]) condition.JoinCondition[hasmanywithpointers.SellerInPointers] { + return condition.NewJoinCondition[hasmanywithpointers.SellerInPointers, hasmanywithpointers.CompanyWithPointers](conditions, "Company", "CompanyID", sellerInPointersConditions.Preload(), "ID") +} +func (sellerInPointersConditions sellerInPointersConditions) PreloadCompany() condition.JoinCondition[hasmanywithpointers.SellerInPointers] { + return sellerInPointersConditions.Company(CompanyWithPointers.Preload()) +} +func (sellerInPointersConditions sellerInPointersConditions) CompanyIdIs() orm.FieldIs[hasmanywithpointers.SellerInPointers, model.UUID] { + return orm.FieldIs[hasmanywithpointers.SellerInPointers, model.UUID]{FieldID: sellerInPointersConditions.CompanyID} +} + +type sellerInPointersConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + CompanyID query.FieldIdentifier[model.UUID] +} + +var SellerInPointers = sellerInPointersConditions{ + CompanyID: query.FieldIdentifier[model.UUID]{ + Field: "CompanyID", + ModelType: sellerInPointersType, + }, + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: sellerInPointersType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: sellerInPointersType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: sellerInPointersType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: sellerInPointersType, + }, +} + +// Preload allows preloading the SellerInPointers when doing a query +func (sellerInPointersConditions sellerInPointersConditions) Preload() condition.Condition[hasmanywithpointers.SellerInPointers] { + return condition.NewPreloadCondition[hasmanywithpointers.SellerInPointers](sellerInPointersConditions.ID, sellerInPointersConditions.CreatedAt, sellerInPointersConditions.UpdatedAt, sellerInPointersConditions.DeletedAt, sellerInPointersConditions.CompanyID) +} + +// PreloadRelations allows preloading all the SellerInPointers's relation when doing a query +func (sellerInPointersConditions sellerInPointersConditions) PreloadRelations() []condition.Condition[hasmanywithpointers.SellerInPointers] { + return []condition.Condition[hasmanywithpointers.SellerInPointers]{sellerInPointersConditions.PreloadCompany()} +} diff --git a/cmd/gen/conditions/tests/results/hasone_city.go b/cmd/gen/conditions/tests/results/hasone_city.go new file mode 100644 index 0000000..5fe92fa --- /dev/null +++ b/cmd/gen/conditions/tests/results/hasone_city.go @@ -0,0 +1,77 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + hasone "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/hasone" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var cityType = reflect.TypeOf(*new(hasone.City)) + +func (cityConditions cityConditions) IdIs() orm.FieldIs[hasone.City, model.UUID] { + return orm.FieldIs[hasone.City, model.UUID]{FieldID: cityConditions.ID} +} +func (cityConditions cityConditions) CreatedAtIs() orm.FieldIs[hasone.City, time.Time] { + return orm.FieldIs[hasone.City, time.Time]{FieldID: cityConditions.CreatedAt} +} +func (cityConditions cityConditions) UpdatedAtIs() orm.FieldIs[hasone.City, time.Time] { + return orm.FieldIs[hasone.City, time.Time]{FieldID: cityConditions.UpdatedAt} +} +func (cityConditions cityConditions) DeletedAtIs() orm.FieldIs[hasone.City, time.Time] { + return orm.FieldIs[hasone.City, time.Time]{FieldID: cityConditions.DeletedAt} +} +func (cityConditions cityConditions) Country(conditions ...condition.Condition[hasone.Country]) condition.JoinCondition[hasone.City] { + return condition.NewJoinCondition[hasone.City, hasone.Country](conditions, "Country", "CountryID", cityConditions.Preload(), "ID") +} +func (cityConditions cityConditions) PreloadCountry() condition.JoinCondition[hasone.City] { + return cityConditions.Country(Country.Preload()) +} +func (cityConditions cityConditions) CountryIdIs() orm.FieldIs[hasone.City, model.UUID] { + return orm.FieldIs[hasone.City, model.UUID]{FieldID: cityConditions.CountryID} +} + +type cityConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + CountryID query.FieldIdentifier[model.UUID] +} + +var City = cityConditions{ + CountryID: query.FieldIdentifier[model.UUID]{ + Field: "CountryID", + ModelType: cityType, + }, + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: cityType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: cityType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: cityType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: cityType, + }, +} + +// Preload allows preloading the City when doing a query +func (cityConditions cityConditions) Preload() condition.Condition[hasone.City] { + return condition.NewPreloadCondition[hasone.City](cityConditions.ID, cityConditions.CreatedAt, cityConditions.UpdatedAt, cityConditions.DeletedAt, cityConditions.CountryID) +} + +// PreloadRelations allows preloading all the City's relation when doing a query +func (cityConditions cityConditions) PreloadRelations() []condition.Condition[hasone.City] { + return []condition.Condition[hasone.City]{cityConditions.PreloadCountry()} +} diff --git a/cmd/gen/conditions/tests/results/hasone_country.go b/cmd/gen/conditions/tests/results/hasone_country.go new file mode 100644 index 0000000..4a8a5e7 --- /dev/null +++ b/cmd/gen/conditions/tests/results/hasone_country.go @@ -0,0 +1,69 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + hasone "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/hasone" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var countryType = reflect.TypeOf(*new(hasone.Country)) + +func (countryConditions countryConditions) IdIs() orm.FieldIs[hasone.Country, model.UUID] { + return orm.FieldIs[hasone.Country, model.UUID]{FieldID: countryConditions.ID} +} +func (countryConditions countryConditions) CreatedAtIs() orm.FieldIs[hasone.Country, time.Time] { + return orm.FieldIs[hasone.Country, time.Time]{FieldID: countryConditions.CreatedAt} +} +func (countryConditions countryConditions) UpdatedAtIs() orm.FieldIs[hasone.Country, time.Time] { + return orm.FieldIs[hasone.Country, time.Time]{FieldID: countryConditions.UpdatedAt} +} +func (countryConditions countryConditions) DeletedAtIs() orm.FieldIs[hasone.Country, time.Time] { + return orm.FieldIs[hasone.Country, time.Time]{FieldID: countryConditions.DeletedAt} +} +func (countryConditions countryConditions) Capital(conditions ...condition.Condition[hasone.City]) condition.JoinCondition[hasone.Country] { + return condition.NewJoinCondition[hasone.Country, hasone.City](conditions, "Capital", "ID", countryConditions.Preload(), "CountryID") +} +func (countryConditions countryConditions) PreloadCapital() condition.JoinCondition[hasone.Country] { + return countryConditions.Capital(City.Preload()) +} + +type countryConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] +} + +var Country = countryConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: countryType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: countryType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: countryType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: countryType, + }, +} + +// Preload allows preloading the Country when doing a query +func (countryConditions countryConditions) Preload() condition.Condition[hasone.Country] { + return condition.NewPreloadCondition[hasone.Country](countryConditions.ID, countryConditions.CreatedAt, countryConditions.UpdatedAt, countryConditions.DeletedAt) +} + +// PreloadRelations allows preloading all the Country's relation when doing a query +func (countryConditions countryConditions) PreloadRelations() []condition.Condition[hasone.Country] { + return []condition.Condition[hasone.Country]{countryConditions.PreloadCapital()} +} diff --git a/cmd/gen/conditions/tests/results/multiplepackage_package1.go b/cmd/gen/conditions/tests/results/multiplepackage_package1.go new file mode 100644 index 0000000..9f6e061 --- /dev/null +++ b/cmd/gen/conditions/tests/results/multiplepackage_package1.go @@ -0,0 +1,70 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + package1 "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/multiplepackage/package1" + package2 "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/multiplepackage/package2" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var package1Type = reflect.TypeOf(*new(package1.Package1)) + +func (package1Conditions package1Conditions) IdIs() orm.FieldIs[package1.Package1, model.UUID] { + return orm.FieldIs[package1.Package1, model.UUID]{FieldID: package1Conditions.ID} +} +func (package1Conditions package1Conditions) CreatedAtIs() orm.FieldIs[package1.Package1, time.Time] { + return orm.FieldIs[package1.Package1, time.Time]{FieldID: package1Conditions.CreatedAt} +} +func (package1Conditions package1Conditions) UpdatedAtIs() orm.FieldIs[package1.Package1, time.Time] { + return orm.FieldIs[package1.Package1, time.Time]{FieldID: package1Conditions.UpdatedAt} +} +func (package1Conditions package1Conditions) DeletedAtIs() orm.FieldIs[package1.Package1, time.Time] { + return orm.FieldIs[package1.Package1, time.Time]{FieldID: package1Conditions.DeletedAt} +} +func (package1Conditions package1Conditions) Package2(conditions ...condition.Condition[package2.Package2]) condition.JoinCondition[package1.Package1] { + return condition.NewJoinCondition[package1.Package1, package2.Package2](conditions, "Package2", "ID", package1Conditions.Preload(), "Package1ID") +} +func (package1Conditions package1Conditions) PreloadPackage2() condition.JoinCondition[package1.Package1] { + return package1Conditions.Package2(Package2.Preload()) +} + +type package1Conditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] +} + +var Package1 = package1Conditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: package1Type, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: package1Type, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: package1Type, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: package1Type, + }, +} + +// Preload allows preloading the Package1 when doing a query +func (package1Conditions package1Conditions) Preload() condition.Condition[package1.Package1] { + return condition.NewPreloadCondition[package1.Package1](package1Conditions.ID, package1Conditions.CreatedAt, package1Conditions.UpdatedAt, package1Conditions.DeletedAt) +} + +// PreloadRelations allows preloading all the Package1's relation when doing a query +func (package1Conditions package1Conditions) PreloadRelations() []condition.Condition[package1.Package1] { + return []condition.Condition[package1.Package1]{package1Conditions.PreloadPackage2()} +} diff --git a/cmd/gen/conditions/tests/results/multiplepackage_package2.go b/cmd/gen/conditions/tests/results/multiplepackage_package2.go new file mode 100644 index 0000000..0e0df8a --- /dev/null +++ b/cmd/gen/conditions/tests/results/multiplepackage_package2.go @@ -0,0 +1,66 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + package2 "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/multiplepackage/package2" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var package2Type = reflect.TypeOf(*new(package2.Package2)) + +func (package2Conditions package2Conditions) IdIs() orm.FieldIs[package2.Package2, model.UUID] { + return orm.FieldIs[package2.Package2, model.UUID]{FieldID: package2Conditions.ID} +} +func (package2Conditions package2Conditions) CreatedAtIs() orm.FieldIs[package2.Package2, time.Time] { + return orm.FieldIs[package2.Package2, time.Time]{FieldID: package2Conditions.CreatedAt} +} +func (package2Conditions package2Conditions) UpdatedAtIs() orm.FieldIs[package2.Package2, time.Time] { + return orm.FieldIs[package2.Package2, time.Time]{FieldID: package2Conditions.UpdatedAt} +} +func (package2Conditions package2Conditions) DeletedAtIs() orm.FieldIs[package2.Package2, time.Time] { + return orm.FieldIs[package2.Package2, time.Time]{FieldID: package2Conditions.DeletedAt} +} +func (package2Conditions package2Conditions) Package1IdIs() orm.FieldIs[package2.Package2, model.UUID] { + return orm.FieldIs[package2.Package2, model.UUID]{FieldID: package2Conditions.Package1ID} +} + +type package2Conditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + Package1ID query.FieldIdentifier[model.UUID] +} + +var Package2 = package2Conditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: package2Type, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: package2Type, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: package2Type, + }, + Package1ID: query.FieldIdentifier[model.UUID]{ + Field: "Package1ID", + ModelType: package2Type, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: package2Type, + }, +} + +// Preload allows preloading the Package2 when doing a query +func (package2Conditions package2Conditions) Preload() condition.Condition[package2.Package2] { + return condition.NewPreloadCondition[package2.Package2](package2Conditions.ID, package2Conditions.CreatedAt, package2Conditions.UpdatedAt, package2Conditions.DeletedAt, package2Conditions.Package1ID) +} diff --git a/cmd/gen/conditions/tests/results/nullabletypes.go b/cmd/gen/conditions/tests/results/nullabletypes.go new file mode 100644 index 0000000..758df60 --- /dev/null +++ b/cmd/gen/conditions/tests/results/nullabletypes.go @@ -0,0 +1,122 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + nullabletypes "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/nullabletypes" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var nullableTypesType = reflect.TypeOf(*new(nullabletypes.NullableTypes)) + +func (nullableTypesConditions nullableTypesConditions) IdIs() orm.FieldIs[nullabletypes.NullableTypes, model.UUID] { + return orm.FieldIs[nullabletypes.NullableTypes, model.UUID]{FieldID: nullableTypesConditions.ID} +} +func (nullableTypesConditions nullableTypesConditions) CreatedAtIs() orm.FieldIs[nullabletypes.NullableTypes, time.Time] { + return orm.FieldIs[nullabletypes.NullableTypes, time.Time]{FieldID: nullableTypesConditions.CreatedAt} +} +func (nullableTypesConditions nullableTypesConditions) UpdatedAtIs() orm.FieldIs[nullabletypes.NullableTypes, time.Time] { + return orm.FieldIs[nullabletypes.NullableTypes, time.Time]{FieldID: nullableTypesConditions.UpdatedAt} +} +func (nullableTypesConditions nullableTypesConditions) DeletedAtIs() orm.FieldIs[nullabletypes.NullableTypes, time.Time] { + return orm.FieldIs[nullabletypes.NullableTypes, time.Time]{FieldID: nullableTypesConditions.DeletedAt} +} +func (nullableTypesConditions nullableTypesConditions) StringIs() orm.StringFieldIs[nullabletypes.NullableTypes] { + return orm.StringFieldIs[nullabletypes.NullableTypes]{FieldIs: orm.FieldIs[nullabletypes.NullableTypes, string]{FieldID: nullableTypesConditions.String}} +} +func (nullableTypesConditions nullableTypesConditions) Int64Is() orm.FieldIs[nullabletypes.NullableTypes, int64] { + return orm.FieldIs[nullabletypes.NullableTypes, int64]{FieldID: nullableTypesConditions.Int64} +} +func (nullableTypesConditions nullableTypesConditions) Int32Is() orm.FieldIs[nullabletypes.NullableTypes, int32] { + return orm.FieldIs[nullabletypes.NullableTypes, int32]{FieldID: nullableTypesConditions.Int32} +} +func (nullableTypesConditions nullableTypesConditions) Int16Is() orm.FieldIs[nullabletypes.NullableTypes, int16] { + return orm.FieldIs[nullabletypes.NullableTypes, int16]{FieldID: nullableTypesConditions.Int16} +} +func (nullableTypesConditions nullableTypesConditions) ByteIs() orm.FieldIs[nullabletypes.NullableTypes, int8] { + return orm.FieldIs[nullabletypes.NullableTypes, int8]{FieldID: nullableTypesConditions.Byte} +} +func (nullableTypesConditions nullableTypesConditions) Float64Is() orm.FieldIs[nullabletypes.NullableTypes, float64] { + return orm.FieldIs[nullabletypes.NullableTypes, float64]{FieldID: nullableTypesConditions.Float64} +} +func (nullableTypesConditions nullableTypesConditions) BoolIs() orm.BoolFieldIs[nullabletypes.NullableTypes] { + return orm.BoolFieldIs[nullabletypes.NullableTypes]{FieldIs: orm.FieldIs[nullabletypes.NullableTypes, bool]{FieldID: nullableTypesConditions.Bool}} +} +func (nullableTypesConditions nullableTypesConditions) TimeIs() orm.FieldIs[nullabletypes.NullableTypes, time.Time] { + return orm.FieldIs[nullabletypes.NullableTypes, time.Time]{FieldID: nullableTypesConditions.Time} +} + +type nullableTypesConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + String query.FieldIdentifier[string] + Int64 query.FieldIdentifier[int64] + Int32 query.FieldIdentifier[int32] + Int16 query.FieldIdentifier[int16] + Byte query.FieldIdentifier[int8] + Float64 query.FieldIdentifier[float64] + Bool query.FieldIdentifier[bool] + Time query.FieldIdentifier[time.Time] +} + +var NullableTypes = nullableTypesConditions{ + Bool: query.FieldIdentifier[bool]{ + Field: "Bool", + ModelType: nullableTypesType, + }, + Byte: query.FieldIdentifier[int8]{ + Field: "Byte", + ModelType: nullableTypesType, + }, + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: nullableTypesType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: nullableTypesType, + }, + Float64: query.FieldIdentifier[float64]{ + Field: "Float64", + ModelType: nullableTypesType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: nullableTypesType, + }, + Int16: query.FieldIdentifier[int16]{ + Field: "Int16", + ModelType: nullableTypesType, + }, + Int32: query.FieldIdentifier[int32]{ + Field: "Int32", + ModelType: nullableTypesType, + }, + Int64: query.FieldIdentifier[int64]{ + Field: "Int64", + ModelType: nullableTypesType, + }, + String: query.FieldIdentifier[string]{ + Field: "String", + ModelType: nullableTypesType, + }, + Time: query.FieldIdentifier[time.Time]{ + Field: "Time", + ModelType: nullableTypesType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: nullableTypesType, + }, +} + +// Preload allows preloading the NullableTypes when doing a query +func (nullableTypesConditions nullableTypesConditions) Preload() condition.Condition[nullabletypes.NullableTypes] { + return condition.NewPreloadCondition[nullabletypes.NullableTypes](nullableTypesConditions.ID, nullableTypesConditions.CreatedAt, nullableTypesConditions.UpdatedAt, nullableTypesConditions.DeletedAt, nullableTypesConditions.String, nullableTypesConditions.Int64, nullableTypesConditions.Int32, nullableTypesConditions.Int16, nullableTypesConditions.Byte, nullableTypesConditions.Float64, nullableTypesConditions.Bool, nullableTypesConditions.Time) +} diff --git a/cmd/gen/conditions/tests/results/overrideforeignkey_bicycle.go b/cmd/gen/conditions/tests/results/overrideforeignkey_bicycle.go new file mode 100644 index 0000000..10dfd02 --- /dev/null +++ b/cmd/gen/conditions/tests/results/overrideforeignkey_bicycle.go @@ -0,0 +1,77 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + overrideforeignkey "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/overrideforeignkey" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var bicycleType = reflect.TypeOf(*new(overrideforeignkey.Bicycle)) + +func (bicycleConditions bicycleConditions) IdIs() orm.FieldIs[overrideforeignkey.Bicycle, model.UUID] { + return orm.FieldIs[overrideforeignkey.Bicycle, model.UUID]{FieldID: bicycleConditions.ID} +} +func (bicycleConditions bicycleConditions) CreatedAtIs() orm.FieldIs[overrideforeignkey.Bicycle, time.Time] { + return orm.FieldIs[overrideforeignkey.Bicycle, time.Time]{FieldID: bicycleConditions.CreatedAt} +} +func (bicycleConditions bicycleConditions) UpdatedAtIs() orm.FieldIs[overrideforeignkey.Bicycle, time.Time] { + return orm.FieldIs[overrideforeignkey.Bicycle, time.Time]{FieldID: bicycleConditions.UpdatedAt} +} +func (bicycleConditions bicycleConditions) DeletedAtIs() orm.FieldIs[overrideforeignkey.Bicycle, time.Time] { + return orm.FieldIs[overrideforeignkey.Bicycle, time.Time]{FieldID: bicycleConditions.DeletedAt} +} +func (bicycleConditions bicycleConditions) Owner(conditions ...condition.Condition[overrideforeignkey.Person]) condition.JoinCondition[overrideforeignkey.Bicycle] { + return condition.NewJoinCondition[overrideforeignkey.Bicycle, overrideforeignkey.Person](conditions, "Owner", "OwnerSomethingID", bicycleConditions.Preload(), "ID") +} +func (bicycleConditions bicycleConditions) PreloadOwner() condition.JoinCondition[overrideforeignkey.Bicycle] { + return bicycleConditions.Owner(Person.Preload()) +} +func (bicycleConditions bicycleConditions) OwnerSomethingIdIs() orm.StringFieldIs[overrideforeignkey.Bicycle] { + return orm.StringFieldIs[overrideforeignkey.Bicycle]{FieldIs: orm.FieldIs[overrideforeignkey.Bicycle, string]{FieldID: bicycleConditions.OwnerSomethingID}} +} + +type bicycleConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + OwnerSomethingID query.FieldIdentifier[string] +} + +var Bicycle = bicycleConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: bicycleType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: bicycleType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: bicycleType, + }, + OwnerSomethingID: query.FieldIdentifier[string]{ + Field: "OwnerSomethingID", + ModelType: bicycleType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: bicycleType, + }, +} + +// Preload allows preloading the Bicycle when doing a query +func (bicycleConditions bicycleConditions) Preload() condition.Condition[overrideforeignkey.Bicycle] { + return condition.NewPreloadCondition[overrideforeignkey.Bicycle](bicycleConditions.ID, bicycleConditions.CreatedAt, bicycleConditions.UpdatedAt, bicycleConditions.DeletedAt, bicycleConditions.OwnerSomethingID) +} + +// PreloadRelations allows preloading all the Bicycle's relation when doing a query +func (bicycleConditions bicycleConditions) PreloadRelations() []condition.Condition[overrideforeignkey.Bicycle] { + return []condition.Condition[overrideforeignkey.Bicycle]{bicycleConditions.PreloadOwner()} +} diff --git a/cmd/gen/conditions/tests/results/overrideforeignkey_person.go b/cmd/gen/conditions/tests/results/overrideforeignkey_person.go new file mode 100644 index 0000000..1b72b50 --- /dev/null +++ b/cmd/gen/conditions/tests/results/overrideforeignkey_person.go @@ -0,0 +1,58 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + overrideforeignkey "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/overrideforeignkey" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var personType = reflect.TypeOf(*new(overrideforeignkey.Person)) + +func (personConditions personConditions) IdIs() orm.FieldIs[overrideforeignkey.Person, model.UUID] { + return orm.FieldIs[overrideforeignkey.Person, model.UUID]{FieldID: personConditions.ID} +} +func (personConditions personConditions) CreatedAtIs() orm.FieldIs[overrideforeignkey.Person, time.Time] { + return orm.FieldIs[overrideforeignkey.Person, time.Time]{FieldID: personConditions.CreatedAt} +} +func (personConditions personConditions) UpdatedAtIs() orm.FieldIs[overrideforeignkey.Person, time.Time] { + return orm.FieldIs[overrideforeignkey.Person, time.Time]{FieldID: personConditions.UpdatedAt} +} +func (personConditions personConditions) DeletedAtIs() orm.FieldIs[overrideforeignkey.Person, time.Time] { + return orm.FieldIs[overrideforeignkey.Person, time.Time]{FieldID: personConditions.DeletedAt} +} + +type personConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] +} + +var Person = personConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: personType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: personType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: personType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: personType, + }, +} + +// Preload allows preloading the Person when doing a query +func (personConditions personConditions) Preload() condition.Condition[overrideforeignkey.Person] { + return condition.NewPreloadCondition[overrideforeignkey.Person](personConditions.ID, personConditions.CreatedAt, personConditions.UpdatedAt, personConditions.DeletedAt) +} diff --git a/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_credit_card.go b/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_credit_card.go new file mode 100644 index 0000000..dc639be --- /dev/null +++ b/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_credit_card.go @@ -0,0 +1,66 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + overrideforeignkeyinverse "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/overrideforeignkeyinverse" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var creditCardType = reflect.TypeOf(*new(overrideforeignkeyinverse.CreditCard)) + +func (creditCardConditions creditCardConditions) IdIs() orm.FieldIs[overrideforeignkeyinverse.CreditCard, model.UUID] { + return orm.FieldIs[overrideforeignkeyinverse.CreditCard, model.UUID]{FieldID: creditCardConditions.ID} +} +func (creditCardConditions creditCardConditions) CreatedAtIs() orm.FieldIs[overrideforeignkeyinverse.CreditCard, time.Time] { + return orm.FieldIs[overrideforeignkeyinverse.CreditCard, time.Time]{FieldID: creditCardConditions.CreatedAt} +} +func (creditCardConditions creditCardConditions) UpdatedAtIs() orm.FieldIs[overrideforeignkeyinverse.CreditCard, time.Time] { + return orm.FieldIs[overrideforeignkeyinverse.CreditCard, time.Time]{FieldID: creditCardConditions.UpdatedAt} +} +func (creditCardConditions creditCardConditions) DeletedAtIs() orm.FieldIs[overrideforeignkeyinverse.CreditCard, time.Time] { + return orm.FieldIs[overrideforeignkeyinverse.CreditCard, time.Time]{FieldID: creditCardConditions.DeletedAt} +} +func (creditCardConditions creditCardConditions) UserReferenceIs() orm.FieldIs[overrideforeignkeyinverse.CreditCard, model.UUID] { + return orm.FieldIs[overrideforeignkeyinverse.CreditCard, model.UUID]{FieldID: creditCardConditions.UserReference} +} + +type creditCardConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + UserReference query.FieldIdentifier[model.UUID] +} + +var CreditCard = creditCardConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: creditCardType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: creditCardType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: creditCardType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: creditCardType, + }, + UserReference: query.FieldIdentifier[model.UUID]{ + Field: "UserReference", + ModelType: creditCardType, + }, +} + +// Preload allows preloading the CreditCard when doing a query +func (creditCardConditions creditCardConditions) Preload() condition.Condition[overrideforeignkeyinverse.CreditCard] { + return condition.NewPreloadCondition[overrideforeignkeyinverse.CreditCard](creditCardConditions.ID, creditCardConditions.CreatedAt, creditCardConditions.UpdatedAt, creditCardConditions.DeletedAt, creditCardConditions.UserReference) +} diff --git a/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_user.go b/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_user.go new file mode 100644 index 0000000..7052382 --- /dev/null +++ b/cmd/gen/conditions/tests/results/overrideforeignkeyinverse_user.go @@ -0,0 +1,69 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + overrideforeignkeyinverse "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/overrideforeignkeyinverse" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var userType = reflect.TypeOf(*new(overrideforeignkeyinverse.User)) + +func (userConditions userConditions) IdIs() orm.FieldIs[overrideforeignkeyinverse.User, model.UUID] { + return orm.FieldIs[overrideforeignkeyinverse.User, model.UUID]{FieldID: userConditions.ID} +} +func (userConditions userConditions) CreatedAtIs() orm.FieldIs[overrideforeignkeyinverse.User, time.Time] { + return orm.FieldIs[overrideforeignkeyinverse.User, time.Time]{FieldID: userConditions.CreatedAt} +} +func (userConditions userConditions) UpdatedAtIs() orm.FieldIs[overrideforeignkeyinverse.User, time.Time] { + return orm.FieldIs[overrideforeignkeyinverse.User, time.Time]{FieldID: userConditions.UpdatedAt} +} +func (userConditions userConditions) DeletedAtIs() orm.FieldIs[overrideforeignkeyinverse.User, time.Time] { + return orm.FieldIs[overrideforeignkeyinverse.User, time.Time]{FieldID: userConditions.DeletedAt} +} +func (userConditions userConditions) CreditCard(conditions ...condition.Condition[overrideforeignkeyinverse.CreditCard]) condition.JoinCondition[overrideforeignkeyinverse.User] { + return condition.NewJoinCondition[overrideforeignkeyinverse.User, overrideforeignkeyinverse.CreditCard](conditions, "CreditCard", "ID", userConditions.Preload(), "UserReference") +} +func (userConditions userConditions) PreloadCreditCard() condition.JoinCondition[overrideforeignkeyinverse.User] { + return userConditions.CreditCard(CreditCard.Preload()) +} + +type userConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] +} + +var User = userConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: userType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: userType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: userType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: userType, + }, +} + +// Preload allows preloading the User when doing a query +func (userConditions userConditions) Preload() condition.Condition[overrideforeignkeyinverse.User] { + return condition.NewPreloadCondition[overrideforeignkeyinverse.User](userConditions.ID, userConditions.CreatedAt, userConditions.UpdatedAt, userConditions.DeletedAt) +} + +// PreloadRelations allows preloading all the User's relation when doing a query +func (userConditions userConditions) PreloadRelations() []condition.Condition[overrideforeignkeyinverse.User] { + return []condition.Condition[overrideforeignkeyinverse.User]{userConditions.PreloadCreditCard()} +} diff --git a/cmd/gen/conditions/tests/results/overridereferences_brand.go b/cmd/gen/conditions/tests/results/overridereferences_brand.go new file mode 100644 index 0000000..080f013 --- /dev/null +++ b/cmd/gen/conditions/tests/results/overridereferences_brand.go @@ -0,0 +1,66 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + overridereferences "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/overridereferences" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var brandType = reflect.TypeOf(*new(overridereferences.Brand)) + +func (brandConditions brandConditions) IdIs() orm.FieldIs[overridereferences.Brand, model.UUID] { + return orm.FieldIs[overridereferences.Brand, model.UUID]{FieldID: brandConditions.ID} +} +func (brandConditions brandConditions) CreatedAtIs() orm.FieldIs[overridereferences.Brand, time.Time] { + return orm.FieldIs[overridereferences.Brand, time.Time]{FieldID: brandConditions.CreatedAt} +} +func (brandConditions brandConditions) UpdatedAtIs() orm.FieldIs[overridereferences.Brand, time.Time] { + return orm.FieldIs[overridereferences.Brand, time.Time]{FieldID: brandConditions.UpdatedAt} +} +func (brandConditions brandConditions) DeletedAtIs() orm.FieldIs[overridereferences.Brand, time.Time] { + return orm.FieldIs[overridereferences.Brand, time.Time]{FieldID: brandConditions.DeletedAt} +} +func (brandConditions brandConditions) NameIs() orm.StringFieldIs[overridereferences.Brand] { + return orm.StringFieldIs[overridereferences.Brand]{FieldIs: orm.FieldIs[overridereferences.Brand, string]{FieldID: brandConditions.Name}} +} + +type brandConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + Name query.FieldIdentifier[string] +} + +var Brand = brandConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: brandType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: brandType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: brandType, + }, + Name: query.FieldIdentifier[string]{ + Field: "Name", + ModelType: brandType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: brandType, + }, +} + +// Preload allows preloading the Brand when doing a query +func (brandConditions brandConditions) Preload() condition.Condition[overridereferences.Brand] { + return condition.NewPreloadCondition[overridereferences.Brand](brandConditions.ID, brandConditions.CreatedAt, brandConditions.UpdatedAt, brandConditions.DeletedAt, brandConditions.Name) +} diff --git a/cmd/gen/conditions/tests/results/overridereferences_phone.go b/cmd/gen/conditions/tests/results/overridereferences_phone.go new file mode 100644 index 0000000..89604f4 --- /dev/null +++ b/cmd/gen/conditions/tests/results/overridereferences_phone.go @@ -0,0 +1,77 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + overridereferences "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/overridereferences" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var phoneType = reflect.TypeOf(*new(overridereferences.Phone)) + +func (phoneConditions phoneConditions) IdIs() orm.FieldIs[overridereferences.Phone, model.UUID] { + return orm.FieldIs[overridereferences.Phone, model.UUID]{FieldID: phoneConditions.ID} +} +func (phoneConditions phoneConditions) CreatedAtIs() orm.FieldIs[overridereferences.Phone, time.Time] { + return orm.FieldIs[overridereferences.Phone, time.Time]{FieldID: phoneConditions.CreatedAt} +} +func (phoneConditions phoneConditions) UpdatedAtIs() orm.FieldIs[overridereferences.Phone, time.Time] { + return orm.FieldIs[overridereferences.Phone, time.Time]{FieldID: phoneConditions.UpdatedAt} +} +func (phoneConditions phoneConditions) DeletedAtIs() orm.FieldIs[overridereferences.Phone, time.Time] { + return orm.FieldIs[overridereferences.Phone, time.Time]{FieldID: phoneConditions.DeletedAt} +} +func (phoneConditions phoneConditions) Brand(conditions ...condition.Condition[overridereferences.Brand]) condition.JoinCondition[overridereferences.Phone] { + return condition.NewJoinCondition[overridereferences.Phone, overridereferences.Brand](conditions, "Brand", "BrandName", phoneConditions.Preload(), "Name") +} +func (phoneConditions phoneConditions) PreloadBrand() condition.JoinCondition[overridereferences.Phone] { + return phoneConditions.Brand(Brand.Preload()) +} +func (phoneConditions phoneConditions) BrandNameIs() orm.StringFieldIs[overridereferences.Phone] { + return orm.StringFieldIs[overridereferences.Phone]{FieldIs: orm.FieldIs[overridereferences.Phone, string]{FieldID: phoneConditions.BrandName}} +} + +type phoneConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + BrandName query.FieldIdentifier[string] +} + +var Phone = phoneConditions{ + BrandName: query.FieldIdentifier[string]{ + Field: "BrandName", + ModelType: phoneType, + }, + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: phoneType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: phoneType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: phoneType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: phoneType, + }, +} + +// Preload allows preloading the Phone when doing a query +func (phoneConditions phoneConditions) Preload() condition.Condition[overridereferences.Phone] { + return condition.NewPreloadCondition[overridereferences.Phone](phoneConditions.ID, phoneConditions.CreatedAt, phoneConditions.UpdatedAt, phoneConditions.DeletedAt, phoneConditions.BrandName) +} + +// PreloadRelations allows preloading all the Phone's relation when doing a query +func (phoneConditions phoneConditions) PreloadRelations() []condition.Condition[overridereferences.Phone] { + return []condition.Condition[overridereferences.Phone]{phoneConditions.PreloadBrand()} +} diff --git a/cmd/gen/conditions/tests/results/overridereferencesinverse_computer.go b/cmd/gen/conditions/tests/results/overridereferencesinverse_computer.go new file mode 100644 index 0000000..4dadc04 --- /dev/null +++ b/cmd/gen/conditions/tests/results/overridereferencesinverse_computer.go @@ -0,0 +1,77 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + overridereferencesinverse "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/overridereferencesinverse" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var computerType = reflect.TypeOf(*new(overridereferencesinverse.Computer)) + +func (computerConditions computerConditions) IdIs() orm.FieldIs[overridereferencesinverse.Computer, model.UUID] { + return orm.FieldIs[overridereferencesinverse.Computer, model.UUID]{FieldID: computerConditions.ID} +} +func (computerConditions computerConditions) CreatedAtIs() orm.FieldIs[overridereferencesinverse.Computer, time.Time] { + return orm.FieldIs[overridereferencesinverse.Computer, time.Time]{FieldID: computerConditions.CreatedAt} +} +func (computerConditions computerConditions) UpdatedAtIs() orm.FieldIs[overridereferencesinverse.Computer, time.Time] { + return orm.FieldIs[overridereferencesinverse.Computer, time.Time]{FieldID: computerConditions.UpdatedAt} +} +func (computerConditions computerConditions) DeletedAtIs() orm.FieldIs[overridereferencesinverse.Computer, time.Time] { + return orm.FieldIs[overridereferencesinverse.Computer, time.Time]{FieldID: computerConditions.DeletedAt} +} +func (computerConditions computerConditions) NameIs() orm.StringFieldIs[overridereferencesinverse.Computer] { + return orm.StringFieldIs[overridereferencesinverse.Computer]{FieldIs: orm.FieldIs[overridereferencesinverse.Computer, string]{FieldID: computerConditions.Name}} +} +func (computerConditions computerConditions) Processor(conditions ...condition.Condition[overridereferencesinverse.Processor]) condition.JoinCondition[overridereferencesinverse.Computer] { + return condition.NewJoinCondition[overridereferencesinverse.Computer, overridereferencesinverse.Processor](conditions, "Processor", "Name", computerConditions.Preload(), "ComputerName") +} +func (computerConditions computerConditions) PreloadProcessor() condition.JoinCondition[overridereferencesinverse.Computer] { + return computerConditions.Processor(Processor.Preload()) +} + +type computerConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + Name query.FieldIdentifier[string] +} + +var Computer = computerConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: computerType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: computerType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: computerType, + }, + Name: query.FieldIdentifier[string]{ + Field: "Name", + ModelType: computerType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: computerType, + }, +} + +// Preload allows preloading the Computer when doing a query +func (computerConditions computerConditions) Preload() condition.Condition[overridereferencesinverse.Computer] { + return condition.NewPreloadCondition[overridereferencesinverse.Computer](computerConditions.ID, computerConditions.CreatedAt, computerConditions.UpdatedAt, computerConditions.DeletedAt, computerConditions.Name) +} + +// PreloadRelations allows preloading all the Computer's relation when doing a query +func (computerConditions computerConditions) PreloadRelations() []condition.Condition[overridereferencesinverse.Computer] { + return []condition.Condition[overridereferencesinverse.Computer]{computerConditions.PreloadProcessor()} +} diff --git a/cmd/gen/conditions/tests/results/overridereferencesinverse_processor.go b/cmd/gen/conditions/tests/results/overridereferencesinverse_processor.go new file mode 100644 index 0000000..661d40d --- /dev/null +++ b/cmd/gen/conditions/tests/results/overridereferencesinverse_processor.go @@ -0,0 +1,66 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + overridereferencesinverse "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/overridereferencesinverse" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var processorType = reflect.TypeOf(*new(overridereferencesinverse.Processor)) + +func (processorConditions processorConditions) IdIs() orm.FieldIs[overridereferencesinverse.Processor, model.UUID] { + return orm.FieldIs[overridereferencesinverse.Processor, model.UUID]{FieldID: processorConditions.ID} +} +func (processorConditions processorConditions) CreatedAtIs() orm.FieldIs[overridereferencesinverse.Processor, time.Time] { + return orm.FieldIs[overridereferencesinverse.Processor, time.Time]{FieldID: processorConditions.CreatedAt} +} +func (processorConditions processorConditions) UpdatedAtIs() orm.FieldIs[overridereferencesinverse.Processor, time.Time] { + return orm.FieldIs[overridereferencesinverse.Processor, time.Time]{FieldID: processorConditions.UpdatedAt} +} +func (processorConditions processorConditions) DeletedAtIs() orm.FieldIs[overridereferencesinverse.Processor, time.Time] { + return orm.FieldIs[overridereferencesinverse.Processor, time.Time]{FieldID: processorConditions.DeletedAt} +} +func (processorConditions processorConditions) ComputerNameIs() orm.StringFieldIs[overridereferencesinverse.Processor] { + return orm.StringFieldIs[overridereferencesinverse.Processor]{FieldIs: orm.FieldIs[overridereferencesinverse.Processor, string]{FieldID: processorConditions.ComputerName}} +} + +type processorConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + ComputerName query.FieldIdentifier[string] +} + +var Processor = processorConditions{ + ComputerName: query.FieldIdentifier[string]{ + Field: "ComputerName", + ModelType: processorType, + }, + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: processorType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: processorType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: processorType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: processorType, + }, +} + +// Preload allows preloading the Processor when doing a query +func (processorConditions processorConditions) Preload() condition.Condition[overridereferencesinverse.Processor] { + return condition.NewPreloadCondition[overridereferencesinverse.Processor](processorConditions.ID, processorConditions.CreatedAt, processorConditions.UpdatedAt, processorConditions.DeletedAt, processorConditions.ComputerName) +} diff --git a/cmd/gen/conditions/tests/results/selfreferential.go b/cmd/gen/conditions/tests/results/selfreferential.go new file mode 100644 index 0000000..107129c --- /dev/null +++ b/cmd/gen/conditions/tests/results/selfreferential.go @@ -0,0 +1,77 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + selfreferential "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/selfreferential" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var employeeType = reflect.TypeOf(*new(selfreferential.Employee)) + +func (employeeConditions employeeConditions) IdIs() orm.FieldIs[selfreferential.Employee, model.UUID] { + return orm.FieldIs[selfreferential.Employee, model.UUID]{FieldID: employeeConditions.ID} +} +func (employeeConditions employeeConditions) CreatedAtIs() orm.FieldIs[selfreferential.Employee, time.Time] { + return orm.FieldIs[selfreferential.Employee, time.Time]{FieldID: employeeConditions.CreatedAt} +} +func (employeeConditions employeeConditions) UpdatedAtIs() orm.FieldIs[selfreferential.Employee, time.Time] { + return orm.FieldIs[selfreferential.Employee, time.Time]{FieldID: employeeConditions.UpdatedAt} +} +func (employeeConditions employeeConditions) DeletedAtIs() orm.FieldIs[selfreferential.Employee, time.Time] { + return orm.FieldIs[selfreferential.Employee, time.Time]{FieldID: employeeConditions.DeletedAt} +} +func (employeeConditions employeeConditions) Boss(conditions ...condition.Condition[selfreferential.Employee]) condition.JoinCondition[selfreferential.Employee] { + return condition.NewJoinCondition[selfreferential.Employee, selfreferential.Employee](conditions, "Boss", "BossID", employeeConditions.Preload(), "ID") +} +func (employeeConditions employeeConditions) PreloadBoss() condition.JoinCondition[selfreferential.Employee] { + return employeeConditions.Boss(Employee.Preload()) +} +func (employeeConditions employeeConditions) BossIdIs() orm.FieldIs[selfreferential.Employee, model.UUID] { + return orm.FieldIs[selfreferential.Employee, model.UUID]{FieldID: employeeConditions.BossID} +} + +type employeeConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] + BossID query.FieldIdentifier[model.UUID] +} + +var Employee = employeeConditions{ + BossID: query.FieldIdentifier[model.UUID]{ + Field: "BossID", + ModelType: employeeType, + }, + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: employeeType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: employeeType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: employeeType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: employeeType, + }, +} + +// Preload allows preloading the Employee when doing a query +func (employeeConditions employeeConditions) Preload() condition.Condition[selfreferential.Employee] { + return condition.NewPreloadCondition[selfreferential.Employee](employeeConditions.ID, employeeConditions.CreatedAt, employeeConditions.UpdatedAt, employeeConditions.DeletedAt, employeeConditions.BossID) +} + +// PreloadRelations allows preloading all the Employee's relation when doing a query +func (employeeConditions employeeConditions) PreloadRelations() []condition.Condition[selfreferential.Employee] { + return []condition.Condition[selfreferential.Employee]{employeeConditions.PreloadBoss()} +} diff --git a/cmd/gen/conditions/tests/results/uintmodel.go b/cmd/gen/conditions/tests/results/uintmodel.go new file mode 100644 index 0000000..7cc5a90 --- /dev/null +++ b/cmd/gen/conditions/tests/results/uintmodel.go @@ -0,0 +1,58 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + uintmodel "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/uintmodel" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var uintModelType = reflect.TypeOf(*new(uintmodel.UintModel)) + +func (uintModelConditions uintModelConditions) IdIs() orm.FieldIs[uintmodel.UintModel, model.UIntID] { + return orm.FieldIs[uintmodel.UintModel, model.UIntID]{FieldID: uintModelConditions.ID} +} +func (uintModelConditions uintModelConditions) CreatedAtIs() orm.FieldIs[uintmodel.UintModel, time.Time] { + return orm.FieldIs[uintmodel.UintModel, time.Time]{FieldID: uintModelConditions.CreatedAt} +} +func (uintModelConditions uintModelConditions) UpdatedAtIs() orm.FieldIs[uintmodel.UintModel, time.Time] { + return orm.FieldIs[uintmodel.UintModel, time.Time]{FieldID: uintModelConditions.UpdatedAt} +} +func (uintModelConditions uintModelConditions) DeletedAtIs() orm.FieldIs[uintmodel.UintModel, time.Time] { + return orm.FieldIs[uintmodel.UintModel, time.Time]{FieldID: uintModelConditions.DeletedAt} +} + +type uintModelConditions struct { + ID query.FieldIdentifier[model.UIntID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] +} + +var UintModel = uintModelConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: uintModelType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: uintModelType, + }, + ID: query.FieldIdentifier[model.UIntID]{ + Field: "ID", + ModelType: uintModelType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: uintModelType, + }, +} + +// Preload allows preloading the UintModel when doing a query +func (uintModelConditions uintModelConditions) Preload() condition.Condition[uintmodel.UintModel] { + return condition.NewPreloadCondition[uintmodel.UintModel](uintModelConditions.ID, uintModelConditions.CreatedAt, uintModelConditions.UpdatedAt, uintModelConditions.DeletedAt) +} diff --git a/cmd/gen/conditions/tests/results/uuidmodel.go b/cmd/gen/conditions/tests/results/uuidmodel.go new file mode 100644 index 0000000..3bc58d9 --- /dev/null +++ b/cmd/gen/conditions/tests/results/uuidmodel.go @@ -0,0 +1,58 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package conditions + +import ( + uuidmodel "github.com/ditrit/badaas-cli/cmd/gen/conditions/tests/uuidmodel" + orm "github.com/ditrit/badaas/orm" + condition "github.com/ditrit/badaas/orm/condition" + model "github.com/ditrit/badaas/orm/model" + query "github.com/ditrit/badaas/orm/query" + "reflect" + "time" +) + +var uuidModelType = reflect.TypeOf(*new(uuidmodel.UUIDModel)) + +func (uuidModelConditions uuidModelConditions) IdIs() orm.FieldIs[uuidmodel.UUIDModel, model.UUID] { + return orm.FieldIs[uuidmodel.UUIDModel, model.UUID]{FieldID: uuidModelConditions.ID} +} +func (uuidModelConditions uuidModelConditions) CreatedAtIs() orm.FieldIs[uuidmodel.UUIDModel, time.Time] { + return orm.FieldIs[uuidmodel.UUIDModel, time.Time]{FieldID: uuidModelConditions.CreatedAt} +} +func (uuidModelConditions uuidModelConditions) UpdatedAtIs() orm.FieldIs[uuidmodel.UUIDModel, time.Time] { + return orm.FieldIs[uuidmodel.UUIDModel, time.Time]{FieldID: uuidModelConditions.UpdatedAt} +} +func (uuidModelConditions uuidModelConditions) DeletedAtIs() orm.FieldIs[uuidmodel.UUIDModel, time.Time] { + return orm.FieldIs[uuidmodel.UUIDModel, time.Time]{FieldID: uuidModelConditions.DeletedAt} +} + +type uuidModelConditions struct { + ID query.FieldIdentifier[model.UUID] + CreatedAt query.FieldIdentifier[time.Time] + UpdatedAt query.FieldIdentifier[time.Time] + DeletedAt query.FieldIdentifier[time.Time] +} + +var UUIDModel = uuidModelConditions{ + CreatedAt: query.FieldIdentifier[time.Time]{ + Field: "CreatedAt", + ModelType: uuidModelType, + }, + DeletedAt: query.FieldIdentifier[time.Time]{ + Field: "DeletedAt", + ModelType: uuidModelType, + }, + ID: query.FieldIdentifier[model.UUID]{ + Field: "ID", + ModelType: uuidModelType, + }, + UpdatedAt: query.FieldIdentifier[time.Time]{ + Field: "UpdatedAt", + ModelType: uuidModelType, + }, +} + +// Preload allows preloading the UUIDModel when doing a query +func (uuidModelConditions uuidModelConditions) Preload() condition.Condition[uuidmodel.UUIDModel] { + return condition.NewPreloadCondition[uuidmodel.UUIDModel](uuidModelConditions.ID, uuidModelConditions.CreatedAt, uuidModelConditions.UpdatedAt, uuidModelConditions.DeletedAt) +} diff --git a/cmd/gen/conditions/tests/selfreferential/badaas-orm_result.go b/cmd/gen/conditions/tests/selfreferential/badaas-orm_result.go new file mode 100644 index 0000000..6502943 --- /dev/null +++ b/cmd/gen/conditions/tests/selfreferential/badaas-orm_result.go @@ -0,0 +1,8 @@ +// Code generated by badaas-cli v0.0.0, DO NOT EDIT. +package selfreferential + +import preload "github.com/ditrit/badaas/orm/preload" + +func (m Employee) GetBoss() (*Employee, error) { + return preload.VerifyPointerLoaded[Employee](m.BossID, m.Boss) +} diff --git a/cmd/gen/conditions/tests/selfreferential/selfreferential.go b/cmd/gen/conditions/tests/selfreferential/selfreferential.go new file mode 100644 index 0000000..576bd42 --- /dev/null +++ b/cmd/gen/conditions/tests/selfreferential/selfreferential.go @@ -0,0 +1,12 @@ +package selfreferential + +import ( + "github.com/ditrit/badaas/orm/model" +) + +type Employee struct { + model.UUIDModel + + Boss *Employee `gorm:"constraint:OnDelete:SET NULL;"` // Self-Referential Has One (Employee 0..* -> 0..1 Employee) + BossID *model.UUID +} diff --git a/cmd/gen/conditions/tests/uintmodel/uintmodel.go b/cmd/gen/conditions/tests/uintmodel/uintmodel.go new file mode 100644 index 0000000..6f2d375 --- /dev/null +++ b/cmd/gen/conditions/tests/uintmodel/uintmodel.go @@ -0,0 +1,7 @@ +package uintmodel + +import "github.com/ditrit/badaas/orm/model" + +type UintModel struct { + model.UIntModel +} diff --git a/cmd/gen/conditions/tests/uuidmodel/uuidmodel.go b/cmd/gen/conditions/tests/uuidmodel/uuidmodel.go new file mode 100644 index 0000000..f6ff444 --- /dev/null +++ b/cmd/gen/conditions/tests/uuidmodel/uuidmodel.go @@ -0,0 +1,7 @@ +package uuidmodel + +import "github.com/ditrit/badaas/orm/model" + +type UUIDModel struct { + model.UUIDModel +} diff --git a/cmd/gen/conditions/type.go b/cmd/gen/conditions/type.go new file mode 100644 index 0000000..5948846 --- /dev/null +++ b/cmd/gen/conditions/type.go @@ -0,0 +1,142 @@ +package conditions + +import ( + "errors" + "fmt" + "go/types" + "regexp" + "strings" + + "github.com/elliotchance/pie/v2" + + "github.com/ditrit/badaas-cli/cmd/utils" +) + +var ( + // badaas/orm/baseModels.go + badaasORMBaseModels = []string{ + modelPath + "." + uuidModel, + modelPath + "." + uIntModel, + } + + // database/sql + nullString = "database/sql.NullString" + nullInt64 = "database/sql.NullInt64" + nullInt32 = "database/sql.NullInt32" + nullInt16 = "database/sql.NullInt16" + nullFloat64 = "database/sql.NullFloat64" + nullByte = "database/sql.NullByte" + nullBool = "database/sql.NullBool" + nullTime = "database/sql.NullTime" + deletedAt = "gorm.io/gorm.DeletedAt" + sqlNullableTypes = []string{ + nullString, nullInt64, nullInt32, nullInt16, nullFloat64, + nullByte, nullBool, nullTime, deletedAt, + } +) + +var ErrFkNotInTypeFields = errors.New("fk not in type's fields") + +type Type struct { + types.Type +} + +// Get the name of the type depending of the internal type +func (t Type) Name() string { + switch typeTyped := t.Type.(type) { + case *types.Named: + return typeTyped.Obj().Name() + default: + return pie.Last(strings.Split(t.String(), ".")) + } +} + +// Get the package of the type depending of the internal type +func (t Type) Pkg() *types.Package { + switch typeTyped := t.Type.(type) { + case *types.Named: + return typeTyped.Obj().Pkg() + default: + return nil + } +} + +// Get the struct under type if it is a Badaas model +// Returns error if the type is not a Badaas model +func (t Type) BadaasModelStruct() (*types.Struct, error) { + structType, ok := t.Underlying().(*types.Struct) + if !ok || !isBadaasModel(structType) { + return nil, fmt.Errorf("type %s is not a Badaas Model", t.String()) + } + + return structType, nil +} + +// Returns true if the type is a Badaas model +func isBadaasModel(structType *types.Struct) bool { + for i := 0; i < structType.NumFields(); i++ { + field := structType.Field(i) + + if field.Embedded() && isBaseModel(field.Type().String()) { + return true + } + } + + return false +} + +func isBaseModel(fieldName string) bool { + return pie.Contains(badaasORMBaseModels, fieldName) +} + +// Returns the fk field of the type to the "field"'s object +// (another field that references that object) +func (t Type) GetFK(field Field) (*Field, error) { + objectFields, err := getFields(t) + if err != nil { + return nil, err + } + + fk := utils.FindFirst(objectFields, func(otherField Field) bool { + return strings.EqualFold(otherField.Name, field.getFKAttribute()) + }) + + if fk == nil { + return nil, ErrFkNotInTypeFields + } + + return fk, nil +} + +var ( + scanMethod = regexp.MustCompile(`func \(\*.*\)\.Scan\([a-zA-Z0-9_-]* (interface\{\}|any)\) error$`) + valueMethod = regexp.MustCompile(`func \(.*\)\.Value\(\) \(database/sql/driver\.Value\, error\)$`) +) + +// Returns true if the type is a Gorm Custom type (https://gorm.io/docs/data_types.html) +func (t Type) IsGormCustomType() bool { + typeNamed, isNamedType := t.Type.(*types.Named) + if !isNamedType { + return false + } + + hasScanMethod := false + hasValueMethod := false + + for i := 0; i < typeNamed.NumMethods(); i++ { + methodSignature := typeNamed.Method(i).String() + + if !hasScanMethod && scanMethod.MatchString(methodSignature) { + hasScanMethod = true + } else if !hasValueMethod && valueMethod.MatchString(methodSignature) { + hasValueMethod = true + } + } + + return hasScanMethod && hasValueMethod +} + +// Returns true if the type is a sql nullable type (sql.NullBool, sql.NullInt, etc.) +func (t Type) IsSQLNullableType() bool { + return pie.Contains(sqlNullableTypes, t.String()) +} diff --git a/cmd/gen/config/badaas.yml b/cmd/gen/config/badaas.yml new file mode 100644 index 0000000..5628860 --- /dev/null +++ b/cmd/gen/config/badaas.yml @@ -0,0 +1,28 @@ +database: + host: badaas-db + name: badaas_db + password: postgres + sslmode: disable + username: root + port: 26257 + init: + retry: 10 + retryTime: 5 +server: + host: "" + port: 8000 + timeout: 15 + pagination: + page: + max: 100 +logger: + mode: prod + request: + template: "Receive {{method}} request on {{url}}" +session: + duration: 14400 + pullInterval: 30 + rollDuration: 3600 +default: + admin: + password: admin \ No newline at end of file diff --git a/cmd/gen/docker.go b/cmd/gen/docker.go new file mode 100644 index 0000000..308ea44 --- /dev/null +++ b/cmd/gen/docker.go @@ -0,0 +1,102 @@ +package gen + +import ( + "embed" + "fmt" + "os" + "path/filepath" + + "github.com/spf13/cobra" + + "github.com/ditrit/verdeter" +) + +const filePermissions = 0o0600 + +// File system embed in the executable that will have the following files: +// +//go:embed docker/* +//go:embed config/* +var genEmbedFS embed.FS + +// genCommand represents the badaas-cli gen command +var genDockerCmd = verdeter.BuildVerdeterCommand(verdeter.VerdeterConfig{ + Use: "docker", + Short: "Generate files and configurations necessary to use badaas over docker", + Long: `gen docker is the command you can use to generate the files and configurations necessary for your project to use BadAss in a simple way.`, + Run: generateDockerFiles, +}) + +// directory where the generated files will be saved +const destBadaasDir = "badaas" + +// copies all docker and configurations related files from the embed file system to the destination folder +func generateDockerFiles(_ *cobra.Command, _ []string) { + sourceDockerDir := "docker" + + copyDir( + filepath.Join(sourceDockerDir, "db"), + filepath.Join(destBadaasDir, "docker", "db"), + ) + + copyDir( + filepath.Join(sourceDockerDir, "api"), + filepath.Join(destBadaasDir, "docker", "api"), + ) + + copyFile( + filepath.Join(sourceDockerDir, ".dockerignore"), + ".dockerignore", + ) + + copyFile( + filepath.Join(sourceDockerDir, "Makefile"), + "Makefile", + ) + + copyDir( + "config", + filepath.Join(destBadaasDir, "config"), + ) +} + +// copies a file from the embed file system to the destination folder +func copyFile(sourcePath, destPath string) { + fileContent, err := genEmbedFS.ReadFile(sourcePath) + if err != nil { + panic(fmt.Errorf("error reading source file %s: %w", sourcePath, err)) + } + + if err := os.WriteFile(destPath, fileContent, filePermissions); err != nil { + panic(fmt.Errorf("error writing on destination file %s: %w", destPath, err)) + } +} + +// copies a directory from the embed file system to the destination folder +func copyDir(sourceDir, destDir string) { + files, err := genEmbedFS.ReadDir(sourceDir) + if err != nil { + panic(fmt.Errorf("error reading source directory %s: %w", sourceDir, err)) + } + + fileInfo, err := os.Stat(destDir) + if err != nil { + if !os.IsNotExist(err) { + panic(fmt.Errorf("error running stat on %s: %w", destDir, err)) + } + + err = os.MkdirAll(destDir, os.ModePerm) + if err != nil { + panic(fmt.Errorf("error creating directory %s: %w", destDir, err)) + } + } else if !fileInfo.IsDir() { + panic(fmt.Errorf("destination path %s is not a directory", destDir)) + } + + for _, file := range files { + copyFile( + filepath.Join(sourceDir, file.Name()), + filepath.Join(destDir, file.Name()), + ) + } +} diff --git a/cmd/gen/docker/.dockerignore b/cmd/gen/docker/.dockerignore new file mode 100644 index 0000000..f7db608 --- /dev/null +++ b/cmd/gen/docker/.dockerignore @@ -0,0 +1,11 @@ +# general +.editorconfig +.git +.gitignore +.github +*.md +LICENSE +.vscode + +# badaas +badaas/docker diff --git a/cmd/gen/docker/Makefile b/cmd/gen/docker/Makefile new file mode 100644 index 0000000..634c8ef --- /dev/null +++ b/cmd/gen/docker/Makefile @@ -0,0 +1,2 @@ +badaas_run: + docker compose -f badaas/docker/db/docker-compose.yml -f badaas/docker/api/docker-compose.yml up --build -d \ No newline at end of file diff --git a/cmd/gen/docker/api/Dockerfile b/cmd/gen/docker/api/Dockerfile new file mode 100644 index 0000000..1ea62ae --- /dev/null +++ b/cmd/gen/docker/api/Dockerfile @@ -0,0 +1,17 @@ +# builder image +FROM golang:1.19-alpine AS builder +RUN apk add build-base +WORKDIR /app +COPY . . +RUN CGO_ENABLED=1 go build -o badaas_service -a . + + +# final image for end users +FROM alpine:3.16.2 +RUN addgroup -S badaas \ + && adduser -S badaas -G badaas +USER badaas +COPY --from=builder /app/badaas_service . +COPY ./badaas/config/badaas.yml . +EXPOSE 8000 +ENTRYPOINT ["./badaas_service", "--config_path", "badaas.yml"] \ No newline at end of file diff --git a/cmd/gen/docker/api/docker-compose.yml b/cmd/gen/docker/api/docker-compose.yml new file mode 100644 index 0000000..6fc1187 --- /dev/null +++ b/cmd/gen/docker/api/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3.5' + +services: + api: + image: badaas-api:latest + build: + context: ../../.. + dockerfile: ./badaas/docker/api/Dockerfile + container_name: "badaas-api" + ports: + - "8000:8000" + depends_on: + - db diff --git a/cmd/gen/docker/db/docker-compose.yml b/cmd/gen/docker/db/docker-compose.yml new file mode 100644 index 0000000..d249a53 --- /dev/null +++ b/cmd/gen/docker/db/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3.5' + +services: + db: + image: cockroachdb/cockroach:latest + container_name: badaas-db + ports: + - "8080:8080" # Web based dashboard + # TODO make this container secure + command: start-single-node --insecure + volumes: + - "${PWD}/badaas/docker/db/.cockroach-data:/cockroach/cockroach-data" + environment: + - COCKROACH_USER=root + - COCKROACH_DATABASE=badaas_db diff --git a/cmd/gen/docker_test.go b/cmd/gen/docker_test.go new file mode 100644 index 0000000..d9d73c3 --- /dev/null +++ b/cmd/gen/docker_test.go @@ -0,0 +1,182 @@ +package gen + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/ditrit/badaas-cli/cmd/testutils" +) + +func TestGenerateDockerFilesCreateFilesWhenDestinationFolderNotExists(t *testing.T) { + generateDockerFiles(nil, nil) + checkFilesExist(t) + teardown() +} + +func TestGenerateDockerFilesOverwriteFilesWhenDestinationFolderExists(t *testing.T) { + destDir := filepath.Join("badaas", "docker", "db") + err := os.MkdirAll(destDir, os.ModePerm) + assert.Nil(t, err) + + destFile := filepath.Join(destDir, "docker-compose.yml") + err = os.WriteFile(destFile, []byte("hello"), 0o0600) + assert.Nil(t, err) + + generateDockerFiles(nil, nil) + checkFilesExist(t) + + fileContent, err := os.ReadFile(destFile) + assert.Nil(t, err) + assert.NotEqual(t, string(fileContent), "hello") + + teardown() +} + +func TestCopyDirCreatesDestinationDirIfItDoesNotExist(t *testing.T) { + copyDir( + filepath.Join("docker", "db"), + filepath.Join("badaas", "docker", "db"), + ) + checkDockerDBFilesExist(t) + teardown() +} + +func TestCopyDirCopyFilesIfTheDestinationFolderAlreadyExists(t *testing.T) { + destDir := filepath.Join("badaas", "docker", "db") + err := os.MkdirAll(destDir, os.ModePerm) + assert.Nil(t, err) + + copyDir(filepath.Join("docker", "db"), destDir) + checkDockerDBFilesExist(t) + teardown() +} + +func TestCopyDirPanicsIfStatOnDestDirIsNotPossible(t *testing.T) { + assertPanic(t, func() { + copyDir(filepath.Join("docker", "db"), "\000") + }, "error running stat") +} + +func TestCopyDirPanicsIfDestDirCreationFails(t *testing.T) { + assertPanic(t, func() { + copyDir(filepath.Join("docker", "db"), "") + }, "error creating directory") +} + +func TestCopyDirPanicsIfReadOnEmbedFileSystemIsNotPossible(t *testing.T) { + assertPanic(t, func() { + copyDir("not_exists", filepath.Join("badaas", "docker", "db")) + }, "error reading source directory") +} + +func TestCopyDirPanicsIfDestDirIsNotADirectory(t *testing.T) { + err := os.WriteFile("file.txt", []byte("hello"), 0o0600) + assert.Nil(t, err) + + assertPanic(t, func() { + copyDir(filepath.Join("docker", "db"), "file.txt") + }, "destination path file.txt is not a directory") +} + +func TestCopyFilePanicsWhenDestPathDoesNotExist(t *testing.T) { + assertPanic(t, func() { + copyFile( + filepath.Join("docker", "db", "docker-compose.yml"), + filepath.Join("badaas", "docker", "db", "docker-compose.yml"), + ) + }, "error writing on destination file") +} + +func TestCopyFileWorksWhenDestPathAlreadyExistsButNotTheFile(t *testing.T) { + destDir := filepath.Join("badaas", "docker", "db") + err := os.MkdirAll(destDir, os.ModePerm) + assert.Nil(t, err) + + copyFile( + filepath.Join("docker", "db", "docker-compose.yml"), + filepath.Join(destDir, "docker-compose.yml"), + ) + checkDockerDBFilesExist(t) + teardown() +} + +func TestCopyFileWorksWhenDestPathAndFileAlready(t *testing.T) { + destDir := filepath.Join("badaas", "docker", "db") + err := os.MkdirAll(destDir, os.ModePerm) + assert.Nil(t, err) + + destFile := filepath.Join(destDir, "docker-compose.yml") + err = os.WriteFile(destFile, []byte("hello"), 0o0600) + assert.Nil(t, err) + + copyFile(filepath.Join("docker", "db", "docker-compose.yml"), destFile) + + checkDockerDBFilesExist(t) + + fileContent, err := os.ReadFile(destFile) + assert.Nil(t, err) + assert.NotEqual(t, string(fileContent), "hello") + + teardown() +} + +func TestCopyFilePanicsIfReadOnEmbedFileSystemIsNotPossible(t *testing.T) { + assertPanic(t, func() { + copyFile( + filepath.Join("docker", "db", "not_exists"), + filepath.Join("badaas", "docker", "db"), + ) + }, "error reading source file") +} + +func TestCopyFilePanicsIfDestPathIsADirectory(t *testing.T) { + err := os.MkdirAll("badaas", os.ModePerm) + assert.Nil(t, err) + + assertPanic(t, func() { + copyFile(filepath.Join("docker", "db", "docker-compose.yml"), "badaas/") + }, "error writing on destination file") + + teardown() +} + +func TestCopyFilePanicsIfWriteOnDestPathIsNotPossible(t *testing.T) { + assertPanic(t, func() { + copyFile(filepath.Join("docker", "db", "docker-compose.yml"), "/badaas.txt") + }, "permission denied") +} + +func assertPanic(t *testing.T, functionShouldPanic func(), errorMessage string) { + defer func() { + if r := recover(); r == nil { + t.Errorf("The function did not panic") + } else { + err := r.(error) + assert.ErrorContains(t, err, errorMessage) + } + }() + functionShouldPanic() +} + +func checkFilesExist(t *testing.T) { + testutils.CheckFileExists(t, ".dockerignore") + testutils.CheckFileExists(t, "Makefile") + testutils.CheckFileExists(t, filepath.Join("badaas", "config", "badaas.yml")) + testutils.CheckFileExists(t, filepath.Join("badaas", "docker", "api", "docker-compose.yml")) + testutils.CheckFileExists(t, filepath.Join("badaas", "docker", "api", "Dockerfile")) + checkDockerDBFilesExist(t) +} + +func checkDockerDBFilesExist(t *testing.T) { + testutils.CheckFileExists(t, filepath.Join("badaas", "docker", "db", "docker-compose.yml")) +} + +func teardown() { + testutils.RemoveFile(".dockerignore") + testutils.RemoveFile("Makefile") + testutils.RemoveFile("file.txt") + testutils.RemoveFile("badaas") +} diff --git a/cmd/gen/gen.go b/cmd/gen/gen.go new file mode 100644 index 0000000..4e97bad --- /dev/null +++ b/cmd/gen/gen.go @@ -0,0 +1,17 @@ +package gen + +import ( + "github.com/ditrit/badaas-cli/cmd/gen/conditions" + "github.com/ditrit/verdeter" +) + +var GenCmd = verdeter.BuildVerdeterCommand(verdeter.VerdeterConfig{ + Use: "gen", + Short: "Files and configurations generator", + Long: `gen is the command you can use to generate the files and configurations necessary for your project to use BadAss in a simple way.`, +}) + +func init() { + GenCmd.AddSubCommand(genDockerCmd) + GenCmd.AddSubCommand(conditions.GenConditionsCmd) +} diff --git a/cmd/log/config.go b/cmd/log/config.go new file mode 100644 index 0000000..777f639 --- /dev/null +++ b/cmd/log/config.go @@ -0,0 +1,24 @@ +package log + +import ( + log "github.com/sirupsen/logrus" + "github.com/spf13/viper" + + "github.com/ditrit/badaas-cli/cmd/version" +) + +var Logger = log.WithField("version", version.Version) + +const VerboseKey = "verbose" + +func init() { + log.SetFormatter(&log.TextFormatter{}) + log.SetLevel(log.InfoLevel) +} + +func SetLevel() { + verbose := viper.GetBool(VerboseKey) + if verbose { + log.SetLevel(log.DebugLevel) + } +} diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 0000000..cf8d768 --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,36 @@ +package cmd + +import ( + "github.com/ditrit/badaas-cli/cmd/gen" + "github.com/ditrit/badaas-cli/cmd/log" + "github.com/ditrit/badaas-cli/cmd/version" + "github.com/ditrit/verdeter" +) + +// rootCmd represents the base command when called without any subcommands +var rootCmd = verdeter.BuildVerdeterCommand(verdeter.VerdeterConfig{ + Use: "badaas-cli", + Short: "the badaas command line client", + Long: `badaas-cli is the command line tool that makes it possible to configure and run your badaas applications easily.`, + Version: version.Version, +}) + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + rootCmd.Execute() +} + +func init() { + rootCmd.AddSubCommand(gen.GenCmd) + + err := rootCmd.GKey( + log.VerboseKey, verdeter.IsBool, "v", + "Verbose logging", + ) + if err != nil { + panic(err) + } + + rootCmd.SetDefault(log.VerboseKey, false) +} diff --git a/cmd/testutils/file.go b/cmd/testutils/file.go new file mode 100644 index 0000000..f7c153a --- /dev/null +++ b/cmd/testutils/file.go @@ -0,0 +1,31 @@ +package testutils + +import ( + "io/fs" + "log" + "os" + "testing" +) + +func CheckFileNotExists(t *testing.T, name string) { + _, err := os.Stat(name) + if err == nil { + t.Error(err, "Should have been an error") + } +} + +func CheckFileExists(t *testing.T, name string) fs.FileInfo { + stat, err := os.Stat(name) + if err != nil { + t.Error(err) + } + + return stat +} + +func RemoveFile(name string) { + err := os.RemoveAll(name) + if err != nil { + log.Fatal(err) + } +} diff --git a/cmd/utils/slice.go b/cmd/utils/slice.go new file mode 100644 index 0000000..2b37095 --- /dev/null +++ b/cmd/utils/slice.go @@ -0,0 +1,15 @@ +package utils + +import ( + "github.com/elliotchance/pie/v2" +) + +func FindFirst[T any](ss []T, fn func(value T) bool) *T { + index := pie.FindFirstUsing(ss, fn) + + if index == -1 { + return nil + } + + return &ss[index] +} diff --git a/cmd/utils/slice_test.go b/cmd/utils/slice_test.go new file mode 100644 index 0000000..df29a67 --- /dev/null +++ b/cmd/utils/slice_test.go @@ -0,0 +1,59 @@ +package utils_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/ditrit/badaas-cli/cmd/utils" +) + +var ( + testResult3 = 33.04 + testResult4 = 0.11 +) + +var findFirstTests = []struct { + ss []float64 + expression func(value float64) bool + expected *float64 +}{ + { + nil, + func(value float64) bool { return value == 1.5 }, + nil, + }, + { + []float64{}, + func(value float64) bool { return value == 0.1 }, + nil, + }, + { + []float64{0.0, 1.5, 3.2}, + func(value float64) bool { return value == 9.99 }, + nil, + }, + { + []float64{5.4, 6.98, 4.987, 33.04}, + func(value float64) bool { return value == 33.04 }, + &testResult3, + }, + { + []float64{9.0, 0.11, 150.44, 33.04}, + func(value float64) bool { return value == 0.11 }, + &testResult4, + }, +} + +func TestFindFirst(t *testing.T) { + for _, test := range findFirstTests { + t.Run("", func(t *testing.T) { + result := utils.FindFirst(test.ss, test.expression) + if result == nil { + assert.Nil(t, test.expected) + } else { + assert.Equal(t, *test.expected, *result) + } + }) + } +} diff --git a/cmd/version/version.go b/cmd/version/version.go new file mode 100644 index 0000000..415100d --- /dev/null +++ b/cmd/version/version.go @@ -0,0 +1,3 @@ +package version + +var Version = "0.0.0" diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..b825a55 --- /dev/null +++ b/go.mod @@ -0,0 +1,48 @@ +module github.com/ditrit/badaas-cli + +go 1.18 + +require ( + github.com/dave/jennifer v1.6.1 + github.com/ditrit/badaas v0.0.0-20230829122312-83f5e8a9f307 + github.com/ditrit/verdeter v0.4.0 + github.com/elliotchance/pie/v2 v2.7.0 + github.com/ettle/strcase v0.1.1 + github.com/fatih/structtag v1.2.0 + github.com/sirupsen/logrus v1.9.3 + github.com/spf13/cobra v1.7.0 + github.com/spf13/viper v1.16.0 + github.com/stretchr/testify v1.8.4 + golang.org/x/tools v0.11.1 + gotest.tools v2.2.0+incompatible +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/google/go-cmp v0.5.9 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/spf13/afero v1.9.5 // indirect + github.com/spf13/cast v1.5.1 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/subosito/gotenv v1.4.2 // indirect + golang.org/x/exp v0.0.0-20220321173239-a90fa8a75705 // indirect + golang.org/x/mod v0.12.0 // indirect + golang.org/x/sys v0.10.0 // indirect + golang.org/x/text v0.9.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..51f5393 --- /dev/null +++ b/go.sum @@ -0,0 +1,526 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/dave/jennifer v1.6.1 h1:T4T/67t6RAA5AIV6+NP8Uk/BIsXgDoqEowgycdQQLuk= +github.com/dave/jennifer v1.6.1/go.mod h1:nXbxhEmQfOZhWml3D1cDK5M1FLnMSozpbFN/m3RmGZc= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/ditrit/badaas v0.0.0-20230829122312-83f5e8a9f307 h1:E0Y+X/qMQuUjy9zx3hpWFXvI3Bc0Jcm5u+HzLkb95hQ= +github.com/ditrit/badaas v0.0.0-20230829122312-83f5e8a9f307/go.mod h1:VVjGFmMgCYWtAaHOGtrRA4nGaZJjqTpwqojUNOUorx8= +github.com/ditrit/verdeter v0.4.0 h1:DzEOFauuXEGNQYP6OgYtHwEyb3w9riem99u0xE/l7+o= +github.com/ditrit/verdeter v0.4.0/go.mod h1:sKpWuOvYqNabLN4aNXqeBhcWpt7nf0frwqk0B5M6ax0= +github.com/elliotchance/pie/v2 v2.7.0 h1:FqoIKg4uj0G/CrLGuMS9ejnFKa92lxE1dEgBD3pShXg= +github.com/elliotchance/pie/v2 v2.7.0/go.mod h1:18t0dgGFH006g4eVdDtWfgFZPQEgl10IoEO8YWEq3Og= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ettle/strcase v0.1.1 h1:htFueZyVeE1XNnMEfbqp5r67qAN/4r6ya1ysq8Q+Zcw= +github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA9o9VY= +github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= +github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= +github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= +github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM= +github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= +github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= +github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc= +github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= +github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20220321173239-a90fa8a75705 h1:ba9YlqfDGTTQ5aZ2fwOoQ1hf32QySyQkR6ODGDzHlnE= +golang.org/x/exp v0.0.0-20220321173239-a90fa8a75705/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.11.1 h1:ojD5zOW8+7dOGzdnNgersm8aPfcDjhMp12UfG93NIMc= +golang.org/x/tools v0.11.1/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 h1:sC1Xj4TYrLqg1n3AN10w871An7wJM0gzgcm8jkIkECQ= +gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= +gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= +gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/main.go b/main.go new file mode 100644 index 0000000..3a3c979 --- /dev/null +++ b/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/ditrit/badaas-cli/cmd" + +func main() { + cmd.Execute() +} diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..fa62460 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=ditrit_badaas-cli +sonar.organization=ditrit +sonar.projectName=badaas-cli +sonar.host.url=https://sonarcloud.io +sonar.sources=. +# as cmd/docker/api/Dockerfile will be used by the user, +# we can't avoid doing COPY . . because we don't know the project structure. +# Anyway, this is done in the builder image, +# so it is not a safety risk even if sonar marks it as such. +sonar.exclusions=**/*_test.go,mocks/***,vendor/***,cmd/gen/docker/api/Dockerfile +sonar.tests=. +sonar.test.inclusions=**/*_test.go,cmd/gen/conditions/tests/*** +sonar.go.coverage.reportPaths=coverage_unit.out/coverage_unit.out \ No newline at end of file