idmsvc-backend

module
v0.0.0-...-1a88b7f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2024 License: Apache-2.0

README

idm-domains-backend

Getting started

Pre-requisites:

  • golang 1.21 (not gcc-go)
  • docker or podman (>4.0.0)
  • docker-compose or podman-compose
  • python3
  • openshift client Installing OpenShift Client.

Packages for fedora 39:

$ sudo dnf upgrade
$ sudo dnf install git golang podman podman-compose
$ sudo dnf remove gcc-go

(Optional) Installing VSCode by repository on fedora 39:

$ sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
$ cat <<EOF | sudo tee /etc/yum.repos.d/vscode.repo
[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
EOF
$ sudo dnf check-update
$ sudo dnf install code

(Optional) Recomended extensions for vscode:

  • Go (highly recommended)
  • REST Client
  • 42Crunch OpenAPI

Once tasks:

  • Install used tools: make install-tools
  • Create your configs/config.yaml file: cp -vf configs/config.example.yaml configs/config.yaml
  • Create your secrets/private.mk file: cp -vf scripts/mk/private.example.mk secrets/private.mk
  • Follow the instructions in secrets/private.mk to set up Quay repository and Red Hat Repository access.
  • Create your configs/bonfire.yaml file: cp -vf configs/bonfire.example.yaml configs/bonfire.yaml
  • Add a GITHUB_TOKEN to ~/.config/bonfire/env if deploying frequently at ephemeral environment, to avoid API access rate limit.

Directory secrets/ is set to be ignored by git and docker.


  • Build by: make build
  • Lint code by: make lint
  • Start local infrastructure by: make compose-up
  • Launch tests by: make test
  • Run by: make run
  • Try locally by running scripts at: ./test/scripts/local-*.sh You can override the used xrhid by: XRHID_AS="service-account" ./test/scripts/local-*.sh
  • Stop local infrastructure by: make compose-down
  • Clean local infrastructure by: make compose-clean
  • Print out useful rules by: make help

  • Run with specific rbac profile and use local rbac mock:

    $ make compose-clean clean build compose-up run APP_CLIENTS_RBAC_PROFILE=domain-read-only
    $ curl "http://localhost:8020/api/rbac/v1/authorize?application=idmsvc"
    $ ./test/scripts/local-domains-list.sh
    
  • Bear in mind the rbac mock is started with the local infra.
  • Be aware to update some change in the rbac mock (such as some change on the custom.yaml profile), you will need to rebuild the container by make mock-rbac-build and restarting the local infra by make compose-clean compose-up.

For ephemeral environment look at: DEVELOPMENT.md file.

Project layout

internal/   Define the internal application components
├── api
│   ├── private: The code generated for the private api.
│   └── public: The code generated for the public api (types, http
│               framework server specific, spec)
├── config: Hold the configuration structure and functions to read it.
├── domain
│   └── model: Define the business model of the application.
├── handler: Hold application and handler interfaces.
│   └── impl: Implementation for the application interface.
├── infrastructure: specific code coupled to the http framework.
│   ├── middleware: all the middleware components comes here.
│   ├── router: wire the route of the service composing the different
│   │           api groups, and adding the middlewares.
│   └── service: define the Service interface
│       └── impl: Implement a Service for the application and different
|                 listeners (api, metrics, kafka consumer)
├── interface: Define the interfaces for `interactor`,
│              `repository` and `presenter` components.
├── test: All the helpers for tests are here
│   └── mock: Store all the generated mocks for the interfaces,
│             keeping the same directory structure
└── usecase: specific implementation for the `interface` directory
             for interactor, presenter and repository components.

cmd/      Define the binaries generated

api/      Define the public and private openapi specification

deployments/   Hold descriptors to deploy with clowder and local
               infrastructure with {podman,docker}-compose.

scripts/  Store useful scripts for the repository
├── db
│   └── migrations:  sql scripts for the migrations.
├── http:  Hold .http files to quickly check the API
└── mk:  Hold all the makefile scripts

See: https://github.com/golang-standards/project-layout

Architecture and Design docs

See: Architecture and design.

Design API

You can design your API importing the public.openapi.yaml file at api-designer at console.redhat.com.

When you have made your changes, then do click Actions > Download Design, and copy the downloaded file as api/public.openapi.yaml.

Now from the base of the repository now update code generated by make generate-api.

Finally, edit your source code to adapt to the changes (if necessary) and update your unit tests to cover new code and update to the changes.

Contributing

See CONTRIBUTING.md guide.

Aknowledgements

Thanks to all mates from hmscontent (content-sources), without all of you this would not be possible; every moment at hmscontent has been adding a grain of sand to build the path on this repository.

Big thanks to everybody.

Generating reference code documentation

TODO Ask if leverage godoc for this

References

Tech stack:

References to investigate

Tools

Http clients

Validate API

Directories

Path Synopsis
cmd
pendo-client
Package main is the entry point for the pendo-client application.
Package main is the entry point for the pendo-client application.
internal
api/metrics
Package metrics returns a hand marshalled /metrics response.
Package metrics returns a hand marshalled /metrics response.
api/openapi
Package openapi returns a hand marshalled openapi.json response.
Package openapi returns a hand marshalled openapi.json response.
api/private
Package private provides primitives to interact with the openapi HTTP API.
Package private provides primitives to interact with the openapi HTTP API.
api/public
Package public provides primitives to interact with the openapi HTTP API.
Package public provides primitives to interact with the openapi HTTP API.
config
The scope of this file is: - Define the configuration struct.
The scope of this file is: - Define the configuration struct.
errors/http/echo
package echo
package echo
infrastructure/token/domain_token
Domain Registration Token * * see docs/domain-token.md for more information
Domain Registration Token * * see docs/domain-token.md for more information
test/builder
Package builder to help on building data models.
Package builder to help on building data models.
test/perf
Package perf contains performance tests for the application.
Package perf contains performance tests for the application.
test/smoke
Package smoke contains all the smoke test for the service
Package smoke contains all the smoke test for the service
usecase/client/rbac
Package rbac provides primitives to interact with the openapi HTTP API.
Package rbac provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL