Skip to content

Commit 8be5432

Browse files
committed
chore(controller-sdk-go): remove app logs
1 parent 2c0c222 commit 8be5432

2 files changed

Lines changed: 0 additions & 83 deletions

File tree

apps/apps.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,12 @@ package apps
33

44
import (
55
"encoding/json"
6-
"errors"
76
"fmt"
8-
"net/http"
9-
"net/url"
107

118
drycc "github.com/drycc/controller-sdk-go"
129
"github.com/drycc/controller-sdk-go/api"
13-
"golang.org/x/net/websocket"
1410
)
1511

16-
// ErrNoLogs is returned when logs are missing from an app.
17-
var ErrNoLogs = errors.New(
18-
`There are currently no log messages. Please check the following things:
19-
1) Logger and fluentd pods are running: kubectl --namespace=drycc get pods.
20-
2) The application is writing logs to the logger component by checking that an entry in the ring buffer was created: kubectl --namespace=drycc logs <logger pod>
21-
3) Making sure that the container logs were mounted properly into the fluentd pod: kubectl --namespace=drycc exec <fluentd pod> ls /var/log/containers
22-
3a) If the above command returns saying /var/log/containers cannot be found then please see the following github issue for a workaround: https://github.com/drycc/logger/issues/50`)
23-
2412
// List lists apps on a Drycc controller.
2513
func List(c *drycc.Client, results int) (api.Apps, int, error) {
2614
body, count, reqErr := c.LimitedRequest("/v2/apps/", results)
@@ -87,36 +75,6 @@ func Get(c *drycc.Client, appID string) (api.App, error) {
8775
return app, reqErr
8876
}
8977

90-
// Logs retrieves logs from an app. The number of log lines fetched can be set by the lines
91-
// argument. Setting lines = -1 will retrieve all app logs.
92-
func Logs(c *drycc.Client, appID string, request api.AppLogsRequest) (*websocket.Conn, error) {
93-
scheme := "ws"
94-
if c.ControllerURL.Scheme == "https" {
95-
scheme = "wss"
96-
}
97-
path := fmt.Sprintf("v2/apps/%s/logs", appID)
98-
endpoint := url.URL{Scheme: scheme, Host: c.ControllerURL.Host, Path: path}
99-
100-
config, err := websocket.NewConfig(endpoint.String(), c.ControllerURL.String())
101-
if err != nil {
102-
return nil, err
103-
}
104-
config.Header = http.Header{
105-
"User-Agent": {c.UserAgent},
106-
"Authorization": {"token " + c.Token},
107-
"X-Drycc-Service-Key": {c.ServiceKey},
108-
}
109-
conn, err := websocket.DialConfig(config)
110-
if err != nil {
111-
return nil, err
112-
}
113-
err = websocket.JSON.Send(conn, request)
114-
if err != nil {
115-
return nil, err
116-
}
117-
return conn, nil
118-
}
119-
12078
// Run a one-time command in your app. This will start a kubernetes job with the
12179
// same container image and environment as the rest of the app.
12280
func Run(c *drycc.Client, appID string, command string, volumes map[string]interface{}, timeout, expires uint32) error {

apps/apps_test.go

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ package apps
33
import (
44
"fmt"
55
"io"
6-
"log"
76
"net/http"
87
"net/http/httptest"
98
"reflect"
10-
"sync"
119
"testing"
1210

1311
drycc "github.com/drycc/controller-sdk-go"
1412
"github.com/drycc/controller-sdk-go/api"
15-
"golang.org/x/net/websocket"
1613
)
1714

1815
const appFixture string = `
@@ -274,44 +271,6 @@ func TestAppsList(t *testing.T) {
274271
}
275272
}
276273

277-
func TestAppsLogs(t *testing.T) {
278-
t.Parallel()
279-
var once sync.Once
280-
var addr string
281-
once.Do(func() {
282-
http.Handle(
283-
"/v2/apps/example-go/logs",
284-
websocket.Handler(func(conn *websocket.Conn) {
285-
io.Copy(conn, conn)
286-
}),
287-
)
288-
server := httptest.NewServer(nil)
289-
addr = server.Listener.Addr().String()
290-
log.Print("Test WebSocket server listening on ", addr)
291-
})
292-
drycc, err := drycc.New(false, addr, "abc")
293-
if err != nil {
294-
t.Fatal(err)
295-
}
296-
expected := api.AppLogsRequest{
297-
Lines: 1,
298-
Follow: false,
299-
Timeout: 300,
300-
}
301-
conn, err := Logs(drycc, "example-go", expected)
302-
if err != nil {
303-
t.Fatal(err)
304-
}
305-
var actual api.AppLogsRequest
306-
err = websocket.JSON.Receive(conn, &actual)
307-
if err != nil {
308-
t.Fatal(err)
309-
}
310-
if !reflect.DeepEqual(actual, expected) {
311-
t.Errorf("Expected: %v, Got %v", expected, actual)
312-
}
313-
}
314-
315274
func TestAppsTransfer(t *testing.T) {
316275
t.Parallel()
317276

0 commit comments

Comments
 (0)