Skip to content

Commit 873cca9

Browse files
committed
Examples added.
1 parent 93d3e2b commit 873cca9

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

examples/down.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"github.com/ugurcsen/go-docker-compose-client/client"
7+
"os"
8+
)
9+
10+
func main() {
11+
ctx, cancelCtx := context.WithCancel(context.Background())
12+
defer cancelCtx()
13+
cli, _ := client.NewClientWithContext(ctx, os.Getenv("project_path"))
14+
stdout, err := cli.Down()
15+
if err != nil {
16+
panic(err)
17+
}
18+
cli.Wait()
19+
fmt.Println(stdout.String())
20+
}

examples/ps.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"github.com/ugurcsen/go-docker-compose-client/client"
7+
"os"
8+
)
9+
10+
func main() {
11+
ctx, cancelCtx := context.WithCancel(context.Background())
12+
defer cancelCtx()
13+
cli, _ := client.NewClientWithContext(ctx, os.Getenv("project_path"))
14+
containers, err := cli.PsAll()
15+
if err != nil {
16+
panic(err)
17+
}
18+
for _, container := range containers {
19+
fmt.Println(container.Labels["com.docker.compose.service"], container.State)
20+
}
21+
}

examples/up.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"github.com/ugurcsen/go-docker-compose-client/client"
7+
"os"
8+
)
9+
10+
func main() {
11+
ctx, cancelCtx := context.WithCancel(context.Background())
12+
defer cancelCtx()
13+
cli, _ := client.NewClientWithContext(ctx, os.Getenv("project_path"))
14+
stdout, err := cli.Up()
15+
if err != nil {
16+
panic(err)
17+
}
18+
cli.Wait()
19+
fmt.Println(stdout.String())
20+
}

0 commit comments

Comments
 (0)