Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
957bc33
added did.store interfaces
woutslakhorst Jan 19, 2021
7390a19
some migration errors
woutslakhorst Jan 19, 2021
0bc6ed1
Update registry structure
stevenvegt Jan 19, 2021
0a236de
Rename registry to vdr
stevenvegt Jan 19, 2021
4f8cfef
Resolver with metdadata
stevenvegt Jan 19, 2021
16eb588
New DocUpdate interface
stevenvegt Jan 19, 2021
a806aad
Change visibility of store
stevenvegt Jan 19, 2021
9da1b33
move crypto mock
woutslakhorst Jan 19, 2021
e99111f
pkg error in crypto mock
woutslakhorst Jan 19, 2021
44cb1a5
added version-less in memory store
woutslakhorst Jan 19, 2021
c2d5b4b
moved typers
woutslakhorst Jan 19, 2021
3329629
added versioning to memory store
woutslakhorst Jan 19, 2021
e5db5a4
added mutex to memory store
woutslakhorst Jan 19, 2021
30e4309
added some comments
woutslakhorst Jan 19, 2021
1c7d8fd
Allow kidNamingFunc to return error
stevenvegt Jan 19, 2021
da2372f
Add crypto KeyCreator interface
stevenvegt Jan 19, 2021
e0c4e15
Add docCreator which creates did document
stevenvegt Jan 19, 2021
d757b21
Code cleanup of did doc create
stevenvegt Jan 20, 2021
0d59ea5
Registry implements Create
stevenvegt Jan 20, 2021
fedc8a7
Add didDocCreator to Registry
stevenvegt Jan 20, 2021
d0d87b5
Fix crypto mock
stevenvegt Jan 20, 2021
649817b
Fix paths in readme and add oapi-gen to makefile
stevenvegt Jan 20, 2021
39e836b
Fix code generation + update generated readme
stevenvegt Jan 20, 2021
f9bf79a
Naively connected the VDR to the store.
stevenvegt Jan 20, 2021
40eb439
Add DocDeactivator interface
stevenvegt Jan 20, 2021
f495f79
added server and client implementation for VDR API
woutslakhorst Jan 20, 2021
77d5988
working server with create-did CLI command
woutslakhorst Jan 20, 2021
c4f2544
copyright and gofmt
woutslakhorst Jan 20, 2021
f6cfdac
added timeoout to api client ctx
woutslakhorst Jan 20, 2021
4e4b872
added CLI resolve
woutslakhorst Jan 20, 2021
0299f54
wrong codestyle badge
woutslakhorst Jan 20, 2021
d660cca
README upd
woutslakhorst Jan 20, 2021
4b1b1b9
swagger UI upd
woutslakhorst Jan 20, 2021
1b45a14
Added model.Hash to crypto/hash
woutslakhorst Jan 21, 2021
71143ec
no annotations in codecov
woutslakhorst Jan 21, 2021
f2e6ac4
Add tests fof didKidNamingFunc
stevenvegt Jan 21, 2021
f475d0f
alias API generated types for DIDDocument and DIDDocumentMetadata
woutslakhorst Jan 21, 2021
86e8125
added DIDDocument and DIDDocumentMetadata to OAS
woutslakhorst Jan 21, 2021
5a60187
added test http handler to test package
woutslakhorst Jan 21, 2021
0e258f9
linter stuff
woutslakhorst Jan 22, 2021
1586d5b
one more linter thingy
woutslakhorst Jan 22, 2021
424bb13
Added some test coverage
woutslakhorst Jan 22, 2021
c0ab668
coverage for vdr api client
woutslakhorst Jan 22, 2021
8ca225d
Rename Registry to VDR
stevenvegt Jan 22, 2021
402f40c
Add interfaces to engine
stevenvegt Jan 22, 2021
a015e0a
remove unused references to crypto from vdr
stevenvegt Jan 22, 2021
148bc22
Update .gitignore
stevenvegt Jan 22, 2021
7c61024
Merge branch 'did_store' of https://github.com/nuts-foundation/nuts-n…
stevenvegt Jan 22, 2021
d01d558
Fix gofmt and golint errors
stevenvegt Jan 22, 2021
4bc6327
unused consts
woutslakhorst Jan 22, 2021
5da542b
Fix PR feedback
stevenvegt Jan 22, 2021
0a41992
Merge branch 'did_store' of https://github.com/nuts-foundation/nuts-n…
stevenvegt Jan 22, 2021
1b7a000
Fix PR feedback
stevenvegt Jan 22, 2021
77d6380
Wrap errors
stevenvegt Jan 22, 2021
21ab085
Fix PR feedback
stevenvegt Jan 25, 2021
9c14417
Fix automatic checks
stevenvegt Jan 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ data

# MacOS
.DS_Store

