Skip to content

Commit

Permalink
ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
dezren39 committed Mar 6, 2024
1 parent c15a601 commit 072d563
Show file tree
Hide file tree
Showing 21 changed files with 1,125 additions and 53 deletions.
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3'
services:
xen-orchestra:
restart: always
image: ronivay/xen-orchestra:latest
container_name: xen-orchestra
stop_grace_period: 1m
ports:
- "1337:80"
environment:
- HTTP_PORT=80
cap_add:
- SYS_ADMIN
- DAC_READ_SEARCH
security_opt:
- apparmor:unconfined
volumes:
- xo-data:/var/lib/xo-server
- redis-data:/var/lib/redis
logging: &default_logging
driver: "json-file"
options:
max-size: "1M"
max-file: "2"
volumes:
xo-data:
redis-data:
57 changes: 57 additions & 0 deletions sources/identity/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,60 @@ identity
identity.exe
*.exe
.ssh

# Auto-generated .gitignore file.
# See https://gowebly.org for more information.

# macOS files.
.DS_Store

# IDE files.
.idea/
.vscode/

# Go workflow files.
go.work

# Environment files.
.env

# Generated folders.
bin/
dist-ssr/
dist/

# Node modules.
node_modules/

# Vendor folders.
vendor/

# Temp folders.
.parcel-cache/
tmp/

# Logs.
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Ignore by extensions.
*.exe
*.exe~
*.dll
*.so
*.dylib
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.local
*.lockb
*.test
*.tmp
*.out
18 changes: 9 additions & 9 deletions sources/identity/cmd/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
icfg "github.com/developing-today/code/src/identity/cmd/configuration"
contextservice "github.com/developing-today/code/src/identity/cmd/context"
d "github.com/developing-today/code/src/identity/cmd/do"
"github.com/developing-today/code/src/identity/cmd/identity"
idc "github.com/developing-today/code/src/identity/cmd/identity/configuration"
ssh "github.com/developing-today/code/src/identity/cmd/ssh"
idc "github.com/developing-today/code/src/identity/cmd/ssh/configuration"
"github.com/developing-today/code/src/identity/cmd/stream"
"github.com/developing-today/code/src/identity/configuration"
"github.com/samber/do/v2"
Expand All @@ -28,7 +28,7 @@ func StartAllAltCmd(command cobra.Command) *cobra.Command {
return &result
}

