#Skipped 1 function(s) with unsupported types: build-and-push after dagger functions
1 messages · Page 1 of 1 (latest)
Not I'm aware of. Could you share a partial view of the main.go with the missing function by any chance?
but based on the error message in the title, I guess the issue is the return type of the function. It should be a type from the core dagger or defined in the module itself. But for instance it can't return a type defined in a dependency.
package main
import (
"context"
"fmt"
)
type Cicd struct{}
// BuildAndPush takes the source code, builds the Dockerfile, and pushes to Harbor
func (m *Cicd) BuildAndPush(
ctx context.Context,
src *Directory, // Dagger will pass the project root here
harborUrl string, // e.g. harbor.example.com
repoPath string, // e.g. my-project/my-app
username string,
password *Secret, // This ensures the password is never logged
) (string, error) {
package main
import (
"context"
"dagger/cicd/internal/dagger"
)
type Cicd struct{}
// BuildAndPush takes the source code, builds the Dockerfile, and pushes to Harbor
func (m Cicd) BuildAndPush(
ctx context.Context,
srcDirectory, // Dagger will pass the project root here
harborUrl string, // e.g. harbor.example.com
repoPath string, // e.g. my-project/my-app
username string,
password *dagger.Secret, // This ensures the password is never logged
) (string, error) {
return "", nil
}
The type of password is not good, it should be *dagger.Secret and for that you need to add the import dagger/cicd/internal/dagger
$ dagger functions
✔ connect 0.2s
✔ load module: . 0.8s
Name Description
build-and-push BuildAndPush takes the source code, builds the Dockerfile, and pushes to Harbor
oh I see! Cool. Thank you!
still getting the same message 🙁
this is the full module code ... package main
import (
"context"
"fmt"
"dagger/cicd/internal/dagger"
)
type Cicd struct{}
// BuildAndPush takes the source code, builds the Dockerfile, and pushes to Harbor
func (m *Cicd) BuildAndPush(
ctx context.Context,
src *Directory, // Dagger will pass the project root here
harborUrl string, // e.g. harbor.example.com
repoPath string, // e.g. my-project/my-app
username string,
password *dagger.Secret,
) (string, error) {
// 1. Build the image
// This automatically looks for "Dockerfile" in the 'src' directory
img := src.DockerBuild()
// 2. Authenticate with Harbor
img = img.WithRegistryAuth(harborUrl, username, password)
// 3. Publish to your registry
// Tagging it with 'latest' for now
addr := fmt.Sprintf("%s/%s:latest", harborUrl, repoPath)
img.Publish(ctx, addr)
return "", nil
}
package main
import (
"context"
"dagger/cicd/internal/dagger"
"fmt"
)
type Cicd struct{}
// BuildAndPush takes the source code, builds the Dockerfile, and pushes to Harbor
func (m Cicd) BuildAndPush(
ctx context.Context,
src *dagger.Directory, // Dagger will pass the project root here
harborUrl string, // e.g. harbor.example.com
repoPath string, // e.g. my-project/my-app
username string,
password *dagger.Secret,
) (string, error) {
// 1. Build the image
// This automatically looks for "Dockerfile" in the 'src' directory
img := src.DockerBuild()
// 2. Authenticate with Harbor
img = img.WithRegistryAuth(harborUrl, username, password)
// 3. Publish to your registry
// Tagging it with 'latest' for now
addr := fmt.Sprintf("%s/%s:latest", harborUrl, repoPath)
img.Publish(ctx, addr)
return "", nil
}
The problem is your src argument, it should be a *dagger.Directory