Skip to content

Commit 0d3c542

Browse files
committed
test: remove unused code
1 parent dea01a1 commit 0d3c542

File tree

2 files changed

+60
-193
lines changed

2 files changed

+60
-193
lines changed

.github/workflows/pr_check.yml

+60-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Unit Test
1+
name: PR Check
22

33
on:
44
pull_request:
@@ -9,7 +9,7 @@ defaults:
99
shell: bash
1010

1111
jobs:
12-
build:
12+
unit_test:
1313
runs-on: ubuntu-latest
1414
env:
1515
GO_VERSION: 1.23.4
@@ -64,4 +64,61 @@ jobs:
6464
# for unit test
6565
cd $WORK
6666
echo Testing code at $PWD ...
67-
make test
67+
make test
68+
69+
code_lint:
70+
runs-on: ubuntu-latest
71+
env:
72+
GO_VERSION: 1.23.4
73+
steps:
74+
- name: Checkout current repository
75+
uses: actions/checkout@v4
76+
with:
77+
fetch-depth: 0
78+
path: agent
79+
80+
- name: Checkout framework repository
81+
uses: actions/checkout@v4
82+
with:
83+
fetch-depth: 0
84+
repository: infinilabs/framework
85+
path: framework
86+
87+
- name: Checkout framework-vendor
88+
uses: actions/checkout@v4
89+
with:
90+
ref: main
91+
fetch-depth: 0
92+
repository: infinilabs/framework-vendor
93+
path: vendor
94+
95+
- name: Set up go toolchain
96+
uses: actions/setup-go@v5
97+
with:
98+
go-version: ${{ env.GO_VERSION }}
99+
check-latest: false
100+
cache: true
101+
102+
- name: Check go toolchain
103+
run: go version
104+
105+
- name: Code lint
106+
env:
107+
GOFLAGS: -tags=ci
108+
run: |
109+
echo Home path is $HOME
110+
export WORKBASE=$HOME/go/src/infini.sh
111+
export WORK=$WORKBASE/agent
112+
113+
# for test workspace
114+
mkdir -p $HOME/go/src/
115+
ln -s $GITHUB_WORKSPACE $WORKBASE
116+
117+
# check work folder
118+
ls -lrt $WORKBASE/
119+
ls -alrt $WORK
120+
121+
# for unit test
122+
cd $WORK
123+
echo Linting code at $PWD ...
124+
make lint

config/config.go

