Skip to content

Commit

Permalink
chore(lint): update linter rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Feb 28, 2025
1 parent 257886e commit 91e5e2c
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 55 deletions.
4 changes: 2 additions & 2 deletions compiler/native/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2446,8 +2446,8 @@ func convertFileToGithubResponse(file string) (github.RepositoryContent, error)
}

content := github.RepositoryContent{
Encoding: github.String(""),
Content: github.String(string(body)),
Encoding: github.Ptr(""),
Content: github.Ptr(string(body)),
}

return content, nil
Expand Down
4 changes: 2 additions & 2 deletions compiler/native/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func (c *client) getTemplate(ctx context.Context, tmpl *yaml.Template, name stri
//nolint:lll // ignore long line length due to input arguments
func (c *client) mergeTemplate(bytes []byte, tmpl *yaml.Template, step *yaml.Step) (*yaml.Build, []string, error) {
switch tmpl.Format {
case constants.PipelineTypeGo, "golang", "":
case constants.PipelineTypeGo, constants.PipelineTypeGoAlt, "":
//nolint:lll // ignore long line length due to return
return native.Render(string(bytes), step.Name, step.Template.Name, step.Environment, step.Template.Variables)
case constants.PipelineTypeStarlark:
Expand All @@ -414,7 +414,7 @@ func (c *client) mergeTemplate(bytes []byte, tmpl *yaml.Template, step *yaml.Ste

func (c *client) mergeDeployTemplate(bytes []byte, tmpl *yaml.Template, d *yaml.Deployment) (*yaml.Build, []string, error) {
switch tmpl.Format {
case constants.PipelineTypeGo, "golang", "":
case constants.PipelineTypeGo, constants.PipelineTypeGoAlt, "":
//nolint:lll // ignore long line length due to return
return native.Render(string(bytes), "", d.Template.Name, make(raw.StringSliceMap), d.Template.Variables)
case constants.PipelineTypeStarlark:
Expand Down
2 changes: 1 addition & 1 deletion compiler/native/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (c *client) Parse(v interface{}, pipelineType string, template *yaml.Templa
)

switch pipelineType {
case constants.PipelineTypeGo, "golang":
case constants.PipelineTypeGo, constants.PipelineTypeGoAlt:
// expand the base configuration
parsedRaw, err := c.ParseRaw(v)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion compiler/types/yaml/yaml/ruleset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"reflect"
"testing"

"github.com/google/go-cmp/cmp"
"gopkg.in/yaml.v3"

"github.com/go-vela/server/compiler/types/pipeline"
"github.com/google/go-cmp/cmp"
)

func TestYaml_Ruleset_ToPipeline(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions constants/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const (
// in Vela to control their pipeline being compiled as Go templates.
PipelineTypeGo = "go"

// PipelineTypeGoAlt defines the alternative value for "go".
PipelineTypeGoAlt = "golang"

// PipelineTypeStarlark defines the pipeline type for allowing users
// in Vela to control their pipeline being compiled as Starlark templates.
PipelineTypeStarlark = "starlark"
Expand Down
6 changes: 3 additions & 3 deletions scm/github/app_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ func ApplyInstallationPermissions(resource, perm string, perms *github.Installat
// convert resource from string
switch strings.ToLower(resource) {
case AppInstallResourceContents:
perms.Contents = github.String(perm)
perms.Contents = github.Ptr(perm)
case AppInstallResourceChecks:
perms.Checks = github.String(perm)
perms.Checks = github.Ptr(perm)
case AppInstallResourcePackages:
perms.Packages = github.String(perm)
perms.Packages = github.Ptr(perm)
// add more supported resources as needed.
default:
return perms, fmt.Errorf("invalid permission resource given for <resource>:<level> in %s:%s", resource, perm)
Expand Down
12 changes: 6 additions & 6 deletions scm/github/app_permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ func TestGetInstallationPermission(t *testing.T) {
{
name: "valid contents permission",
resource: AppInstallResourceContents,
permissions: &github.InstallationPermissions{Contents: github.String(AppInstallPermissionRead)},
permissions: &github.InstallationPermissions{Contents: github.Ptr(AppInstallPermissionRead)},
expectedPerm: AppInstallPermissionRead,
},
{
name: "valid checks permission",
resource: AppInstallResourceChecks,
permissions: &github.InstallationPermissions{Checks: github.String(AppInstallPermissionWrite)},
permissions: &github.InstallationPermissions{Checks: github.Ptr(AppInstallPermissionWrite)},
expectedPerm: AppInstallPermissionWrite,
},
{
name: "valid packages permission",
resource: AppInstallResourcePackages,
permissions: &github.InstallationPermissions{Packages: github.String(AppInstallPermissionNone)},
permissions: &github.InstallationPermissions{Packages: github.Ptr(AppInstallPermissionNone)},
expectedPerm: AppInstallPermissionNone,
},
{
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestApplyInstallationPermissions(t *testing.T) {
perm: AppInstallPermissionRead,
initialPerms: &github.InstallationPermissions{},
expectedPerms: &github.InstallationPermissions{
Contents: github.String(AppInstallPermissionRead),
Contents: github.Ptr(AppInstallPermissionRead),
},
},
{
Expand All @@ -80,7 +80,7 @@ func TestApplyInstallationPermissions(t *testing.T) {
perm: AppInstallPermissionWrite,
initialPerms: &github.InstallationPermissions{},
expectedPerms: &github.InstallationPermissions{
Checks: github.String(AppInstallPermissionWrite),
Checks: github.Ptr(AppInstallPermissionWrite),
},
},
{
Expand All @@ -89,7 +89,7 @@ func TestApplyInstallationPermissions(t *testing.T) {
perm: AppInstallPermissionNone,
initialPerms: &github.InstallationPermissions{},
expectedPerms: &github.InstallationPermissions{
Packages: github.String(AppInstallPermissionNone),
Packages: github.Ptr(AppInstallPermissionNone),
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion scm/github/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (c *client) CreateDeployment(ctx context.Context, u *api.User, r *api.Repo,
deployment := &github.DeploymentRequest{
Ref: d.Ref,
Task: d.Task,
AutoMerge: github.Bool(false),
AutoMerge: github.Ptr(false),
RequiredContexts: &[]string{},
Payload: payload,
Environment: d.Target,
Expand Down
18 changes: 9 additions & 9 deletions scm/github/github_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ func TestClient_installationCanReadRepo(t *testing.T) {
client: appsClient,
repo: accessibleRepo,
installation: &github.Installation{
ID: github.Int64(1),
ID: github.Ptr(int64(1)),
Account: &github.User{
Login: github.String("github"),
Login: github.Ptr("github"),
},
RepositorySelection: github.String(constants.AppInstallRepositoriesSelectionSelected),
RepositorySelection: github.Ptr(constants.AppInstallRepositoriesSelectionSelected),
},
want: true,
wantErr: false,
Expand All @@ -87,11 +87,11 @@ func TestClient_installationCanReadRepo(t *testing.T) {
client: appsClient,
repo: inaccessibleRepo,
installation: &github.Installation{
ID: github.Int64(2),
ID: github.Ptr(int64(2)),
Account: &github.User{
Login: github.String("github"),
Login: github.Ptr("github"),
},
RepositorySelection: github.String(constants.AppInstallRepositoriesSelectionSelected),
RepositorySelection: github.Ptr(constants.AppInstallRepositoriesSelectionSelected),
},
want: false,
wantErr: false,
Expand All @@ -101,11 +101,11 @@ func TestClient_installationCanReadRepo(t *testing.T) {
client: oauthClient,
repo: accessibleRepo,
installation: &github.Installation{
ID: github.Int64(1),
ID: github.Ptr(int64(1)),
Account: &github.User{
Login: github.String("github"),
Login: github.Ptr("github"),
},
RepositorySelection: github.String(constants.AppInstallRepositoriesSelectionSelected),
RepositorySelection: github.Ptr(constants.AppInstallRepositoriesSelectionSelected),
},
want: false,
wantErr: true,
Expand Down
44 changes: 22 additions & 22 deletions scm/github/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ func (c *client) CreateWebhook(ctx context.Context, u *api.User, r *api.Repo, h
hook := &github.Hook{
Events: events,
Config: &github.HookConfig{
URL: github.String(fmt.Sprintf("%s/webhook", c.config.ServerWebhookAddress)),
ContentType: github.String("form"),
Secret: github.String(r.GetHash()),
URL: github.Ptr(fmt.Sprintf("%s/webhook", c.config.ServerWebhookAddress)),
ContentType: github.Ptr("form"),
Secret: github.Ptr(r.GetHash()),
},
Active: github.Bool(true),
Active: github.Ptr(true),
}

// send API call to create the webhook
Expand Down Expand Up @@ -276,11 +276,11 @@ func (c *client) Update(ctx context.Context, u *api.User, r *api.Repo, hookID in
hook := &github.Hook{
Events: events,
Config: &github.HookConfig{
URL: github.String(fmt.Sprintf("%s/webhook", c.config.ServerWebhookAddress)),
ContentType: github.String("form"),
Secret: github.String(r.GetHash()),
URL: github.Ptr(fmt.Sprintf("%s/webhook", c.config.ServerWebhookAddress)),
ContentType: github.Ptr("form"),
Secret: github.Ptr(r.GetHash()),
},
Active: github.Bool(true),
Active: github.Ptr(true),
}

// send API call to update the webhook
Expand Down Expand Up @@ -378,14 +378,14 @@ func (c *client) Status(ctx context.Context, u *api.User, b *api.Build, org, nam

// create the status object to make the API call
status := &github.DeploymentStatusRequest{
Description: github.String(description),
Environment: github.String(b.GetDeploy()),
State: github.String(state),
Description: github.Ptr(description),
Environment: github.Ptr(b.GetDeploy()),
State: github.Ptr(state),
}

// provide "Details" link in GitHub UI if server was configured with it
if len(c.config.WebUIAddress) > 0 {
status.LogURL = github.String(url)
status.LogURL = github.Ptr(url)
}

_, _, err = client.Repositories.CreateDeploymentStatus(ctx, org, name, int64(number), status)
Expand All @@ -395,14 +395,14 @@ func (c *client) Status(ctx context.Context, u *api.User, b *api.Build, org, nam

// create the status object to make the API call
status := &github.RepoStatus{
Context: github.String(context),
Description: github.String(description),
State: github.String(state),
Context: github.Ptr(context),
Description: github.Ptr(description),
State: github.Ptr(state),
}

// provide "Details" link in GitHub UI if server was configured with it
if len(c.config.WebUIAddress) > 0 && b.GetStatus() != constants.StatusSkipped {
status.TargetURL = github.String(url)
status.TargetURL = github.Ptr(url)
}

// send API call to create the status context for the commit
Expand Down Expand Up @@ -464,14 +464,14 @@ func (c *client) StepStatus(ctx context.Context, u *api.User, b *api.Build, s *a

// create the status object to make the API call
status := &github.RepoStatus{
Context: github.String(context),
Description: github.String(description),
State: github.String(state),
Context: github.Ptr(context),
Description: github.Ptr(description),
State: github.Ptr(state),
}

// provide "Details" link in GitHub UI if server was configured with it
if len(c.config.WebUIAddress) > 0 && b.GetStatus() != constants.StatusSkipped {
status.TargetURL = github.String(url)
status.TargetURL = github.Ptr(url)
}

// send API call to create the status context for the commit
Expand Down Expand Up @@ -719,8 +719,8 @@ func (c *client) GetNetrcPassword(ctx context.Context, db database.Interface, r
//
// the default is contents:read and checks:write
ghPermissions := &github.InstallationPermissions{
Contents: github.String(AppInstallPermissionRead),
Checks: github.String(AppInstallPermissionWrite),
Contents: github.Ptr(AppInstallPermissionRead),
Checks: github.Ptr(AppInstallPermissionWrite),
}

permissions := g.Permissions
Expand Down
16 changes: 8 additions & 8 deletions scm/github/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1848,48 +1848,48 @@ func TestGithub_applyGitHubInstallationPermission(t *testing.T) {
{
name: "valid read permission for contents",
perms: &github.InstallationPermissions{
Contents: github.String(AppInstallPermissionNone),
Contents: github.Ptr(AppInstallPermissionNone),
},
resource: AppInstallResourceContents,
perm: AppInstallPermissionRead,
wantPerms: &github.InstallationPermissions{
Contents: github.String(AppInstallPermissionRead),
Contents: github.Ptr(AppInstallPermissionRead),
},
wantErr: false,
},
{
name: "valid write permission for checks",
perms: &github.InstallationPermissions{
Checks: github.String(AppInstallPermissionNone),
Checks: github.Ptr(AppInstallPermissionNone),
},
resource: AppInstallResourceChecks,
perm: AppInstallPermissionWrite,
wantPerms: &github.InstallationPermissions{
Checks: github.String(AppInstallPermissionWrite),
Checks: github.Ptr(AppInstallPermissionWrite),
},
wantErr: false,
},
{
name: "invalid permission value",
perms: &github.InstallationPermissions{
Contents: github.String(AppInstallPermissionNone),
Contents: github.Ptr(AppInstallPermissionNone),
},
resource: AppInstallResourceContents,
perm: "invalid",
wantPerms: &github.InstallationPermissions{
Contents: github.String(AppInstallPermissionNone),
Contents: github.Ptr(AppInstallPermissionNone),
},
wantErr: true,
},
{
name: "invalid permission key",
perms: &github.InstallationPermissions{
Contents: github.String(AppInstallPermissionNone),
Contents: github.Ptr(AppInstallPermissionNone),
},
resource: "invalid",
perm: AppInstallPermissionRead,
wantPerms: &github.InstallationPermissions{
Contents: github.String(AppInstallPermissionNone),
Contents: github.Ptr(AppInstallPermissionNone),
},
wantErr: true,
},
Expand Down

0 comments on commit 91e5e2c

Please sign in to comment.