Skip to content

Commit

Permalink
Add docs on how to leverage lib for local extension development, impr…
Browse files Browse the repository at this point in the history
…ove Godoc for existing fields (#10)

Co-authored-by: Daniil <[email protected]>
  • Loading branch information
eliasjf and daniilstrata authored Aug 15, 2023
1 parent fad1ebf commit 6bd07b5
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 2 deletions.
52 changes: 51 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
# service-extension
# Service Extension Library

## Local Setup
To develop Service Extensions on your local machine, follow the instructions below.
The steps listed below are only to aid in local development and are not required to run
the Maverics platform.

Download the latest version of Go. [Instructions](https://go.dev/doc/install) can be found on the Go website.

After Go is downloaded, create a project directory. For organizational purpose, it is
recommended to create this project alongside other Maverics configuration files. For
example, in an `/etc/maverics/extensions` directory for Linux users.

Next run `go mod init example.com/extensions` to initialize a Go module which will be
used for tracking dependencies. You can replace `example.com` with the name of your
company. Your directory structure look similar to the below.
```
etc
└── maveircs
├── extensions
│ ├── go.mod
│ └── go.sum
└── maverics.yaml
```

After the `go.mod` file has been successfully created, next run
`go get github.com/strata-io/service-extension` to add this library as a dependency
to your Go project. Adding this library as a dependency to your Go project will enable
the library to be imported in your Service Extensions.

You are now able to import and use the Service Extension library! The code snippet
below demonstrates how the library can be imported.

`/etc/maverics/extensions/auth.go`
```go
package main

import (

"github.com/strata-io/service-extension/orchestrator"
)

func IsAuthenticated(api orchestrator.Orchestrator, rw http.ResponseWriter, req *http.Request) bool {
return false
}
```

## Documentation
For library documentation, please visit the [Godoc site](https://pkg.go.dev/github.com/strata-io/service-extension).

For Maverics specific documentation, please visit the [product doc site](https://docs.strata.io/).
2 changes: 2 additions & 0 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ package log
type Logger interface {
// Debug will log at debug level.
Debug(keyPairs ...any)

// Info will log at info level.
Info(keyPairs ...any)

// Error will log at error level.
Error(keyPairs ...any)
}
14 changes: 14 additions & 0 deletions orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,24 @@ import (
)

type Orchestrator interface {
// Logger gets a logger.
Logger() log.Logger

// SessionProvider gets a session provider.
SessionProvider() session.Provider

// SecretProvider gets a secret provider. An error is returned if a secret
// provider is not configured.
SecretProvider() (secret.Provider, error)

// IdentityProvider gets an identity provider by name. An error is returned if
// the identity provider is not found.
IdentityProvider(name string) (idfabric.IdentityProvider, error)

// AttributeProvider gets an attribute provider by name. An error is returned if
// the attribute provider is not found.
AttributeProvider(name string) (idfabric.AttributeProvider, error)

// Router gets a router.
Router() router.Router
}
2 changes: 2 additions & 0 deletions secret/secret.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package secret

// Provider is used to retrieve secrets from the configured secret store.
type Provider interface {
// Get retrieves the key from the secret provider.
Get(key string) any

// GetString retrieves the key from the secret provider as a string value.
GetString(key string) string
}
2 changes: 1 addition & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package session
import "net/http"

// Provider enables a way to interact with the underlying session store. Methods
// on the provider take a request in order to lookup the associated session.
// on the provider take a request in order to look up the associated session.
//
// Example:
//
Expand Down

0 comments on commit 6bd07b5

Please sign in to comment.