-190
Original file line numberDiff line numberDiff line change
@@ -1,191 +1 @@
11
package config
2-
3-
//
4-
//import (
5-
// "encoding/json"
6-
// "errors"
7-
// log "github.com/cihub/seelog"
8-
// "infini.sh/agent/model"
9-
// "infini.sh/framework/core/env"
10-
// "infini.sh/framework/core/event"
11-
// "infini.sh/framework/core/global"
12-
// "infini.sh/framework/core/kv"
13-
// "infini.sh/framework/core/model"
14-
// "strconv"
15-
// "strings"
16-
// "sync"
17-
// "time"
18-
//)
19-
//
20-
//type ManagedConfig struct {
21-
// Manager *Manager `config:"manager"`
22-
//}
23-
//
24-
//type Manager struct {
25-
// Endpoint string `config:"endpoint"`
26-
//}
27-
//
28-
//var agentConfig *ManagedConfig
29-
//var hostInfo *model.Instance
30-
//var hostInfoObserver []func(newHostInfo *model.Instance)
31-
//var instanceLock sync.RWMutex
32-
//
33-
//const (
34-
// UrlUploadInstanceInfo string = "/agent/instance"
35-
// UrlUpdateInstanceInfo = "/agent/instance/:instance_id"
36-
// UrlHearBeat = "/agent/instance/:instance_id/_heartbeat"
37-
// UrlGetInstanceInfo = "/agent/instance/:instance_id"
38-
//)
39-
//
40-
//func InitConfig() {
41-
// appConfig := &ManagedConfig{}
42-
// ok, err := env.ParseConfig("configs", appConfig)
43-
// if err != nil {
44-
// panic(err)
45-
// }
46-
// if !ok {
47-
// panic("config.InitConfig: can not find agent config")
48-
// }
49-
// agentConfig = appConfig
50-
// hostInfoObserver = make([]func(newHostInfo *model.Instance), 1)
51-
//}
52-
//
53-
//func RegisterHostInfoObserver(fn func(newHostInfo *model.Instance)) {
54-
// hostInfoObserver = append(hostInfoObserver, fn)
55-
//}
56-
//
57-
//func NotifyHostInfoObserver(newHostInfo *model.Instance) {
58-
// for i := 0; i < len(hostInfoObserver); i++ {
59-
// if hostInfoObserver[i] != nil {
60-
// hostInfoObserver[i](newHostInfo)
61-
// }
62-
// }
63-
//}
64-
//
65-
//func GetManagerEndpoint() string {
66-
// if agentConfig == nil || agentConfig.Manager == nil {
67-
// return ""
68-
// }
69-
// endPoint := agentConfig.Manager.Endpoint
70-
// if strings.HasSuffix(endPoint, "/") {
71-
// endPoint = endPoint[:len(endPoint)-1]
72-
// }
73-
// return agentConfig.Manager.Endpoint
74-
//}
75-
//
76-
//func GetListenPort() uint {
77-
// bindAddress := global.Env().SystemConfig.APIConfig.NetworkConfig.Binding
78-
// if strings.Contains(bindAddress, ":") {
79-
// temps := strings.Split(bindAddress, ":")
80-
// port, _ := strconv.Atoi(temps[1])
81-
// return uint(port)
82-
// }
83-
// return 0
84-
//}
85-
//
86-
//func IsHTTPS() bool {
87-
// return global.Env().SystemConfig.APIConfig.TLSConfig.TLSEnabled
88-
//}
89-
//
90-
//func IsAgentActivated() bool {
91-
// instanceInfo := GetInstanceInfo()
92-
// if instanceInfo == nil || !instanceInfo.IsRunning {
93-
// return false
94-
// }
95-
// return true
96-
//}
97-
//
98-
//func GetInstanceInfo() *model.Instance {
99-
// if hostInfo != nil {
100-
// return hostInfo
101-
// }
102-
// hostInfo = getInstanceInfoFromKV()
103-
// return hostInfo
104-
//}
105-
//
106-
////func GetOrInitInstanceInfo() *model.Instance {
107-
//// if hostInfo != nil {
108-
//// return hostInfo
109-
//// }
110-
//// hostInfo = getInstanceInfoFromKV()
111-
//// if hostInfo == nil {
112-
//// hostInfo = &model.Instance{
113-
//// IPs: util.GetLocalIPs(),
114-
//// Host: agent.HostInfo{},
115-
//// }
116-
//// _, majorIp, _, err := util.GetPublishNetworkDeviceInfo(agentConfig.MajorIpPattern)
117-
//// if err != nil {
118-
//// log.Error(err)
119-
//// }
120-
//// hostInfo.MajorIP = majorIp
121-
//// }
122-
//// SetInstanceInfo(hostInfo)
123-
//// return hostInfo
124-
////}
125-
//
126-
//func UpdateAgentBootTime() {
127-
// instanceInfo := GetInstanceInfo()
128-
// instanceInfo.BootTime = time.Now().UnixMilli()
129-
// SetInstanceInfo(instanceInfo)
130-
//}
131-
//
132-
//func SetInstanceInfo(host *model.Instance) error {
133-
// if host == nil {
134-
// return errors.New("host info can not be nil")
135-
// }
136-
// instanceLock.Lock()
137-
// defer instanceLock.Unlock()
138-
// hostInfo = host
139-
// event.UpdateAgentID(hostInfo.AgentID)
140-
// hostByte, _ := json.Marshal(host)
141-
// if host.IsRunning {
142-
// NotifyHostInfoObserver(hostInfo)
143-
// }
144-
// return kv.AddValue(model.KVInstanceBucket, []byte(model.KVInstanceInfo), hostByte)
145-
//}
146-
//
147-
//func SetInstanceInfoNoNotify(host *model.Instance) error {
148-
// if host == nil {
149-
// return errors.New("host info can not be nil")
150-
// }
151-
//
152-
// instanceLock.Lock()
153-
// defer instanceLock.Unlock()
154-
// hostInfo = host
155-
// event.UpdateAgentID(hostInfo.AgentID)
156-
// hostByte, _ := json.Marshal(host)
157-
// return kv.AddValue(model.KVInstanceBucket, []byte(model.KVInstanceInfo), hostByte)
158-
//}
159-
//
160-
//func DeleteInstanceInfo() error {
161-
// hostInfo = nil
162-
// return kv.DeleteKey(model.KVInstanceBucket, []byte(model.KVInstanceInfo))
163-
//}
164-
//
165-
//func ReloadHostInfo() {
166-
// hostInf := getInstanceInfoFromKV()
167-
// if hostInf == nil {
168-
// return
169-
// }
170-
// ret, _ := json.Marshal(hostInf)
171-
// log.Debugf(string(ret))
172-
//}
173-
//
174-
//var host *model.Instance
175-
//
176-
//func getInstanceInfoFromKV() *model.Instance {
177-
// hs, err := kv.GetValue(model.KVInstanceBucket, []byte(model.KVInstanceInfo))
178-
// if err != nil {
179-
// log.Error(err)
180-
// return nil
181-
// }
182-
// if hs == nil {
183-
// return nil
184-
// }
185-
// err = json.Unmarshal(hs, &host)
186-
// if err != nil {
187-
// log.Errorf("config.getInstanceInfoFromKV: %v\n", err)
188-
// return nil
189-
// }
190-
// return host
191-
//}

0 commit comments

Comments
 (0)