Skip to content

Commit

Permalink
fix(lint): lint err 찾아서 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
archmagece committed Oct 1, 2024
1 parent fa920fd commit 48318de
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 23 deletions.
2 changes: 1 addition & 1 deletion configs/apt_proxy_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type AptProxy struct {

type AptProxyConfig struct {
Path string `json:"path,omitempty"`
UserCache bool `json:"user_cache,omitempty" default:false`
UserCache bool `json:"user_cache,omitempty"`
Proxies map[string][]AptProxy `json:"proxies"`
}

Expand Down
2 changes: 1 addition & 1 deletion configs/global_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

type Cache struct {
TTL int `yaml:"ttl,omitempty" default:36000`
TTL int `yaml:"ttl,omitempty"`
}

type GlobalConfig struct {
Expand Down
11 changes: 7 additions & 4 deletions dtos/api_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ import (
"net/http"
)

//ResponseData structure
// ResponseData structure
type ResponseData struct {
Data interface{} `json:"data"`
Meta interface{} `json:"meta"`
}

//Message returns map data
// Message returns map data
func Message(status int, message string) map[string]interface{} {
return map[string]interface{}{"status": status, "message": message}
}

//Respond returns basic response structure
// Respond returns basic response structure
func Respond(w http.ResponseWriter, data map[string]interface{}) {
w.Header().Add("Content-Type", "application/json")
json.NewEncoder(w).Encode(data)
err := json.NewEncoder(w).Encode(data)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
12 changes: 8 additions & 4 deletions handlers/proxy/apt_proxy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func AptProxy(c *gin.Context) {
pathOs := c.Param("osType")
requestPath := c.Param("requestPath")

// fixme di
// nolint:godox fixme di??
storageDir := helpers.GetStorageDir()
globalConfig := configs.GlobalConfig{}
globalConfig.ReadConfig()
Expand All @@ -40,11 +40,15 @@ func AptProxy(c *gin.Context) {
filename := filepath.Base(filefullpath)
if _, err := os.Stat(filefullpath); os.IsNotExist(err) {
dirpath := filepath.Dir(filefullpath)
os.MkdirAll(dirpath, os.ModePerm)
err = os.MkdirAll(dirpath, os.ModePerm)
if err != nil {
log.Fatal(err)
return
}
out, err := os.Create(filefullpath)
if err != nil {
panic(err)
return
//return
}
defer out.Close()

Expand All @@ -66,7 +70,7 @@ func AptProxy(c *gin.Context) {
return
}
resp.Body.Close()
break
//break
}
}

Expand Down
11 changes: 8 additions & 3 deletions handlers/proxy/docker_proxy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func DockerProxy(c *gin.Context) {
imageName := c.Param("imageName")
tag := c.Param("tag")

// fixme di
// nolint:godox fixme di??
storageDir := helpers.GetStorageDir()
globalConfig := configs.GlobalConfig{}
globalConfig.ReadConfig()
Expand All @@ -30,11 +30,16 @@ func DockerProxy(c *gin.Context) {
filename := filepath.Base(filefullpath)
if _, err := os.Stat(filefullpath); os.IsNotExist(err) {
dirpath := filepath.Dir(filefullpath)
os.MkdirAll(dirpath, os.ModePerm)
err = os.MkdirAll(dirpath, os.ModePerm)
if err != nil {
log.Fatal(err)
return
}
out, err := os.Create(filefullpath)
if err != nil {
panic(err)
return
//log.Fatal(err)
//return
}
defer out.Close()

Expand Down
12 changes: 8 additions & 4 deletions handlers/proxy/maven_proxy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func MavenProxy(c *gin.Context) {

requestPath := c.Param("path")

// fixme di
// nolint:godox fixme di??
storageDir := helpers.GetStorageDir()
globalConfig := configs.GlobalConfig{}
globalConfig.ReadConfig()
Expand All @@ -61,7 +61,11 @@ func MavenProxy(c *gin.Context) {
filename := filepath.Base(filefullpath)
if _, err := os.Stat(filefullpath); os.IsNotExist(err) {
dirpath := filepath.Dir(filefullpath)
os.MkdirAll(dirpath, 0766)
err = os.MkdirAll(dirpath, 0766)
if err != nil {
log.Fatal(err)
return
}

// Get the data
fmt.Println(len(config.Proxies))
Expand All @@ -85,8 +89,8 @@ func MavenProxy(c *gin.Context) {
}
resp.Body.Close()
responseContent = bytes
// FIXME ???? ai코드??
break
// nolint:godox // FIXME ???? ai코드??
//break
}
} else {
bytes, _ := os.ReadFile(filefullpath)
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ func main() {
}

fmt.Println("http://localhost:" + port + "\n")
r.Run(":" + port)
err := r.Run(":" + port)
if err != nil {
fmt.Println(err)
}
}
6 changes: 5 additions & 1 deletion routers/health_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ func HealthRouter(r *gin.Engine) {
// You can also validate env format using regex
StorageDirCheck := checks.NewEnvCheck("STORAGE_DIR")
//StorageDirCheck.SetRegexValidator("^(~|/).+")
healthcheck.New(r, config.DefaultConfig(), []checks.Check{confDirCheck, StorageDirCheck})
err := healthcheck.New(r, config.DefaultConfig(), []checks.Check{confDirCheck, StorageDirCheck})
if err != nil {
// nolint:godox fixme panic이 맞나?
panic(err)
}

//ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
//defer stop()
Expand Down
8 changes: 4 additions & 4 deletions routers/proxy_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package routers
import (
"github.com/gin-gonic/gin"
"proxynd/configs"
proxynd "proxynd/handlers/proxy"
proxyhandler "proxynd/handlers/proxy"
"proxynd/helpers"
)

func ProxyRouter(r *gin.Engine) {
// fixme di??
// nolint:godox fixme di??
storageDir := helpers.GetStorageDir()
globalConfig := configs.GlobalConfig{}
globalConfig.ReadConfig()
Expand All @@ -18,7 +18,7 @@ func ProxyRouter(r *gin.Engine) {

if mavenProxyConfig.ConfigExists() {
mavenGroup := r.Group("/proxy/maven")
mavenGroup.GET("*path", proxynd.MavenProxy)
mavenGroup.GET("*path", proxyhandler.MavenProxy)
} else {
r.GET("/proxy/maven/*path", func(c *gin.Context) {
c.HTML(200, "alert.html", gin.H{
Expand All @@ -33,7 +33,7 @@ func ProxyRouter(r *gin.Engine) {

if aptProxyConfig.ConfigExists() {
aptGroup := r.Group("/proxy/apt")
aptGroup.GET(":osType/*requestPath", proxynd.AptProxy)
aptGroup.GET(":osType/*requestPath", proxyhandler.AptProxy)
} else {
r.GET("/proxy/maven/*path", func(c *gin.Context) {
c.HTML(200, "alert.html", gin.H{
Expand Down

0 comments on commit 48318de

Please sign in to comment.