From e1555dac204e800f14cf3f478c1c8a04254a906a Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Fri, 19 Jul 2024 11:36:47 +0200 Subject: [PATCH 01/18] feat(aaaaa): abcdef --- tools/make/dagger.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/make/dagger.mk b/tools/make/dagger.mk index ed29918..0539ca7 100644 --- a/tools/make/dagger.mk +++ b/tools/make/dagger.mk @@ -14,7 +14,7 @@ dagger/check-generation: ## Check files are generated on Dagger dagger/lint: ## Lint the code on Dagger @dagger call lint --dir . -.PHONY: dagger/publish +.PHONY: dagger/publish dagger/publish: ## Publish with tag on git, docker hub, etc. on Dagger @dagger call publish --dir . --tag ${TAG} From 44d0331b5a6cbcc418aafc1dcf2a7c2822c2efc2 Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 01:14:38 +0200 Subject: [PATCH 02/18] feat(ci): add git publish --- .github/workflows/ci.yaml | 123 +- build/ci/.gitattributes | 1 + build/ci/.gitignore | 4 + build/ci/cmd.go | 39 +- build/ci/dagger.gen.go | 652 +----- build/ci/docker_image.go | 63 + build/ci/git.go | 169 ++ build/ci/go.mod | 57 +- build/ci/go.sum | 201 +- build/ci/internal/dagger/dagger.gen.go | 1934 ++++++++++++++--- .../ci/internal/querybuilder/querybuilder.go | 34 +- build/ci/publish.go | 81 - build/ci/runner.go | 2 +- build/ci/utils.go | 6 +- dagger.json | 2 +- go.mod | 20 +- go.sum | 85 +- pkg/utils/git/git.go | 94 - tools/make/dagger.mk | 16 +- 19 files changed, 2183 insertions(+), 1400 deletions(-) create mode 100644 build/ci/.gitignore create mode 100644 build/ci/docker_image.go create mode 100644 build/ci/git.go delete mode 100644 build/ci/publish.go delete mode 100644 pkg/utils/git/git.go diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d22ec35..38631ae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,66 +9,87 @@ on: - main jobs: - test: - name: Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4.1.1 - - uses: actions/setup-go@v5.0.0 - with: - go-version-file: go.mod - cache: true - - name: Run tests - uses: dagger/dagger-for-github@v5 - with: - verb: call - args: tests --dir . - version: "0.11.0" - examples: - name: Examples - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4.1.1 - - uses: actions/setup-go@v5.0.0 - with: - go-version-file: go.mod - cache: true - - name: Run examples - uses: dagger/dagger-for-github@v5 - with: - verb: call - args: examples --dir . - version: "0.11.0" - lint: - name: Lint - runs-on: ubuntu-latest - timeout-minutes: 5 - steps: - - uses: actions/checkout@v4.1.1 - - uses: actions/setup-go@v5.0.0 - with: - go-version-file: go.mod - cache: true - - name: Lint - uses: dagger/dagger-for-github@v5 - with: - verb: call - args: lint --dir . - version: "0.11.0" + # tests: + # name: Tests + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4.1.1 + # - uses: actions/setup-go@v5.0.0 + # with: + # go-version-file: go.mod + # cache: true + # - name: Run tests + # uses: dagger/dagger-for-github@v5 + # with: + # verb: call + # args: tests --dir . + # version: "0.11.0" + + # examples: + # name: Examples + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4.1.1 + # - uses: actions/setup-go@v5.0.0 + # with: + # go-version-file: go.mod + # cache: true + # - name: Run examples + # uses: dagger/dagger-for-github@v5 + # with: + # verb: call + # args: examples --dir . + # version: "0.11.0" + + # lint: + # name: Lint + # runs-on: ubuntu-latest + # timeout-minutes: 5 + # steps: + # - uses: actions/checkout@v4.1.1 + # - uses: actions/setup-go@v5.0.0 + # with: + # go-version-file: go.mod + # cache: true + # - name: Lint + # uses: dagger/dagger-for-github@v5 + # with: + # verb: call + # args: lint --dir . + # version: "0.11.0" + + # check-generation: + # name: Check generation + # runs-on: ubuntu-latest + # timeout-minutes: 5 + # steps: + # - uses: actions/checkout@v4.1.1 + # - uses: actions/setup-go@v5.0.0 + # with: + # go-version-file: go.mod + # cache: true + # - name: Lint + # uses: dagger/dagger-for-github@v5 + # with: + # verb: call + # args: check-generation --dir . + # version: "0.11.0" - check-generation: - name: Check generation + publish: + name: Publish asyncapi-codegen new version + # needs: ["tests", "examples", "lint", "check-generation"] runs-on: ubuntu-latest timeout-minutes: 5 + # if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4.1.1 - uses: actions/setup-go@v5.0.0 with: go-version-file: go.mod cache: true - - name: Lint + - name: Publish on git uses: dagger/dagger-for-github@v5 with: verb: call - args: check-generation --dir . - version: "0.11.0" \ No newline at end of file + args: publish --src-dir . --ssh-dir=~/.ssh + version: "0.11.0" \ No newline at end of file diff --git a/build/ci/.gitattributes b/build/ci/.gitattributes index 6911ed2..3a45493 100644 --- a/build/ci/.gitattributes +++ b/build/ci/.gitattributes @@ -1,3 +1,4 @@ /dagger.gen.go linguist-generated /internal/dagger/** linguist-generated /internal/querybuilder/** linguist-generated +/internal/telemetry/** linguist-generated diff --git a/build/ci/.gitignore b/build/ci/.gitignore new file mode 100644 index 0000000..7ebabcc --- /dev/null +++ b/build/ci/.gitignore @@ -0,0 +1,4 @@ +/dagger.gen.go +/internal/dagger +/internal/querybuilder +/internal/telemetry diff --git a/build/ci/cmd.go b/build/ci/cmd.go index d3864c8..8e2efa7 100644 --- a/build/ci/cmd.go +++ b/build/ci/cmd.go @@ -43,21 +43,21 @@ func (ci *AsyncapiCodegenCi) cachedBrokers() map[string]*dagger.Service { // Execute all check operations (generate, lint, examples, and tests) func (ci *AsyncapiCodegenCi) Check( ctx context.Context, - dir *Directory, + srcDir *dagger.Directory, ) (string, error) { - if _, err := ci.CheckGeneration(ctx, dir); err != nil { + if _, err := ci.CheckGeneration(ctx, srcDir); err != nil { return "", err } - if _, err := ci.Lint(ctx, dir); err != nil { + if _, err := ci.Lint(ctx, srcDir); err != nil { return "", err } - if _, err := ci.Examples(ctx, dir); err != nil { + if _, err := ci.Examples(ctx, srcDir); err != nil { return "", err } - if _, err := ci.Tests(ctx, dir); err != nil { + if _, err := ci.Tests(ctx, srcDir); err != nil { return "", err } @@ -68,11 +68,11 @@ func (ci *AsyncapiCodegenCi) Check( // source code and check that there is no change. func (ci *AsyncapiCodegenCi) CheckGeneration( ctx context.Context, - dir *Directory, + srcDir *dagger.Directory, ) (string, error) { _, err := dag.Container(). From(golangImage). - With(sourceCodeAndGoCache(dir)). + With(sourceCodeAndGoCache(srcDir)). WithExec([]string{"sh", "./scripts/check-generation.sh"}). Stdout(ctx) @@ -82,11 +82,11 @@ func (ci *AsyncapiCodegenCi) CheckGeneration( // Lint AsyncAPI-Codegen source code. func (ci *AsyncapiCodegenCi) Lint( ctx context.Context, - dir *Directory, + srcDir *dagger.Directory, ) (string, error) { return dag.Container(). From(linterImage). - With(sourceCodeAndGoCache(dir)). + With(sourceCodeAndGoCache(srcDir)). WithMountedCache("/root/.cache/golangci-lint", dag.CacheVolume("golangci-lint")). WithExec([]string{"golangci-lint", "run"}). Stdout(ctx) @@ -95,10 +95,10 @@ func (ci *AsyncapiCodegenCi) Lint( // Run AsyncAPI-Codegen examples. func (ci *AsyncapiCodegenCi) Examples( ctx context.Context, - dir *Directory, + srcDir *dagger.Directory, ) (string, error) { // Get examples subdirs - subdirs, err := directoriesAtSublevel(ctx, dir.Directory("examples"), 2, "./examples") + subdirs, err := directoriesAtSublevel(ctx, srcDir.Directory("examples"), 2, "./examples") if err != nil { return "", err } @@ -110,7 +110,7 @@ func (ci *AsyncapiCodegenCi) Examples( app := dag.Container(). From(golangImage). // Add source code as work directory - With(sourceCodeAndGoCache(dir)). + With(sourceCodeAndGoCache(srcDir)). // Set broker as dependency With(bindBrokers(ci.cachedBrokers())). // Execute command @@ -125,7 +125,7 @@ func (ci *AsyncapiCodegenCi) Examples( // Add base image From(golangImage). // Add source code as work directory - With(sourceCodeAndGoCache(dir)). + With(sourceCodeAndGoCache(srcDir)). // Set broker as dependency With(bindBrokers(ci.cachedBrokers())). // Add app as dependency of user @@ -144,13 +144,13 @@ func (ci *AsyncapiCodegenCi) Examples( // Run tests from AsyncAPICodegen func (ci *AsyncapiCodegenCi) Tests( ctx context.Context, - dir *Directory, + srcDir *dagger.Directory, ) (string, error) { return dag.Container(). // Add base image From(golangImage). // Add source code as work directory - With(sourceCodeAndGoCache(dir)). + With(sourceCodeAndGoCache(srcDir)). // Set brokers as dependencies of app and user With(bindBrokers(ci.cachedBrokers())). // Execute command @@ -163,10 +163,13 @@ func (ci *AsyncapiCodegenCi) Tests( // git tag. func (ci *AsyncapiCodegenCi) Publish( ctx context.Context, - dir *Directory, - tag string, + srcDir *dagger.Directory, + sshDir *dagger.Directory, ) error { - if err := publishDocker(ctx, dir, tag); err != nil { + gi := NewGit(srcDir, sshDir) + + // Push new commit tag if needed + if err := gi.PushNewSemVerIfNeeded(ctx); err != nil { return err } diff --git a/build/ci/dagger.gen.go b/build/ci/dagger.gen.go index 98f7c35..c6407b0 100644 --- a/build/ci/dagger.gen.go +++ b/build/ci/dagger.gen.go @@ -4,490 +4,38 @@ package main import ( "context" - "dagger/asyncapi-codegen-ci/internal/dagger" "encoding/json" "fmt" + "log/slog" "os" -) - -var dag = dagger.Connect() - -type DaggerObject = dagger.DaggerObject - -type ExecError = dagger.ExecError - -// The `CacheVolumeID` scalar type represents an identifier for an object of type CacheVolume. -type CacheVolumeID = dagger.CacheVolumeID - -// The `ContainerID` scalar type represents an identifier for an object of type Container. -type ContainerID = dagger.ContainerID - -// The `CurrentModuleID` scalar type represents an identifier for an object of type CurrentModule. -type CurrentModuleID = dagger.CurrentModuleID - -// The `DirectoryID` scalar type represents an identifier for an object of type Directory. -type DirectoryID = dagger.DirectoryID - -// The `EnvVariableID` scalar type represents an identifier for an object of type EnvVariable. -type EnvVariableID = dagger.EnvVariableID - -// The `FieldTypeDefID` scalar type represents an identifier for an object of type FieldTypeDef. -type FieldTypeDefID = dagger.FieldTypeDefID - -// The `FileID` scalar type represents an identifier for an object of type File. -type FileID = dagger.FileID - -// The `FunctionArgID` scalar type represents an identifier for an object of type FunctionArg. -type FunctionArgID = dagger.FunctionArgID - -// The `FunctionCallArgValueID` scalar type represents an identifier for an object of type FunctionCallArgValue. -type FunctionCallArgValueID = dagger.FunctionCallArgValueID - -// The `FunctionCallID` scalar type represents an identifier for an object of type FunctionCall. -type FunctionCallID = dagger.FunctionCallID - -// The `FunctionID` scalar type represents an identifier for an object of type Function. -type FunctionID = dagger.FunctionID - -// The `GeneratedCodeID` scalar type represents an identifier for an object of type GeneratedCode. -type GeneratedCodeID = dagger.GeneratedCodeID - -// The `GitModuleSourceID` scalar type represents an identifier for an object of type GitModuleSource. -type GitModuleSourceID = dagger.GitModuleSourceID - -// The `GitRefID` scalar type represents an identifier for an object of type GitRef. -type GitRefID = dagger.GitRefID - -// The `GitRepositoryID` scalar type represents an identifier for an object of type GitRepository. -type GitRepositoryID = dagger.GitRepositoryID - -// The `InputTypeDefID` scalar type represents an identifier for an object of type InputTypeDef. -type InputTypeDefID = dagger.InputTypeDefID - -// The `InterfaceTypeDefID` scalar type represents an identifier for an object of type InterfaceTypeDef. -type InterfaceTypeDefID = dagger.InterfaceTypeDefID - -// An arbitrary JSON-encoded value. -type JSON = dagger.JSON - -// The `LabelID` scalar type represents an identifier for an object of type Label. -type LabelID = dagger.LabelID - -// The `ListTypeDefID` scalar type represents an identifier for an object of type ListTypeDef. -type ListTypeDefID = dagger.ListTypeDefID - -// The `LocalModuleSourceID` scalar type represents an identifier for an object of type LocalModuleSource. -type LocalModuleSourceID = dagger.LocalModuleSourceID - -// The `ModuleDependencyID` scalar type represents an identifier for an object of type ModuleDependency. -type ModuleDependencyID = dagger.ModuleDependencyID - -// The `ModuleID` scalar type represents an identifier for an object of type Module. -type ModuleID = dagger.ModuleID - -// The `ModuleSourceID` scalar type represents an identifier for an object of type ModuleSource. -type ModuleSourceID = dagger.ModuleSourceID - -// The `ObjectTypeDefID` scalar type represents an identifier for an object of type ObjectTypeDef. -type ObjectTypeDefID = dagger.ObjectTypeDefID - -// The platform config OS and architecture in a Container. -// -// The format is [os]/[platform]/[version] (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64"). -type Platform = dagger.Platform - -// The `PortID` scalar type represents an identifier for an object of type Port. -type PortID = dagger.PortID - -// The `SecretID` scalar type represents an identifier for an object of type Secret. -type SecretID = dagger.SecretID - -// The `ServiceID` scalar type represents an identifier for an object of type Service. -type ServiceID = dagger.ServiceID - -// The `SocketID` scalar type represents an identifier for an object of type Socket. -type SocketID = dagger.SocketID - -// The `TerminalID` scalar type represents an identifier for an object of type Terminal. -type TerminalID = dagger.TerminalID - -// The `TypeDefID` scalar type represents an identifier for an object of type TypeDef. -type TypeDefID = dagger.TypeDefID - -// The absence of a value. -// -// A Null Void is used as a placeholder for resolvers that do not return anything. -type Void = dagger.Void - -// Key value object that represents a build argument. -type BuildArg = dagger.BuildArg - -// Key value object that represents a pipeline label. -type PipelineLabel = dagger.PipelineLabel - -// Port forwarding rules for tunneling network traffic. -type PortForward = dagger.PortForward - -// A directory whose contents persist across runs. -type CacheVolume = dagger.CacheVolume - -// An OCI-compatible container, also known as a Docker container. -type Container = dagger.Container - -type WithContainerFunc = dagger.WithContainerFunc - -// ContainerAsTarballOpts contains options for Container.AsTarball -type ContainerAsTarballOpts = dagger.ContainerAsTarballOpts - -// ContainerBuildOpts contains options for Container.Build -type ContainerBuildOpts = dagger.ContainerBuildOpts - -// ContainerExportOpts contains options for Container.Export -type ContainerExportOpts = dagger.ContainerExportOpts - -// ContainerImportOpts contains options for Container.Import -type ContainerImportOpts = dagger.ContainerImportOpts - -// ContainerPipelineOpts contains options for Container.Pipeline -type ContainerPipelineOpts = dagger.ContainerPipelineOpts - -// ContainerPublishOpts contains options for Container.Publish -type ContainerPublishOpts = dagger.ContainerPublishOpts - -// ContainerTerminalOpts contains options for Container.Terminal -type ContainerTerminalOpts = dagger.ContainerTerminalOpts - -// ContainerWithDefaultTerminalCmdOpts contains options for Container.WithDefaultTerminalCmd -type ContainerWithDefaultTerminalCmdOpts = dagger.ContainerWithDefaultTerminalCmdOpts - -// ContainerWithDirectoryOpts contains options for Container.WithDirectory -type ContainerWithDirectoryOpts = dagger.ContainerWithDirectoryOpts - -// ContainerWithEntrypointOpts contains options for Container.WithEntrypoint -type ContainerWithEntrypointOpts = dagger.ContainerWithEntrypointOpts - -// ContainerWithEnvVariableOpts contains options for Container.WithEnvVariable -type ContainerWithEnvVariableOpts = dagger.ContainerWithEnvVariableOpts - -// ContainerWithExecOpts contains options for Container.WithExec -type ContainerWithExecOpts = dagger.ContainerWithExecOpts - -// ContainerWithExposedPortOpts contains options for Container.WithExposedPort -type ContainerWithExposedPortOpts = dagger.ContainerWithExposedPortOpts - -// ContainerWithFileOpts contains options for Container.WithFile -type ContainerWithFileOpts = dagger.ContainerWithFileOpts - -// ContainerWithFilesOpts contains options for Container.WithFiles -type ContainerWithFilesOpts = dagger.ContainerWithFilesOpts - -// ContainerWithMountedCacheOpts contains options for Container.WithMountedCache -type ContainerWithMountedCacheOpts = dagger.ContainerWithMountedCacheOpts - -// ContainerWithMountedDirectoryOpts contains options for Container.WithMountedDirectory -type ContainerWithMountedDirectoryOpts = dagger.ContainerWithMountedDirectoryOpts - -// ContainerWithMountedFileOpts contains options for Container.WithMountedFile -type ContainerWithMountedFileOpts = dagger.ContainerWithMountedFileOpts - -// ContainerWithMountedSecretOpts contains options for Container.WithMountedSecret -type ContainerWithMountedSecretOpts = dagger.ContainerWithMountedSecretOpts - -// ContainerWithNewFileOpts contains options for Container.WithNewFile -type ContainerWithNewFileOpts = dagger.ContainerWithNewFileOpts - -// ContainerWithUnixSocketOpts contains options for Container.WithUnixSocket -type ContainerWithUnixSocketOpts = dagger.ContainerWithUnixSocketOpts - -// ContainerWithoutEntrypointOpts contains options for Container.WithoutEntrypoint -type ContainerWithoutEntrypointOpts = dagger.ContainerWithoutEntrypointOpts - -// ContainerWithoutExposedPortOpts contains options for Container.WithoutExposedPort -type ContainerWithoutExposedPortOpts = dagger.ContainerWithoutExposedPortOpts - -// Reflective module API provided to functions at runtime. -type CurrentModule = dagger.CurrentModule - -// CurrentModuleWorkdirOpts contains options for CurrentModule.Workdir -type CurrentModuleWorkdirOpts = dagger.CurrentModuleWorkdirOpts - -// A directory. -type Directory = dagger.Directory - -type WithDirectoryFunc = dagger.WithDirectoryFunc - -// DirectoryAsModuleOpts contains options for Directory.AsModule -type DirectoryAsModuleOpts = dagger.DirectoryAsModuleOpts - -// DirectoryDockerBuildOpts contains options for Directory.DockerBuild -type DirectoryDockerBuildOpts = dagger.DirectoryDockerBuildOpts - -// DirectoryEntriesOpts contains options for Directory.Entries -type DirectoryEntriesOpts = dagger.DirectoryEntriesOpts - -// DirectoryPipelineOpts contains options for Directory.Pipeline -type DirectoryPipelineOpts = dagger.DirectoryPipelineOpts - -// DirectoryWithDirectoryOpts contains options for Directory.WithDirectory -type DirectoryWithDirectoryOpts = dagger.DirectoryWithDirectoryOpts - -// DirectoryWithFileOpts contains options for Directory.WithFile -type DirectoryWithFileOpts = dagger.DirectoryWithFileOpts - -// DirectoryWithFilesOpts contains options for Directory.WithFiles -type DirectoryWithFilesOpts = dagger.DirectoryWithFilesOpts - -// DirectoryWithNewDirectoryOpts contains options for Directory.WithNewDirectory -type DirectoryWithNewDirectoryOpts = dagger.DirectoryWithNewDirectoryOpts - -// DirectoryWithNewFileOpts contains options for Directory.WithNewFile -type DirectoryWithNewFileOpts = dagger.DirectoryWithNewFileOpts - -// An environment variable name and value. -type EnvVariable = dagger.EnvVariable - -// A definition of a field on a custom object defined in a Module. -// -// A field on an object has a static value, as opposed to a function on an object whose value is computed by invoking code (and can accept arguments). -type FieldTypeDef = dagger.FieldTypeDef - -// A file. -type File = dagger.File - -type WithFileFunc = dagger.WithFileFunc - -// FileExportOpts contains options for File.Export -type FileExportOpts = dagger.FileExportOpts - -// Function represents a resolver provided by a Module. -// -// A function always evaluates against a parent object and is given a set of named arguments. -type Function = dagger.Function - -type WithFunctionFunc = dagger.WithFunctionFunc - -// FunctionWithArgOpts contains options for Function.WithArg -type FunctionWithArgOpts = dagger.FunctionWithArgOpts - -// An argument accepted by a function. -// -// This is a specification for an argument at function definition time, not an argument passed at function call time. -type FunctionArg = dagger.FunctionArg - -// An active function call. -type FunctionCall = dagger.FunctionCall - -// A value passed as a named argument to a function call. -type FunctionCallArgValue = dagger.FunctionCallArgValue - -// The result of running an SDK's codegen. -type GeneratedCode = dagger.GeneratedCode -type WithGeneratedCodeFunc = dagger.WithGeneratedCodeFunc - -// Module source originating from a git repo. -type GitModuleSource = dagger.GitModuleSource - -// A git ref (tag, branch, or commit). -type GitRef = dagger.GitRef - -// GitRefTreeOpts contains options for GitRef.Tree -type GitRefTreeOpts = dagger.GitRefTreeOpts - -// A git repository. -type GitRepository = dagger.GitRepository - -// A graphql input type, which is essentially just a group of named args. -// This is currently only used to represent pre-existing usage of graphql input types -// in the core API. It is not used by user modules and shouldn't ever be as user -// module accept input objects via their id rather than graphql input types. -type InputTypeDef = dagger.InputTypeDef - -// A definition of a custom interface defined in a Module. -type InterfaceTypeDef = dagger.InterfaceTypeDef - -// A simple key value object that represents a label. -type Label = dagger.Label - -// A definition of a list type in a Module. -type ListTypeDef = dagger.ListTypeDef - -// Module source that that originates from a path locally relative to an arbitrary directory. -type LocalModuleSource = dagger.LocalModuleSource - -// A Dagger module. -type Module = dagger.Module - -type WithModuleFunc = dagger.WithModuleFunc - -// The configuration of dependency of a module. -type ModuleDependency = dagger.ModuleDependency - -// The source needed to load and run a module, along with any metadata about the source such as versions/urls/etc. -type ModuleSource = dagger.ModuleSource - -type WithModuleSourceFunc = dagger.WithModuleSourceFunc - -// A definition of a custom object defined in a Module. -type ObjectTypeDef = dagger.ObjectTypeDef - -// A port exposed by a container. -type Port = dagger.Port - -// The root of the DAG. -type Client = dagger.Client - -type WithClientFunc = dagger.WithClientFunc - -// ContainerOpts contains options for Client.Container -type ContainerOpts = dagger.ContainerOpts - -// DirectoryOpts contains options for Client.Directory -type DirectoryOpts = dagger.DirectoryOpts - -// GitOpts contains options for Client.Git -type GitOpts = dagger.GitOpts - -// HTTPOpts contains options for Client.HTTP -type HTTPOpts = dagger.HTTPOpts - -// ModuleDependencyOpts contains options for Client.ModuleDependency -type ModuleDependencyOpts = dagger.ModuleDependencyOpts - -// ModuleSourceOpts contains options for Client.ModuleSource -type ModuleSourceOpts = dagger.ModuleSourceOpts - -// PipelineOpts contains options for Client.Pipeline -type PipelineOpts = dagger.PipelineOpts - -// SecretOpts contains options for Client.Secret -type SecretOpts = dagger.SecretOpts - -// A reference to a secret value, which can be handled more safely than the value itself. -type Secret = dagger.Secret - -// A content-addressed service providing TCP connectivity. -type Service = dagger.Service - -// ServiceEndpointOpts contains options for Service.Endpoint -type ServiceEndpointOpts = dagger.ServiceEndpointOpts - -// ServiceStopOpts contains options for Service.Stop -type ServiceStopOpts = dagger.ServiceStopOpts - -// ServiceUpOpts contains options for Service.Up -type ServiceUpOpts = dagger.ServiceUpOpts - -// A Unix or TCP/IP socket that can be mounted into a container. -type Socket = dagger.Socket - -// An interactive terminal that clients can connect to. -type Terminal = dagger.Terminal - -// A definition of a parameter or return type in a Module. -type TypeDef = dagger.TypeDef - -type WithTypeDefFunc = dagger.WithTypeDefFunc - -// TypeDefWithFieldOpts contains options for TypeDef.WithField -type TypeDefWithFieldOpts = dagger.TypeDefWithFieldOpts - -// TypeDefWithInterfaceOpts contains options for TypeDef.WithInterface -type TypeDefWithInterfaceOpts = dagger.TypeDefWithInterfaceOpts - -// TypeDefWithObjectOpts contains options for TypeDef.WithObject -type TypeDefWithObjectOpts = dagger.TypeDefWithObjectOpts - -// Sharing mode of the cache volume. -type CacheSharingMode = dagger.CacheSharingMode - -const ( - // Shares the cache volume amongst many build pipelines, but will serialize the writes - Locked CacheSharingMode = dagger.Locked - - // Keeps a cache volume for a single build pipeline - Private CacheSharingMode = dagger.Private - - // Shares the cache volume amongst many build pipelines - Shared CacheSharingMode = dagger.Shared -) - -// Compression algorithm to use for image layers. -type ImageLayerCompression = dagger.ImageLayerCompression - -const ( - Estargz ImageLayerCompression = dagger.Estargz - - Gzip ImageLayerCompression = dagger.Gzip - - Uncompressed ImageLayerCompression = dagger.Uncompressed - - Zstd ImageLayerCompression = dagger.Zstd -) - -// Mediatypes to use in published or exported image metadata. -type ImageMediaTypes = dagger.ImageMediaTypes - -const ( - Dockermediatypes ImageMediaTypes = dagger.Dockermediatypes - - Ocimediatypes ImageMediaTypes = dagger.Ocimediatypes -) - -// The kind of module source. -type ModuleSourceKind = dagger.ModuleSourceKind - -const ( - GitSource ModuleSourceKind = dagger.GitSource - - LocalSource ModuleSourceKind = dagger.LocalSource -) - -// Transport layer network protocol associated to a port. -type NetworkProtocol = dagger.NetworkProtocol - -const ( - Tcp NetworkProtocol = dagger.Tcp + "dagger/asyncapi-codegen-ci/internal/dagger" + "dagger/asyncapi-codegen-ci/internal/telemetry" - Udp NetworkProtocol = dagger.Udp + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/sdk/resource" + semconv "go.opentelemetry.io/otel/semconv/v1.4.0" + "go.opentelemetry.io/otel/trace" ) -// Distinguishes the different kinds of TypeDefs. -type TypeDefKind = dagger.TypeDefKind - -const ( - // A boolean value. - BooleanKind TypeDefKind = dagger.BooleanKind - - // A graphql input type, used only when representing the core API via TypeDefs. - InputKind TypeDefKind = dagger.InputKind - - // An integer value. - IntegerKind TypeDefKind = dagger.IntegerKind +var dag = dagger.Connect() - // A named type of functions that can be matched+implemented by other objects+interfaces. - // - // Always paired with an InterfaceTypeDef. - InterfaceKind TypeDefKind = dagger.InterfaceKind +func Tracer() trace.Tracer { + return otel.Tracer("dagger.io/sdk.go") +} - // A list of values all having the same type. - // - // Always paired with a ListTypeDef. - ListKind TypeDefKind = dagger.ListKind +// used for local MarshalJSON implementations +var marshalCtx = context.Background() - // A named type defined in the GraphQL schema, with fields and functions. - // - // Always paired with an ObjectTypeDef. - ObjectKind TypeDefKind = dagger.ObjectKind +// called by main() +func setMarshalContext(ctx context.Context) { + marshalCtx = ctx + dagger.SetMarshalContext(ctx) +} - // A string value. - StringKind TypeDefKind = dagger.StringKind +type DaggerObject = dagger.DaggerObject - // A special kind used to signify that no value is returned. - // - // This is used for functions that have no return value. The outer TypeDef specifying this Kind is always Optional, as the Void is never actually represented. - VoidKind TypeDefKind = dagger.VoidKind -) +type ExecError = dagger.ExecError // ptr returns a pointer to the given value. func ptr[T any](v T) *T { @@ -521,61 +69,77 @@ func (r *AsyncapiCodegenCi) UnmarshalJSON(bs []byte) error { func main() { ctx := context.Background() + // Direct slog to the new stderr. This is only for dev time debugging, and + // runtime errors/warnings. + slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{ + Level: slog.LevelWarn, + }))) + + if err := dispatch(ctx); err != nil { + fmt.Println(err.Error()) + os.Exit(2) + } +} + +func dispatch(ctx context.Context) error { + ctx = telemetry.InitEmbedded(ctx, resource.NewWithAttributes( + semconv.SchemaURL, + semconv.ServiceNameKey.String("dagger-go-sdk"), + // TODO version? + )) + defer telemetry.Close() + + // A lot of the "work" actually happens when we're marshalling the return + // value, which entails getting object IDs, which happens in MarshalJSON, + // which has no ctx argument, so we use this lovely global variable. + setMarshalContext(ctx) + fnCall := dag.CurrentFunctionCall() parentName, err := fnCall.ParentName(ctx) if err != nil { - fmt.Println(err.Error()) - os.Exit(2) + return fmt.Errorf("get parent name: %w", err) } fnName, err := fnCall.Name(ctx) if err != nil { - fmt.Println(err.Error()) - os.Exit(2) + return fmt.Errorf("get fn name: %w", err) } parentJson, err := fnCall.Parent(ctx) if err != nil { - fmt.Println(err.Error()) - os.Exit(2) + return fmt.Errorf("get fn parent: %w", err) } fnArgs, err := fnCall.InputArgs(ctx) if err != nil { - fmt.Println(err.Error()) - os.Exit(2) + return fmt.Errorf("get fn args: %w", err) } inputArgs := map[string][]byte{} for _, fnArg := range fnArgs { argName, err := fnArg.Name(ctx) if err != nil { - fmt.Println(err.Error()) - os.Exit(2) + return fmt.Errorf("get fn arg name: %w", err) } argValue, err := fnArg.Value(ctx) if err != nil { - fmt.Println(err.Error()) - os.Exit(2) + return fmt.Errorf("get fn arg value: %w", err) } inputArgs[argName] = []byte(argValue) } result, err := invoke(ctx, []byte(parentJson), parentName, fnName, inputArgs) if err != nil { - fmt.Println(err.Error()) - os.Exit(2) + return fmt.Errorf("invoke: %w", err) } resultBytes, err := json.Marshal(result) if err != nil { - fmt.Println(err.Error()) - os.Exit(2) + return fmt.Errorf("marshal: %w", err) } - _, err = fnCall.ReturnValue(ctx, JSON(resultBytes)) - if err != nil { - fmt.Println(err.Error()) - os.Exit(2) + if err = fnCall.ReturnValue(ctx, dagger.JSON(resultBytes)); err != nil { + return fmt.Errorf("store return value: %w", err) } + return nil } - func invoke(ctx context.Context, parentJSON []byte, parentName string, fnName string, inputArgs map[string][]byte) (_ any, err error) { + _ = inputArgs switch parentName { case "AsyncapiCodegenCi": switch fnName { @@ -585,91 +149,91 @@ func invoke(ctx context.Context, parentJSON []byte, parentName string, fnName st if err != nil { panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err)) } - var dir *Directory - if inputArgs["dir"] != nil { - err = json.Unmarshal([]byte(inputArgs["dir"]), &dir) + var srcDir *dagger.Directory + if inputArgs["srcDir"] != nil { + err = json.Unmarshal([]byte(inputArgs["srcDir"]), &srcDir) if err != nil { - panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg dir", err)) + panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg srcDir", err)) } } - return (*AsyncapiCodegenCi).Check(&parent, ctx, dir) - case "Generate": + return (*AsyncapiCodegenCi).Check(&parent, ctx, srcDir) + case "CheckGeneration": var parent AsyncapiCodegenCi err = json.Unmarshal(parentJSON, &parent) if err != nil { panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err)) } - var dir *Directory - if inputArgs["dir"] != nil { - err = json.Unmarshal([]byte(inputArgs["dir"]), &dir) + var srcDir *dagger.Directory + if inputArgs["srcDir"] != nil { + err = json.Unmarshal([]byte(inputArgs["srcDir"]), &srcDir) if err != nil { - panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg dir", err)) + panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg srcDir", err)) } } - return (*AsyncapiCodegenCi).CheckGeneration(&parent, ctx, dir) + return (*AsyncapiCodegenCi).CheckGeneration(&parent, ctx, srcDir) case "Lint": var parent AsyncapiCodegenCi err = json.Unmarshal(parentJSON, &parent) if err != nil { panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err)) } - var dir *Directory - if inputArgs["dir"] != nil { - err = json.Unmarshal([]byte(inputArgs["dir"]), &dir) + var srcDir *dagger.Directory + if inputArgs["srcDir"] != nil { + err = json.Unmarshal([]byte(inputArgs["srcDir"]), &srcDir) if err != nil { - panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg dir", err)) + panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg srcDir", err)) } } - return (*AsyncapiCodegenCi).Lint(&parent, ctx, dir) + return (*AsyncapiCodegenCi).Lint(&parent, ctx, srcDir) case "Examples": var parent AsyncapiCodegenCi err = json.Unmarshal(parentJSON, &parent) if err != nil { panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err)) } - var dir *Directory - if inputArgs["dir"] != nil { - err = json.Unmarshal([]byte(inputArgs["dir"]), &dir) + var srcDir *dagger.Directory + if inputArgs["srcDir"] != nil { + err = json.Unmarshal([]byte(inputArgs["srcDir"]), &srcDir) if err != nil { - panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg dir", err)) + panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg srcDir", err)) } } - return (*AsyncapiCodegenCi).Examples(&parent, ctx, dir) + return (*AsyncapiCodegenCi).Examples(&parent, ctx, srcDir) case "Tests": var parent AsyncapiCodegenCi err = json.Unmarshal(parentJSON, &parent) if err != nil { panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err)) } - var dir *Directory - if inputArgs["dir"] != nil { - err = json.Unmarshal([]byte(inputArgs["dir"]), &dir) + var srcDir *dagger.Directory + if inputArgs["srcDir"] != nil { + err = json.Unmarshal([]byte(inputArgs["srcDir"]), &srcDir) if err != nil { - panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg dir", err)) + panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg srcDir", err)) } } - return (*AsyncapiCodegenCi).Tests(&parent, ctx, dir) + return (*AsyncapiCodegenCi).Tests(&parent, ctx, srcDir) case "Publish": var parent AsyncapiCodegenCi err = json.Unmarshal(parentJSON, &parent) if err != nil { panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err)) } - var dir *Directory - if inputArgs["dir"] != nil { - err = json.Unmarshal([]byte(inputArgs["dir"]), &dir) + var srcDir *dagger.Directory + if inputArgs["srcDir"] != nil { + err = json.Unmarshal([]byte(inputArgs["srcDir"]), &srcDir) if err != nil { - panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg dir", err)) + panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg srcDir", err)) } } - var tag string - if inputArgs["tag"] != nil { - err = json.Unmarshal([]byte(inputArgs["tag"]), &tag) + var sshDir *dagger.Directory + if inputArgs["sshDir"] != nil { + err = json.Unmarshal([]byte(inputArgs["sshDir"]), &sshDir) if err != nil { - panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg tag", err)) + panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg sshDir", err)) } } - return nil, (*AsyncapiCodegenCi).Publish(&parent, ctx, dir, tag) + return nil, (*AsyncapiCodegenCi).Publish(&parent, ctx, srcDir, sshDir) default: return nil, fmt.Errorf("unknown function %s", fnName) } @@ -677,38 +241,38 @@ func invoke(ctx context.Context, parentJSON []byte, parentName string, fnName st return dag.Module(). WithDescription("A generated module for AsyncapiCodegenCi functions\n\nThis module has been generated via dagger init and serves as a reference to\nbasic module structure as you get started with Dagger.\n\nTwo functions have been pre-created. You can modify, delete, or add to them,\nas needed. They demonstrate usage of arguments and return types using simple\necho and grep commands. The functions can be called from the dagger CLI or\nfrom one of the SDKs.\n\nThe first line in this comment block is a short description line and the\nrest is a long description with more detail on the module's purpose or usage,\nif appropriate. All modules should have a short description.\n"). WithObject( - dag.TypeDef().WithObject("AsyncapiCodegenCi", TypeDefWithObjectOpts{Description: "AsyncapiCodegenCi is the Dagger CI module for AsyncAPI Codegen."}). + dag.TypeDef().WithObject("AsyncapiCodegenCi", dagger.TypeDefWithObjectOpts{Description: "AsyncapiCodegenCi is the Dagger CI module for AsyncAPI Codegen."}). WithFunction( dag.Function("Check", - dag.TypeDef().WithKind(StringKind)). + dag.TypeDef().WithKind(dagger.StringKind)). WithDescription("Execute all check operations (generate, lint, examples, and tests)"). - WithArg("dir", dag.TypeDef().WithObject("Directory"))). + WithArg("srcDir", dag.TypeDef().WithObject("Directory"))). WithFunction( - dag.Function("Generate", - dag.TypeDef().WithKind(StringKind)). - WithDescription("Generate files from Golang generate command on AsyncAPI-Codegen source code."). - WithArg("dir", dag.TypeDef().WithObject("Directory"))). + dag.Function("CheckGeneration", + dag.TypeDef().WithKind(dagger.StringKind)). + WithDescription("CheckGeneration generate files from Golang generate command on AsyncAPI-Codegen\nsource code and check that there is no change."). + WithArg("srcDir", dag.TypeDef().WithObject("Directory"))). WithFunction( dag.Function("Lint", - dag.TypeDef().WithKind(StringKind)). + dag.TypeDef().WithKind(dagger.StringKind)). WithDescription("Lint AsyncAPI-Codegen source code."). - WithArg("dir", dag.TypeDef().WithObject("Directory"))). + WithArg("srcDir", dag.TypeDef().WithObject("Directory"))). WithFunction( dag.Function("Examples", - dag.TypeDef().WithKind(StringKind)). + dag.TypeDef().WithKind(dagger.StringKind)). WithDescription("Run AsyncAPI-Codegen examples."). - WithArg("dir", dag.TypeDef().WithObject("Directory"))). + WithArg("srcDir", dag.TypeDef().WithObject("Directory"))). WithFunction( dag.Function("Tests", - dag.TypeDef().WithKind(StringKind)). + dag.TypeDef().WithKind(dagger.StringKind)). WithDescription("Run tests from AsyncAPICodegen"). - WithArg("dir", dag.TypeDef().WithObject("Directory"))). + WithArg("srcDir", dag.TypeDef().WithObject("Directory"))). WithFunction( dag.Function("Publish", - dag.TypeDef().WithKind(VoidKind).WithOptional(true)). + dag.TypeDef().WithKind(dagger.VoidKind).WithOptional(true)). WithDescription("Publish tag on git repository and docker image(s) on Docker Hub\nNote: if this is not 'main' branch, then it will just push docker image with\ngit tag."). - WithArg("dir", dag.TypeDef().WithObject("Directory")). - WithArg("tag", dag.TypeDef().WithKind(StringKind)))), nil + WithArg("srcDir", dag.TypeDef().WithObject("Directory")). + WithArg("sshDir", dag.TypeDef().WithObject("Directory")))), nil default: return nil, fmt.Errorf("unknown object %s", parentName) } diff --git a/build/ci/docker_image.go b/build/ci/docker_image.go new file mode 100644 index 0000000..5eb0ec4 --- /dev/null +++ b/build/ci/docker_image.go @@ -0,0 +1,63 @@ +package main + +const ( + // dockerImageName is the name of the docker image. + dockerImageName = "lerenn/asyncapi-codegen" +) + +var ( + // platforms represents the different OS/Arch platform wanted for docker hub. + platforms = []runnerType{ + {OS: "linux", Arch: "386", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, + {OS: "linux", Arch: "amd64", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, + {OS: "linux", Arch: "arm/v6", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, + {OS: "linux", Arch: "arm/v7", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, + {OS: "linux", Arch: "arm64/v8", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, + {OS: "linux", Arch: "mips64le", BuildBaseImage: "golang", TargetBaseImage: "debian:12"}, + {OS: "linux", Arch: "ppc64le", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, + {OS: "linux", Arch: "s390x", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, + } +) + +// func publishDocker(ctx context.Context, dir *dagger.Directory, tag string) error { +// // Get images for each platform +// platformVariants := make([]*dagger.Container, len(platforms)) +// for i, p := range platforms { +// platformVariants[i] = runnerFromDockerfile(dir, p) +// } + +// // Set publication options from images +// publishOpts := dagger.ContainerPublishOpts{ +// PlatformVariants: platformVariants, +// } + +// // Get last git commit hash +// hash, err := git.GetLastCommitHash(".") +// if err != nil { +// return err +// } + +// // Publish with hash +// if _, err := dag.Container().Publish(ctx, dockerImageName+":"+hash, publishOpts); err != nil { +// return err +// } + +// // Stop here if this not main branch +// if name, err := git.ActualBranchName("."); err != nil { +// return err +// } else if name != "main" { +// return nil +// } + +// // Publish with tag passed in argument +// if _, err := dag.Container().Publish(ctx, dockerImageName+":"+tag, publishOpts); err != nil { +// return err +// } + +// // Publish with "latest" as tag +// if _, err := dag.Container().Publish(ctx, dockerImageName+":latest", publishOpts); err != nil { +// return err +// } + +// return nil +// } diff --git a/build/ci/git.go b/build/ci/git.go new file mode 100644 index 0000000..b86b16c --- /dev/null +++ b/build/ci/git.go @@ -0,0 +1,169 @@ +package main + +import ( + "context" + "dagger/asyncapi-codegen-ci/internal/dagger" + "errors" + "fmt" + "strconv" + "strings" +) + +type Git struct { + container *dagger.Container + + lastCommit struct { + title string + shortSHA string + } + + lastTag string + newSemVer string +} + +func NewGit(srcDir, sshDir *dagger.Directory) Git { + return Git{ + container: dag.Container(). + From("alpine/git"). + WithMountedDirectory("/git", srcDir). + WithMountedDirectory("/root/.ssh", sshDir), + } +} + +func (g *Git) GetLastCommitShortSHA(ctx context.Context) (string, error) { + // Check if already doesn't exist + if g.lastCommit.shortSHA != "" { + return g.lastCommit.shortSHA, nil + } + + res, err := g.container. + WithExec([]string{"git", "rev-parse", "--short", "HEAD"}). + Stdout(ctx) + if err != nil { + return "", err + } + g.lastCommit.shortSHA = res + + return g.lastCommit.shortSHA, nil +} + +func (g *Git) GetLastCommitTitle(ctx context.Context) (string, error) { + // Check if already doesn't exist + if g.lastCommit.title != "" { + return g.lastCommit.title, nil + } + + res, err := g.container. + WithExec([]string{"git", "log", "-1", "--pretty=%B"}). + Stdout(ctx) + if err != nil { + return "", err + } + g.lastCommit.title = res + + return g.lastCommit.title, nil +} + +func (g *Git) GetLastTag(ctx context.Context) (string, error) { + // Check if already doesn't exist + if g.lastTag != "" { + return g.lastTag, nil + } + + res, err := g.container. + WithExec([]string{"git", "describe", "--tags", "--abbrev=0"}). + Stdout(ctx) + if err != nil { + return "", err + } + g.lastTag = res + + return g.lastTag, nil +} + +func (g *Git) GetLastSemanticVersionedTag(ctx context.Context) (major, minor, patch int, err error) { + // Get last tag + tag, err := g.GetLastTag(ctx) + if err != nil { + return 0, 0, 0, err + } + + // Remove wrong characters + tag = strings.TrimPrefix(tag, "v") + tag = strings.TrimSuffix(tag, "\n") + + // Split tag into parts + parts := strings.Split(tag, ".") + if len(parts) != 3 { + return 0, 0, 0, errors.New("invalid tag format:" + tag) + } + + // Convert parts to integers + major, err = strconv.Atoi(parts[0]) + if err != nil { + return 0, 0, 0, err + } + minor, err = strconv.Atoi(parts[1]) + if err != nil { + return 0, 0, 0, err + } + patch, err = strconv.Atoi(parts[2]) + if err != nil { + return 0, 0, 0, err + } + + return major, minor, patch, nil +} + +func (g *Git) GetNewSemVerIfNeeded(ctx context.Context) (string, error) { + // Check if already doesn't exist + if g.newSemVer != "" { + return g.newSemVer, nil + } + + // Get last commit title + title, err := g.GetLastCommitTitle(ctx) + if err != nil { + return "", err + } + + // Get last semantic versioned tag + major, minor, patch, err := g.GetLastSemanticVersionedTag(ctx) + if err != nil { + return "", err + } + + // Change the version + switch { + case strings.HasPrefix(title, "BREAKING CHANGE"): + major += 1 + case strings.HasPrefix(title, "feat"): + minor += 1 + case strings.HasPrefix(title, "fix"): + patch += 1 + default: + return "", nil + } + + return fmt.Sprintf("v%d.%d.%d", major, minor, patch), nil +} + +func (g *Git) PushNewSemVerIfNeeded(ctx context.Context) error { + // Get new semver + semver, err := g.GetNewSemVerIfNeeded(ctx) + if err != nil { + return err + } + + // Check if semver is empty + if semver == "" { + return nil + } + + // Push new tag + _, err = g.container. + WithExec([]string{"git", "tag", semver}). + WithExec([]string{"git", "push", "--tags"}). + Stdout(ctx) + return err +} diff --git a/build/ci/go.mod b/build/ci/go.mod index 8dd2cc4..b6939d7 100644 --- a/build/ci/go.mod +++ b/build/ci/go.mod @@ -3,38 +3,41 @@ module dagger/asyncapi-codegen-ci go 1.21.7 require ( - github.com/99designs/gqlgen v0.17.31 - github.com/Khan/genqlient v0.6.0 + github.com/99designs/gqlgen v0.17.49 + github.com/Khan/genqlient v0.7.0 github.com/lerenn/asyncapi-codegen v0.34.0 - github.com/vektah/gqlparser/v2 v2.5.6 + github.com/vektah/gqlparser/v2 v2.5.16 golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa - golang.org/x/sync v0.6.0 + golang.org/x/sync v0.7.0 ) require ( - dario.cat/mergo v1.0.0 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect - github.com/cloudflare/circl v1.3.3 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect - github.com/emirpasic/gods v1.18.1 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.5.0 // indirect - github.com/go-git/go-git/v5 v5.11.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect - github.com/sergi/go-diff v1.3.1 // indirect - github.com/skeema/knownhosts v1.2.1 // indirect - github.com/stretchr/testify v1.9.0 // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect - golang.org/x/crypto v0.23.0 // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.25.0 // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/tools v0.16.1 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect + github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect + github.com/sosodev/duration v1.3.1 // indirect + go.opentelemetry.io/otel v1.28.0 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 + go.opentelemetry.io/otel/log v0.4.0 + go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/sdk v1.28.0 + go.opentelemetry.io/otel/sdk/log v0.4.0 + go.opentelemetry.io/otel/trace v1.28.0 + go.opentelemetry.io/proto/otlp v1.3.1 + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect + google.golang.org/grpc v1.64.0 + google.golang.org/protobuf v1.34.1 // indirect ) replace github.com/lerenn/asyncapi-codegen => ../../ diff --git a/build/ci/go.sum b/build/ci/go.sum index 56a6ba5..5c2fbf6 100644 --- a/build/ci/go.sum +++ b/build/ci/go.sum @@ -1,161 +1,86 @@ -dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= -dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= -github.com/99designs/gqlgen v0.17.31 h1:VncSQ82VxieHkea8tz11p7h/zSbvHSxSDZfywqWt158= -github.com/99designs/gqlgen v0.17.31/go.mod h1:i4rEatMrzzu6RXaHydq1nmEPZkb3bKQsnxNRHS4DQB4= -github.com/Khan/genqlient v0.6.0 h1:Bwb1170ekuNIVIwTJEqvO8y7RxBxXu639VJOkKSrwAk= -github.com/Khan/genqlient v0.6.0/go.mod h1:rvChwWVTqXhiapdhLDV4bp9tz/Xvtewwkon4DpWWCRM= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= -github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= +github.com/99designs/gqlgen v0.17.49 h1:b3hNGexHd33fBSAd4NDT/c3NCcQzcAVkknhN9ym36YQ= +github.com/99designs/gqlgen v0.17.49/go.mod h1:tC8YFVZMed81x7UJ7ORUwXF4Kn6SXuucFqQBhN8+BU0= +github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w= +github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= -github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= -github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= -github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= -github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= -github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= -github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= -github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= -github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= -github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= -github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= -github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= -github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= -github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= -github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= -github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= +github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= +github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/vektah/gqlparser/v2 v2.5.6 h1:Ou14T0N1s191eRMZ1gARVqohcbe1e8FrcONScsq8cRU= -github.com/vektah/gqlparser/v2 v2.5.6/go.mod h1:z8xXUff237NntSuH8mLFijZ+1tjV1swDbpDqjJmk6ME= -github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= -github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0vy5p8= +github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww= +go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= +go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 h1:oM0GTNKGlc5qHctWeIGTVyda4iFFalOzMZ3Ehj5rwB4= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88/go.mod h1:JGG8ebaMO5nXOPnvKEl+DiA4MGwFjCbjsxT1WHIEBPY= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 h1:ccBrA8nCY5mM0y5uO7FT0ze4S0TuFcWdDB2FxGMTjkI= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0/go.mod h1:/9pb6634zi2Lk8LYg9Q0X8Ar6jka4dkFOylBLbVQPCE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 h1:R9DE4kQ4k+YtfLI2ULwX82VtNQ2J8yZmA7ZIF/D+7Mc= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0/go.mod h1:OQFyQVrDlbe+R7xrEyDr/2Wr67Ol0hRUgsfA+V5A95s= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 h1:qFffATk0X+HD+f1Z8lswGiOQYKHRlzfmdJm0wEaVrFA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0/go.mod h1:MOiCmryaYtc+V0Ei+Tx9o5S1ZjA7kzLucuVuyzBZloQ= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 h1:QY7/0NeRPKlzusf40ZE4t1VlMKbqSNT7cJRYzWuja0s= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0/go.mod h1:HVkSiDhTM9BoUJU8qE6j2eSWLLXvi1USXjyd2BXT8PY= +go.opentelemetry.io/otel/log v0.4.0 h1:/vZ+3Utqh18e8TPjuc3ecg284078KWrR8BRz+PQAj3o= +go.opentelemetry.io/otel/log v0.4.0/go.mod h1:DhGnQvky7pHy82MIRV43iXh3FlKN8UUKftn0KbLOq6I= +go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= +go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= +go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= +go.opentelemetry.io/otel/sdk/log v0.4.0 h1:1mMI22L82zLqf6KtkjrRy5BbagOTWdJsqMY/HSqILAA= +go.opentelemetry.io/otel/sdk/log v0.4.0/go.mod h1:AYJ9FVF0hNOgAVzUG/ybg/QttnXhUePWAupmCqtdESo= +go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= +go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= +go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= -golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= -golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 h1:P8OJ/WCl/Xo4E4zoe4/bifHpSmmKwARqyqE4nW6J2GQ= +google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5/go.mod h1:RGnPtTG7r4i8sPlNyDeikXF99hMM+hN6QMm4ooG9g2g= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 h1:AgADTJarZTBqgjiUzRgfaBchgYB3/WFTC80GPwsMcRI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= +google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/build/ci/internal/dagger/dagger.gen.go b/build/ci/internal/dagger/dagger.gen.go index eee56fb..cddddac 100644 --- a/build/ci/internal/dagger/dagger.gen.go +++ b/build/ci/internal/dagger/dagger.gen.go @@ -16,10 +16,27 @@ import ( "github.com/Khan/genqlient/graphql" "github.com/vektah/gqlparser/v2/gqlerror" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/propagation" + "go.opentelemetry.io/otel/trace" "dagger/asyncapi-codegen-ci/internal/querybuilder" + "dagger/asyncapi-codegen-ci/internal/telemetry" ) +func Tracer() trace.Tracer { + return otel.Tracer("dagger.io/sdk.go") +} + +// reassigned at runtime after the span is initialized +var marshalCtx = context.Background() + +// SetMarshalContext is a hack that lets us set the ctx to use for +// MarshalJSON implementations that get an object's ID. +func SetMarshalContext(ctx context.Context) { + marshalCtx = ctx +} + // assertNotNil panic if the given value is nil. // This function is used to validate that input with pointer type are not nil. // See https://github.com/dagger/dagger/issues/5696 for more context. @@ -114,9 +131,24 @@ type ContainerID string // The `CurrentModuleID` scalar type represents an identifier for an object of type CurrentModule. type CurrentModuleID string +// The `DaggerEngineCacheEntryID` scalar type represents an identifier for an object of type DaggerEngineCacheEntry. +type DaggerEngineCacheEntryID string + +// The `DaggerEngineCacheEntrySetID` scalar type represents an identifier for an object of type DaggerEngineCacheEntrySet. +type DaggerEngineCacheEntrySetID string + +// The `DaggerEngineCacheID` scalar type represents an identifier for an object of type DaggerEngineCache. +type DaggerEngineCacheID string + // The `DirectoryID` scalar type represents an identifier for an object of type Directory. type DirectoryID string +// The `EnumTypeDefID` scalar type represents an identifier for an object of type EnumTypeDef. +type EnumTypeDefID string + +// The `EnumValueTypeDefID` scalar type represents an identifier for an object of type EnumValueTypeDef. +type EnumValueTypeDefID string + // The `EnvVariableID` scalar type represents an identifier for an object of type EnvVariable. type EnvVariableID string @@ -177,6 +209,9 @@ type ModuleID string // The `ModuleSourceID` scalar type represents an identifier for an object of type ModuleSource. type ModuleSourceID string +// The `ModuleSourceViewID` scalar type represents an identifier for an object of type ModuleSourceView. +type ModuleSourceViewID string + // The `ObjectTypeDefID` scalar type represents an identifier for an object of type ObjectTypeDef. type ObjectTypeDefID string @@ -188,6 +223,9 @@ type Platform string // The `PortID` scalar type represents an identifier for an object of type Port. type PortID string +// The `ScalarTypeDefID` scalar type represents an identifier for an object of type ScalarTypeDef. +type ScalarTypeDefID string + // The `SecretID` scalar type represents an identifier for an object of type Secret. type SecretID string @@ -284,7 +322,7 @@ func (r *CacheVolume) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *CacheVolume) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -305,7 +343,7 @@ type Container struct { query *querybuilder.Selection envVariable *string - export *bool + export *string id *ContainerID imageRef *string label *string @@ -521,7 +559,7 @@ func (r *Container) ExperimentalWithAllGPUs() *Container { // EXPERIMENTAL API! Subject to change/removal at any time. // -// Configures the provided list of devices to be accesible to this container. +// Configures the provided list of devices to be accessible to this container. // // This currently works for Nvidia devices only. func (r *Container) ExperimentalWithGPU(devices []string) *Container { @@ -551,10 +589,8 @@ type ContainerExportOpts struct { // Writes the container as an OCI tarball to the destination file path on the host. // -// Return true on success. -// // It can also export platform variants. -func (r *Container) Export(ctx context.Context, path string, opts ...ContainerExportOpts) (bool, error) { +func (r *Container) Export(ctx context.Context, path string, opts ...ContainerExportOpts) (string, error) { if r.export != nil { return *r.export, nil } @@ -575,7 +611,7 @@ func (r *Container) Export(ctx context.Context, path string, opts ...ContainerEx } q = q.Arg("path", path) - var response bool + var response string q = q.Bind(&response) return response, q.Execute(ctx) @@ -671,7 +707,7 @@ func (r *Container) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *Container) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -914,7 +950,13 @@ func (r *Container) Stdout(ctx context.Context) (string, error) { func (r *Container) Sync(ctx context.Context) (*Container, error) { q := r.query.Select("sync") - return r, q.Execute(ctx) + var id ContainerID + if err := q.Bind(&id).Execute(ctx); err != nil { + return nil, err + } + return &Container{ + query: q.Root().Select("loadContainerFromID").Arg("id", id), + }, nil } // ContainerTerminalOpts contains options for Container.Terminal @@ -929,8 +971,8 @@ type ContainerTerminalOpts struct { InsecureRootCapabilities bool } -// Return an interactive terminal for this container using its configured default terminal command if not overridden by args (or sh as a fallback default). -func (r *Container) Terminal(opts ...ContainerTerminalOpts) *Terminal { +// Opens an interactive terminal for this container using its configured default terminal command if not overridden by args (or sh as a fallback default). +func (r *Container) Terminal(opts ...ContainerTerminalOpts) *Container { q := r.query.Select("terminal") for i := len(opts) - 1; i >= 0; i-- { // `cmd` optional argument @@ -947,7 +989,7 @@ func (r *Container) Terminal(opts ...ContainerTerminalOpts) *Terminal { } } - return &Terminal{ + return &Container{ query: q, } } @@ -1092,8 +1134,10 @@ func (r *Container) WithEnvVariable(name string, value string, opts ...Container // ContainerWithExecOpts contains options for Container.WithExec type ContainerWithExecOpts struct { - // If the container has an entrypoint, ignore it for args rather than using it to wrap them. + // DEPRECATED: For true this can be removed. For false, use `useEntrypoint` instead. SkipEntrypoint bool + // If the container has an entrypoint, prepend it to the args. + UseEntrypoint bool // Content to write to the command's standard input before closing (e.g., "Hello world"). Stdin string // Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout"). @@ -1116,6 +1160,10 @@ func (r *Container) WithExec(args []string, opts ...ContainerWithExecOpts) *Cont if !querybuilder.IsZeroValue(opts[i].SkipEntrypoint) { q = q.Arg("skipEntrypoint", opts[i].SkipEntrypoint) } + // `useEntrypoint` optional argument + if !querybuilder.IsZeroValue(opts[i].UseEntrypoint) { + q = q.Arg("useEntrypoint", opts[i].UseEntrypoint) + } // `stdin` optional argument if !querybuilder.IsZeroValue(opts[i].Stdin) { q = q.Arg("stdin", opts[i].Stdin) @@ -1405,7 +1453,7 @@ func (r *Container) WithMountedSecret(path string, source *Secret, opts ...Conta } } -// Retrieves this container plus a temporary directory mounted at the given path. +// Retrieves this container plus a temporary directory mounted at the given path. Any writes will be ephemeral to a single withExec call; they will not be persisted to subsequent withExecs. func (r *Container) WithMountedTemp(path string) *Container { q := r.query.Select("withMountedTemp") q = q.Arg("path", path) @@ -1417,8 +1465,6 @@ func (r *Container) WithMountedTemp(path string) *Container { // ContainerWithNewFileOpts contains options for Container.WithNewFile type ContainerWithNewFileOpts struct { - // Content of the file to write (e.g., "Hello world!"). - Contents string // Permission given to the written file (e.g., 0600). Permissions int // A user:group to set for the file. @@ -1430,13 +1476,9 @@ type ContainerWithNewFileOpts struct { } // Retrieves this container plus a new file written at the given path. -func (r *Container) WithNewFile(path string, opts ...ContainerWithNewFileOpts) *Container { +func (r *Container) WithNewFile(path string, contents string, opts ...ContainerWithNewFileOpts) *Container { q := r.query.Select("withNewFile") for i := len(opts) - 1; i >= 0; i-- { - // `contents` optional argument - if !querybuilder.IsZeroValue(opts[i].Contents) { - q = q.Arg("contents", opts[i].Contents) - } // `permissions` optional argument if !querybuilder.IsZeroValue(opts[i].Permissions) { q = q.Arg("permissions", opts[i].Permissions) @@ -1447,6 +1489,7 @@ func (r *Container) WithNewFile(path string, opts ...ContainerWithNewFileOpts) * } } q = q.Arg("path", path) + q = q.Arg("contents", contents) return &Container{ query: q, @@ -1564,6 +1607,16 @@ func (r *Container) WithoutDefaultArgs() *Container { } } +// Retrieves this container with the directory at the given path removed. +func (r *Container) WithoutDirectory(path string) *Container { + q := r.query.Select("withoutDirectory") + q = q.Arg("path", path) + + return &Container{ + query: q, + } +} + // ContainerWithoutEntrypointOpts contains options for Container.WithoutEntrypoint type ContainerWithoutEntrypointOpts struct { // Don't remove the default arguments when unsetting the entrypoint. @@ -1617,6 +1670,16 @@ func (r *Container) WithoutExposedPort(port int, opts ...ContainerWithoutExposed } } +// Retrieves this container with the file at the given path removed. +func (r *Container) WithoutFile(path string) *Container { + q := r.query.Select("withoutFile") + q = q.Arg("path", path) + + return &Container{ + query: q, + } +} + // Indicate that subsequent operations should not be featured more prominently in the UI. // // This is the initial state of all containers. @@ -1658,6 +1721,16 @@ func (r *Container) WithoutRegistryAuth(address string) *Container { } } +// Retrieves this container minus the given environment variable containing the secret. +func (r *Container) WithoutSecretVariable(name string) *Container { + q := r.query.Select("withoutSecretVariable") + q = q.Arg("name", name) + + return &Container{ + query: q, + } +} + // Retrieves this container with a previously added Unix socket removed. func (r *Container) WithoutUnixSocket(path string) *Container { q := r.query.Select("withoutUnixSocket") @@ -1750,7 +1823,7 @@ func (r *CurrentModule) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *CurrentModule) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -1826,204 +1899,197 @@ func (r *CurrentModule) WorkdirFile(path string) *File { } } -// A directory. -type Directory struct { +// A cache storage for the Dagger engine +type DaggerEngineCache struct { query *querybuilder.Selection - export *bool - id *DirectoryID - sync *DirectoryID -} -type WithDirectoryFunc func(r *Directory) *Directory - -// With calls the provided function with current Directory. -// -// This is useful for reusability and readability by not breaking the calling chain. -func (r *Directory) With(f WithDirectoryFunc) *Directory { - return f(r) + id *DaggerEngineCacheID + keepBytes *int + prune *Void } -func (r *Directory) WithGraphQLQuery(q *querybuilder.Selection) *Directory { - return &Directory{ +func (r *DaggerEngineCache) WithGraphQLQuery(q *querybuilder.Selection) *DaggerEngineCache { + return &DaggerEngineCache{ query: q, } } -// DirectoryAsModuleOpts contains options for Directory.AsModule -type DirectoryAsModuleOpts struct { - // An optional subpath of the directory which contains the module's configuration file. - // - // This is needed when the module code is in a subdirectory but requires parent directories to be loaded in order to execute. For example, the module source code may need a go.mod, project.toml, package.json, etc. file from a parent directory. - // - // If not set, the module source code is loaded from the root of the directory. - SourceRootPath string -} - -// Load the directory as a Dagger module -func (r *Directory) AsModule(opts ...DirectoryAsModuleOpts) *Module { - q := r.query.Select("asModule") - for i := len(opts) - 1; i >= 0; i-- { - // `sourceRootPath` optional argument - if !querybuilder.IsZeroValue(opts[i].SourceRootPath) { - q = q.Arg("sourceRootPath", opts[i].SourceRootPath) - } - } +// The current set of entries in the cache +func (r *DaggerEngineCache) EntrySet() *DaggerEngineCacheEntrySet { + q := r.query.Select("entrySet") - return &Module{ + return &DaggerEngineCacheEntrySet{ query: q, } } -// Gets the difference between this directory and an another directory. -func (r *Directory) Diff(other *Directory) *Directory { - assertNotNil("other", other) - q := r.query.Select("diff") - q = q.Arg("other", other) - - return &Directory{ - query: q, +// A unique identifier for this DaggerEngineCache. +func (r *DaggerEngineCache) ID(ctx context.Context) (DaggerEngineCacheID, error) { + if r.id != nil { + return *r.id, nil } + q := r.query.Select("id") + + var response DaggerEngineCacheID + + q = q.Bind(&response) + return response, q.Execute(ctx) } -// Retrieves a directory at the given path. -func (r *Directory) Directory(path string) *Directory { - q := r.query.Select("directory") - q = q.Arg("path", path) +// XXX_GraphQLType is an internal function. It returns the native GraphQL type name +func (r *DaggerEngineCache) XXX_GraphQLType() string { + return "DaggerEngineCache" +} - return &Directory{ - query: q, +// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object +func (r *DaggerEngineCache) XXX_GraphQLIDType() string { + return "DaggerEngineCacheID" +} + +// XXX_GraphQLID is an internal function. It returns the underlying type ID +func (r *DaggerEngineCache) XXX_GraphQLID(ctx context.Context) (string, error) { + id, err := r.ID(ctx) + if err != nil { + return "", err } + return string(id), nil } -// DirectoryDockerBuildOpts contains options for Directory.DockerBuild -type DirectoryDockerBuildOpts struct { - // The platform to build. - Platform Platform - // Path to the Dockerfile to use (e.g., "frontend.Dockerfile"). - Dockerfile string - // Target build stage to build. - Target string - // Build arguments to use in the build. - BuildArgs []BuildArg - // Secrets to pass to the build. - // - // They will be mounted at /run/secrets/[secret-name]. - Secrets []*Secret +func (r *DaggerEngineCache) MarshalJSON() ([]byte, error) { + id, err := r.ID(marshalCtx) + if err != nil { + return nil, err + } + return json.Marshal(id) +} +func (r *DaggerEngineCache) UnmarshalJSON(bs []byte) error { + var id string + err := json.Unmarshal(bs, &id) + if err != nil { + return err + } + *r = *dag.LoadDaggerEngineCacheFromID(DaggerEngineCacheID(id)) + return nil } -// Builds a new Docker container from this directory. -func (r *Directory) DockerBuild(opts ...DirectoryDockerBuildOpts) *Container { - q := r.query.Select("dockerBuild") - for i := len(opts) - 1; i >= 0; i-- { - // `platform` optional argument - if !querybuilder.IsZeroValue(opts[i].Platform) { - q = q.Arg("platform", opts[i].Platform) - } - // `dockerfile` optional argument - if !querybuilder.IsZeroValue(opts[i].Dockerfile) { - q = q.Arg("dockerfile", opts[i].Dockerfile) - } - // `target` optional argument - if !querybuilder.IsZeroValue(opts[i].Target) { - q = q.Arg("target", opts[i].Target) - } - // `buildArgs` optional argument - if !querybuilder.IsZeroValue(opts[i].BuildArgs) { - q = q.Arg("buildArgs", opts[i].BuildArgs) - } - // `secrets` optional argument - if !querybuilder.IsZeroValue(opts[i].Secrets) { - q = q.Arg("secrets", opts[i].Secrets) - } +// The maximum bytes to keep in the cache without pruning, after which automatic pruning may kick in. +func (r *DaggerEngineCache) KeepBytes(ctx context.Context) (int, error) { + if r.keepBytes != nil { + return *r.keepBytes, nil } + q := r.query.Select("keepBytes") - return &Container{ - query: q, + var response int + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// Prune the cache of releaseable entries +func (r *DaggerEngineCache) Prune(ctx context.Context) error { + if r.prune != nil { + return nil } + q := r.query.Select("prune") + + return q.Execute(ctx) } -// DirectoryEntriesOpts contains options for Directory.Entries -type DirectoryEntriesOpts struct { - // Location of the directory to look at (e.g., "/src"). - Path string +// An individual cache entry in a cache entry set +type DaggerEngineCacheEntry struct { + query *querybuilder.Selection + + activelyUsed *bool + createdTimeUnixNano *int + description *string + diskSpaceBytes *int + id *DaggerEngineCacheEntryID + mostRecentUseTimeUnixNano *int } -// Returns a list of files and directories at the given path. -func (r *Directory) Entries(ctx context.Context, opts ...DirectoryEntriesOpts) ([]string, error) { - q := r.query.Select("entries") - for i := len(opts) - 1; i >= 0; i-- { - // `path` optional argument - if !querybuilder.IsZeroValue(opts[i].Path) { - q = q.Arg("path", opts[i].Path) - } +func (r *DaggerEngineCacheEntry) WithGraphQLQuery(q *querybuilder.Selection) *DaggerEngineCacheEntry { + return &DaggerEngineCacheEntry{ + query: q, } +} - var response []string +// Whether the cache entry is actively being used. +func (r *DaggerEngineCacheEntry) ActivelyUsed(ctx context.Context) (bool, error) { + if r.activelyUsed != nil { + return *r.activelyUsed, nil + } + q := r.query.Select("activelyUsed") + + var response bool q = q.Bind(&response) return response, q.Execute(ctx) } -// Writes the contents of the directory to a path on the host. -func (r *Directory) Export(ctx context.Context, path string) (bool, error) { - if r.export != nil { - return *r.export, nil +// The time the cache entry was created, in Unix nanoseconds. +func (r *DaggerEngineCacheEntry) CreatedTimeUnixNano(ctx context.Context) (int, error) { + if r.createdTimeUnixNano != nil { + return *r.createdTimeUnixNano, nil } - q := r.query.Select("export") - q = q.Arg("path", path) + q := r.query.Select("createdTimeUnixNano") - var response bool + var response int q = q.Bind(&response) return response, q.Execute(ctx) } -// Retrieves a file at the given path. -func (r *Directory) File(path string) *File { - q := r.query.Select("file") - q = q.Arg("path", path) - - return &File{ - query: q, +// The description of the cache entry. +func (r *DaggerEngineCacheEntry) Description(ctx context.Context) (string, error) { + if r.description != nil { + return *r.description, nil } + q := r.query.Select("description") + + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) } -// Returns a list of files and directories that matche the given pattern. -func (r *Directory) Glob(ctx context.Context, pattern string) ([]string, error) { - q := r.query.Select("glob") - q = q.Arg("pattern", pattern) +// The disk space used by the cache entry. +func (r *DaggerEngineCacheEntry) DiskSpaceBytes(ctx context.Context) (int, error) { + if r.diskSpaceBytes != nil { + return *r.diskSpaceBytes, nil + } + q := r.query.Select("diskSpaceBytes") - var response []string + var response int q = q.Bind(&response) return response, q.Execute(ctx) } -// A unique identifier for this Directory. -func (r *Directory) ID(ctx context.Context) (DirectoryID, error) { +// A unique identifier for this DaggerEngineCacheEntry. +func (r *DaggerEngineCacheEntry) ID(ctx context.Context) (DaggerEngineCacheEntryID, error) { if r.id != nil { return *r.id, nil } q := r.query.Select("id") - var response DirectoryID + var response DaggerEngineCacheEntryID q = q.Bind(&response) return response, q.Execute(ctx) } // XXX_GraphQLType is an internal function. It returns the native GraphQL type name -func (r *Directory) XXX_GraphQLType() string { - return "Directory" +func (r *DaggerEngineCacheEntry) XXX_GraphQLType() string { + return "DaggerEngineCacheEntry" } // XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object -func (r *Directory) XXX_GraphQLIDType() string { - return "DirectoryID" +func (r *DaggerEngineCacheEntry) XXX_GraphQLIDType() string { + return "DaggerEngineCacheEntryID" } // XXX_GraphQLID is an internal function. It returns the underlying type ID -func (r *Directory) XXX_GraphQLID(ctx context.Context) (string, error) { +func (r *DaggerEngineCacheEntry) XXX_GraphQLID(ctx context.Context) (string, error) { id, err := r.ID(ctx) if err != nil { return "", err @@ -2031,56 +2097,479 @@ func (r *Directory) XXX_GraphQLID(ctx context.Context) (string, error) { return string(id), nil } -func (r *Directory) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) +func (r *DaggerEngineCacheEntry) MarshalJSON() ([]byte, error) { + id, err := r.ID(marshalCtx) if err != nil { return nil, err } return json.Marshal(id) } -func (r *Directory) UnmarshalJSON(bs []byte) error { +func (r *DaggerEngineCacheEntry) UnmarshalJSON(bs []byte) error { var id string err := json.Unmarshal(bs, &id) if err != nil { return err } - *r = *dag.LoadDirectoryFromID(DirectoryID(id)) + *r = *dag.LoadDaggerEngineCacheEntryFromID(DaggerEngineCacheEntryID(id)) return nil } -// DirectoryPipelineOpts contains options for Directory.Pipeline -type DirectoryPipelineOpts struct { - // Description of the sub-pipeline. - Description string - // Labels to apply to the sub-pipeline. - Labels []PipelineLabel -} - -// Creates a named sub-pipeline. -func (r *Directory) Pipeline(name string, opts ...DirectoryPipelineOpts) *Directory { - q := r.query.Select("pipeline") - for i := len(opts) - 1; i >= 0; i-- { - // `description` optional argument - if !querybuilder.IsZeroValue(opts[i].Description) { - q = q.Arg("description", opts[i].Description) - } - // `labels` optional argument - if !querybuilder.IsZeroValue(opts[i].Labels) { - q = q.Arg("labels", opts[i].Labels) - } +// The most recent time the cache entry was used, in Unix nanoseconds. +func (r *DaggerEngineCacheEntry) MostRecentUseTimeUnixNano(ctx context.Context) (int, error) { + if r.mostRecentUseTimeUnixNano != nil { + return *r.mostRecentUseTimeUnixNano, nil } - q = q.Arg("name", name) + q := r.query.Select("mostRecentUseTimeUnixNano") - return &Directory{ - query: q, - } -} + var response int + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// A set of cache entries returned by a query to a cache +type DaggerEngineCacheEntrySet struct { + query *querybuilder.Selection + + diskSpaceBytes *int + entryCount *int + id *DaggerEngineCacheEntrySetID +} + +func (r *DaggerEngineCacheEntrySet) WithGraphQLQuery(q *querybuilder.Selection) *DaggerEngineCacheEntrySet { + return &DaggerEngineCacheEntrySet{ + query: q, + } +} + +// The total disk space used by the cache entries in this set. +func (r *DaggerEngineCacheEntrySet) DiskSpaceBytes(ctx context.Context) (int, error) { + if r.diskSpaceBytes != nil { + return *r.diskSpaceBytes, nil + } + q := r.query.Select("diskSpaceBytes") + + var response int + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// The list of individual cache entries in the set +func (r *DaggerEngineCacheEntrySet) Entries(ctx context.Context) ([]DaggerEngineCacheEntry, error) { + q := r.query.Select("entries") + + q = q.Select("id") + + type entries struct { + Id DaggerEngineCacheEntryID + } + + convert := func(fields []entries) []DaggerEngineCacheEntry { + out := []DaggerEngineCacheEntry{} + + for i := range fields { + val := DaggerEngineCacheEntry{id: &fields[i].Id} + val.query = q.Root().Select("loadDaggerEngineCacheEntryFromID").Arg("id", fields[i].Id) + out = append(out, val) + } + + return out + } + var response []entries + + q = q.Bind(&response) + + err := q.Execute(ctx) + if err != nil { + return nil, err + } + + return convert(response), nil +} + +// The number of cache entries in this set. +func (r *DaggerEngineCacheEntrySet) EntryCount(ctx context.Context) (int, error) { + if r.entryCount != nil { + return *r.entryCount, nil + } + q := r.query.Select("entryCount") + + var response int + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// A unique identifier for this DaggerEngineCacheEntrySet. +func (r *DaggerEngineCacheEntrySet) ID(ctx context.Context) (DaggerEngineCacheEntrySetID, error) { + if r.id != nil { + return *r.id, nil + } + q := r.query.Select("id") + + var response DaggerEngineCacheEntrySetID + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// XXX_GraphQLType is an internal function. It returns the native GraphQL type name +func (r *DaggerEngineCacheEntrySet) XXX_GraphQLType() string { + return "DaggerEngineCacheEntrySet" +} + +// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object +func (r *DaggerEngineCacheEntrySet) XXX_GraphQLIDType() string { + return "DaggerEngineCacheEntrySetID" +} + +// XXX_GraphQLID is an internal function. It returns the underlying type ID +func (r *DaggerEngineCacheEntrySet) XXX_GraphQLID(ctx context.Context) (string, error) { + id, err := r.ID(ctx) + if err != nil { + return "", err + } + return string(id), nil +} + +func (r *DaggerEngineCacheEntrySet) MarshalJSON() ([]byte, error) { + id, err := r.ID(marshalCtx) + if err != nil { + return nil, err + } + return json.Marshal(id) +} +func (r *DaggerEngineCacheEntrySet) UnmarshalJSON(bs []byte) error { + var id string + err := json.Unmarshal(bs, &id) + if err != nil { + return err + } + *r = *dag.LoadDaggerEngineCacheEntrySetFromID(DaggerEngineCacheEntrySetID(id)) + return nil +} + +// A directory. +type Directory struct { + query *querybuilder.Selection + + export *string + id *DirectoryID + sync *DirectoryID +} +type WithDirectoryFunc func(r *Directory) *Directory + +// With calls the provided function with current Directory. +// +// This is useful for reusability and readability by not breaking the calling chain. +func (r *Directory) With(f WithDirectoryFunc) *Directory { + return f(r) +} + +func (r *Directory) WithGraphQLQuery(q *querybuilder.Selection) *Directory { + return &Directory{ + query: q, + } +} + +// DirectoryAsModuleOpts contains options for Directory.AsModule +type DirectoryAsModuleOpts struct { + // An optional subpath of the directory which contains the module's configuration file. + // + // This is needed when the module code is in a subdirectory but requires parent directories to be loaded in order to execute. For example, the module source code may need a go.mod, project.toml, package.json, etc. file from a parent directory. + // + // If not set, the module source code is loaded from the root of the directory. + SourceRootPath string + // The engine version to upgrade to. + EngineVersion string +} + +// Load the directory as a Dagger module +func (r *Directory) AsModule(opts ...DirectoryAsModuleOpts) *Module { + q := r.query.Select("asModule") + for i := len(opts) - 1; i >= 0; i-- { + // `sourceRootPath` optional argument + if !querybuilder.IsZeroValue(opts[i].SourceRootPath) { + q = q.Arg("sourceRootPath", opts[i].SourceRootPath) + } + // `engineVersion` optional argument + if !querybuilder.IsZeroValue(opts[i].EngineVersion) { + q = q.Arg("engineVersion", opts[i].EngineVersion) + } + } + + return &Module{ + query: q, + } +} + +// Gets the difference between this directory and an another directory. +func (r *Directory) Diff(other *Directory) *Directory { + assertNotNil("other", other) + q := r.query.Select("diff") + q = q.Arg("other", other) + + return &Directory{ + query: q, + } +} + +// Retrieves a directory at the given path. +func (r *Directory) Directory(path string) *Directory { + q := r.query.Select("directory") + q = q.Arg("path", path) + + return &Directory{ + query: q, + } +} + +// DirectoryDockerBuildOpts contains options for Directory.DockerBuild +type DirectoryDockerBuildOpts struct { + // The platform to build. + Platform Platform + // Path to the Dockerfile to use (e.g., "frontend.Dockerfile"). + Dockerfile string + // Target build stage to build. + Target string + // Build arguments to use in the build. + BuildArgs []BuildArg + // Secrets to pass to the build. + // + // They will be mounted at /run/secrets/[secret-name]. + Secrets []*Secret +} + +// Builds a new Docker container from this directory. +func (r *Directory) DockerBuild(opts ...DirectoryDockerBuildOpts) *Container { + q := r.query.Select("dockerBuild") + for i := len(opts) - 1; i >= 0; i-- { + // `platform` optional argument + if !querybuilder.IsZeroValue(opts[i].Platform) { + q = q.Arg("platform", opts[i].Platform) + } + // `dockerfile` optional argument + if !querybuilder.IsZeroValue(opts[i].Dockerfile) { + q = q.Arg("dockerfile", opts[i].Dockerfile) + } + // `target` optional argument + if !querybuilder.IsZeroValue(opts[i].Target) { + q = q.Arg("target", opts[i].Target) + } + // `buildArgs` optional argument + if !querybuilder.IsZeroValue(opts[i].BuildArgs) { + q = q.Arg("buildArgs", opts[i].BuildArgs) + } + // `secrets` optional argument + if !querybuilder.IsZeroValue(opts[i].Secrets) { + q = q.Arg("secrets", opts[i].Secrets) + } + } + + return &Container{ + query: q, + } +} + +// DirectoryEntriesOpts contains options for Directory.Entries +type DirectoryEntriesOpts struct { + // Location of the directory to look at (e.g., "/src"). + Path string +} + +// Returns a list of files and directories at the given path. +func (r *Directory) Entries(ctx context.Context, opts ...DirectoryEntriesOpts) ([]string, error) { + q := r.query.Select("entries") + for i := len(opts) - 1; i >= 0; i-- { + // `path` optional argument + if !querybuilder.IsZeroValue(opts[i].Path) { + q = q.Arg("path", opts[i].Path) + } + } + + var response []string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// DirectoryExportOpts contains options for Directory.Export +type DirectoryExportOpts struct { + // If true, then the host directory will be wiped clean before exporting so that it exactly matches the directory being exported; this means it will delete any files on the host that aren't in the exported dir. If false (the default), the contents of the directory will be merged with any existing contents of the host directory, leaving any existing files on the host that aren't in the exported directory alone. + Wipe bool +} + +// Writes the contents of the directory to a path on the host. +func (r *Directory) Export(ctx context.Context, path string, opts ...DirectoryExportOpts) (string, error) { + if r.export != nil { + return *r.export, nil + } + q := r.query.Select("export") + for i := len(opts) - 1; i >= 0; i-- { + // `wipe` optional argument + if !querybuilder.IsZeroValue(opts[i].Wipe) { + q = q.Arg("wipe", opts[i].Wipe) + } + } + q = q.Arg("path", path) + + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// Retrieves a file at the given path. +func (r *Directory) File(path string) *File { + q := r.query.Select("file") + q = q.Arg("path", path) + + return &File{ + query: q, + } +} + +// Returns a list of files and directories that matche the given pattern. +func (r *Directory) Glob(ctx context.Context, pattern string) ([]string, error) { + q := r.query.Select("glob") + q = q.Arg("pattern", pattern) + + var response []string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// A unique identifier for this Directory. +func (r *Directory) ID(ctx context.Context) (DirectoryID, error) { + if r.id != nil { + return *r.id, nil + } + q := r.query.Select("id") + + var response DirectoryID + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// XXX_GraphQLType is an internal function. It returns the native GraphQL type name +func (r *Directory) XXX_GraphQLType() string { + return "Directory" +} + +// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object +func (r *Directory) XXX_GraphQLIDType() string { + return "DirectoryID" +} + +// XXX_GraphQLID is an internal function. It returns the underlying type ID +func (r *Directory) XXX_GraphQLID(ctx context.Context) (string, error) { + id, err := r.ID(ctx) + if err != nil { + return "", err + } + return string(id), nil +} + +func (r *Directory) MarshalJSON() ([]byte, error) { + id, err := r.ID(marshalCtx) + if err != nil { + return nil, err + } + return json.Marshal(id) +} +func (r *Directory) UnmarshalJSON(bs []byte) error { + var id string + err := json.Unmarshal(bs, &id) + if err != nil { + return err + } + *r = *dag.LoadDirectoryFromID(DirectoryID(id)) + return nil +} + +// DirectoryPipelineOpts contains options for Directory.Pipeline +type DirectoryPipelineOpts struct { + // Description of the sub-pipeline. + Description string + // Labels to apply to the sub-pipeline. + Labels []PipelineLabel +} + +// Creates a named sub-pipeline. +func (r *Directory) Pipeline(name string, opts ...DirectoryPipelineOpts) *Directory { + q := r.query.Select("pipeline") + for i := len(opts) - 1; i >= 0; i-- { + // `description` optional argument + if !querybuilder.IsZeroValue(opts[i].Description) { + q = q.Arg("description", opts[i].Description) + } + // `labels` optional argument + if !querybuilder.IsZeroValue(opts[i].Labels) { + q = q.Arg("labels", opts[i].Labels) + } + } + q = q.Arg("name", name) + + return &Directory{ + query: q, + } +} // Force evaluation in the engine. func (r *Directory) Sync(ctx context.Context) (*Directory, error) { q := r.query.Select("sync") - return r, q.Execute(ctx) + var id DirectoryID + if err := q.Bind(&id).Execute(ctx); err != nil { + return nil, err + } + return &Directory{ + query: q.Root().Select("loadDirectoryFromID").Arg("id", id), + }, nil +} + +// DirectoryTerminalOpts contains options for Directory.Terminal +type DirectoryTerminalOpts struct { + // If set, override the container's default terminal command and invoke these command arguments instead. + Cmd []string + // Provides Dagger access to the executed command. + // + // Do not use this option unless you trust the command being executed; the command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM. + ExperimentalPrivilegedNesting bool + // Execute the command with all root capabilities. This is similar to running a command with "sudo" or executing "docker run" with the "--privileged" flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands. + InsecureRootCapabilities bool + // If set, override the default container used for the terminal. + Container *Container +} + +// Opens an interactive terminal in new container with this directory mounted inside. +func (r *Directory) Terminal(opts ...DirectoryTerminalOpts) *Directory { + q := r.query.Select("terminal") + for i := len(opts) - 1; i >= 0; i-- { + // `cmd` optional argument + if !querybuilder.IsZeroValue(opts[i].Cmd) { + q = q.Arg("cmd", opts[i].Cmd) + } + // `experimentalPrivilegedNesting` optional argument + if !querybuilder.IsZeroValue(opts[i].ExperimentalPrivilegedNesting) { + q = q.Arg("experimentalPrivilegedNesting", opts[i].ExperimentalPrivilegedNesting) + } + // `insecureRootCapabilities` optional argument + if !querybuilder.IsZeroValue(opts[i].InsecureRootCapabilities) { + q = q.Arg("insecureRootCapabilities", opts[i].InsecureRootCapabilities) + } + // `container` optional argument + if !querybuilder.IsZeroValue(opts[i].Container) { + q = q.Arg("container", opts[i].Container) + } + } + + return &Directory{ + query: q, + } } // DirectoryWithDirectoryOpts contains options for Directory.WithDirectory @@ -2223,16 +2712,243 @@ func (r *Directory) WithoutDirectory(path string) *Directory { return &Directory{ query: q, } -} +} + +// Retrieves this directory with the file at the given path removed. +func (r *Directory) WithoutFile(path string) *Directory { + q := r.query.Select("withoutFile") + q = q.Arg("path", path) + + return &Directory{ + query: q, + } +} + +// A definition of a custom enum defined in a Module. +type EnumTypeDef struct { + query *querybuilder.Selection + + description *string + id *EnumTypeDefID + name *string + sourceModuleName *string +} + +func (r *EnumTypeDef) WithGraphQLQuery(q *querybuilder.Selection) *EnumTypeDef { + return &EnumTypeDef{ + query: q, + } +} + +// A doc string for the enum, if any. +func (r *EnumTypeDef) Description(ctx context.Context) (string, error) { + if r.description != nil { + return *r.description, nil + } + q := r.query.Select("description") + + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// A unique identifier for this EnumTypeDef. +func (r *EnumTypeDef) ID(ctx context.Context) (EnumTypeDefID, error) { + if r.id != nil { + return *r.id, nil + } + q := r.query.Select("id") + + var response EnumTypeDefID + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// XXX_GraphQLType is an internal function. It returns the native GraphQL type name +func (r *EnumTypeDef) XXX_GraphQLType() string { + return "EnumTypeDef" +} + +// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object +func (r *EnumTypeDef) XXX_GraphQLIDType() string { + return "EnumTypeDefID" +} + +// XXX_GraphQLID is an internal function. It returns the underlying type ID +func (r *EnumTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) { + id, err := r.ID(ctx) + if err != nil { + return "", err + } + return string(id), nil +} + +func (r *EnumTypeDef) MarshalJSON() ([]byte, error) { + id, err := r.ID(marshalCtx) + if err != nil { + return nil, err + } + return json.Marshal(id) +} +func (r *EnumTypeDef) UnmarshalJSON(bs []byte) error { + var id string + err := json.Unmarshal(bs, &id) + if err != nil { + return err + } + *r = *dag.LoadEnumTypeDefFromID(EnumTypeDefID(id)) + return nil +} + +// The name of the enum. +func (r *EnumTypeDef) Name(ctx context.Context) (string, error) { + if r.name != nil { + return *r.name, nil + } + q := r.query.Select("name") + + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// If this EnumTypeDef is associated with a Module, the name of the module. Unset otherwise. +func (r *EnumTypeDef) SourceModuleName(ctx context.Context) (string, error) { + if r.sourceModuleName != nil { + return *r.sourceModuleName, nil + } + q := r.query.Select("sourceModuleName") + + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// The values of the enum. +func (r *EnumTypeDef) Values(ctx context.Context) ([]EnumValueTypeDef, error) { + q := r.query.Select("values") + + q = q.Select("id") + + type values struct { + Id EnumValueTypeDefID + } + + convert := func(fields []values) []EnumValueTypeDef { + out := []EnumValueTypeDef{} + + for i := range fields { + val := EnumValueTypeDef{id: &fields[i].Id} + val.query = q.Root().Select("loadEnumValueTypeDefFromID").Arg("id", fields[i].Id) + out = append(out, val) + } + + return out + } + var response []values + + q = q.Bind(&response) + + err := q.Execute(ctx) + if err != nil { + return nil, err + } + + return convert(response), nil +} + +// A definition of a value in a custom enum defined in a Module. +type EnumValueTypeDef struct { + query *querybuilder.Selection + + description *string + id *EnumValueTypeDefID + name *string +} + +func (r *EnumValueTypeDef) WithGraphQLQuery(q *querybuilder.Selection) *EnumValueTypeDef { + return &EnumValueTypeDef{ + query: q, + } +} + +// A doc string for the enum value, if any. +func (r *EnumValueTypeDef) Description(ctx context.Context) (string, error) { + if r.description != nil { + return *r.description, nil + } + q := r.query.Select("description") + + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// A unique identifier for this EnumValueTypeDef. +func (r *EnumValueTypeDef) ID(ctx context.Context) (EnumValueTypeDefID, error) { + if r.id != nil { + return *r.id, nil + } + q := r.query.Select("id") + + var response EnumValueTypeDefID + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// XXX_GraphQLType is an internal function. It returns the native GraphQL type name +func (r *EnumValueTypeDef) XXX_GraphQLType() string { + return "EnumValueTypeDef" +} + +// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object +func (r *EnumValueTypeDef) XXX_GraphQLIDType() string { + return "EnumValueTypeDefID" +} + +// XXX_GraphQLID is an internal function. It returns the underlying type ID +func (r *EnumValueTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) { + id, err := r.ID(ctx) + if err != nil { + return "", err + } + return string(id), nil +} + +func (r *EnumValueTypeDef) MarshalJSON() ([]byte, error) { + id, err := r.ID(marshalCtx) + if err != nil { + return nil, err + } + return json.Marshal(id) +} +func (r *EnumValueTypeDef) UnmarshalJSON(bs []byte) error { + var id string + err := json.Unmarshal(bs, &id) + if err != nil { + return err + } + *r = *dag.LoadEnumValueTypeDefFromID(EnumValueTypeDefID(id)) + return nil +} + +// The name of the enum value. +func (r *EnumValueTypeDef) Name(ctx context.Context) (string, error) { + if r.name != nil { + return *r.name, nil + } + q := r.query.Select("name") -// Retrieves this directory with the file at the given path removed. -func (r *Directory) WithoutFile(path string) *Directory { - q := r.query.Select("withoutFile") - q = q.Arg("path", path) + var response string - return &Directory{ - query: q, - } + q = q.Bind(&response) + return response, q.Execute(ctx) } // An environment variable name and value. @@ -2283,7 +2999,7 @@ func (r *EnvVariable) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *EnvVariable) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -2388,7 +3104,7 @@ func (r *FieldTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *FieldTypeDef) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -2431,7 +3147,7 @@ type File struct { query *querybuilder.Selection contents *string - export *bool + export *string id *FileID name *string size *int @@ -2472,7 +3188,7 @@ type FileExportOpts struct { } // Writes the file to a file path on the host. -func (r *File) Export(ctx context.Context, path string, opts ...FileExportOpts) (bool, error) { +func (r *File) Export(ctx context.Context, path string, opts ...FileExportOpts) (string, error) { if r.export != nil { return *r.export, nil } @@ -2485,7 +3201,7 @@ func (r *File) Export(ctx context.Context, path string, opts ...FileExportOpts) } q = q.Arg("path", path) - var response bool + var response string q = q.Bind(&response) return response, q.Execute(ctx) @@ -2524,7 +3240,7 @@ func (r *File) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *File) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -2570,7 +3286,23 @@ func (r *File) Size(ctx context.Context) (int, error) { func (r *File) Sync(ctx context.Context) (*File, error) { q := r.query.Select("sync") - return r, q.Execute(ctx) + var id FileID + if err := q.Bind(&id).Execute(ctx); err != nil { + return nil, err + } + return &File{ + query: q.Root().Select("loadFileFromID").Arg("id", id), + }, nil +} + +// Retrieves this file with its name set to the given name. +func (r *File) WithName(name string) *File { + q := r.query.Select("withName") + q = q.Arg("name", name) + + return &File{ + query: q, + } } // Retrieves this file with its created/modified timestamps set to the given time. @@ -2687,7 +3419,7 @@ func (r *Function) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *Function) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -2842,7 +3574,7 @@ func (r *FunctionArg) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *FunctionArg) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -2930,7 +3662,7 @@ func (r *FunctionCall) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *FunctionCall) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -3019,17 +3751,14 @@ func (r *FunctionCall) ParentName(ctx context.Context) (string, error) { } // Set the return value of the function call to the provided value. -func (r *FunctionCall) ReturnValue(ctx context.Context, value JSON) (Void, error) { +func (r *FunctionCall) ReturnValue(ctx context.Context, value JSON) error { if r.returnValue != nil { - return *r.returnValue, nil + return nil } q := r.query.Select("returnValue") q = q.Arg("value", value) - var response Void - - q = q.Bind(&response) - return response, q.Execute(ctx) + return q.Execute(ctx) } // A value passed as a named argument to a function call. @@ -3080,7 +3809,7 @@ func (r *FunctionCallArgValue) XXX_GraphQLID(ctx context.Context) (string, error } func (r *FunctionCallArgValue) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -3185,7 +3914,7 @@ func (r *GeneratedCode) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *GeneratedCode) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -3249,6 +3978,7 @@ type GitModuleSource struct { commit *string htmlURL *string id *GitModuleSourceID + root *string rootSubpath *string version *string } @@ -3259,7 +3989,7 @@ func (r *GitModuleSource) WithGraphQLQuery(q *querybuilder.Selection) *GitModule } } -// The URL from which the source's git repo can be cloned. +// The URL to clone the root of the git repo from func (r *GitModuleSource) CloneURL(ctx context.Context) (string, error) { if r.cloneURL != nil { return *r.cloneURL, nil @@ -3340,7 +4070,7 @@ func (r *GitModuleSource) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *GitModuleSource) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -3356,6 +4086,19 @@ func (r *GitModuleSource) UnmarshalJSON(bs []byte) error { return nil } +// The clean module name of the root of the module +func (r *GitModuleSource) Root(ctx context.Context) (string, error) { + if r.root != nil { + return *r.root, nil + } + q := r.query.Select("root") + + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + // The path to the root of the module source under the context directory. This directory contains its configuration file. It also contains its source code (possibly as a subdirectory). func (r *GitModuleSource) RootSubpath(ctx context.Context) (string, error) { if r.rootSubpath != nil { @@ -3442,7 +4185,7 @@ func (r *GitRef) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *GitRef) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -3458,27 +4201,9 @@ func (r *GitRef) UnmarshalJSON(bs []byte) error { return nil } -// GitRefTreeOpts contains options for GitRef.Tree -type GitRefTreeOpts struct { - // DEPRECATED: This option should be passed to `git` instead. - SSHKnownHosts string - // DEPRECATED: This option should be passed to `git` instead. - SSHAuthSocket *Socket -} - // The filesystem tree at this ref. -func (r *GitRef) Tree(opts ...GitRefTreeOpts) *Directory { +func (r *GitRef) Tree() *Directory { q := r.query.Select("tree") - for i := len(opts) - 1; i >= 0; i-- { - // `sshKnownHosts` optional argument - if !querybuilder.IsZeroValue(opts[i].SSHKnownHosts) { - q = q.Arg("sshKnownHosts", opts[i].SSHKnownHosts) - } - // `sshAuthSocket` optional argument - if !querybuilder.IsZeroValue(opts[i].SSHAuthSocket) { - q = q.Arg("sshAuthSocket", opts[i].SSHAuthSocket) - } - } return &Directory{ query: q, @@ -3491,6 +4216,14 @@ type GitRepository struct { id *GitRepositoryID } +type WithGitRepositoryFunc func(r *GitRepository) *GitRepository + +// With calls the provided function with current GitRepository. +// +// This is useful for reusability and readability by not breaking the calling chain. +func (r *GitRepository) With(f WithGitRepositoryFunc) *GitRepository { + return f(r) +} func (r *GitRepository) WithGraphQLQuery(q *querybuilder.Selection) *GitRepository { return &GitRepository{ @@ -3518,6 +4251,15 @@ func (r *GitRepository) Commit(id string) *GitRef { } } +// Returns details for HEAD. +func (r *GitRepository) Head() *GitRef { + q := r.query.Select("head") + + return &GitRef{ + query: q, + } +} + // A unique identifier for this GitRepository. func (r *GitRepository) ID(ctx context.Context) (GitRepositoryID, error) { if r.id != nil { @@ -3551,7 +4293,7 @@ func (r *GitRepository) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *GitRepository) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -3587,6 +4329,50 @@ func (r *GitRepository) Tag(name string) *GitRef { } } +// GitRepositoryTagsOpts contains options for GitRepository.Tags +type GitRepositoryTagsOpts struct { + // Glob patterns (e.g., "refs/tags/v*"). + Patterns []string +} + +// tags that match any of the given glob patterns. +func (r *GitRepository) Tags(ctx context.Context, opts ...GitRepositoryTagsOpts) ([]string, error) { + q := r.query.Select("tags") + for i := len(opts) - 1; i >= 0; i-- { + // `patterns` optional argument + if !querybuilder.IsZeroValue(opts[i].Patterns) { + q = q.Arg("patterns", opts[i].Patterns) + } + } + + var response []string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// Header to authenticate the remote with. +func (r *GitRepository) WithAuthHeader(header *Secret) *GitRepository { + assertNotNil("header", header) + q := r.query.Select("withAuthHeader") + q = q.Arg("header", header) + + return &GitRepository{ + query: q, + } +} + +// Token to authenticate the remote with. +func (r *GitRepository) WithAuthToken(token *Secret) *GitRepository { + assertNotNil("token", token) + q := r.query.Select("withAuthToken") + q = q.Arg("token", token) + + return &GitRepository{ + query: q, + } +} + // A graphql input type, which is essentially just a group of named args. // This is currently only used to represent pre-existing usage of graphql input types // in the core API. It is not used by user modules and shouldn't ever be as user @@ -3670,7 +4456,7 @@ func (r *InputTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *InputTypeDef) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -3794,7 +4580,7 @@ func (r *InterfaceTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *InterfaceTypeDef) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -3884,7 +4670,7 @@ func (r *Label) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *Label) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -3981,7 +4767,7 @@ func (r *ListTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *ListTypeDef) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -4053,7 +4839,7 @@ func (r *LocalModuleSource) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *LocalModuleSource) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -4186,6 +4972,39 @@ func (r *Module) Description(ctx context.Context) (string, error) { return response, q.Execute(ctx) } +// Enumerations served by this module. +func (r *Module) Enums(ctx context.Context) ([]TypeDef, error) { + q := r.query.Select("enums") + + q = q.Select("id") + + type enums struct { + Id TypeDefID + } + + convert := func(fields []enums) []TypeDef { + out := []TypeDef{} + + for i := range fields { + val := TypeDef{id: &fields[i].Id} + val.query = q.Root().Select("loadTypeDefFromID").Arg("id", fields[i].Id) + out = append(out, val) + } + + return out + } + var response []enums + + q = q.Bind(&response) + + err := q.Execute(ctx) + if err != nil { + return nil, err + } + + return convert(response), nil +} + // The generated files and directories made on top of the module source's context directory. func (r *Module) GeneratedContextDiff() *Directory { q := r.query.Select("generatedContextDiff") @@ -4237,7 +5056,7 @@ func (r *Module) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *Module) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -4366,16 +5185,13 @@ func (r *Module) SDK(ctx context.Context) (string, error) { // Serve a module's API in the current session. // // Note: this can only be called once per session. In the future, it could return a stream or service to remove the side effect. -func (r *Module) Serve(ctx context.Context) (Void, error) { +func (r *Module) Serve(ctx context.Context) error { if r.serve != nil { - return *r.serve, nil + return nil } q := r.query.Select("serve") - var response Void - - q = q.Bind(&response) - return response, q.Execute(ctx) + return q.Execute(ctx) } // The source for the module. @@ -4397,6 +5213,17 @@ func (r *Module) WithDescription(description string) *Module { } } +// This module plus the given Enum type and associated values +func (r *Module) WithEnum(enum *TypeDef) *Module { + assertNotNil("enum", enum) + q := r.query.Select("withEnum") + q = q.Arg("enum", enum) + + return &Module{ + query: q, + } +} + // This module plus the given Interface type and associated functions func (r *Module) WithInterface(iface *TypeDef) *Module { assertNotNil("iface", iface) @@ -4419,10 +5246,22 @@ func (r *Module) WithObject(object *TypeDef) *Module { } } +// ModuleWithSourceOpts contains options for Module.WithSource +type ModuleWithSourceOpts struct { + // The engine version to upgrade to. + EngineVersion string +} + // Retrieves the module with basic configuration loaded if present. -func (r *Module) WithSource(source *ModuleSource) *Module { +func (r *Module) WithSource(source *ModuleSource, opts ...ModuleWithSourceOpts) *Module { assertNotNil("source", source) q := r.query.Select("withSource") + for i := len(opts) - 1; i >= 0; i-- { + // `engineVersion` optional argument + if !querybuilder.IsZeroValue(opts[i].EngineVersion) { + q = q.Arg("engineVersion", opts[i].EngineVersion) + } + } q = q.Arg("source", source) return &Module{ @@ -4477,7 +5316,7 @@ func (r *ModuleDependency) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *ModuleDependency) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -4562,9 +5401,21 @@ func (r *ModuleSource) AsLocalSource() *LocalModuleSource { } } +// ModuleSourceAsModuleOpts contains options for ModuleSource.AsModule +type ModuleSourceAsModuleOpts struct { + // The engine version to upgrade to. + EngineVersion string +} + // Load the source as a module. If this is a local source, the parent directory must have been provided during module source creation -func (r *ModuleSource) AsModule() *Module { +func (r *ModuleSource) AsModule(opts ...ModuleSourceAsModuleOpts) *Module { q := r.query.Select("asModule") + for i := len(opts) - 1; i >= 0; i-- { + // `engineVersion` optional argument + if !querybuilder.IsZeroValue(opts[i].EngineVersion) { + q = q.Arg("engineVersion", opts[i].EngineVersion) + } + } return &Module{ query: q, @@ -4682,7 +5533,7 @@ func (r *ModuleSource) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *ModuleSource) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -4761,6 +5612,28 @@ func (r *ModuleSource) ResolveDependency(dep *ModuleSource) *ModuleSource { } } +// ModuleSourceResolveDirectoryFromCallerOpts contains options for ModuleSource.ResolveDirectoryFromCaller +type ModuleSourceResolveDirectoryFromCallerOpts struct { + // If set, the name of the view to apply to the path. + ViewName string +} + +// Load a directory from the caller optionally with a given view applied. +func (r *ModuleSource) ResolveDirectoryFromCaller(path string, opts ...ModuleSourceResolveDirectoryFromCallerOpts) *Directory { + q := r.query.Select("resolveDirectoryFromCaller") + for i := len(opts) - 1; i >= 0; i-- { + // `viewName` optional argument + if !querybuilder.IsZeroValue(opts[i].ViewName) { + q = q.Arg("viewName", opts[i].ViewName) + } + } + q = q.Arg("path", path) + + return &Directory{ + query: q, + } +} + // Load the source from its path on the caller's filesystem, including only needed+configured files and directories. Only valid for local sources. func (r *ModuleSource) ResolveFromCaller() *ModuleSource { q := r.query.Select("resolveFromCaller") @@ -4796,6 +5669,49 @@ func (r *ModuleSource) SourceSubpath(ctx context.Context) (string, error) { return response, q.Execute(ctx) } +// Retrieve a named view defined for this module source. +func (r *ModuleSource) View(name string) *ModuleSourceView { + q := r.query.Select("view") + q = q.Arg("name", name) + + return &ModuleSourceView{ + query: q, + } +} + +// The named views defined for this module source, which are sets of directory filters that can be applied to directory arguments provided to functions. +func (r *ModuleSource) Views(ctx context.Context) ([]ModuleSourceView, error) { + q := r.query.Select("views") + + q = q.Select("id") + + type views struct { + Id ModuleSourceViewID + } + + convert := func(fields []views) []ModuleSourceView { + out := []ModuleSourceView{} + + for i := range fields { + val := ModuleSourceView{id: &fields[i].Id} + val.query = q.Root().Select("loadModuleSourceViewFromID").Arg("id", fields[i].Id) + out = append(out, val) + } + + return out + } + var response []views + + q = q.Bind(&response) + + err := q.Execute(ctx) + if err != nil { + return nil, err + } + + return convert(response), nil +} + // Update the module source with a new context directory. Only valid for local sources. func (r *ModuleSource) WithContextDirectory(dir *Directory) *ModuleSource { assertNotNil("dir", dir) @@ -4847,6 +5763,103 @@ func (r *ModuleSource) WithSourceSubpath(path string) *ModuleSource { } } +// Update the module source with a new named view. +func (r *ModuleSource) WithView(name string, patterns []string) *ModuleSource { + q := r.query.Select("withView") + q = q.Arg("name", name) + q = q.Arg("patterns", patterns) + + return &ModuleSource{ + query: q, + } +} + +// A named set of path filters that can be applied to directory arguments provided to functions. +type ModuleSourceView struct { + query *querybuilder.Selection + + id *ModuleSourceViewID + name *string +} + +func (r *ModuleSourceView) WithGraphQLQuery(q *querybuilder.Selection) *ModuleSourceView { + return &ModuleSourceView{ + query: q, + } +} + +// A unique identifier for this ModuleSourceView. +func (r *ModuleSourceView) ID(ctx context.Context) (ModuleSourceViewID, error) { + if r.id != nil { + return *r.id, nil + } + q := r.query.Select("id") + + var response ModuleSourceViewID + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// XXX_GraphQLType is an internal function. It returns the native GraphQL type name +func (r *ModuleSourceView) XXX_GraphQLType() string { + return "ModuleSourceView" +} + +// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object +func (r *ModuleSourceView) XXX_GraphQLIDType() string { + return "ModuleSourceViewID" +} + +// XXX_GraphQLID is an internal function. It returns the underlying type ID +func (r *ModuleSourceView) XXX_GraphQLID(ctx context.Context) (string, error) { + id, err := r.ID(ctx) + if err != nil { + return "", err + } + return string(id), nil +} + +func (r *ModuleSourceView) MarshalJSON() ([]byte, error) { + id, err := r.ID(marshalCtx) + if err != nil { + return nil, err + } + return json.Marshal(id) +} +func (r *ModuleSourceView) UnmarshalJSON(bs []byte) error { + var id string + err := json.Unmarshal(bs, &id) + if err != nil { + return err + } + *r = *dag.LoadModuleSourceViewFromID(ModuleSourceViewID(id)) + return nil +} + +// The name of the view +func (r *ModuleSourceView) Name(ctx context.Context) (string, error) { + if r.name != nil { + return *r.name, nil + } + q := r.query.Select("name") + + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// The patterns of the view used to filter paths +func (r *ModuleSourceView) Patterns(ctx context.Context) ([]string, error) { + q := r.query.Select("patterns") + + var response []string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + // A definition of a custom object defined in a Module. type ObjectTypeDef struct { query *querybuilder.Selection @@ -4984,7 +5997,7 @@ func (r *ObjectTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *ObjectTypeDef) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -5102,7 +6115,7 @@ func (r *Port) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *Port) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -5187,27 +6200,14 @@ func (r *Client) BuiltinContainer(digest string) *Container { func (r *Client) CacheVolume(key string) *CacheVolume { q := r.query.Select("cacheVolume") q = q.Arg("key", key) - - return &CacheVolume{ - query: q, - } -} - -// Checks if the current Dagger Engine is compatible with an SDK's required version. -func (r *Client) CheckVersionCompatibility(ctx context.Context, version string) (bool, error) { - q := r.query.Select("checkVersionCompatibility") - q = q.Arg("version", version) - - var response bool - - q = q.Bind(&response) - return response, q.Execute(ctx) + + return &CacheVolume{ + query: q, + } } // ContainerOpts contains options for Client.Container type ContainerOpts struct { - // DEPRECATED: Use `loadContainerFromID` instead. - ID ContainerID // Platform to initialize the container with. Platform Platform } @@ -5218,10 +6218,6 @@ type ContainerOpts struct { func (r *Client) Container(opts ...ContainerOpts) *Container { q := r.query.Select("container") for i := len(opts) - 1; i >= 0; i-- { - // `id` optional argument - if !querybuilder.IsZeroValue(opts[i].ID) { - q = q.Arg("id", opts[i].ID) - } // `platform` optional argument if !querybuilder.IsZeroValue(opts[i].Platform) { q = q.Arg("platform", opts[i].Platform) @@ -5296,37 +6292,15 @@ func (r *Client) DefaultPlatform(ctx context.Context) (Platform, error) { return response, q.Execute(ctx) } -// DirectoryOpts contains options for Client.Directory -type DirectoryOpts struct { - // DEPRECATED: Use `loadDirectoryFromID` isntead. - ID DirectoryID -} - // Creates an empty directory. -func (r *Client) Directory(opts ...DirectoryOpts) *Directory { +func (r *Client) Directory() *Directory { q := r.query.Select("directory") - for i := len(opts) - 1; i >= 0; i-- { - // `id` optional argument - if !querybuilder.IsZeroValue(opts[i].ID) { - q = q.Arg("id", opts[i].ID) - } - } return &Directory{ query: q, } } -// Deprecated: Use LoadFileFromID instead. -func (r *Client) File(id FileID) *File { - q := r.query.Select("file") - q = q.Arg("id", id) - - return &File{ - query: q, - } -} - // Creates a function. func (r *Client) Function(name string, returnType *TypeDef) *Function { assertNotNil("returnType", returnType) @@ -5442,6 +6416,36 @@ func (r *Client) LoadCurrentModuleFromID(id CurrentModuleID) *CurrentModule { } } +// Load a DaggerEngineCacheEntry from its ID. +func (r *Client) LoadDaggerEngineCacheEntryFromID(id DaggerEngineCacheEntryID) *DaggerEngineCacheEntry { + q := r.query.Select("loadDaggerEngineCacheEntryFromID") + q = q.Arg("id", id) + + return &DaggerEngineCacheEntry{ + query: q, + } +} + +// Load a DaggerEngineCacheEntrySet from its ID. +func (r *Client) LoadDaggerEngineCacheEntrySetFromID(id DaggerEngineCacheEntrySetID) *DaggerEngineCacheEntrySet { + q := r.query.Select("loadDaggerEngineCacheEntrySetFromID") + q = q.Arg("id", id) + + return &DaggerEngineCacheEntrySet{ + query: q, + } +} + +// Load a DaggerEngineCache from its ID. +func (r *Client) LoadDaggerEngineCacheFromID(id DaggerEngineCacheID) *DaggerEngineCache { + q := r.query.Select("loadDaggerEngineCacheFromID") + q = q.Arg("id", id) + + return &DaggerEngineCache{ + query: q, + } +} + // Load a Directory from its ID. func (r *Client) LoadDirectoryFromID(id DirectoryID) *Directory { q := r.query.Select("loadDirectoryFromID") @@ -5452,6 +6456,26 @@ func (r *Client) LoadDirectoryFromID(id DirectoryID) *Directory { } } +// Load a EnumTypeDef from its ID. +func (r *Client) LoadEnumTypeDefFromID(id EnumTypeDefID) *EnumTypeDef { + q := r.query.Select("loadEnumTypeDefFromID") + q = q.Arg("id", id) + + return &EnumTypeDef{ + query: q, + } +} + +// Load a EnumValueTypeDef from its ID. +func (r *Client) LoadEnumValueTypeDefFromID(id EnumValueTypeDefID) *EnumValueTypeDef { + q := r.query.Select("loadEnumValueTypeDefFromID") + q = q.Arg("id", id) + + return &EnumValueTypeDef{ + query: q, + } +} + // Load a EnvVariable from its ID. func (r *Client) LoadEnvVariableFromID(id EnvVariableID) *EnvVariable { q := r.query.Select("loadEnvVariableFromID") @@ -5642,6 +6666,16 @@ func (r *Client) LoadModuleSourceFromID(id ModuleSourceID) *ModuleSource { } } +// Load a ModuleSourceView from its ID. +func (r *Client) LoadModuleSourceViewFromID(id ModuleSourceViewID) *ModuleSourceView { + q := r.query.Select("loadModuleSourceViewFromID") + q = q.Arg("id", id) + + return &ModuleSourceView{ + query: q, + } +} + // Load a ObjectTypeDef from its ID. func (r *Client) LoadObjectTypeDefFromID(id ObjectTypeDefID) *ObjectTypeDef { q := r.query.Select("loadObjectTypeDefFromID") @@ -5662,6 +6696,16 @@ func (r *Client) LoadPortFromID(id PortID) *Port { } } +// Load a ScalarTypeDef from its ID. +func (r *Client) LoadScalarTypeDefFromID(id ScalarTypeDefID) *ScalarTypeDef { + q := r.query.Select("loadScalarTypeDefFromID") + q = q.Arg("id", id) + + return &ScalarTypeDef{ + query: q, + } +} + // Load a Secret from its ID. func (r *Client) LoadSecretFromID(id SecretID) *Secret { q := r.query.Select("loadSecretFromID") @@ -5829,32 +6873,135 @@ func (r *Client) SetSecret(name string, plaintext string) *Secret { } } -// Loads a socket by its ID. -// -// Deprecated: Use LoadSocketFromID instead. -func (r *Client) Socket(id SocketID) *Socket { - q := r.query.Select("socket") - q = q.Arg("id", id) +// Create a new TypeDef. +func (r *Client) TypeDef() *TypeDef { + q := r.query.Select("typeDef") - return &Socket{ + return &TypeDef{ query: q, } } -// Create a new TypeDef. -func (r *Client) TypeDef() *TypeDef { - q := r.query.Select("typeDef") +// Get the current Dagger Engine version. +func (r *Client) Version(ctx context.Context) (string, error) { + q := r.query.Select("version") - return &TypeDef{ + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// A definition of a custom scalar defined in a Module. +type ScalarTypeDef struct { + query *querybuilder.Selection + + description *string + id *ScalarTypeDefID + name *string + sourceModuleName *string +} + +func (r *ScalarTypeDef) WithGraphQLQuery(q *querybuilder.Selection) *ScalarTypeDef { + return &ScalarTypeDef{ query: q, } } +// A doc string for the scalar, if any. +func (r *ScalarTypeDef) Description(ctx context.Context) (string, error) { + if r.description != nil { + return *r.description, nil + } + q := r.query.Select("description") + + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// A unique identifier for this ScalarTypeDef. +func (r *ScalarTypeDef) ID(ctx context.Context) (ScalarTypeDefID, error) { + if r.id != nil { + return *r.id, nil + } + q := r.query.Select("id") + + var response ScalarTypeDefID + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// XXX_GraphQLType is an internal function. It returns the native GraphQL type name +func (r *ScalarTypeDef) XXX_GraphQLType() string { + return "ScalarTypeDef" +} + +// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object +func (r *ScalarTypeDef) XXX_GraphQLIDType() string { + return "ScalarTypeDefID" +} + +// XXX_GraphQLID is an internal function. It returns the underlying type ID +func (r *ScalarTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) { + id, err := r.ID(ctx) + if err != nil { + return "", err + } + return string(id), nil +} + +func (r *ScalarTypeDef) MarshalJSON() ([]byte, error) { + id, err := r.ID(marshalCtx) + if err != nil { + return nil, err + } + return json.Marshal(id) +} +func (r *ScalarTypeDef) UnmarshalJSON(bs []byte) error { + var id string + err := json.Unmarshal(bs, &id) + if err != nil { + return err + } + *r = *dag.LoadScalarTypeDefFromID(ScalarTypeDefID(id)) + return nil +} + +// The name of the scalar. +func (r *ScalarTypeDef) Name(ctx context.Context) (string, error) { + if r.name != nil { + return *r.name, nil + } + q := r.query.Select("name") + + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + +// If this ScalarTypeDef is associated with a Module, the name of the module. Unset otherwise. +func (r *ScalarTypeDef) SourceModuleName(ctx context.Context) (string, error) { + if r.sourceModuleName != nil { + return *r.sourceModuleName, nil + } + q := r.query.Select("sourceModuleName") + + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + // A reference to a secret value, which can be handled more safely than the value itself. type Secret struct { query *querybuilder.Selection id *SecretID + name *string plaintext *string } @@ -5897,7 +7044,7 @@ func (r *Secret) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *Secret) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -5913,6 +7060,19 @@ func (r *Secret) UnmarshalJSON(bs []byte) error { return nil } +// The name of this secret. +func (r *Secret) Name(ctx context.Context) (string, error) { + if r.name != nil { + return *r.name, nil + } + q := r.query.Select("name") + + var response string + + q = q.Bind(&response) + return response, q.Execute(ctx) +} + // The value of this secret. func (r *Secret) Plaintext(ctx context.Context) (string, error) { if r.plaintext != nil { @@ -6025,7 +7185,7 @@ func (r *Service) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *Service) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -6080,7 +7240,13 @@ func (r *Service) Ports(ctx context.Context) ([]Port, error) { func (r *Service) Start(ctx context.Context) (*Service, error) { q := r.query.Select("start") - return r, q.Execute(ctx) + var id ServiceID + if err := q.Bind(&id).Execute(ctx); err != nil { + return nil, err + } + return &Service{ + query: q.Root().Select("loadServiceFromID").Arg("id", id), + }, nil } // ServiceStopOpts contains options for Service.Stop @@ -6099,7 +7265,13 @@ func (r *Service) Stop(ctx context.Context, opts ...ServiceStopOpts) (*Service, } } - return r, q.Execute(ctx) + var id ServiceID + if err := q.Bind(&id).Execute(ctx); err != nil { + return nil, err + } + return &Service{ + query: q.Root().Select("loadServiceFromID").Arg("id", id), + }, nil } // ServiceUpOpts contains options for Service.Up @@ -6113,9 +7285,9 @@ type ServiceUpOpts struct { } // Creates a tunnel that forwards traffic from the caller's network to this service. -func (r *Service) Up(ctx context.Context, opts ...ServiceUpOpts) (Void, error) { +func (r *Service) Up(ctx context.Context, opts ...ServiceUpOpts) error { if r.up != nil { - return *r.up, nil + return nil } q := r.query.Select("up") for i := len(opts) - 1; i >= 0; i-- { @@ -6129,10 +7301,7 @@ func (r *Service) Up(ctx context.Context, opts ...ServiceUpOpts) (Void, error) { } } - var response Void - - q = q.Bind(&response) - return response, q.Execute(ctx) + return q.Execute(ctx) } // A Unix or TCP/IP socket that can be mounted into a container. @@ -6181,7 +7350,7 @@ func (r *Socket) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *Socket) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -6201,8 +7370,8 @@ func (r *Socket) UnmarshalJSON(bs []byte) error { type Terminal struct { query *querybuilder.Selection - id *TerminalID - websocketEndpoint *string + id *TerminalID + sync *TerminalID } func (r *Terminal) WithGraphQLQuery(q *querybuilder.Selection) *Terminal { @@ -6244,7 +7413,7 @@ func (r *Terminal) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *Terminal) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -6260,17 +7429,19 @@ func (r *Terminal) UnmarshalJSON(bs []byte) error { return nil } -// An http endpoint at which this terminal can be connected to over a websocket. -func (r *Terminal) WebsocketEndpoint(ctx context.Context) (string, error) { - if r.websocketEndpoint != nil { - return *r.websocketEndpoint, nil - } - q := r.query.Select("websocketEndpoint") - - var response string +// Forces evaluation of the pipeline in the engine. +// +// It doesn't run the default command if no exec has been set. +func (r *Terminal) Sync(ctx context.Context) (*Terminal, error) { + q := r.query.Select("sync") - q = q.Bind(&response) - return response, q.Execute(ctx) + var id TerminalID + if err := q.Bind(&id).Execute(ctx); err != nil { + return nil, err + } + return &Terminal{ + query: q.Root().Select("loadTerminalFromID").Arg("id", id), + }, nil } // A definition of a parameter or return type in a Module. @@ -6296,6 +7467,15 @@ func (r *TypeDef) WithGraphQLQuery(q *querybuilder.Selection) *TypeDef { } } +// If kind is ENUM, the enum-specific type definition. If kind is not ENUM, this will be null. +func (r *TypeDef) AsEnum() *EnumTypeDef { + q := r.query.Select("asEnum") + + return &EnumTypeDef{ + query: q, + } +} + // If kind is INPUT, the input-specific type definition. If kind is not INPUT, this will be null. func (r *TypeDef) AsInput() *InputTypeDef { q := r.query.Select("asInput") @@ -6332,6 +7512,15 @@ func (r *TypeDef) AsObject() *ObjectTypeDef { } } +// If kind is SCALAR, the scalar-specific type definition. If kind is not SCALAR, this will be null. +func (r *TypeDef) AsScalar() *ScalarTypeDef { + q := r.query.Select("asScalar") + + return &ScalarTypeDef{ + query: q, + } +} + // A unique identifier for this TypeDef. func (r *TypeDef) ID(ctx context.Context) (TypeDefID, error) { if r.id != nil { @@ -6365,7 +7554,7 @@ func (r *TypeDef) XXX_GraphQLID(ctx context.Context) (string, error) { } func (r *TypeDef) MarshalJSON() ([]byte, error) { - id, err := r.ID(context.Background()) + id, err := r.ID(marshalCtx) if err != nil { return nil, err } @@ -6418,6 +7607,52 @@ func (r *TypeDef) WithConstructor(function *Function) *TypeDef { } } +// TypeDefWithEnumOpts contains options for TypeDef.WithEnum +type TypeDefWithEnumOpts struct { + // A doc string for the enum, if any + Description string +} + +// Returns a TypeDef of kind Enum with the provided name. +// +// Note that an enum's values may be omitted if the intent is only to refer to an enum. This is how functions are able to return their own, or any other circular reference. +func (r *TypeDef) WithEnum(name string, opts ...TypeDefWithEnumOpts) *TypeDef { + q := r.query.Select("withEnum") + for i := len(opts) - 1; i >= 0; i-- { + // `description` optional argument + if !querybuilder.IsZeroValue(opts[i].Description) { + q = q.Arg("description", opts[i].Description) + } + } + q = q.Arg("name", name) + + return &TypeDef{ + query: q, + } +} + +// TypeDefWithEnumValueOpts contains options for TypeDef.WithEnumValue +type TypeDefWithEnumValueOpts struct { + // A doc string for the value, if any + Description string +} + +// Adds a static value for an Enum TypeDef, failing if the type is not an enum. +func (r *TypeDef) WithEnumValue(value string, opts ...TypeDefWithEnumValueOpts) *TypeDef { + q := r.query.Select("withEnumValue") + for i := len(opts) - 1; i >= 0; i-- { + // `description` optional argument + if !querybuilder.IsZeroValue(opts[i].Description) { + q = q.Arg("description", opts[i].Description) + } + } + q = q.Arg("value", value) + + return &TypeDef{ + query: q, + } +} + // TypeDefWithFieldOpts contains options for TypeDef.WithField type TypeDefWithFieldOpts struct { // A doc string for the field, if any @@ -6528,6 +7763,27 @@ func (r *TypeDef) WithOptional(optional bool) *TypeDef { } } +// TypeDefWithScalarOpts contains options for TypeDef.WithScalar +type TypeDefWithScalarOpts struct { + Description string +} + +// Returns a TypeDef of kind Scalar with the provided name. +func (r *TypeDef) WithScalar(name string, opts ...TypeDefWithScalarOpts) *TypeDef { + q := r.query.Select("withScalar") + for i := len(opts) - 1; i >= 0; i-- { + // `description` optional argument + if !querybuilder.IsZeroValue(opts[i].Description) { + q = q.Arg("description", opts[i].Description) + } + } + q = q.Arg("name", name) + + return &TypeDef{ + query: q, + } +} + type CacheSharingMode string func (CacheSharingMode) IsEnum() {} @@ -6595,6 +7851,11 @@ const ( // A boolean value. BooleanKind TypeDefKind = "BOOLEAN_KIND" + // A GraphQL enum type and its values + // + // Always paired with an EnumTypeDef. + EnumKind TypeDefKind = "ENUM_KIND" + // A graphql input type, used only when representing the core API via TypeDefs. InputKind TypeDefKind = "INPUT_KIND" @@ -6616,6 +7877,9 @@ const ( // Always paired with an ObjectTypeDef. ObjectKind TypeDefKind = "OBJECT_KIND" + // A scalar value of any basic kind. + ScalarKind TypeDefKind = "SCALAR_KIND" + // A string value. StringKind TypeDefKind = "STRING_KIND" @@ -6674,6 +7938,13 @@ func getClientParams() (graphql.Client, *querybuilder.Selection) { httpClient := &http.Client{ Transport: roundTripperFunc(func(r *http.Request) (*http.Response, error) { r.SetBasicAuth(sessionToken, "") + + // detect $TRACEPARENT set by 'dagger run' + r = r.WithContext(fallbackSpanContext(r.Context())) + + // propagate span context via headers (i.e. for Dagger-in-Dagger) + otel.GetTextMapPropagator().Inject(r.Context(), propagation.HeaderCarrier(r.Header)) + return dialTransport.RoundTrip(r) }), } @@ -6682,6 +7953,13 @@ func getClientParams() (graphql.Client, *querybuilder.Selection) { return gqlClient, querybuilder.Query() } +func fallbackSpanContext(ctx context.Context) context.Context { + if trace.SpanContextFromContext(ctx).IsValid() { + return ctx + } + return otel.GetTextMapPropagator().Extract(ctx, telemetry.NewEnvCarrier(true)) +} + // TODO: pollutes namespace, move to non internal package in dagger.io/dagger type roundTripperFunc func(*http.Request) (*http.Response, error) diff --git a/build/ci/internal/querybuilder/querybuilder.go b/build/ci/internal/querybuilder/querybuilder.go index 64a32e0..f57b134 100644 --- a/build/ci/internal/querybuilder/querybuilder.go +++ b/build/ci/internal/querybuilder/querybuilder.go @@ -20,7 +20,7 @@ type Selection struct { name string alias string args map[string]*argument - bind interface{} + bind any prev *Selection @@ -52,8 +52,8 @@ func (s *Selection) SelectWithAlias(alias, name string) *Selection { return sel } -func (s *Selection) Select(name string) *Selection { - return s.SelectWithAlias("", name) +func (s *Selection) Select(name ...string) *Selection { + return s.SelectWithAlias("", strings.Join(name, " ")) } func (s *Selection) Arg(name string, value any) *Selection { @@ -70,6 +70,13 @@ func (s *Selection) Arg(name string, value any) *Selection { func (s *Selection) Bind(v interface{}) *Selection { sel := *s + // When there's multiple fields, bind the parent. + if strings.Contains(sel.name, " ") { + prev := *s.prev + prev.bind = v + sel.prev = &prev + return &sel + } sel.bind = v return &sel } @@ -97,8 +104,17 @@ func (s *Selection) Build(ctx context.Context) (string, error) { b.WriteString("query") path := s.path() + multiple := false for _, sel := range path { + if multiple { + return "", fmt.Errorf("sibling selections not end of chain") + } + + if strings.Contains(sel.name, " ") { + multiple = true + } + b.WriteRune('{') if sel.alias != "" { @@ -128,7 +144,7 @@ func (s *Selection) Build(ctx context.Context) (string, error) { return b.String(), nil } -func (s *Selection) unpack(data interface{}) error { +func (s *Selection) unpack(data any) error { for _, i := range s.path() { k := i.name if i.alias != "" { @@ -137,12 +153,10 @@ func (s *Selection) unpack(data interface{}) error { // Try to assert type of the value switch f := data.(type) { - case map[string]interface{}: + case map[string]any: data = f[k] - case []interface{}: - data = f default: - fmt.Printf("type not found %s\n", f) + data = f } if i.bind != nil { @@ -150,7 +164,9 @@ func (s *Selection) unpack(data interface{}) error { if err != nil { return err } - json.Unmarshal(marshalled, s.bind) + if err := json.Unmarshal(marshalled, i.bind); err != nil { + return err + } } } diff --git a/build/ci/publish.go b/build/ci/publish.go deleted file mode 100644 index df63c64..0000000 --- a/build/ci/publish.go +++ /dev/null @@ -1,81 +0,0 @@ -package main - -import ( - "context" - "dagger/asyncapi-codegen-ci/internal/dagger" - - "github.com/lerenn/asyncapi-codegen/pkg/utils/git" -) - -const ( - // dockerImageName is the name of the docker image. - dockerImageName = "lerenn/asyncapi-codegen" -) - -var ( - // platforms represents the different OS/Arch platform wanted for docker hub. - platforms = []runnerType{ - {OS: "linux", Arch: "386", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, - {OS: "linux", Arch: "amd64", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, - {OS: "linux", Arch: "arm/v6", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, - {OS: "linux", Arch: "arm/v7", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, - {OS: "linux", Arch: "arm64/v8", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, - {OS: "linux", Arch: "mips64le", BuildBaseImage: "golang", TargetBaseImage: "debian:12"}, - {OS: "linux", Arch: "ppc64le", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, - {OS: "linux", Arch: "s390x", BuildBaseImage: "golang:alpine", TargetBaseImage: "alpine"}, - } -) - -// Publish should publish tag on git repository and docker image(s) on Docker Hub -// Note: if this is not 'main' branch, then it will just push docker image with -// git tag. -func Publish(ctx context.Context, dir *Directory, tag string) error { - if err := publishDocker(ctx, dir, tag); err != nil { - return err - } - - return nil -} - -func publishDocker(ctx context.Context, dir *dagger.Directory, tag string) error { - // Get images for each platform - platformVariants := make([]*dagger.Container, len(platforms)) - for i, p := range platforms { - platformVariants[i] = runnerFromDockerfile(dir, p) - } - - // Set publication options from images - publishOpts := dagger.ContainerPublishOpts{ - PlatformVariants: platformVariants, - } - - // Get last git commit hash - hash, err := git.GetLastCommitHash(".") - if err != nil { - return err - } - - // Publish with hash - if _, err := dag.Container().Publish(ctx, dockerImageName+":"+hash, publishOpts); err != nil { - return err - } - - // Stop here if this not main branch - if name, err := git.ActualBranchName("."); err != nil { - return err - } else if name != "main" { - return nil - } - - // Publish with tag passed in argument - if _, err := dag.Container().Publish(ctx, dockerImageName+":"+tag, publishOpts); err != nil { - return err - } - - // Publish with "latest" as tag - if _, err := dag.Container().Publish(ctx, dockerImageName+":latest", publishOpts); err != nil { - return err - } - - return nil -} diff --git a/build/ci/runner.go b/build/ci/runner.go index 728f5ef..37d2c9e 100644 --- a/build/ci/runner.go +++ b/build/ci/runner.go @@ -14,7 +14,7 @@ type runnerType struct { } // runnerFromDockerfile returns a dagger container based on the repository Dockerfile. -func runnerFromDockerfile(dir *Directory, rt runnerType) *dagger.Container { +func runnerFromDockerfile(dir *dagger.Directory, rt runnerType) *dagger.Container { // Get running OS, if that's an OS unsupported by Docker, replace by Linux os := runtime.GOOS if os == "darwin" { diff --git a/build/ci/utils.go b/build/ci/utils.go index 9fc45c4..021ed0c 100644 --- a/build/ci/utils.go +++ b/build/ci/utils.go @@ -6,7 +6,7 @@ import ( "sync" ) -func sourceCodeAndGoCache(dir *Directory) func(r *dagger.Container) *dagger.Container { +func sourceCodeAndGoCache(dir *dagger.Directory) func(r *dagger.Container) *dagger.Container { sourceCodeMountPath := "/go/src/github.com/lerenn/asyncapi-codegen" return func(r *dagger.Container) *dagger.Container { return r. @@ -17,7 +17,7 @@ func sourceCodeAndGoCache(dir *Directory) func(r *dagger.Container) *dagger.Cont } } -func directoriesAtSublevel(ctx context.Context, dir *Directory, sublevel int, basePath string) ([]string, error) { +func directoriesAtSublevel(ctx context.Context, dir *dagger.Directory, sublevel int, basePath string) ([]string, error) { paths := make([]string, 0) entries, err := dir.Entries(ctx) @@ -57,7 +57,7 @@ func directoriesAtSublevel(ctx context.Context, dir *Directory, sublevel int, ba return paths, nil } -func isDir(ctx context.Context, parentDir *Directory, path string) (bool, error) { +func isDir(ctx context.Context, parentDir *dagger.Directory, path string) (bool, error) { _, isNotDirErr := parentDir.Directory(path).Sync(ctx) if isNotDirErr == nil { // If it is a directory do not keep further checking diff --git a/dagger.json b/dagger.json index 8510289..2bacfe9 100644 --- a/dagger.json +++ b/dagger.json @@ -2,5 +2,5 @@ "name": "asyncapi-codegen-ci", "sdk": "go", "source": "build/ci", - "engineVersion": "v0.10.2" + "engineVersion": "v0.12.1" } diff --git a/go.mod b/go.mod index d3abd33..7440f2a 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( cloud.google.com/go v0.114.0 github.com/fatih/color v1.15.0 github.com/ghodss/yaml v1.0.0 - github.com/go-git/go-git/v5 v5.11.0 github.com/go-playground/validator/v10 v10.20.0 github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.6.0 @@ -22,35 +21,22 @@ require ( ) require ( - dario.cat/mergo v1.0.0 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect - github.com/cloudflare/circl v1.3.3 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/emirpasic/gods v1.18.1 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/klauspost/compress v1.17.0 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/nats-io/nkeys v0.4.6 // indirect github.com/nats-io/nuid v1.0.1 // indirect github.com/pierrec/lz4/v4 v4.1.17 // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/sergi/go-diff v1.3.1 // indirect - github.com/skeema/knownhosts v1.2.1 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect @@ -59,7 +45,7 @@ require ( golang.org/x/net v0.25.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/text v0.15.0 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 4fb9567..ded5910 100644 --- a/go.sum +++ b/go.sum @@ -1,45 +1,16 @@ cloud.google.com/go v0.114.0 h1:OIPFAdfrFDFO2ve2U7r/H5SwSbBzEdrBdE7xkgwc+kY= cloud.google.com/go v0.114.0/go.mod h1:ZV9La5YYxctro1HTPug5lXH/GefROyW8PPD4T8n9J8E= -dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= -dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= -github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= -github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= -github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= -github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= -github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= -github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= -github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= -github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= -github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= -github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= @@ -48,8 +19,6 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -58,14 +27,10 @@ github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSAS github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= -github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -87,41 +52,28 @@ github.com/nats-io/nkeys v0.4.6 h1:IzVe95ru2CT6ta874rt9saQRkWfe2nFj1NtvYSLqMzY= github.com/nats-io/nkeys v0.4.6/go.mod h1:4DxZNzenSVd1cYQoAa8948QY3QDjrHfcfVADymtkpts= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc= github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= -github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/segmentio/kafka-go v0.4.42 h1:qffhBZCz4WcWyNuHEclHjIMLs2slp6mZO8px+5W5tfU= github.com/segmentio/kafka-go v0.4.42/go.mod h1:d0g15xPMqoUookug0OU75DhGZxXwCFxSLeJ4uphwJzg= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= -github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= -github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= @@ -131,77 +83,48 @@ github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gi github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= -golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/utils/git/git.go b/pkg/utils/git/git.go deleted file mode 100644 index a4e75b1..0000000 --- a/pkg/utils/git/git.go +++ /dev/null @@ -1,94 +0,0 @@ -package git - -import ( - "github.com/go-git/go-git/v5" - "github.com/go-git/go-git/v5/config" - "github.com/go-git/go-git/v5/plumbing/object" -) - -// TagCommit tags the last commit on the actual branch. -func TagCommit(path, tag string) error { - // Open git repository - repo, err := git.PlainOpen(path) - if err != nil { - return err - } - - // Get last commit - commit, err := lastCommit(path) - if err != nil { - return err - } - - // Create tag - _, err = repo.CreateTag(tag, commit.Hash, nil) - return err -} - -// GetLastCommitHash returns the hash of the last commit on the actual branch. -func GetLastCommitHash(path string) (string, error) { - commit, err := lastCommit(path) - if err != nil { - return "", err - } - - return commit.Hash.String(), nil -} - -func lastCommit(path string) (*object.Commit, error) { - // Open git repository - repo, err := git.PlainOpen(path) - if err != nil { - return nil, err - } - - // Get commit iterator - commitIter, err := repo.CommitObjects() - if err != nil { - return nil, err - } - - var commit = &object.Commit{} - if err := commitIter.ForEach(func(c *object.Commit) error { - if c.Author.When.After(commit.Author.When) { - commit = c - } - return nil - }); err != nil { - return nil, err - } - - return commit, nil -} - -// ActualBranchName returns the name of the actual git branch. -func ActualBranchName(path string) (string, error) { - // Open git repository - repo, err := git.PlainOpen(path) - if err != nil { - return "", err - } - - ref, err := repo.Head() - if err != nil { - return "", err - } - - return ref.Name().Short(), nil -} - -// PushTags will execute a git push with tags. -func PushTags(path, tag string) error { - // Open git repository - repo, err := git.PlainOpen(path) - if err != nil { - return err - } - - return repo.Push(&git.PushOptions{ - RemoteName: "origin", - RefSpecs: []config.RefSpec{ - config.RefSpec("+refs/tags/" + tag + ":refs/tags/" + tag), - }, - }) -} diff --git a/tools/make/dagger.mk b/tools/make/dagger.mk index 0539ca7..431d59e 100644 --- a/tools/make/dagger.mk +++ b/tools/make/dagger.mk @@ -1,27 +1,29 @@ +DAGGER_CMD := dagger -vvv + .PHONY: dagger/check dagger/check: ## Run all the checks before commit on Dagger - @dagger call check --dir . + @$(DAGGER_CMD) call check --src-dir . .PHONY: dagger/examples dagger/examples: ## Run all the examples on Dagger - @dagger call examples --dir . + @$(DAGGER_CMD) call examples --src-dir . .PHONY: dagger/check-generation dagger/check-generation: ## Check files are generated on Dagger - @dagger call check-generation --dir . + @$(DAGGER_CMD) call check-generation --src-dir . .PHONY: dagger/lint dagger/lint: ## Lint the code on Dagger - @dagger call lint --dir . + @$(DAGGER_CMD) call lint --src-dir . .PHONY: dagger/publish dagger/publish: ## Publish with tag on git, docker hub, etc. on Dagger - @dagger call publish --dir . --tag ${TAG} + @$(DAGGER_CMD) call publish --src-dir . --ssh-dir=~/.ssh .PHONY: dagger/test dagger/test: ## Perform tests on Dagger - @dagger call tests --dir . + @$(DAGGER_CMD) call tests --src-dir . .PHONY: dagger/help dagger/help: ## Display Dagger module help message - @dagger functions \ No newline at end of file + @$(DAGGER_CMD) functions \ No newline at end of file From 68d6e6145057a00672d6980adb6adfa3638aaec3 Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 01:20:55 +0200 Subject: [PATCH 03/18] feat(toto): try to fix --- .github/workflows/ci.yaml | 4 +++- build/ci/cmd.go | 1 + build/ci/git.go | 13 +++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 38631ae..e697d24 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -77,6 +77,8 @@ jobs: publish: name: Publish asyncapi-codegen new version + permissions: + contents: write # needs: ["tests", "examples", "lint", "check-generation"] runs-on: ubuntu-latest timeout-minutes: 5 @@ -91,5 +93,5 @@ jobs: uses: dagger/dagger-for-github@v5 with: verb: call - args: publish --src-dir . --ssh-dir=~/.ssh + args: publish --src-dir . version: "0.11.0" \ No newline at end of file diff --git a/build/ci/cmd.go b/build/ci/cmd.go index 8e2efa7..62104e9 100644 --- a/build/ci/cmd.go +++ b/build/ci/cmd.go @@ -164,6 +164,7 @@ func (ci *AsyncapiCodegenCi) Tests( func (ci *AsyncapiCodegenCi) Publish( ctx context.Context, srcDir *dagger.Directory, + // +optional sshDir *dagger.Directory, ) error { gi := NewGit(srcDir, sshDir) diff --git a/build/ci/git.go b/build/ci/git.go index b86b16c..1e9a62e 100644 --- a/build/ci/git.go +++ b/build/ci/git.go @@ -22,11 +22,16 @@ type Git struct { } func NewGit(srcDir, sshDir *dagger.Directory) Git { + container := dag.Container(). + From("alpine/git"). + WithMountedDirectory("/git", srcDir) + + if sshDir != nil { + container = container.WithMountedDirectory("/root/.ssh", sshDir) + } + return Git{ - container: dag.Container(). - From("alpine/git"). - WithMountedDirectory("/git", srcDir). - WithMountedDirectory("/root/.ssh", sshDir), + container: container, } } From e65fed38cb8a1c4840c150b8c85abdb1372d5e55 Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 01:46:22 +0200 Subject: [PATCH 04/18] feat(test): test --- build/ci/dagger.gen.go | 2 +- build/ci/git.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/ci/dagger.gen.go b/build/ci/dagger.gen.go index c6407b0..9210d41 100644 --- a/build/ci/dagger.gen.go +++ b/build/ci/dagger.gen.go @@ -272,7 +272,7 @@ func invoke(ctx context.Context, parentJSON []byte, parentName string, fnName st dag.TypeDef().WithKind(dagger.VoidKind).WithOptional(true)). WithDescription("Publish tag on git repository and docker image(s) on Docker Hub\nNote: if this is not 'main' branch, then it will just push docker image with\ngit tag."). WithArg("srcDir", dag.TypeDef().WithObject("Directory")). - WithArg("sshDir", dag.TypeDef().WithObject("Directory")))), nil + WithArg("sshDir", dag.TypeDef().WithObject("Directory").WithOptional(true)))), nil default: return nil, fmt.Errorf("unknown object %s", parentName) } diff --git a/build/ci/git.go b/build/ci/git.go index 1e9a62e..a3b5ab6 100644 --- a/build/ci/git.go +++ b/build/ci/git.go @@ -42,7 +42,7 @@ func (g *Git) GetLastCommitShortSHA(ctx context.Context) (string, error) { } res, err := g.container. - WithExec([]string{"git", "rev-parse", "--short", "HEAD"}). + WithExec([]string{"rev-parse", "--short", "HEAD"}). Stdout(ctx) if err != nil { return "", err @@ -59,7 +59,7 @@ func (g *Git) GetLastCommitTitle(ctx context.Context) (string, error) { } res, err := g.container. - WithExec([]string{"git", "log", "-1", "--pretty=%B"}). + WithExec([]string{"log", "-1", "--pretty=%B"}). Stdout(ctx) if err != nil { return "", err @@ -76,7 +76,7 @@ func (g *Git) GetLastTag(ctx context.Context) (string, error) { } res, err := g.container. - WithExec([]string{"git", "describe", "--tags", "--abbrev=0"}). + WithExec([]string{"describe", "--tags", "--abbrev=0"}). Stdout(ctx) if err != nil { return "", err @@ -167,8 +167,8 @@ func (g *Git) PushNewSemVerIfNeeded(ctx context.Context) error { // Push new tag _, err = g.container. - WithExec([]string{"git", "tag", semver}). - WithExec([]string{"git", "push", "--tags"}). + WithExec([]string{"tag", semver}). + WithExec([]string{"push", "--tags"}). Stdout(ctx) return err } From e295ebde38d393c0633bac6ebf9bc0e47eef6068 Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:19:05 +0200 Subject: [PATCH 05/18] feat(aaa): restore git --- build/ci/git.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build/ci/git.go b/build/ci/git.go index a3b5ab6..1e9a62e 100644 --- a/build/ci/git.go +++ b/build/ci/git.go @@ -42,7 +42,7 @@ func (g *Git) GetLastCommitShortSHA(ctx context.Context) (string, error) { } res, err := g.container. - WithExec([]string{"rev-parse", "--short", "HEAD"}). + WithExec([]string{"git", "rev-parse", "--short", "HEAD"}). Stdout(ctx) if err != nil { return "", err @@ -59,7 +59,7 @@ func (g *Git) GetLastCommitTitle(ctx context.Context) (string, error) { } res, err := g.container. - WithExec([]string{"log", "-1", "--pretty=%B"}). + WithExec([]string{"git", "log", "-1", "--pretty=%B"}). Stdout(ctx) if err != nil { return "", err @@ -76,7 +76,7 @@ func (g *Git) GetLastTag(ctx context.Context) (string, error) { } res, err := g.container. - WithExec([]string{"describe", "--tags", "--abbrev=0"}). + WithExec([]string{"git", "describe", "--tags", "--abbrev=0"}). Stdout(ctx) if err != nil { return "", err @@ -167,8 +167,8 @@ func (g *Git) PushNewSemVerIfNeeded(ctx context.Context) error { // Push new tag _, err = g.container. - WithExec([]string{"tag", semver}). - WithExec([]string{"push", "--tags"}). + WithExec([]string{"git", "tag", semver}). + WithExec([]string{"git", "push", "--tags"}). Stdout(ctx) return err } From 60c3ca94facba6294f9b101bafd45217754296b4 Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:20:59 +0200 Subject: [PATCH 06/18] feat(b)= remove entrypoint --- build/ci/git.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/ci/git.go b/build/ci/git.go index 1e9a62e..e70674f 100644 --- a/build/ci/git.go +++ b/build/ci/git.go @@ -24,7 +24,8 @@ type Git struct { func NewGit(srcDir, sshDir *dagger.Directory) Git { container := dag.Container(). From("alpine/git"). - WithMountedDirectory("/git", srcDir) + WithMountedDirectory("/git", srcDir). + WithoutEntrypoint() if sshDir != nil { container = container.WithMountedDirectory("/root/.ssh", sshDir) From eb6c31495c78926613312d187d9d6343f0384dc4 Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:25:35 +0200 Subject: [PATCH 07/18] fix: add a workdir --- build/ci/git.go | 1 + 1 file changed, 1 insertion(+) diff --git a/build/ci/git.go b/build/ci/git.go index e70674f..65d3d6b 100644 --- a/build/ci/git.go +++ b/build/ci/git.go @@ -25,6 +25,7 @@ func NewGit(srcDir, sshDir *dagger.Directory) Git { container := dag.Container(). From("alpine/git"). WithMountedDirectory("/git", srcDir). + WithWorkdir("/git"). WithoutEntrypoint() if sshDir != nil { From e29687936fdf86685bfc357e15327eaaf4b427fe Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:27:38 +0200 Subject: [PATCH 08/18] fix: debug --- build/ci/git.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/ci/git.go b/build/ci/git.go index 65d3d6b..a0c7589 100644 --- a/build/ci/git.go +++ b/build/ci/git.go @@ -78,6 +78,8 @@ func (g *Git) GetLastTag(ctx context.Context) (string, error) { } res, err := g.container. + WithExec([]string{"ls"}). + WithExec([]string{"pwd"}). WithExec([]string{"git", "describe", "--tags", "--abbrev=0"}). Stdout(ctx) if err != nil { From 3ef3276d2742b077a069aaf034633ae6bde043c4 Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:31:42 +0200 Subject: [PATCH 09/18] fix: get more --- .github/workflows/ci.yaml | 3 +++ build/ci/git.go | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e697d24..a371677 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -85,6 +85,9 @@ jobs: # if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4.1.1 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 10 - uses: actions/setup-go@v5.0.0 with: go-version-file: go.mod diff --git a/build/ci/git.go b/build/ci/git.go index a0c7589..65d3d6b 100644 --- a/build/ci/git.go +++ b/build/ci/git.go @@ -78,8 +78,6 @@ func (g *Git) GetLastTag(ctx context.Context) (string, error) { } res, err := g.container. - WithExec([]string{"ls"}). - WithExec([]string{"pwd"}). WithExec([]string{"git", "describe", "--tags", "--abbrev=0"}). Stdout(ctx) if err != nil { From 5e6d833ee5201810da3cf7b2a133d08fb9e0366b Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:34:40 +0200 Subject: [PATCH 10/18] fix: fix toto --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a371677..7b0c719 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -87,7 +87,6 @@ jobs: - uses: actions/checkout@v4.1.1 with: ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 10 - uses: actions/setup-go@v5.0.0 with: go-version-file: go.mod From 60b1a9cfab17d52c9b352945b478a5532907ffb0 Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:38:21 +0200 Subject: [PATCH 11/18] feat: add fetch-tags --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7b0c719..35aba8b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -87,6 +87,8 @@ jobs: - uses: actions/checkout@v4.1.1 with: ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 20 + fetch-tags: true - uses: actions/setup-go@v5.0.0 with: go-version-file: go.mod From 3151d3002e3e03502771447c4c2cf8cd16229faa Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:41:55 +0200 Subject: [PATCH 12/18] fix: try with all history --- .github/workflows/ci.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 35aba8b..b20339b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -87,8 +87,7 @@ jobs: - uses: actions/checkout@v4.1.1 with: ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 20 - fetch-tags: true + fetch-depth: 0 - uses: actions/setup-go@v5.0.0 with: go-version-file: go.mod From 8203987acd2199785453d0957bd5c78f8d83bf35 Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:44:36 +0200 Subject: [PATCH 13/18] reenable CI --- .github/workflows/ci.yaml | 128 +++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b20339b..fca1470 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,80 +9,80 @@ on: - main jobs: - # tests: - # name: Tests - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4.1.1 - # - uses: actions/setup-go@v5.0.0 - # with: - # go-version-file: go.mod - # cache: true - # - name: Run tests - # uses: dagger/dagger-for-github@v5 - # with: - # verb: call - # args: tests --dir . - # version: "0.11.0" + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + - uses: actions/setup-go@v5.0.0 + with: + go-version-file: go.mod + cache: true + - name: Run tests + uses: dagger/dagger-for-github@v5 + with: + verb: call + args: tests --dir . + version: "0.11.0" - # examples: - # name: Examples - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4.1.1 - # - uses: actions/setup-go@v5.0.0 - # with: - # go-version-file: go.mod - # cache: true - # - name: Run examples - # uses: dagger/dagger-for-github@v5 - # with: - # verb: call - # args: examples --dir . - # version: "0.11.0" + examples: + name: Examples + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + - uses: actions/setup-go@v5.0.0 + with: + go-version-file: go.mod + cache: true + - name: Run examples + uses: dagger/dagger-for-github@v5 + with: + verb: call + args: examples --dir . + version: "0.11.0" - # lint: - # name: Lint - # runs-on: ubuntu-latest - # timeout-minutes: 5 - # steps: - # - uses: actions/checkout@v4.1.1 - # - uses: actions/setup-go@v5.0.0 - # with: - # go-version-file: go.mod - # cache: true - # - name: Lint - # uses: dagger/dagger-for-github@v5 - # with: - # verb: call - # args: lint --dir . - # version: "0.11.0" + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4.1.1 + - uses: actions/setup-go@v5.0.0 + with: + go-version-file: go.mod + cache: true + - name: Lint + uses: dagger/dagger-for-github@v5 + with: + verb: call + args: lint --dir . + version: "0.11.0" - # check-generation: - # name: Check generation - # runs-on: ubuntu-latest - # timeout-minutes: 5 - # steps: - # - uses: actions/checkout@v4.1.1 - # - uses: actions/setup-go@v5.0.0 - # with: - # go-version-file: go.mod - # cache: true - # - name: Lint - # uses: dagger/dagger-for-github@v5 - # with: - # verb: call - # args: check-generation --dir . - # version: "0.11.0" + check-generation: + name: Check generation + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4.1.1 + - uses: actions/setup-go@v5.0.0 + with: + go-version-file: go.mod + cache: true + - name: Lint + uses: dagger/dagger-for-github@v5 + with: + verb: call + args: check-generation --dir . + version: "0.11.0" publish: name: Publish asyncapi-codegen new version permissions: contents: write - # needs: ["tests", "examples", "lint", "check-generation"] + needs: ["tests", "examples", "lint", "check-generation"] runs-on: ubuntu-latest timeout-minutes: 5 - # if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4.1.1 with: From 7d6d2cddcc661fde881f0922529ef650bf81292a Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:44:46 +0200 Subject: [PATCH 14/18] add reset of minor/patch --- build/ci/git.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/ci/git.go b/build/ci/git.go index 65d3d6b..48c6e93 100644 --- a/build/ci/git.go +++ b/build/ci/git.go @@ -144,8 +144,11 @@ func (g *Git) GetNewSemVerIfNeeded(ctx context.Context) (string, error) { switch { case strings.HasPrefix(title, "BREAKING CHANGE"): major += 1 + minor = 0 + patch = 0 case strings.HasPrefix(title, "feat"): minor += 1 + patch = 0 case strings.HasPrefix(title, "fix"): patch += 1 default: From 82f120050be12df213d29bbbc21e28f6d1472f4f Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:49:23 +0200 Subject: [PATCH 15/18] fix --- build/ci/cmd.go | 3 +- build/ci/docker_image.go | 95 ++++++++++++++++++++++------------------ build/ci/git.go | 22 +++++++++- 3 files changed, 75 insertions(+), 45 deletions(-) diff --git a/build/ci/cmd.go b/build/ci/cmd.go index 62104e9..1c60b12 100644 --- a/build/ci/cmd.go +++ b/build/ci/cmd.go @@ -174,5 +174,6 @@ func (ci *AsyncapiCodegenCi) Publish( return err } - return nil + // Publish docker image + return publishDocker(ctx, srcDir, gi) } diff --git a/build/ci/docker_image.go b/build/ci/docker_image.go index 5eb0ec4..98c18c1 100644 --- a/build/ci/docker_image.go +++ b/build/ci/docker_image.go @@ -1,5 +1,10 @@ package main +import ( + "context" + "dagger/asyncapi-codegen-ci/internal/dagger" +) + const ( // dockerImageName is the name of the docker image. dockerImageName = "lerenn/asyncapi-codegen" @@ -19,45 +24,51 @@ var ( } ) -// func publishDocker(ctx context.Context, dir *dagger.Directory, tag string) error { -// // Get images for each platform -// platformVariants := make([]*dagger.Container, len(platforms)) -// for i, p := range platforms { -// platformVariants[i] = runnerFromDockerfile(dir, p) -// } - -// // Set publication options from images -// publishOpts := dagger.ContainerPublishOpts{ -// PlatformVariants: platformVariants, -// } - -// // Get last git commit hash -// hash, err := git.GetLastCommitHash(".") -// if err != nil { -// return err -// } - -// // Publish with hash -// if _, err := dag.Container().Publish(ctx, dockerImageName+":"+hash, publishOpts); err != nil { -// return err -// } - -// // Stop here if this not main branch -// if name, err := git.ActualBranchName("."); err != nil { -// return err -// } else if name != "main" { -// return nil -// } - -// // Publish with tag passed in argument -// if _, err := dag.Container().Publish(ctx, dockerImageName+":"+tag, publishOpts); err != nil { -// return err -// } - -// // Publish with "latest" as tag -// if _, err := dag.Container().Publish(ctx, dockerImageName+":latest", publishOpts); err != nil { -// return err -// } - -// return nil -// } +func publishDocker(ctx context.Context, dir *dagger.Directory, git Git) error { + // Get images for each platform + platformVariants := make([]*dagger.Container, len(platforms)) + for i, p := range platforms { + platformVariants[i] = runnerFromDockerfile(dir, p) + } + + // Set publication options from images + publishOpts := dagger.ContainerPublishOpts{ + PlatformVariants: platformVariants, + } + + // Get last git commit hash + hash, err := git.GetLastCommitShortSHA(ctx) + if err != nil { + return err + } + + // Publish with hash + if _, err := dag.Container().Publish(ctx, dockerImageName+":"+hash, publishOpts); err != nil { + return err + } + + // Stop here if this not main branch + if name, err := git.GetActualBranch(ctx); err != nil { + return err + } else if name != "main" { + return nil + } + + // Get last git tag + tag, err := git.GetLastTag(ctx) + if err != nil { + return err + } + + // Publish with tag passed in argument + if _, err := dag.Container().Publish(ctx, dockerImageName+":"+tag, publishOpts); err != nil { + return err + } + + // Publish with "latest" as tag + if _, err := dag.Container().Publish(ctx, dockerImageName+":latest", publishOpts); err != nil { + return err + } + + return nil +} diff --git a/build/ci/git.go b/build/ci/git.go index 48c6e93..3c368ab 100644 --- a/build/ci/git.go +++ b/build/ci/git.go @@ -17,8 +17,9 @@ type Git struct { shortSHA string } - lastTag string - newSemVer string + lastTag string + newSemVer string + actualBranch string } func NewGit(srcDir, sshDir *dagger.Directory) Git { @@ -54,6 +55,23 @@ func (g *Git) GetLastCommitShortSHA(ctx context.Context) (string, error) { return g.lastCommit.shortSHA, nil } +func (g *Git) GetActualBranch(ctx context.Context) (string, error) { + // Check if already doesn't exist + if g.actualBranch != "" { + return g.actualBranch, nil + } + + res, err := g.container. + WithExec([]string{"git", "rev-parse", "--abbrev-ref", "HEAD"}). + Stdout(ctx) + if err != nil { + return "", err + } + g.actualBranch = res + + return g.actualBranch, nil +} + func (g *Git) GetLastCommitTitle(ctx context.Context) (string, error) { // Check if already doesn't exist if g.lastCommit.title != "" { From 3937067aaf176a1a6d4444aca2d75c222436e673 Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:50:34 +0200 Subject: [PATCH 16/18] remove option in Daggerc command --- tools/make/dagger.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/make/dagger.mk b/tools/make/dagger.mk index 431d59e..b8337c3 100644 --- a/tools/make/dagger.mk +++ b/tools/make/dagger.mk @@ -1,4 +1,4 @@ -DAGGER_CMD := dagger -vvv +DAGGER_CMD := dagger .PHONY: dagger/check dagger/check: ## Run all the checks before commit on Dagger From 8b3e9bd828cbe43f9ce02e89840048ea70f676f5 Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 09:55:11 +0200 Subject: [PATCH 17/18] fix the github action --- .github/workflows/ci.yaml | 8 ++++---- build/ci/docker_image.go | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fca1470..e997080 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,7 +22,7 @@ jobs: uses: dagger/dagger-for-github@v5 with: verb: call - args: tests --dir . + args: tests --src-dir . version: "0.11.0" examples: @@ -38,7 +38,7 @@ jobs: uses: dagger/dagger-for-github@v5 with: verb: call - args: examples --dir . + args: examples --src-dir . version: "0.11.0" lint: @@ -55,7 +55,7 @@ jobs: uses: dagger/dagger-for-github@v5 with: verb: call - args: lint --dir . + args: lint --src-dir . version: "0.11.0" check-generation: @@ -72,7 +72,7 @@ jobs: uses: dagger/dagger-for-github@v5 with: verb: call - args: check-generation --dir . + args: check-generation --src-dir . version: "0.11.0" publish: diff --git a/build/ci/docker_image.go b/build/ci/docker_image.go index 98c18c1..96d6844 100644 --- a/build/ci/docker_image.go +++ b/build/ci/docker_image.go @@ -54,10 +54,12 @@ func publishDocker(ctx context.Context, dir *dagger.Directory, git Git) error { return nil } - // Get last git tag - tag, err := git.GetLastTag(ctx) + // Check if there is a new sem ver, if there is none, just stop here + tag, err := git.GetNewSemVerIfNeeded(ctx) if err != nil { return err + } else if tag == "" { + return nil } // Publish with tag passed in argument From 94f895a2939d6fa01e40fcf5de3e72d76fa79df2 Mon Sep 17 00:00:00 2001 From: Louis FRADIN Date: Mon, 22 Jul 2024 10:12:39 +0200 Subject: [PATCH 18/18] rename github action jobs --- .github/workflows/ci.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e997080..80ce625 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ on: jobs: tests: - name: Tests + name: Run tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.1.1 @@ -26,7 +26,7 @@ jobs: version: "0.11.0" examples: - name: Examples + name: Run examples runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.1.1 @@ -42,7 +42,7 @@ jobs: version: "0.11.0" lint: - name: Lint + name: Run linter runs-on: ubuntu-latest timeout-minutes: 5 steps: @@ -59,7 +59,7 @@ jobs: version: "0.11.0" check-generation: - name: Check generation + name: Check generation has been run runs-on: ubuntu-latest timeout-minutes: 5 steps: @@ -76,7 +76,7 @@ jobs: version: "0.11.0" publish: - name: Publish asyncapi-codegen new version + name: Publish a new version permissions: contents: write needs: ["tests", "examples", "lint", "check-generation"]