Skip to content

Commit cb99937

Browse files
authored
Version V0.1.0-alpha.4 release
2 parents 91a6e07 + d37e306 commit cb99937

File tree

108 files changed

+5263
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+5263
-203
lines changed

.env.sample

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ CADDY_ENDPOINT=http://localhost:2019
2222
CADDY_DATA_VOLUME=/etc/nixopus/caddy/data
2323
CADDY_CONFIG_VOLUME=/etc/nixopus/caddy/config
2424
DB_VOLUME=/etc/nixopus/db
25-
ALLOWED_ORIGIN=https://DOMAIN
25+
ALLOWED_ORIGIN=https://DOMAIN
26+
REDIS_URL=redis://localhost:6379

.github/workflows/format.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
- 'api/**'
1313
- 'view/**'
1414

15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
1519
jobs:
1620
format-api:
1721
name: Format API
@@ -20,6 +24,7 @@ jobs:
2024
- uses: actions/checkout@v4
2125
with:
2226
ref: ${{ github.head_ref }}
27+
token: ${{ secrets.GITHUB_TOKEN }}
2328

2429
- uses: actions/setup-go@v5
2530
with:
@@ -30,15 +35,25 @@ jobs:
3035

3136
- name: Run gofmt
3237
working-directory: api
33-
run: gofmt -l -w .
38+
run: |
39+
echo "Running gofmt..."
40+
gofmt -l -w .
41+
git status
3442
3543
- name: Commit API changes
44+
id: api-commit
3645
if: github.event_name == 'pull_request'
3746
uses: stefanzweifel/git-auto-commit-action@v5
3847
with:
3948
commit_message: 'style(api): format Go code'
4049
branch: ${{ github.head_ref }}
4150
file_pattern: 'api/**/*.go'
51+
commit_user_name: 'github-actions[bot]'
52+
commit_user_email: 'github-actions[bot]@users.noreply.github.com'
53+
skip_dirty_check: false
54+
skip_fetch: true
55+
skip_checkout: true
56+
disable_globbing: false
4257

4358
format-view:
4459
name: Format View
@@ -47,6 +62,7 @@ jobs:
4762
- uses: actions/checkout@v4
4863
with:
4964
ref: ${{ github.head_ref }}
65+
token: ${{ secrets.GITHUB_TOKEN }}
5066

5167
- uses: actions/setup-node@v4
5268
with:
@@ -66,9 +82,16 @@ jobs:
6682
run: yarn format
6783

6884
- name: Commit View changes
85+
id: view-commit
6986
if: github.event_name == 'pull_request'
7087
uses: stefanzweifel/git-auto-commit-action@v5
7188
with:
7289
commit_message: 'style(view): format frontend code'
7390
branch: ${{ github.head_ref }}
74-
file_pattern: 'view/**/*.{js,jsx,ts,tsx,css,md,json}'
91+
file_pattern: 'view/**'
92+
commit_user_name: 'github-actions[bot]'
93+
commit_user_email: 'github-actions[bot]@users.noreply.github.com'
94+
skip_dirty_check: false
95+
skip_fetch: true
96+
skip_checkout: true
97+
disable_globbing: false

.github/workflows/test.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Test Nixopus API
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
- feat/develop
8+
- test/unit_test
9+
paths:
10+
- 'api/**'
11+
push:
12+
branches:
13+
- 'master'
14+
- 'feat/develop'
15+
- 'test/unit_test'
16+
paths:
17+
- 'api/**'
18+
19+
jobs:
20+
test:
21+
runs-on: ubuntu-latest
22+
services:
23+
test-db:
24+
image: postgres:14-alpine
25+
env:
26+
POSTGRES_USER: nixopus
27+
POSTGRES_PASSWORD: nixopus
28+
POSTGRES_DB: nixopus_test
29+
ports:
30+
- 5433:5432
31+
options: >-
32+
--health-cmd pg_isready
33+
--health-interval 10s
34+
--health-timeout 5s
35+
--health-retries 5
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- uses: actions/setup-go@v5
41+
with:
42+
go-version: '1.22'
43+
check-latest: true
44+
cache: true
45+
cache-dependency-path: api/go.sum
46+
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
- name: Wait for PostgreSQL
51+
run: |
52+
for i in {1..10}; do
53+
if pg_isready -h localhost -p 5433 -U nixopus -d nixopus_test; then
54+
echo "PostgreSQL is ready"
55+
exit 0
56+
fi
57+
echo "Waiting for PostgreSQL... $i"
58+
sleep 2
59+
done
60+
echo "PostgreSQL failed to start"
61+
exit 1
62+
63+
- name: Build and run tests
64+
env:
65+
DB_HOST: localhost
66+
DB_PORT: 5433
67+
DB_USER: nixopus
68+
DB_PASSWORD: nixopus
69+
DB_NAME: nixopus_test
70+
run: |
71+
cd api && make test

