Skip to content

Commit ac2b4e3

Browse files
committed
update docker client api
1 parent c6e2bd2 commit ac2b4e3

File tree

2 files changed

+127
-14
lines changed

2 files changed

+127
-14
lines changed

.gitignore

Lines changed: 116 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
tinyfaas-*
22
cmd/manager/rproxy-*.bin
33
tmp/
4-
5-
# Created by https://www.toptal.com/developers/gitignore/api/go,node,python,visualstudiocode,macos
6-
# Edit at https://www.toptal.com/developers/gitignore?templates=go,node,python,visualstudiocode,macos
4+
# Created by https://www.toptal.com/developers/gitignore/api/go,node,macos,python,visualstudiocode,intellij
5+
# Edit at https://www.toptal.com/developers/gitignore?templates=go,node,macos,python,visualstudiocode,intellij
76

87
### Go ###
98
# If you prefer the allow list template instead of the deny list, see community template:
@@ -28,6 +27,119 @@ tmp/
2827
# Go workspace file
2928
go.work
3029

30+
### Intellij ###
31+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
32+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
33+
34+
# User-specific stuff
35+
.idea/**/workspace.xml
36+
.idea/**/tasks.xml
37+
.idea/**/usage.statistics.xml
38+
.idea/**/dictionaries
39+
.idea/**/shelf
40+
41+
# AWS User-specific
42+
.idea/**/aws.xml
43+
44+
# Generated files
45+
.idea/**/contentModel.xml
46+
47+
# Sensitive or high-churn files
48+
.idea/**/dataSources/
49+
.idea/**/dataSources.ids
50+
.idea/**/dataSources.local.xml
51+
.idea/**/sqlDataSources.xml
52+
.idea/**/dynamic.xml
53+
.idea/**/uiDesigner.xml
54+
.idea/**/dbnavigator.xml
55+
56+
# Gradle
57+
.idea/**/gradle.xml
58+
.idea/**/libraries
59+
60+
# Gradle and Maven with auto-import
61+
# When using Gradle or Maven with auto-import, you should exclude module files,
62+
# since they will be recreated, and may cause churn. Uncomment if using
63+
# auto-import.
64+
# .idea/artifacts
65+
# .idea/compiler.xml
66+
# .idea/jarRepositories.xml
67+
# .idea/modules.xml
68+
# .idea/*.iml
69+
# .idea/modules
70+
# *.iml
71+
# *.ipr
72+
73+
# CMake
74+
cmake-build-*/
75+
76+
# Mongo Explorer plugin
77+
.idea/**/mongoSettings.xml
78+
79+
# File-based project format
80+
*.iws
81+
82+
# IntelliJ
83+
out/
84+
85+
# mpeltonen/sbt-idea plugin
86+
.idea_modules/
87+
88+
# JIRA plugin
89+
atlassian-ide-plugin.xml
90+
91+
# Cursive Clojure plugin
92+
.idea/replstate.xml
93+
94+
# SonarLint plugin
95+
.idea/sonarlint/
96+
97+
# Crashlytics plugin (for Android Studio and IntelliJ)
98+
com_crashlytics_export_strings.xml
99+
crashlytics.properties
100+
crashlytics-build.properties
101+
fabric.properties
102+
103+
# Editor-based Rest Client
104+
.idea/httpRequests
105+
106+
# Android studio 3.1+ serialized cache file
107+
.idea/caches/build_file_checksums.ser
108+
109+
### Intellij Patch ###
110+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
111+
112+
# *.iml
113+
# modules.xml
114+
# .idea/misc.xml
115+
# *.ipr
116+
117+
# Sonarlint plugin
118+
# https://plugins.jetbrains.com/plugin/7973-sonarlint
119+
.idea/**/sonarlint/
120+
121+
# SonarQube Plugin
122+
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
123+
.idea/**/sonarIssues.xml
124+
125+
# Markdown Navigator plugin
126+
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
127+
.idea/**/markdown-navigator.xml
128+
.idea/**/markdown-navigator-enh.xml
129+
.idea/**/markdown-navigator/
130+
131+
# Cache file creation bug
132+
# See https://youtrack.jetbrains.com/issue/JBR-2257
133+
.idea/$CACHE_FILE$
134+
135+
# CodeStream plugin
136+
# https://plugins.jetbrains.com/plugin/12206-codestream
137+
.idea/codestream.xml
138+
139+
# Azure Toolkit for IntelliJ plugin
140+
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
141+
.idea/**/azureSettings.xml
142+
31143
### macOS ###
32144
# General
33145
.DS_Store
@@ -388,4 +500,4 @@ pyrightconfig.json
388500
.history
389501
.ionide
390502

