mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 09:13:49 +08:00
feat: 初步支持环境管理
This commit is contained in:
@@ -9,7 +9,6 @@ type App struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Slug string `json:"slug"`
|
||||
Icon string `json:"icon"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Categories []string `json:"categories"`
|
||||
|
||||
47
pkg/api/environment.go
Normal file
47
pkg/api/environment.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package api
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Environment struct {
|
||||
Type string `json:"type"`
|
||||
Slug string `json:"slug"`
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Description string `json:"description"`
|
||||
Order int `json:"order"`
|
||||
}
|
||||
|
||||
type Environments []*Environment
|
||||
|
||||
// Environments 返回所有环境
|
||||
func (r *API) Environments() (*Environments, error) {
|
||||
resp, err := r.client.R().SetResult(&Response{}).Get("/environments")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !resp.IsSuccess() {
|
||||
return nil, fmt.Errorf("failed to get environments: %s", resp.String())
|
||||
}
|
||||
|
||||
environments, err := getResponseData[Environments](resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return environments, nil
|
||||
}
|
||||
|
||||
// EnvironmentCallback 环境下载回调
|
||||
func (r *API) EnvironmentCallback(typ, slug string) error {
|
||||
resp, err := r.client.R().
|
||||
SetResult(&Response{}).
|
||||
Post(fmt.Sprintf("/environments/%s/%s/callback", typ, slug))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !resp.IsSuccess() {
|
||||
return fmt.Errorf("failed to callback environment: %s", resp.String())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user