func StartAllCmd(ctx context.Context, config *configuration.IdentityServerConfiguration) *cobra.Command {
func StartAllCmd(ctx context.Context, config *configuration.SshServerConfiguration) *cobra.Command {
if ctx == nil {
ctx = context.Background()
}
Expand All @@ -41,12 +41,12 @@ func StartAllCmd(ctx context.Context, config *configuration.IdentityServerConfig
Run: StartAllServices(ctx, config),
Aliases: []string{"s", "run", "serve", "publish", "pub", "p", "i", "y", "u", "o", "p", "q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "b"},
}
result.AddCommand(charm.StartCharmCmd(ctx, config), identity.StartIdentityCmd(ctx, config), stream.StartStreamCmd(ctx, config))
result.AddCommand(charm.StartCharmCmd(ctx, config), ssh.StartIdentityCmd(ctx, config), stream.StartStreamCmd(ctx, config))
result.AddCommand(StartAllAltCmd(*result))
return result
}

func StartAllServices(ctx context.Context, config *configuration.IdentityServerConfiguration) func(*cobra.Command, []string) {
func StartAllServices(ctx context.Context, config *configuration.SshServerConfiguration) func(*cobra.Command, []string) {
if ctx == nil {
ctx = context.Background()
}
Expand All @@ -61,7 +61,7 @@ func StartAllServices(ctx context.Context, config *configuration.IdentityServerC
}
}

func StartServices(ctx context.Context, config *configuration.IdentityServerConfiguration) func(*cobra.Command, []string) {
func StartServices(ctx context.Context, config *configuration.SshServerConfiguration) func(*cobra.Command, []string) {
return func(cmd *cobra.Command, args []string) {
log.Info("Setting up shutdown context")
ctx, cancel := context.WithCancel(ctx)
Expand Down Expand Up @@ -152,16 +152,16 @@ func StartServices(ctx context.Context, config *configuration.IdentityServerConf
log.Info("Providing services")

d.Provide(i, contextservice.NewContextService(ctx))
d.Provide(i, idc.NewIdentityServerConfigurationService(config))
d.Provide(i, idc.NewSshServerConfigurationService(config))
d.Provide(i, command.NewCommandService(cmd, args))
d.Provide(i, icfg.NewConfigurationService(config.Configuration, config.ConfigurationSeparator, config.ConfigurationLocations))
d.Provide(i, charm.NewCharmService)
d.Provide(i, identity.NewIdentityService)
d.Provide(i, ssh.NewSshService)
d.Provide(i, stream.NewStreamService)

log.Info("Starting services")
d.Start[charm.CharmService](i)
d.Start[identity.IdentityService](i)
d.Start[ssh.SshService](i)
d.Start[stream.StreamService](i)
log.Info("Services started")

Expand Down
4 changes: 2 additions & 2 deletions sources/identity/cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
charmcmd "github.com/charmbracelet/charm/cmd"

"github.com/developing-today/code/src/identity/cmd/all"
"github.com/developing-today/code/src/identity/cmd/identity/configuration"
"github.com/developing-today/code/src/identity/cmd/ssh/configuration"
cfg "github.com/developing-today/code/src/identity/configuration"
"github.com/spf13/cobra"
)
Expand All @@ -22,7 +22,7 @@ func DefaultRootCmdWithContext(ctx context.Context) *cobra.Command {
return RootCmd(ctx, configuration.LoadDefaultConfiguration())
}

func RootCmd(ctx context.Context, config *cfg.IdentityServerConfiguration) *cobra.Command {
func RootCmd(ctx context.Context, config *cfg.SshServerConfiguration) *cobra.Command {
if ctx == nil {
ctx = context.Background()
}
Expand Down
56 changes: 56 additions & 0 deletions sources/identity/cmd/ssh/configuration/configuration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package configuration

import (
"github.com/charmbracelet/log"
"github.com/developing-today/code/src/identity/configuration"
"github.com/knadh/koanf"
"github.com/samber/do/v2"
)

func NewConfiguration() *configuration.SshServerConfiguration {
return &configuration.SshServerConfiguration{
ConfigurationSeparator: configuration.Separator,
Configuration: koanf.New(configuration.Separator),
ConfigurationLocations: &configuration.ConfigurationLocations{
ConfigurationFilePaths: []string{
configuration.ConfigurationFilePath,
// identity.kdl identity.config.kdl config.identity.kdl identity.config
// run these against ? binary dir ? pwd of execution ? appdata ? .config ? .local ???
// then check for further locations/env-prefixes/etc from first pass, rerun on top with second pass
// (maybe config.kdl next to binary sets a new set of configurationPaths, finish out loading from defaults, then load from new paths)
// this pattern continues, after hard-code default env/file search, then custom file/env search, then eventually maybe nats/centrifuge/s3 or other remote or db config
},
EmbeddedConfigurationFilePaths: []string{
configuration.EmbeddedConfigurationFilePath,
},
},
EmbedFS: &configuration.EmbedFS,
}
}

func LoadDefaultConfiguration() *configuration.SshServerConfiguration {
config := NewConfiguration()
config.LoadConfiguration()
log.Info("Loaded config", "config", config.Configuration.Sprint())
return config
}

type SshServiceConfiguration interface {
Configuration() *configuration.SshServerConfiguration
}

type IdentityServiceConfigurationImpl struct {
config *configuration.SshServerConfiguration
}

func (isc *IdentityServiceConfigurationImpl) Configuration() *configuration.SshServerConfiguration {
return isc.config
}

func NewSshServerConfigurationService(config *configuration.SshServerConfiguration) func(do.Injector) (SshServiceConfiguration, error) {
return func(i do.Injector) (SshServiceConfiguration, error) {
return &IdentityServiceConfigurationImpl{
config: config,
}, nil
}
}
Loading

0 comments on commit 072d563

Please sign in to comment.