Skip to content

Commit

Permalink
Merge pull request #621 from kthcloud/dev
Browse files Browse the repository at this point in the history
Maintenance Update
  • Loading branch information
saffronjam authored May 31, 2024
2 parents d1a4a36 + e75fbf3 commit 1a90c21
Show file tree
Hide file tree
Showing 56 changed files with 1,820 additions and 853 deletions.
49 changes: 11 additions & 38 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,58 +13,31 @@ on:
- '.github/workflows/run-tests.yml'

jobs:
acc:
tests:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.20.0'

- name: Create config directory
run: sudo mkdir -p /etc/deploy && sudo chown $USER /etc/deploy
go-version: '>=1.21.0'

- name: Create config file from secret
- name: Install local environment
id: setup-local
run: |
echo "${{ vars.CONFIG_FILE }}" | sudo tee /etc/deploy/config.yaml > /dev/null
cd scripts/local
chmod +x ./setup.sh && ./setup.sh -y --configure-dns
cd ../..
ls -la
- name: Export configuration file path
run: echo "DEPLOY_CONFIG_FILE=/etc/deploy/config.yaml" >> $GITHUB_ENV
run: echo "DEPLOY_CONFIG_FILE=config.local.yml" >> $GITHUB_ENV

- name: Run acceptance tests
run: go test -timeout 30m ./test/acc/...
e2e:
runs-on: ubuntu-latest

# This assumes that the configuration file connects to Redis at localhost:6379
services:
redis:
image: redis
ports:
- 6379:6379

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.20.0'

- name: Create config directory
run: sudo mkdir -p /etc/deploy && sudo chown $USER /etc/deploy

- name: Create config file from secret
run: |
echo "${{ vars.CONFIG_FILE }}" | sudo tee /etc/deploy/config.yaml > /dev/null
- name: Export configuration file path
run: echo "DEPLOY_CONFIG_FILE=/etc/deploy/config.yaml" >> $GITHUB_ENV
go test -timeout 30m ./test/acc/...
- name: Start main program
run: |
Expand All @@ -79,4 +52,4 @@ jobs:
- name: Run e2e tests
run: go test -timeout 30m ./test/e2e/...

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ scripts/local/config/
scripts/local/go-deploy-placeholder/

# Generated by scripts/setup.sh
config-local.yml
config.local.yml

# Caches kubeconfig
cache/
Expand Down
11 changes: 1 addition & 10 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ func Create(opts *Options) *App {
{Name: "Validate application", Task: func() error { return validateApp(opts) }},
{Name: "Setup environment", Task: func() error { return config.SetupEnvironment(opts.Mode) }},
{Name: "Setup metrics", Task: metrics.Setup},
{Name: "Enable test mode if requested", Task: enableTestIfRequested},
{Name: "Setup database", Task: db.Setup},
{Name: "Clean up old tests", Task: intializer.CleanUpOldTests},
{Name: "Synchronize VM ports", Task: intializer.SynchronizeVmPorts},
{Name: "Run migrations", Task: migrator.Migrate},
{Name: "Reset running jobs", Task: func() error { return job_repo.New().ResetRunning() }},
{Name: "Ensure system deployments exists", Task: intializer.EnsureSystemDeploymentsExists},
{Name: "Ensure test users exist", Task: intializer.EnsureTestUsersExist},
}

for idx, task := range initTasks {
Expand Down Expand Up @@ -195,12 +195,3 @@ func validateApp(options *Options) error {

return nil
}

func enableTestIfRequested() error {
if config.Config.Mode == mode.Test {
log.Printf("%sRUNNING IN TEST MODE. NO AUTHENTICATION WILL BE REQUIRED%s", log.Bold, log.Reset)
config.Config.MongoDB.Name = config.Config.MongoDB.Name + "-test"
}

return nil
}
172 changes: 0 additions & 172 deletions config.local.yml

This file was deleted.

4 changes: 3 additions & 1 deletion models/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ const (
type ConfigType struct {
Port int `yaml:"port"`
ExternalUrl string `yaml:"externalUrl"`
Mode string `yaml:"mode"`
// Mode is the mode in which the application is running
// It is set using the command line flag --mode
Mode string
// Filepath is the path to the configuration file
// It is set by the SetupEnvironment function when the configuration is loaded
Filepath string
Expand Down
5 changes: 3 additions & 2 deletions models/model/deployment_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type DeploymentUpdateParams struct {
}

type DeploymentUpdateOwnerParams struct {
NewOwnerID string
OldOwnerID string
NewOwnerID string
OldOwnerID string
MigrationCode *string
}
4 changes: 4 additions & 0 deletions models/model/deployment_related.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const (
LogSourceBuild = "build"
)

var (
EmptyReplicaStatus = &ReplicaStatus{}
)

type App struct {
Name string `bson:"name"`

Expand Down
16 changes: 13 additions & 3 deletions models/model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ var (
FetchGravatarInterval = 10 * time.Minute
)

const (
TestAdminUserID = "955f0f87-37fd-4792-90eb-9bf6989e698a"
TestPowerUserID = "955f0f87-37fd-4792-90eb-9bf6989e698b"
TestDefaultUserID = "955f0f87-37fd-4792-90eb-9bf6989e698c"

TestAdminUserApiKey = "test-api-key-admin"
TestPowerUserApiKey = "test-api-key-power"
TestDefaultUserApiKey = "test-api-key-default"
)

type User struct {
ID string `bson:"id"`
Username string `bson:"username"`
Expand All @@ -22,9 +32,9 @@ type User struct {
IsAdmin bool `bson:"isAdmin"`
EffectiveRole EffectiveRole `bson:"effectiveRole"`

PublicKeys []PublicKey `bson:"publicKeys"`
ApiKeys []ApiKey `bson:"apiKeys"`
UserData []UserData `bson:"userData"`
PublicKeys []PublicKey `bson:"publicKeys,omitempty"`
ApiKeys []ApiKey `bson:"apiKeys,omitempty"`
UserData []UserData `bson:"userData,omitempty"`

LastAuthenticatedAt time.Time `bson:"lastAuthenticatedAt"`
}
Expand Down
5 changes: 3 additions & 2 deletions models/model/vm_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ type VmUpdateParams struct {
}

type VmUpdateOwnerParams struct {
NewOwnerID string
OldOwnerID string
NewOwnerID string
OldOwnerID string
MigrationCode *string
}

type VmActionParams struct {
Expand Down
Loading

0 comments on commit 1a90c21

Please sign in to comment.