Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): add instance only when metadata is not nil #1201

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions compiler/native/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"github.com/hashicorp/go-retryablehttp"

api "github.com/go-vela/server/api/types"
"github.com/go-vela/server/internal"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
"github.com/go-vela/types/pipeline"
Expand Down Expand Up @@ -62,22 +61,21 @@
event = event + ":" + action
}

// populate metadata when not provided using compiler.WithMetadata
if c.metadata == nil {
c.metadata = &internal.Metadata{Database: &internal.Database{}, Queue: &internal.Queue{}, Source: &internal.Source{}, Vela: &internal.Vela{}}
}

// create the ruledata to purge steps
r := &pipeline.RuleData{
Branch: c.build.GetBranch(),
Comment: c.comment,
Event: event,
Path: c.files,
Repo: c.repo.GetFullName(),
Tag: strings.TrimPrefix(c.build.GetRef(), "refs/tags/"),
Target: c.build.GetDeploy(),
Label: c.labels,
Instance: c.metadata.Vela.Address,
Branch: c.build.GetBranch(),
Comment: c.comment,
Event: event,
Path: c.files,
Repo: c.repo.GetFullName(),
Tag: strings.TrimPrefix(c.build.GetRef(), "refs/tags/"),
Target: c.build.GetDeploy(),
Label: c.labels,
}

// add instance when we have the metadata (local exec will not)
if c.metadata != nil && c.metadata.Vela != nil {
r.Instance = c.metadata.Vela.Address
}

switch {
Expand Down Expand Up @@ -332,7 +330,7 @@

if c.ModificationService.Endpoint != "" {
// send config to external endpoint for modification
p, err = c.modifyConfig(p, c.build, c.repo)

Check failure on line 333 in compiler/native/compile.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] compiler/native/compile.go#L333

Function `modifyConfig` should pass the context parameter (contextcheck)
Raw output
compiler/native/compile.go:333:26: Function `modifyConfig` should pass the context parameter (contextcheck)
		p, err = c.modifyConfig(p, c.build, c.repo)
		                       ^
if err != nil {
return nil, _pipeline, err
}
Expand Down Expand Up @@ -427,7 +425,7 @@

if c.ModificationService.Endpoint != "" {
// send config to external endpoint for modification
p, err = c.modifyConfig(p, c.build, c.repo)

Check failure on line 428 in compiler/native/compile.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] compiler/native/compile.go#L428

Function `modifyConfig` should pass the context parameter (contextcheck)
Raw output
compiler/native/compile.go:428:26: Function `modifyConfig` should pass the context parameter (contextcheck)
		p, err = c.modifyConfig(p, c.build, c.repo)
		                       ^
if err != nil {
return nil, _pipeline, err
}
Expand Down
Loading