Skip to content

Commit

Permalink
refactor: remove cmd directory, put embed into internal
Browse files Browse the repository at this point in the history
  • Loading branch information
ElaBosak233 committed Apr 2, 2024
1 parent b9bd6a9 commit d72acd3
Show file tree
Hide file tree
Showing 23 changed files with 26 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Auto detect text files and perform LF normalization
* text=auto
*.py linguist-vendored
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@ uploads
/media/
/assets/
/config/
/application.json
/configs/*
/k8s-config.yml
/platform.json
/ca/
/build/
/captures/
test.go
dist
_PgsHub.exe
_Cloudsdale.exe
signature.json
configs/signature.json
config.json

__pycache__
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Cloudsdale
# Cloudsdale

The **Cloudsdale** project is an *open-source, light-weight, Jeopardy-style's* CTF platform.

You can read more in the [Documentation](https://docs.ctf.e23.dev).
4 changes: 1 addition & 3 deletions cmd/cloudsdale/main.go → cloudsdale.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package main

import "github.com/elabosak233/cloudsdale/internal/app"

// @title Cloudsdale API
// @version 1.0
// @description Hack for fun not for profit.
// @title Cloudsdale
// @securityDefinitions.api_key ApiKeyAuth
// @in header
// @name Authorization
Expand Down
6 changes: 3 additions & 3 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2524,12 +2524,12 @@ const docTemplate = `{

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Version: "",
Host: "",
BasePath: "/api",
Schemes: []string{},
Title: "Cloudsdale API",
Description: "Hack for fun not for profit.",
Title: "Cloudsdale",
Description: "",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
Expand Down
6 changes: 2 additions & 4 deletions docs/swagger.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"swagger": "2.0",
"info": {
"description": "Hack for fun not for profit.",
"title": "Cloudsdale API",
"contact": {},
"version": "1.0"
"title": "Cloudsdale",
"contact": {}
},
"basePath": "/api",
"paths": {
Expand Down
4 changes: 1 addition & 3 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,7 @@ definitions:
type: object
info:
contact: {}
description: Hack for fun not for profit.
title: Cloudsdale API
version: "1.0"
title: Cloudsdale
paths:
/categories/:
get:
Expand Down
2 changes: 1 addition & 1 deletion internal/assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package assets

import (
"fmt"
"github.com/elabosak233/cloudsdale/embed"
"github.com/elabosak233/cloudsdale/internal/config"
"github.com/elabosak233/cloudsdale/internal/embed"
"os"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/casbin/casbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"github.com/casbin/casbin/v2"
"github.com/casbin/casbin/v2/model"
gormadapter "github.com/casbin/gorm-adapter/v3"
"github.com/elabosak233/cloudsdale/embed"
"github.com/elabosak233/cloudsdale/internal/database"
"github.com/elabosak233/cloudsdale/internal/embed"
"go.uber.org/zap"
)

Expand Down
4 changes: 2 additions & 2 deletions internal/config/application.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

import (
"github.com/elabosak233/cloudsdale/embed"
"github.com/elabosak233/cloudsdale/internal/embed"
"github.com/spf13/viper"
"go.uber.org/zap"
"io"
Expand Down Expand Up @@ -115,7 +115,7 @@ func AppCfg() *ApplicationCfg {

func InitApplicationCfg() {
v1 = viper.New()
configFile := path.Join("application.json")
configFile := path.Join("configs/application.json")
v1.SetConfigType("json")
v1.SetConfigFile(configFile)
if _, err := os.Stat(configFile); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/config/platform.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

import (
"github.com/elabosak233/cloudsdale/embed"
"github.com/elabosak233/cloudsdale/internal/embed"
"github.com/spf13/viper"
"go.uber.org/zap"
"io"
Expand Down Expand Up @@ -36,7 +36,7 @@ func PltCfg() *PlatformCfg {

func InitPlatformCfg() {
v2 = viper.New()
configFile := path.Join("platform.json")
configFile := path.Join("configs/platform.json")
v2.SetConfigType("json")
v2.SetConfigFile(configFile)
if _, err := os.Stat(configFile); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/config/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func SigCfg() *SignatureCfg {

func InitSignatureCfg() {
v3 = viper.New()
configFile := path.Join("signature.json")
configFile := path.Join("configs/signature.json")
v3.SetConfigType("json")
v3.SetConfigFile(configFile)

Expand Down
2 changes: 1 addition & 1 deletion internal/container/provider/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package provider
import (
"fmt"
"github.com/TwiN/go-color"
"github.com/elabosak233/cloudsdale/embed"
"github.com/elabosak233/cloudsdale/internal/config"
"github.com/elabosak233/cloudsdale/internal/embed"
"go.uber.org/zap"
"io"
"io/fs"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions scripts/buildtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_last_commit_id():
class Swag:
@staticmethod
def init():
subprocess.call("swag init -g ./cmd/cloudsdale/main.go -o ./docs", shell=True)
subprocess.call("swag init -g ./cloudsdale.go -o ./docs", shell=True)


class Go:
Expand All @@ -38,14 +38,14 @@ def run():
os.environ["DEBUG"] = "true"
Swag.init()
try:
subprocess.call(f"go run {gen_params(build=False)} {package}/cmd/cloudsdale", shell=True)
subprocess.call(f"go run {gen_params(build=False)} {package}", shell=True)
except KeyboardInterrupt:
print("Run Finished.")

@staticmethod
def build():
Swag.init()
if subprocess.call(f"go build {gen_params()} -o ./build/ {package}/cmd/cloudsdale", shell=True) == 0:
if subprocess.call(f"go build {gen_params()} -o ./build/ {package}", shell=True) == 0:
print("Build Finished.")


Expand Down

0 comments on commit d72acd3

Please sign in to comment.