Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v7

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -64,7 +64,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v4

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -77,6 +77,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"
10 changes: 5 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v7
- uses: actions/setup-go@v6
with:
go-version: 1.23.x
go-version: 1.26.x
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
version: v1.63
version: v2.12.2
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: 1.23.x
go-version: 1.26.x
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4
- name: Login to GHCR
uses: docker/login-action@v3
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: '~> v2'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ jobs:
test:
strategy:
matrix:
go: [1.22.x, 1.23.x]
go: [1.26.x]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v7
- uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
- name: Test
Expand Down
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "2"
linters:
settings:
errcheck:
exclude-functions:
- fmt.Fprintf
- fmt.Fprintln
- fmt.Fprint
6 changes: 3 additions & 3 deletions cmd/base/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ func SetupProxy(cmd *cobra.Command, manager *config.Manager) {
}
if proxy != "" {
if strings.HasPrefix(proxy, "https") {
os.Setenv("HTTPS_PROXY", proxy)
_ = os.Setenv("HTTPS_PROXY", proxy)
} else {
os.Setenv("HTTP_PROXY", proxy)
_ = os.Setenv("HTTP_PROXY", proxy)
}
}
}
Expand All @@ -98,7 +98,7 @@ func ReadInputJSON(path string, in io.Reader, input any) error {
if err != nil {
return fmt.Errorf("failed to open file: %w", err)
}
defer file.Close()
defer file.Close() //nolint:errcheck
inputReader = file
} else {
inputReader = in
Expand Down
4 changes: 2 additions & 2 deletions cmd/config/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func newUpdateCmd(cmdContext *base.CmdContext) *cobra.Command {

// fillConfigOptions adds cmd flag to configOptions only if flag exists in KnownConfigFlags
func fillConfigOptions(cmd *cobra.Command, f *pflag.Flag, configOptions map[string]any) {
if strings.HasPrefix(f.Name, "no-") {
optionName := strings.TrimPrefix(f.Name, "no-")
if after, ok := strings.CutPrefix(f.Name, "no-"); ok {
optionName := after
configOptions[optionName] = nil
return
}
Expand Down
24 changes: 10 additions & 14 deletions cmd/entities/cloud-instances/cloud_instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ var (
FlavorID: "flavor-1",
FlavorName: "m1.small",
ImageID: "image-1",
ImageName: stringPtr("Ubuntu 20.04"),
PublicIPv4Address: stringPtr("1.2.3.4"),
PrivateIPv4Address: stringPtr("10.0.0.1"),
LocalIPv4Address: stringPtr("192.168.0.1"),
PublicIPv6Address: stringPtr("2001:db8::1"),
ImageName: new("Ubuntu 20.04"),
PublicIPv4Address: new("1.2.3.4"),
PrivateIPv4Address: new("10.0.0.1"),
LocalIPv4Address: new("192.168.0.1"),
PublicIPv6Address: new("2001:db8::1"),
GPNEnabled: true,
IPv6Enabled: true,
BackupCopies: 2,
Expand All @@ -52,11 +52,11 @@ var (
FlavorID: "flavor-1",
FlavorName: "m1.small",
ImageID: "image-1",
ImageName: stringPtr("Ubuntu 20.04"),
PublicIPv4Address: stringPtr("1.2.3.4"),
PrivateIPv4Address: stringPtr("10.0.0.1"),
LocalIPv4Address: stringPtr("192.168.0.1"),
PublicIPv6Address: stringPtr("2001:db8::1"),
ImageName: new("Ubuntu 20.04"),
PublicIPv4Address: new("1.2.3.4"),
PrivateIPv4Address: new("10.0.0.1"),
LocalIPv4Address: new("192.168.0.1"),
PublicIPv6Address: new("2001:db8::1"),
GPNEnabled: true,
IPv6Enabled: true,
BackupCopies: 2,
Expand All @@ -67,10 +67,6 @@ var (
}
)

func stringPtr(s string) *string {
return &s
}

func TestListCloudInstancesCmd(t *testing.T) {
testInstance1 := testCloudInstance
testInstance2 := testCloudInstance2
Expand Down
2 changes: 1 addition & 1 deletion cmd/entities/cloud-volumes/cloud_volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var (
RegionID: 1,
RegionCode: testRegionCode,
Size: 100,
Description: testutils.PtrString("Test volume"),
Description: new("Test volume"),
Labels: map[string]string{"foo": "bar"},
Created: &fixedTime,
}
Expand Down
46 changes: 23 additions & 23 deletions cmd/entities/hosts/hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ var (
}
testConfigDetails = serverscom.ConfigurationDetails{
RAMSize: 2,
ServerModelID: testutils.PtrInt64(1),
ServerModelName: testutils.PtrString("server-model-123"),
PublicUplinkID: testutils.PtrInt64(2),
PublicUplinkName: testutils.PtrString("Public 1 Gbps without redundancy"),
PrivateUplinkID: testutils.PtrInt64(3),
PrivateUplinkName: testutils.PtrString("Private 1 Gbps without redundancy"),
BandwidthID: testutils.PtrInt64(4),
BandwidthName: testutils.PtrString("20000 GB"),
OperatingSystemID: testutils.PtrInt64(5),
OperatingSystemFullName: testutils.PtrString("CentOS 7 x86_64"),
ServerModelID: new(int64(1)),
ServerModelName: new("server-model-123"),
PublicUplinkID: new(int64(2)),
PublicUplinkName: new("Public 1 Gbps without redundancy"),
PrivateUplinkID: new(int64(3)),
PrivateUplinkName: new("Private 1 Gbps without redundancy"),
BandwidthID: new(int64(4)),
BandwidthName: new("20000 GB"),
OperatingSystemID: new(int64(5)),
OperatingSystemFullName: new("CentOS 7 x86_64"),
}
testDS = serverscom.DedicatedServer{
ID: testId,
Expand Down Expand Up @@ -259,23 +259,23 @@ func TestAddEBMCmd(t *testing.T) {
Slots: []serverscom.DedicatedServerSlotInput{
{
Position: 1,
DriveModelID: testutils.PtrInt64(3456),
DriveModelID: new(int64(3456)),
},
{
Position: 2,
DriveModelID: testutils.PtrInt64(3456),
DriveModelID: new(int64(3456)),
},
},
Layout: []serverscom.DedicatedServerLayoutInput{
{
SlotPositions: []int{1, 2},
Raid: testutils.PtrInt(1),
Raid: new(1),
Partitions: []serverscom.DedicatedServerLayoutPartitionInput{
{
Target: "/boot",
Size: 500,
Fill: false,
Fs: testutils.PtrString("ext4"),
Fs: new("ext4"),
},
},
},
Expand All @@ -284,8 +284,8 @@ func TestAddEBMCmd(t *testing.T) {
Hosts: []serverscom.DedicatedServerHostInput{
{
Hostname: "example.aa",
PublicIPv4NetworkID: testutils.PtrString("PublicNet123"),
PrivateIPv4NetworkID: testutils.PtrString("PrivateNet456"),
PublicIPv4NetworkID: new("PublicNet123"),
PrivateIPv4NetworkID: new("PrivateNet456"),
Labels: map[string]string{
"environment": "testing",
},
Expand Down Expand Up @@ -325,13 +325,13 @@ func TestAddEBMCmd(t *testing.T) {
input := expectedInput
input.Drives.Layout = append(input.Drives.Layout, serverscom.DedicatedServerLayoutInput{
SlotPositions: []int{3, 4},
Raid: testutils.PtrInt(0),
Raid: new(0),
Partitions: []serverscom.DedicatedServerLayoutPartitionInput{
{
Target: "/boot",
Size: 500,
Fill: false,
Fs: testutils.PtrString("ext4"),
Fs: new("ext4"),
},
},
})
Expand Down Expand Up @@ -364,7 +364,7 @@ func TestAddEBMCmd(t *testing.T) {
configureMock: func(mock *mocks.MockHostsService) {
input := expectedInput
input.Features = []string{"public_ipxe_boot"}
input.IPXEConfig = testutils.PtrString("#!ipxe\nboot")
input.IPXEConfig = new("#!ipxe\nboot")
mock.EXPECT().
CreateDedicatedServers(gomock.Any(), input).
Return([]serverscom.DedicatedServer{testDS}, nil)
Expand All @@ -380,7 +380,7 @@ func TestAddEBMCmd(t *testing.T) {
},
configureMock: func(mock *mocks.MockHostsService) {
input := expectedInput
input.IPXEConfig = testutils.PtrString("#!ipxe\nboot")
input.IPXEConfig = new("#!ipxe\nboot")
mock.EXPECT().
CreateDedicatedServers(gomock.Any(), input).
Return([]serverscom.DedicatedServer{testDS}, nil)
Expand All @@ -395,7 +395,7 @@ func TestAddEBMCmd(t *testing.T) {
},
configureMock: func(mock *mocks.MockHostsService) {
input := expectedInput
input.IPXEConfig = testutils.PtrString("#!ipxe\nboot")
input.IPXEConfig = new("#!ipxe\nboot")
mock.EXPECT().
CreateDedicatedServers(gomock.Any(), input).
Return([]serverscom.DedicatedServer{testDS}, nil)
Expand Down Expand Up @@ -474,8 +474,8 @@ func TestAddSBMCmd(t *testing.T) {
Hosts: []serverscom.SBMServerHostInput{
{
Hostname: "example.aa",
PublicIPv4NetworkID: testutils.PtrString("PublicNetTest123"),
PrivateIPv4NetworkID: testutils.PtrString("PrivateNetTest456"),
PublicIPv4NetworkID: new("PublicNetTest123"),
PrivateIPv4NetworkID: new("PrivateNetTest456"),
Labels: map[string]string{
"environment": "testing",
},
Expand Down
8 changes: 4 additions & 4 deletions cmd/entities/hosts/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func parseLayout(layouts []string) ([]serverscom.DedicatedServerLayoutInput, err

for _, l := range layouts {
var lInput serverscom.DedicatedServerLayoutInput
parts := strings.Split(l, ",")
parts := strings.SplitSeq(l, ",")

for _, part := range parts {
for part := range parts {
pair := strings.SplitN(part, "=", 2)
if len(pair) != 2 {
continue
Expand Down Expand Up @@ -80,9 +80,9 @@ func parsePartitions(partitions []string) ([]parsedPartition, error) {

for _, p := range partitions {
var pp parsedPartition
parts := strings.Split(p, ",")
parts := strings.SplitSeq(p, ",")

for _, part := range parts {
for part := range parts {
pair := strings.SplitN(part, "=", 2)
if len(pair) != 2 {
continue
Expand Down
4 changes: 2 additions & 2 deletions cmd/entities/l2_segments/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ func parseMembers(members []string) ([]serverscom.L2SegmentMemberInput, error) {

for _, member := range members {
m := serverscom.L2SegmentMemberInput{}
parts := strings.Split(member, ",")
parts := strings.SplitSeq(member, ",")

for _, p := range parts {
for p := range parts {
props := strings.SplitN(p, "=", 2)
if len(props) != 2 {
return nil, fmt.Errorf("invalid member format: %s", p)
Expand Down
4 changes: 2 additions & 2 deletions cmd/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ Example: srvctl login context-name`,
RunE: func(cmd *cobra.Command, args []string) error {
// login only if SC_TOKEN env is not set
if os.Getenv("SC_TOKEN") != "" {
return errors.New("SC_TOKEN env is set. Please unset it before using login command.")
return errors.New("SC_TOKEN env is set. Please unset it before using login command")
}

if !term.IsTerminal(int(os.Stdout.Fd())) {
return errors.New("TTY required to enter the token.")
return errors.New("TTY required to enter the token")
}
manager := cmdContext.GetManager()

Expand Down
4 changes: 2 additions & 2 deletions cmd/login/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ func TestLoginCmd(t *testing.T) {
if err != nil {
t.Fatalf("failed to open pty: %v", err)
}
defer ptmx.Close()
defer tty.Close()
defer ptmx.Close() //nolint:errcheck
defer tty.Close() //nolint:errcheck

oldStdout := os.Stdout
defer func() { os.Stdout = oldStdout }()
Expand Down
12 changes: 0 additions & 12 deletions cmd/testutils/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,3 @@ func NewTestCmdContext(scClient *serverscom.Client) *base.CmdContext {
cli := client.NewWithClient(scClient)
return base.NewCmdContext(manager, cli)
}

func PtrInt64(i int64) *int64 {
return &i
}

func PtrInt(i int) *int {
return &i
}

func PtrString(s string) *string {
return &s
}
Loading