Skip to content

Commit

Permalink
chore: replace deprecated pointer package with ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrox committed Jan 10, 2024
1 parent 7a1969d commit 7d750d3
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 95 deletions.
4 changes: 2 additions & 2 deletions create/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -208,7 +208,7 @@ func (app *applicationCmd) config() apps.Config {
Command: app.DeployJob.Command,
},
FiniteJob: apps.FiniteJob{
Retries: pointer.Int32(app.DeployJob.Retries),
Retries: ptr.To(app.DeployJob.Retries),
Timeout: &metav1.Duration{Duration: app.DeployJob.Timeout},
},
}
Expand Down
48 changes: 24 additions & 24 deletions create/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

const (
Expand Down Expand Up @@ -120,11 +120,11 @@ func TestApplication(t *testing.T) {
},
Wait: false,
Name: "custom-name",
Size: pointer.String("mini"),
Size: ptr.To("mini"),
Hosts: []string{"custom.example.org", "custom2.example.org"},
Port: pointer.Int32(1337),
Replicas: pointer.Int32(42),
BasicAuth: pointer.Bool(false),
Port: ptr.To(int32(1337)),
Replicas: ptr.To(int32(42)),
BasicAuth: ptr.To(false),
Env: map[string]string{"hello": "world"},
BuildEnv: map[string]string{"BP_GO_TARGETS": "./cmd/web-server"},
DeployJob: deployJob{Command: "date", Name: "print-date", Retries: 2, Timeout: time.Minute},
Expand Down Expand Up @@ -152,8 +152,8 @@ func TestApplication(t *testing.T) {
cmd: applicationCmd{
Wait: false,
Name: "basic-auth",
Size: pointer.String("mini"),
BasicAuth: pointer.Bool(true),
Size: ptr.To("mini"),
BasicAuth: ptr.To(true),
},
checkApp: func(t *testing.T, cmd applicationCmd, app *apps.Application) {
assert.Equal(t, cmd.Name, app.Name)
Expand All @@ -165,8 +165,8 @@ func TestApplication(t *testing.T) {
cmd: applicationCmd{
Git: gitConfig{
URL: "https://github.com/ninech/doesnotexist.git",
Username: pointer.String("deploy"),
Password: pointer.String("hunter2"),
Username: ptr.To("deploy"),
Password: ptr.To("hunter2"),
},
Wait: false,
Name: "user-pass-auth",
Expand All @@ -187,11 +187,11 @@ func TestApplication(t *testing.T) {
cmd: applicationCmd{
Git: gitConfig{
URL: "https://github.com/ninech/doesnotexist.git",
SSHPrivateKey: pointer.String(dummySSHRSAPrivateKey),
SSHPrivateKey: ptr.To(dummySSHRSAPrivateKey),
},
Wait: false,
Name: "ssh-key-auth",
Size: pointer.String("mini"),
Size: ptr.To("mini"),
},
checkApp: func(t *testing.T, cmd applicationCmd, app *apps.Application) {
auth := util.GitAuth{SSHPrivateKey: cmd.Git.SSHPrivateKey}
Expand All @@ -208,11 +208,11 @@ func TestApplication(t *testing.T) {
cmd: applicationCmd{
Git: gitConfig{
URL: "https://github.com/ninech/doesnotexist.git",
SSHPrivateKey: pointer.String(dummySSHED25519PrivateKey),
SSHPrivateKey: ptr.To(dummySSHED25519PrivateKey),
},
Wait: false,
Name: "ssh-key-auth-ed25519",
Size: pointer.String("mini"),
Size: ptr.To("mini"),
},
checkApp: func(t *testing.T, cmd applicationCmd, app *apps.Application) {
auth := util.GitAuth{SSHPrivateKey: cmd.Git.SSHPrivateKey}
Expand All @@ -229,14 +229,14 @@ func TestApplication(t *testing.T) {
cmd: applicationCmd{
Git: gitConfig{
URL: "https://github.com/ninech/doesnotexist.git",
SSHPrivateKeyFromFile: pointer.String(filenameRSAKey),
SSHPrivateKeyFromFile: ptr.To(filenameRSAKey),
},
Wait: false,
Name: "ssh-key-auth-from-file",
Size: pointer.String("mini"),
Size: ptr.To("mini"),
},
checkApp: func(t *testing.T, cmd applicationCmd, app *apps.Application) {
auth := util.GitAuth{SSHPrivateKey: pointer.String("notused")}
auth := util.GitAuth{SSHPrivateKey: ptr.To("notused")}
authSecret := auth.Secret(app)
if err := apiClient.Get(ctx, api.ObjectName(authSecret), authSecret); err != nil {
t.Fatal(err)
Expand All @@ -250,14 +250,14 @@ func TestApplication(t *testing.T) {
cmd: applicationCmd{
Git: gitConfig{
URL: "https://github.com/ninech/doesnotexist.git",
SSHPrivateKeyFromFile: pointer.String(filenameED25519Key),
SSHPrivateKeyFromFile: ptr.To(filenameED25519Key),
},
Wait: false,
Name: "ssh-key-auth-from-file-ed25519",
Size: pointer.String("mini"),
Size: ptr.To("mini"),
},
checkApp: func(t *testing.T, cmd applicationCmd, app *apps.Application) {
auth := util.GitAuth{SSHPrivateKey: pointer.String("notused")}
auth := util.GitAuth{SSHPrivateKey: ptr.To("notused")}
authSecret := auth.Secret(app)
if err := apiClient.Get(ctx, api.ObjectName(authSecret), authSecret); err != nil {
t.Fatal(err)
Expand All @@ -271,11 +271,11 @@ func TestApplication(t *testing.T) {
cmd: applicationCmd{
Git: gitConfig{
URL: "https://github.com/ninech/doesnotexist.git",
SSHPrivateKey: pointer.String("not valid"),
SSHPrivateKey: ptr.To("not valid"),
},
Wait: false,
Name: "ssh-key-auth-non-valid",
Size: pointer.String("mini"),
Size: ptr.To("mini"),
},
errorExpected: true,
},
Expand All @@ -286,7 +286,7 @@ func TestApplication(t *testing.T) {
},
Wait: false,
Name: "deploy-job-empty-command",
Size: pointer.String("mini"),
Size: ptr.To("mini"),
DeployJob: deployJob{Command: "", Name: "print-date", Retries: 2, Timeout: time.Minute},
},
checkApp: func(t *testing.T, cmd applicationCmd, app *apps.Application) {
Expand All @@ -300,7 +300,7 @@ func TestApplication(t *testing.T) {
},
Wait: false,
Name: "deploy-job-empty-name",
Size: pointer.String("mini"),
Size: ptr.To("mini"),
DeployJob: deployJob{Command: "date", Name: "", Retries: 2, Timeout: time.Minute},
},
checkApp: func(t *testing.T, cmd applicationCmd, app *apps.Application) {
Expand Down Expand Up @@ -334,7 +334,7 @@ func TestApplicationWait(t *testing.T) {
Wait: true,
WaitTimeout: time.Second * 5,
Name: "some-name",
BasicAuth: pointer.Bool(true),
BasicAuth: ptr.To(true),
}
project := "default"

Expand Down
4 changes: 2 additions & 2 deletions create/project_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/ninech/nctl/api"
"github.com/ninech/nctl/api/util"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

// all fields need to be pointers so we can detect if they have been set by
Expand Down Expand Up @@ -41,7 +41,7 @@ func (cmd *configCmd) newProjectConfig(namespace string) *apps.ProjectConfig {
Command: cmd.DeployJob.Command,
},
FiniteJob: apps.FiniteJob{
Retries: pointer.Int32(cmd.DeployJob.Retries),
Retries: ptr.To(cmd.DeployJob.Retries),
Timeout: &metav1.Duration{Duration: cmd.DeployJob.Timeout},
},
}
Expand Down
10 changes: 5 additions & 5 deletions create/project_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/ninech/nctl/api/util"
"github.com/ninech/nctl/internal/test"
"github.com/stretchr/testify/assert"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

func TestProjectConfig(t *testing.T) {
Expand All @@ -29,10 +29,10 @@ func TestProjectConfig(t *testing.T) {
"all fields set": {
cmd: configCmd{
Size: string(test.AppMini),
Port: pointer.Int32(1337),
Replicas: pointer.Int32(42),
Port: ptr.To(int32(1337)),
Replicas: ptr.To(int32(42)),
Env: &map[string]string{"key1": "val1"},
BasicAuth: pointer.Bool(true),
BasicAuth: ptr.To(true),
DeployJob: deployJob{
Command: "exit 0", Name: "exit",
Retries: 1, Timeout: time.Minute * 5,
Expand All @@ -55,7 +55,7 @@ func TestProjectConfig(t *testing.T) {
"some fields not set": {
cmd: configCmd{
Size: string(test.AppMicro),
Replicas: pointer.Int32(1),
Replicas: ptr.To(int32(1)),
},
project: "namespace-2",
checkConfig: func(t *testing.T, cmd configCmd, cfg *apps.ProjectConfig) {
Expand Down
6 changes: 3 additions & 3 deletions get/project_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/ninech/nctl/internal/test"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)
Expand Down Expand Up @@ -182,8 +182,8 @@ func fakeProjectConfig(
ForProvider: apps.ProjectConfigParameters{
Config: apps.Config{
Size: test.AppMicro,
Replicas: pointer.Int32(1),
Port: pointer.Int32(9000),
Replicas: ptr.To(int32(1)),
Port: ptr.To(int32(9000)),
Env: util.EnvVarsFromMap(map[string]string{"key1": "val1"}),
},
},
Expand Down
6 changes: 3 additions & 3 deletions get/releases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ import (
"github.com/ninech/nctl/internal/test"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

var (
defaultConfig = apps.Config{
Size: test.AppMicro,
Replicas: pointer.Int32(1),
Port: pointer.Int32(8080),
Replicas: ptr.To(int32(1)),
Port: ptr.To(int32(8080)),
}

defaultCreationTime = metav1.NewTime(test.MustParseTime(time.RFC3339, "2023-03-13T14:00:00Z"))
Expand Down
Loading

0 comments on commit 7d750d3

Please sign in to comment.