Skip to content

Commit

Permalink
Self-service building (backend pieces) (#39)
Browse files Browse the repository at this point in the history
* Add query to get a user's groups

so that the frontend can display a list of folders they can put a new
environment in

* Document LDAP config

* Properly format exceptions from backend

Converting an exception to a string just extracts the message – you
don't get to see what type the exception was, which is critical.

* Install watchfiles in dev

This is required for the server to efficiently restart on file changes.

* Return useful error when builder connection fails

* Make builder URL configurable

* Send package versions to builder

* Make it possible to export the GraphQL schema

with `strawberry export-schema softpack_core.graphql:GraphQL.schema`

* Eagerly create softpack.yml when build queued

* Upgrade jinja2: Closes #34

* Remove requirements.txt

This isn't used for anything??
  • Loading branch information
sersorrel authored Jan 29, 2024
1 parent e15695b commit ea9186f
Show file tree
Hide file tree
Showing 13 changed files with 309 additions and 62 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,21 @@ $ source spack/share/spack/setup-env.sh
```

To start the service, you will also need to configure a git repository to store
artifacts.
artifacts, and configure details of an LDAP server to query group information:

```yaml
artifacts:
repo: # see "integration tests" below

ldap:
server: "ldaps://ldap.example"
base: "ou=group,dc=example,dc=ac,dc=uk"
filter: "memberuid={user}"
group:
attr: "cn"
pattern: ".*"

```

### Stable release

Expand Down
97 changes: 92 additions & 5 deletions poetry.lock

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

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ types-setuptools = "^67.7.0.1"
types-PyYAML = "^6.0.12.9"
types-requests = "^2.30.0.0"
virtualenv = "^20.20.0"
watchfiles = "^0.21.0"

[tool.poetry.group.doc]
optional = true
Expand Down
25 changes: 0 additions & 25 deletions requirements.txt

This file was deleted.

6 changes: 5 additions & 1 deletion softpack_core/config/conf/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ server:
- http://localhost:3000
- http://localhost:5173

builder:
host: 0.0.0.0
port: 8001

artifacts:
repo:
url: https://github.com/mjkw31/softpack-artifacts
Expand All @@ -35,4 +39,4 @@ spack:
# filter:
# group:
# attr:
# pattern:
# pattern:
7 changes: 7 additions & 0 deletions softpack_core/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class HeaderConfig(BaseModel):
port: int


class BuilderConfig(BaseModel):
"""Builder config model."""

host: str
port: int


class VaultConfig(BaseModel):
"""HashiCorp vault config."""

Expand Down
2 changes: 2 additions & 0 deletions softpack_core/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from .models import (
ArtifactsConfig,
BuilderConfig,
LDAPConfig,
ServerConfig,
SpackConfig,
Expand All @@ -32,6 +33,7 @@ class Settings(BaseSettings):
ldap: Optional[LDAPConfig]
artifacts: ArtifactsConfig
spack: SpackConfig
builder: BuilderConfig

class Config:
"""Configuration loader."""
Expand Down
6 changes: 4 additions & 2 deletions softpack_core/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
from .app import app
from .schemas.base import BaseSchema
from .schemas.environment import EnvironmentSchema
from .schemas.groups import GroupsSchema
from .schemas.package_collection import PackageCollectionSchema


class GraphQL(API):
"""GraphQL API."""

prefix = "/graphql"
schemas = [EnvironmentSchema, PackageCollectionSchema]
schemas = [EnvironmentSchema, PackageCollectionSchema, GroupsSchema]
commands = Typer(help="GraphQL commands.")

@staticmethod
Expand Down Expand Up @@ -126,4 +127,5 @@ def __init__(self, schema: strawberry.Schema, prefix: str) -> None:
"""
super().__init__(schema=schema, path=prefix)

router = Router(schema=Schema(schemas), prefix=prefix)
schema = Schema(schemas)
router = Router(schema=schema, prefix=prefix)
Loading

0 comments on commit ea9186f

Please sign in to comment.