diff --git a/.drone.yml b/.drone.yml index cdf6917..259ae9a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,5 +6,5 @@ steps: - name: "build" image: harbor.front.kjuulh.io/docker-proxy/library/golang:latest commands: - - "go run main.go" + - "go run main.go https://github.com/kpenfound/greetings-api.git" - "go test ./..." diff --git a/go.mod b/go.mod index 715fdcd..92f6bcd 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module drone-dagger-test go 1.19 + +replace github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220414164044-61404de7df1a+incompatible diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e69de29 diff --git a/main.go b/main.go index d64d38c..a786824 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,35 @@ package main -import "fmt" +import ( + "context" + "fmt" + "os" +) func main() { fmt.Printf("hello, world!\n") + + if len(os.Args) < 2 { + fmt.Println("must pass in a git repo to build") + os.Exit(1) + } + repo := os.Args[1] + if err := build(repo); err != nil { + fmt.Println(err) + } +} + +func build(repoUrl string) error { + fmt.Printf("Building %s\n", repoUrl) + + // 1. Get a context + ctx := context.Background() + // 2. Initialize dagger client + client, err := dagger.Connect(ctx) + if err != nil { + return err + } + defer client.Close() + + return nil }