# ignore generated pem files from running the nuts-node executable.
/*.pem
56 changes: 49 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The server and client API is generated from the open-api spec:

.. code-block:: shell

oapi-codegen -generate types,server,client -package api docs/_static/example.yaml > api/generated.go
make gen-api

Generating Mocks
****************
Expand All @@ -51,16 +51,15 @@ These mocks are used by other modules

.. code-block:: shell

mockgen -destination=mock/mock_example.go -package=mock -source=example.go

make gen-mocks
README
******

The readme is auto-generated from a template and uses the documentation to fill in the blanks.

.. code-block:: shell

./generate_readme.sh
make gen-readme

This script uses ``rst_include`` which is installed as part of the dependencies for generating the documentation.

Expand All @@ -74,11 +73,54 @@ The documentation can be build by running

/docs $ make html

The resulting html will be available from ``docs/_build/html/index.html``
Requirements for running sphinx
===============================

- install python3
- install pip3 (if it doesn't install automatically)
- ``pip3 install sphinx``
- ``pip3 install recommonmark``
- ``pip3 install sphinx_rtd_theme``
- ``pip3 install rst_include``
- ``pip3 install sphinx-jsonschema``
- ``pip3 install sphinxcontrib-httpdomain``

Configuration
*************

config stuff
============
The Nuts-go library contains some configuration logic which allows for usage of configFiles, Environment variables and commandLine params transparently.
If a Nuts engine is added as Engine it'll automatically work for the given engine. It is also possible for an engine to add the capabilities on a standalone basis.
This allows for testing from within a repo.

The parameters follow the following convention:
``$ nuts --parameter X`` is equal to ``$ NUTS_PARAMETER=X nuts`` is equal to ``parameter: X`` in a yaml file.

Or for this piece of yaml

.. code-block:: yaml

nested:
parameter: X

is equal to ``$ nuts --nested.parameter X`` is equal to ``$ NUTS_NESTED_PARAMETER=X nuts``

Config parameters for engines are prepended by the ``engine.ConfigKey`` by default (configurable):

.. code-block:: yaml

engine:
nested:
parameter: X

is equal to ``$ nuts --engine.nested.parameter X`` is equal to ``$ NUTS_ENGINE_NESTED_PARAMETER=X nuts``


Options
*******

The following options can be configured:

.. marker-for-config-options

.. include:: options.rst

4 changes: 2 additions & 2 deletions README_template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Distributed registry for storing and querying health care providers their vendor
:target: https://codecov.io/gh/nuts-foundation/nuts-node
:alt: Code coverage

.. image:: https://api.codeclimate.com/v1/badges/040468237c838c03ff7d/maintainability
.. image:: https://api.codeclimate.com/v1/badges/69f77bd34f3ac253cae0/maintainability
:target: https://codeclimate.com/github/nuts-foundation/nuts-node/maintainability
:alt: Maintainability

Expand All @@ -25,5 +25,5 @@ Distributed registry for storing and querying health care providers their vendor
Configuration
*************

.. include:: docs/pages/configuration.rst
.. include:: docs/pages/configuration/configuration.rst
:start-after: .. marker-for-readme
15 changes: 10 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Nuts go
* Copyright (C) 2019 Nuts community
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -23,6 +23,8 @@ import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/nuts-foundation/nuts-node/core"
crypto "github.com/nuts-foundation/nuts-node/crypto/engine"
vdr "github.com/nuts-foundation/nuts-node/vdr/engine"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -102,6 +104,9 @@ func registerEngines() {
core.RegisterEngine(core.NewStatusEngine())
core.RegisterEngine(core.NewLoggerEngine())
core.RegisterEngine(core.NewMetricsEngine())
core.RegisterEngine(crypto.NewCryptoEngine())
core.RegisterEngine(vdr.NewVDREngine())

}

func injectConfig(cfg *core.NutsGlobalConfig) {
Expand All @@ -116,7 +121,7 @@ func injectConfig(cfg *core.NutsGlobalConfig) {
func configureEngines() {
for _, e := range core.EngineCtl.Engines {
// only if Engine is dynamically configurable
if e.Configure != nil {
if e.Configurable != nil {
if err := e.Configure(); err != nil {
logrus.Fatal(err)
}
Expand All @@ -132,7 +137,7 @@ func addFlagSets(cmd *cobra.Command, cfg *core.NutsGlobalConfig) {

func startEngines() {
for _, e := range core.EngineCtl.Engines {
if e.Start != nil {
if e.Runnable != nil {
if err := e.Start(); err != nil {
logrus.Fatal(err)
}
Expand All @@ -142,7 +147,7 @@ func startEngines() {

func shutdownEngines() {
for _, e := range core.EngineCtl.Engines {
if e.Shutdown != nil {
if e.Runnable != nil {
if err := e.Shutdown(); err != nil {
logrus.Error(err)
}
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ ignore:
- "mock/*"
- "**/mock.go"
- "docs/*"
github_checks:
annotations: false
4 changes: 2 additions & 2 deletions core/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Nuts go
* Copyright (C) 2019 Nuts community
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
4 changes: 2 additions & 2 deletions core/config_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Nuts go
* Copyright (C) 2019 Nuts community
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
4 changes: 2 additions & 2 deletions core/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Nuts go core
* Copyright (C) 2019 Nuts community
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
9 changes: 7 additions & 2 deletions core/diagnostics.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Nuts go core
* Copyright (C) 2019 Nuts community
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -19,6 +19,11 @@

