Skip to content

Commit 597e615

Browse files
committed
incus-osd/applications: Add openfga app
Signed-off-by: Mathias Gibbens <mathias.gibbens@futurfusion.io>
1 parent 1e3d7d3 commit 597e615

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package applications
2+
3+
import (
4+
"context"
5+
"crypto/tls"
6+
"errors"
7+
8+
"github.com/lxc/incus-os/incus-osd/internal/systemd"
9+
)
10+
11+
type openfga struct {
12+
common //nolint:unused
13+
}
14+
15+
// Start starts the systemd unit.
16+
func (*openfga) Start(ctx context.Context, _ string) error {
17+
// Start the unit.
18+
return systemd.EnableUnit(ctx, true, "openfga.service")
19+
}
20+
21+
// Stop stops the systemd unit.
22+
func (*openfga) Stop(ctx context.Context, _ string) error {
23+
// Stop the unit.
24+
return systemd.StopUnit(ctx, "openfga.service")
25+
}
26+
27+
// Update triggers restart after an application update.
28+
func (*openfga) Update(ctx context.Context, _ string) error {
29+
// Reload the systemd daemon to pickup any service definition changes.
30+
err := systemd.ReloadDaemon(ctx)
31+
if err != nil {
32+
return err
33+
}
34+
35+
// Restart the unit.
36+
return systemd.RestartUnit(ctx, "openfga.service")
37+
}
38+
39+
// Initialize runs first time initialization.
40+
func (*openfga) Initialize(_ context.Context) error {
41+
return nil
42+
}
43+
44+
// IsRunning reports if the application is currently running.
45+
func (*openfga) IsRunning(ctx context.Context) bool {
46+
return systemd.IsActive(ctx, "openfga.service")
47+
}
48+
49+
// IsPrimary reports if the application is a primary application.
50+
func (*openfga) IsPrimary() bool {
51+
return false
52+
}
53+
54+
// GetCertificate returns the keypair for the server certificate.
55+
func (*openfga) GetCertificate() (*tls.Certificate, error) {
56+
return nil, errors.New("not supported")
57+
}
58+
59+
// AddTrustedCertificate adds a new trusted certificate to the application.
60+
func (*openfga) AddTrustedCertificate(_ context.Context, _ string, _ string) error {
61+
return errors.New("not supported")
62+
}

incus-osd/internal/applications/load.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ func Load(_ context.Context, name string) (Application, error) {
1919
app = &incus{}
2020
case "migration-manager":
2121
app = &migrationManager{}
22+
case "openfga":
23+
app = &openfga{}
2224
case "operations-center":
2325
app = &operationsCenter{}
2426
default:

0 commit comments

Comments
 (0)