.github/workflows/test.yaml.disabled

Lines changed: 0 additions & 28 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [v0.1.0-alpha.4] - Unreleased
6+
7+
### Features
8+
- Users can enable or disable features in Nixopus as needed, giving them full control based on their individual preferences and use cases (#66)
9+
- Added caching layer for API endpoints to improve performance by caching frequently accessed middleware checks (#69)
10+
- Added container management interface with detailed view and actions (restart, stop, remove) (#72)
11+
12+
### Fixes
13+
- Skip automatic update checks and disable update functionality in development environment (#71)
14+
- Automatic port mapping for docker configurations (#73)
15+
16+
### Tests
17+
- Added unit tests for audit, auth, domain features service and storage layers (#68)
18+
19+
### CI
20+
- Spin up Test CI during feat/develop or master branches as the target and for PR's
21+
- Fixed auto commit not working for formatting nixopus api and nixopus view
22+
23+
### Chore
24+
- Added common.loading translations to i18n files
25+
- Prevent domain belongs to server checking logic from Dev Environment
26+
- Removed log viewer components description
27+
28+
[Unreleased]: https://github.com/raghavyuva/nixopus/compare/v0.1.0-alpha.3...HEAD
29+
[v0.1.0-alpha.4]: https://github.com/raghavyuva/nixopus/compare/v0.1.0-alpha.3...v0.1.0-alpha.4

api/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ run: build
66
@./bin/$(APP_NAME)
77

88
test:
9-
@go test -v ./...
9+
@go test -p 1 ./... -v -count=1

api/api/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"version": "v1",
55
"status": "active",
6-
"release_date": "2025-04-22T18:27:03.726562+05:30",
6+
"release_date": "2025-05-04T14:01:41.985272+05:30",
77
"end_of_life": "0001-01-01T00:00:00Z",
88
"changes": [
99
"Initial API version"

api/doc/openapi.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

api/internal/cache/cache.go

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cache
33
import (
44
"context"
55
"encoding/json"
6+
"fmt"
67
"time"
78

89
"github.com/go-redis/redis"
@@ -13,8 +14,10 @@ import (
1314
const (
1415
UserCacheKeyPrefix = "user:"
1516
OrgMembershipCacheKeyPrefix = "org_membership:"
16-
UserCacheTTL = 15 * time.Minute
17+
UserCacheTTL = 10 * time.Minute
1718
OrgMembershipCacheTTL = 30 * time.Minute
19+
FeatureFlagCacheKeyPrefix = "feature_flag:"
20+
FeatureFlagCacheTTL = 10 * time.Minute
1821
)
1922

2023
type Cache struct {
@@ -26,6 +29,9 @@ type CacheRepository interface {
2629
SetUser(ctx context.Context, email string, user *types.User) error
2730
GetOrgMembership(ctx context.Context, userID, orgID string) (bool, error)
2831
SetOrgMembership(ctx context.Context, userID, orgID string, belongs bool) error
32+
GetFeatureFlag(ctx context.Context, orgID, featureName string) (bool, error)
33+
SetFeatureFlag(ctx context.Context, orgID, featureName string, enabled bool) error
34+
InvalidateFeatureFlag(ctx context.Context, orgID, featureName string) error
2935
}
3036

3137
func NewCache(redisURL string) (*Cache, error) {
@@ -109,3 +115,29 @@ func (c *Cache) InvalidateOrgMembership(ctx context.Context, userID, orgID strin
109115
key := OrgMembershipCacheKeyPrefix + userID + ":" + orgID
110116
return c.client.Del(key).Err()
111117
}
118+
119+
func (c *Cache) GetFeatureFlag(ctx context.Context, orgID, featureName string) (bool, error) {
120+
key := fmt.Sprintf("%s:%s:%s", FeatureFlagCacheKeyPrefix, orgID, featureName)
121+
val, err := c.client.Get(key).Result()
122+
if err == redis.Nil {
123+
return false, redis.Nil
124+
}
125+
if err != nil {
126+
return false, err
127+
}
128+
return val == "true", nil
129+
}
130+
131+
func (c *Cache) SetFeatureFlag(ctx context.Context, orgID, featureName string, enabled bool) error {
132+
key := fmt.Sprintf("%s:%s:%s", FeatureFlagCacheKeyPrefix, orgID, featureName)
133+
val := "false"
134+
if enabled {
135+
val = "true"
136+
}
137+
return c.client.Set(key, val, FeatureFlagCacheTTL).Err()
138+
}
139+
140+
func (c *Cache) InvalidateFeatureFlag(ctx context.Context, orgID, featureName string) error {
141+
key := fmt.Sprintf("%s:%s:%s", FeatureFlagCacheKeyPrefix, orgID, featureName)
142+
return c.client.Del(key).Err()
143+
}

0 commit comments

Comments
 (0)