package core

// Diagnosable allows the implementer, mostly engines, to return diagnostics.
type Diagnosable interface {
Diagnostics() []DiagnosticResult
}

// DiagnosticResult are the result of different checks giving information on how well the system is doing
type DiagnosticResult interface {
// Name returns a simple and understandable name of the check
Expand Down
4 changes: 2 additions & 2 deletions core/diagnostics_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Nuts go core
* Copyright (C) 2019 Nuts community
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
33 changes: 20 additions & 13 deletions core/engine.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Nuts go
* Copyright (C) 2019 Nuts community
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -50,6 +50,21 @@ type EchoRouter interface {

// START_DOC_ENGINE_1

// Runnable is the interface that groups the Start and Shutdown methods.
// When an engine implements these they will be called on startup and shutdown.
// Start and Shutdown should not be called more than once
type Runnable interface {
Start() error
Shutdown() error
}

// Configurable is the interface that contains the Configure method.
// When an engine implements the Configurable interface, it will be called before startup.
// Configure should only be called once per engine instance
type Configurable interface {
Configure() error
}

// Engine contains all the configuration options and callbacks needed by the executable to configure, start, monitor and shutdown the engines
type Engine struct {
// Name holds the human readable name of the engine
Expand All @@ -70,23 +85,15 @@ type Engine struct {
// Config is the pointer to a config struct. The config will be unmarshalled using the ConfigKey.
Config interface{}

// Configure checks if the combination of config parameters is allowed
Configure func() error

// Diagnostics returns a slice of DiagnosticResult
Diagnostics func() []DiagnosticResult
Diagnosable
Runnable
Configurable

// FlasSet contains all engine-local configuration possibilities so they can be displayed through the help command
FlagSet *pflag.FlagSet

// Routes passes the Echo router to the specific engine for it to register their routes.
Routes func(router EchoRouter)

// Shutdown the engine
Shutdown func() error

// Start the engine, this will spawn any clients, background tasks or active processes.
Start func() error
}

// END_DOC_ENGINE_1
Expand Down
4 changes: 2 additions & 2 deletions core/engine_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Nuts go
* Copyright (C) 2019 Nuts community
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
19 changes: 13 additions & 6 deletions core/logging.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Nuts go
* Copyright (C) 2019 Nuts community
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -42,9 +42,16 @@ func NewLoggerEngine() *Engine {
log.Infof("Verbosity is set to %s\n", lc.verbosity)
},
},
Diagnostics: func() []DiagnosticResult {
dr := &GenericDiagnosticResult{Title: "verbosity", Outcome: lc.verbosity}
return []DiagnosticResult{dr}
},
Diagnosable: loggerEngine{config: &lc},
}
}

type loggerEngine struct {
config *loggerConfig
}

// Diagnostics returns the diagnostics of the LoggerEngine.
func (l loggerEngine) Diagnostics() []DiagnosticResult {
Comment thread
stevenvegt marked this conversation as resolved.
dr := &GenericDiagnosticResult{Title: "verbosity", Outcome: l.config.verbosity}
return []DiagnosticResult{dr}
}
16 changes: 9 additions & 7 deletions core/metrics.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Nuts go core
* Copyright (C) 2020 Nuts community
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -25,21 +25,23 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
)

const NutsMetricsPrefix = "nuts_"

// NewMetricsEngine creates a new Engine for exposing prometheus metrics via http.
// Metrics are exposed on /metrics, by default the GoCollector and ProcessCollector are enabled.
Comment thread
stevenvegt marked this conversation as resolved.
func NewMetricsEngine() *Engine {
return &Engine{
Name: "Metrics",
Configure: configure,
Name: "Metrics",
Configurable: metricsEngine{},
Routes: func(router EchoRouter) {
router.GET("/metrics", echo.WrapHandler(promhttp.Handler()))
},
}
}

func configure() error {
type metricsEngine struct{}

// Configure configures the MetricsEngine.
// It configures and registers the prometheus collector
func (metricsEngine) Configure() error {
Comment thread
stevenvegt marked this conversation as resolved.
collectors := []prometheus.Collector{
prometheus.NewGoCollector(),
prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}),
Expand Down
4 changes: 2 additions & 2 deletions core/metrics_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Nuts go core
* Copyright (C) 2020 Nuts community
* Nuts node
* Copyright (C) 2021 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Loading