391-
# End of https://www.toptal.com/developers/gitignore/api/go,node,python,visualstudiocode,macos
503+
# End of https://www.toptal.com/developers/gitignore/api/go,node,macos,python,visualstudiocode,intellij

pkg/docker/handler.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ import (
1313
"sync"
1414
"time"
1515

16-
"github.com/OpenFogStack/tinyFaaS/pkg/manager"
17-
"github.com/OpenFogStack/tinyFaaS/pkg/util"
1816
"github.com/docker/docker/api/types"
1917
"github.com/docker/docker/api/types/container"
2018
"github.com/docker/docker/client"
2119
"github.com/docker/docker/pkg/archive"
2220
"github.com/docker/docker/pkg/stdcopy"
2321
"github.com/google/uuid"
22+
23+
"github.com/OpenFogStack/tinyFaaS/pkg/manager"
24+
"github.com/OpenFogStack/tinyFaaS/pkg/util"
2425
)
2526

2627
const (
@@ -227,13 +228,13 @@ func (dh *dockerHandler) Start() error {
227228
// docker start <container>
228229

229230
wg := sync.WaitGroup{}
230-
for _, container := range dh.containers {
231+
for _, c := range dh.containers {
231232
wg.Add(1)
232233
go func(c string) {
233234
err := dh.client.ContainerStart(
234235
context.Background(),
235236
c,
236-
types.ContainerStartOptions{},
237+
container.StartOptions{},
237238
)
238239
wg.Done()
239240
if err != nil {
@@ -242,7 +243,7 @@ func (dh *dockerHandler) Start() error {
242243
}
243244

244245
log.Println("started container", c)
245-
}(container)
246+
}(c)
246247
}
247248
wg.Wait()
248249

@@ -329,7 +330,7 @@ func (dh *dockerHandler) Destroy() error {
329330
err = dh.client.ContainerRemove(
330331
context.Background(),
331332
c,
332-
types.ContainerRemoveOptions{},
333+
container.RemoveOptions{},
333334
)
334335
wg.Done()
335336
if err != nil {
@@ -374,11 +375,11 @@ func (dh *dockerHandler) Logs() (io.Reader, error) {
374375
// get container logs
375376
// docker logs <container>
376377
var logs bytes.Buffer
377-
for _, container := range dh.containers {
378+
for _, c := range dh.containers {
378379
l, err := dh.client.ContainerLogs(
379380
context.Background(),
380-
container,
381-
types.ContainerLogsOptions{
381+
c,
382+
container.LogsOptions{
382383
ShowStdout: true,
383384
ShowStderr: true,
384385
Timestamps: true,
@@ -404,7 +405,7 @@ func (dh *dockerHandler) Logs() (io.Reader, error) {
404405
scanner := bufio.NewScanner(&lstdout)
405406

406407
for scanner.Scan() {
407-
logs.WriteString(fmt.Sprintf("function=%s handler=%s %s\n", dh.name, container, scanner.Text()))
408+
logs.WriteString(fmt.Sprintf("function=%s handler=%s %s\n", dh.name, c, scanner.Text()))
408409
}
409410

410411
if err := scanner.Err(); err != nil {

0 commit comments

Comments
 (0)