Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Bump z
Browse files Browse the repository at this point in the history
Update z and refactor `z.P` calls to use its new name, `z.Pointer`.

Signed-off-by: Nick Hale <[email protected]>
  • Loading branch information
njhale committed Jul 14, 2023
1 parent 474682e commit a3eaed4
Show file tree
Hide file tree
Showing 24 changed files with 92 additions and 92 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/acorn-io/baaah v0.0.0-20230707151126-5d519d272865
github.com/acorn-io/mink v0.0.0-20230523184405-ceaaa366d500
github.com/acorn-io/namegenerator v0.0.0-20220915160418-9e3d5a0ffe78
github.com/acorn-io/z v0.0.0-20230710161405-78afed0850a8
github.com/acorn-io/z v0.0.0-20230714155009-a770ecbbdc45
github.com/adrg/xdg v0.4.0
github.com/aws/aws-sdk-go-v2 v1.18.0
github.com/aws/aws-sdk-go-v2/config v1.18.23
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ github.com/acorn-io/namegenerator v0.0.0-20220915160418-9e3d5a0ffe78 h1:5zs9L/CX
github.com/acorn-io/namegenerator v0.0.0-20220915160418-9e3d5a0ffe78/go.mod h1:/5647+1/L7m7Aq7upTLtfLznTLYttURzH7Y23LKrW0M=
github.com/acorn-io/wrangler v0.0.0-20230619194218-746dc7cf6a0c h1:4k4uuDw+PT3neNLCALme0hGe67XjoR/0cUXnxaT5d+g=
github.com/acorn-io/wrangler v0.0.0-20230619194218-746dc7cf6a0c/go.mod h1:D6Tu6oVX8aGtCHsMCtYaysgVK3ad920MTSeAu7rzb5U=
github.com/acorn-io/z v0.0.0-20230710161405-78afed0850a8 h1:E8/GtUHuIBRNLXv/uHwjjZqQg2B6BDCU5RXQA/OgDCQ=
github.com/acorn-io/z v0.0.0-20230710161405-78afed0850a8/go.mod h1:5UO0+eOne2Zhvn7Ox5IiK4u+4dlCSLmHfTQWORRdEyo=
github.com/acorn-io/z v0.0.0-20230714155009-a770ecbbdc45 h1:+od+ijNLAt+tc33uZa71qkE4eyvubts45thVXz8J7DU=
github.com/acorn-io/z v0.0.0-20230714155009-a770ecbbdc45/go.mod h1:5UO0+eOne2Zhvn7Ox5IiK4u+4dlCSLmHfTQWORRdEyo=
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
Expand Down
2 changes: 1 addition & 1 deletion integration/client/apps/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ func TestAppRunImageVariations(t *testing.T) {
name: "autoupgrade",
image: "foo/bar:**",
options: &client.AppRunOptions{
AutoUpgrade: z.P(true),
AutoUpgrade: z.Pointer(true),
},
},
{
Expand Down
6 changes: 3 additions & 3 deletions integration/run/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ func TestAutoUpgradeImageValidation(t *testing.T) {

app, err := c.AppRun(ctx, "ghcr.io/acorn-io/library/nginx:latest", &client.AppRunOptions{
Name: "myapp",
AutoUpgrade: z.P(true),
AutoUpgrade: z.Pointer(true),
})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -1697,7 +1697,7 @@ func TestAutoUpgradeLocalImage(t *testing.T) {

// Attempt to run an auto-upgrade app with a non-existent local image. Should get an error.
_, err = c.AppRun(ctx, "mylocalimage", &client.AppRunOptions{
AutoUpgrade: z.P(true),
AutoUpgrade: z.Pointer(true),
})
if err == nil {
t.Fatalf("expected to get a not found error, instead got %v", err)
Expand All @@ -1724,7 +1724,7 @@ func TestAutoUpgradeLocalImage(t *testing.T) {
}

_, err = c.AppRun(ctx, appImage, &client.AppRunOptions{
AutoUpgrade: z.P(true),
AutoUpgrade: z.Pointer(true),
})
if err != nil {
t.Fatal(err)
Expand Down
50 changes: 25 additions & 25 deletions pkg/apis/internal.acorn.io/v1/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@ func TestValidateMemory(t *testing.T) {
specMemory: MemoryMap{},
container: Container{},
containerName: "onecontainer",
specMemDefault: z.P(100 * Mi),
specMemDefault: z.Pointer(100 * Mi),
specMemMaximum: new(int64),
want: z.P(100 * Mi),
want: z.Pointer(100 * Mi),
err: nil,
},
{
name: "successful with setting from user",
specMemory: MemoryMap{"onecontainer": z.P(512 * Mi)},
specMemory: MemoryMap{"onecontainer": z.Pointer(512 * Mi)},
container: Container{},
containerName: "onecontainer",
specMemDefault: new(int64),
specMemMaximum: new(int64),
want: z.P(512 * Mi),
want: z.Pointer(512 * Mi),
err: nil,
},
{
name: "successful with setting from Acornfile",
specMemory: MemoryMap{},
container: Container{Memory: z.P(512 * Mi)},
container: Container{Memory: z.Pointer(512 * Mi)},
containerName: "onecontainer",
specMemDefault: new(int64),
specMemMaximum: new(int64),
want: z.P(512 * Mi),
want: z.Pointer(512 * Mi),
err: nil,
},
{
Expand All @@ -55,9 +55,9 @@ func TestValidateMemory(t *testing.T) {
specMemory: MemoryMap{"onecontainer": new(int64)},
container: Container{},
containerName: "onecontainer",
specMemDefault: z.P(512 * Mi),
specMemMaximum: z.P(512 * Mi),
want: z.P(512 * Mi),
specMemDefault: z.Pointer(512 * Mi),
specMemMaximum: z.Pointer(512 * Mi),
want: z.Pointer(512 * Mi),
err: nil,
},
{
Expand All @@ -66,9 +66,9 @@ func TestValidateMemory(t *testing.T) {
specMemory: MemoryMap{},
container: Container{Memory: new(int64)},
containerName: "onecontainer",
specMemDefault: z.P(512 * Mi),
specMemMaximum: z.P(512 * Mi),
want: z.P(512 * Mi),
specMemDefault: z.Pointer(512 * Mi),
specMemMaximum: z.Pointer(512 * Mi),
want: z.Pointer(512 * Mi),
err: nil,
},
{
Expand All @@ -78,37 +78,37 @@ func TestValidateMemory(t *testing.T) {
container: Container{Memory: new(int64)},
containerName: "onecontainer",
specMemDefault: new(int64),
specMemMaximum: z.P(512 * Mi),
want: z.P(512 * Mi),
specMemMaximum: z.Pointer(512 * Mi),
want: z.Pointer(512 * Mi),
err: nil,
},
{
name: "successful overwrite of Acornfile with user setting",
specMemory: MemoryMap{"onecontainer": z.P(512 * Mi)},
container: Container{Memory: z.P(256 * Mi)},
specMemory: MemoryMap{"onecontainer": z.Pointer(512 * Mi)},
container: Container{Memory: z.Pointer(256 * Mi)},
containerName: "onecontainer",
specMemDefault: new(int64),
specMemMaximum: new(int64),
want: z.P(512 * Mi),
want: z.Pointer(512 * Mi),
err: nil,
},
{
name: "failure from user setting exceeding the maximum memory",
specMemory: MemoryMap{"onecontainer": z.P(512 * Mi)},
specMemory: MemoryMap{"onecontainer": z.Pointer(512 * Mi)},
container: Container{},
containerName: "onecontainer",
specMemDefault: z.P(128 * Mi),
specMemMaximum: z.P(128 * Mi),
specMemDefault: z.Pointer(128 * Mi),
specMemMaximum: z.Pointer(128 * Mi),
want: nil,
err: ErrInvalidSetMemory,
},
{
name: "failure from Acornfile setting exceeding the maximum memory",
specMemory: MemoryMap{},
container: Container{Memory: z.P(512 * Mi)},
container: Container{Memory: z.Pointer(512 * Mi)},
containerName: "onecontainer",
specMemDefault: z.P(128 * Mi),
specMemMaximum: z.P(128 * Mi),
specMemDefault: z.Pointer(128 * Mi),
specMemMaximum: z.Pointer(128 * Mi),
want: nil,
err: ErrInvalidAcornMemory,
},
Expand All @@ -117,8 +117,8 @@ func TestValidateMemory(t *testing.T) {
specMemory: MemoryMap{},
container: Container{},
containerName: "onecontainer",
specMemDefault: z.P(512 * Mi),
specMemMaximum: z.P(128 * Mi),
specMemDefault: z.Pointer(512 * Mi),
specMemMaximum: z.Pointer(128 * Mi),
want: nil,
err: ErrInvalidDefaultMemory,
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/appdefinition/appdefinition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ acorns: first: {
assert.True(t, *acorn.NotifyUpgrade)
assert.Equal(t, "20s", acorn.AutoUpgradeInterval)
assert.Equal(t, v1.MemoryMap{
"": z.P[int64](1 << 30),
"": z.Pointer[int64](1 << 30),
}, acorn.Memory)
assert.Equal(t, v1.NameValue{
Name: "a",
Expand Down Expand Up @@ -1797,7 +1797,7 @@ acorns: first: {
Target: "def",
}, acorn.Links[0])
assert.Equal(t, v1.MemoryMap{
"foo": z.P[int64](1 << 30),
"foo": z.Pointer[int64](1 << 30),
}, acorn.Memory)
assert.Equal(t, v1.NameValues{
{
Expand Down
6 changes: 3 additions & 3 deletions pkg/autoupgrade/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestDetermineAppsToRefresh(t *testing.T) {
now := time.Now()
thirtySecondsAgo := now.Add(-30 * time.Second)
oneMinuteAgo := now.Add(-time.Minute)
ptrTrue := z.P(true)
ptrTrue := z.Pointer(true)
appImages := map[string]string{
"test-1": "acorn/test-1:v#.*.**",
"acorn-1": "acorn/acorn-1:v1.1.1-*",
Expand Down Expand Up @@ -189,7 +189,7 @@ func TestDetermineAppsToRefresh(t *testing.T) {
func TestRefreshImages(t *testing.T) {
now := time.Now()
thirtySecondsAgo := now.Add(-30 * time.Second)
ptrTrue := z.P(true)
ptrTrue := z.Pointer(true)
appImages := map[string]string{
"test-1": "acorn/test-1:v#.#.#",
"acorn-1": "docker.io/acorn/acorn-1:v1.1.1-*",
Expand Down Expand Up @@ -451,7 +451,7 @@ func TestDaemonSync(t *testing.T) {
start := time.Now()
tenMinutesAgo := time.Now().Add(-10 * time.Minute)
fiftySecondsAgo := time.Now().Add(-50 * time.Second)
ptrTrue := z.P(true)
ptrTrue := z.Pointer(true)
appImages := map[string]string{
"test-1": "30s",
"acorn-1": "1m",
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ func (c *DefaultClient) appStop(ctx context.Context, name string) error {
return err
}
if app.Spec.Stop == nil || !*app.Spec.Stop {
app.Spec.Stop = z.P(true)
app.Spec.Stop = z.Pointer(true)
return c.Client.Update(ctx, app)
}
return nil
Expand Down
8 changes: 4 additions & 4 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ func TestAcornDNSStates(t *testing.T) {
// acornDNS is explicitly disabled, expect no clusterDomain to be returned
name: "acornDNS disabled expect no clusterdomains",
conf: &apiv1.Config{
AcornDNS: z.P("disabled"),
AcornDNS: z.Pointer("disabled"),
},
expectedClusterDomains: nil,
},
{
// acornDNS is explicitly disabled. User defined domain, expect just user defined domain
name: "acornDNS disabled expect custom clusterdomains",
conf: &apiv1.Config{
AcornDNS: z.P("disabled"),
AcornDNS: z.Pointer("disabled"),
ClusterDomains: []string{".custom.com"},
},
expectedClusterDomains: []string{".custom.com"},
Expand All @@ -59,7 +59,7 @@ func TestAcornDNSStates(t *testing.T) {
// acornDNS is in "auto" mode. No user configured domain, expect local as a fallback
name: "acornDNS auto expect local clusterdomain",
conf: &apiv1.Config{
AcornDNS: z.P("auto"),
AcornDNS: z.Pointer("auto"),
},
expectedClusterDomains: []string{".local.oss-acorn.io"},
prepare: func(f *mocks.MockReader) {
Expand All @@ -71,7 +71,7 @@ func TestAcornDNSStates(t *testing.T) {
// acornDNS is in "auto" mode, but user configured a domain, expect just the user configured domain
name: "acornDNS auto expect custom clusterdomain",
conf: &apiv1.Config{
AcornDNS: z.P("auto"),
AcornDNS: z.Pointer("auto"),
ClusterDomains: []string{".custom.com"},
},
expectedClusterDomains: []string{".custom.com"},
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/appdefinition/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ func toDeployment(req router.Request, appInstance *v1.AppInstance, tag name.Refe
Affinity: appInstance.Status.Scheduling[name].Affinity,
Tolerations: appInstance.Status.Scheduling[name].Tolerations,
PriorityClassName: appInstance.Status.Scheduling[name].PriorityClassName,
TerminationGracePeriodSeconds: z.P[int64](5),
TerminationGracePeriodSeconds: z.Pointer[int64](5),
ImagePullSecrets: pullSecrets.ForContainer(name, append(containers, initContainers...)),
EnableServiceLinks: new(bool),
Containers: containers,
Expand All @@ -659,7 +659,7 @@ func toDeployment(req router.Request, appInstance *v1.AppInstance, tag name.Refe
}

if stateful {
dep.Spec.Replicas = z.P[int32](1)
dep.Spec.Replicas = z.Pointer[int32](1)
dep.Spec.Template.Spec.Hostname = dep.Name
dep.Spec.Strategy.Type = appsv1.RecreateDeploymentStrategyType
} else if dep.Spec.Replicas == nil || *dep.Spec.Replicas == 1 {
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/appdefinition/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func toJob(req router.Request, appInstance *v1.AppInstance, pullSecrets *PullSec
Spec: corev1.PodSpec{
Affinity: appInstance.Status.Scheduling[name].Affinity,
Tolerations: appInstance.Status.Scheduling[name].Tolerations,
TerminationGracePeriodSeconds: z.P[int64](5),
TerminationGracePeriodSeconds: z.Pointer[int64](5),
ImagePullSecrets: pullSecrets.ForContainer(name, append(containers, initContainers...)),
EnableServiceLinks: new(bool),
RestartPolicy: corev1.RestartPolicyNever,
Expand All @@ -164,7 +164,7 @@ func toJob(req router.Request, appInstance *v1.AppInstance, pullSecrets *PullSec
interpolator.AddMissingAnnotations(appInstance.GetStopped(), baseAnnotations)

if container.Schedule == "" {
jobSpec.BackoffLimit = z.P[int32](1000)
jobSpec.BackoffLimit = z.Pointer[int32](1000)
job := &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand Down Expand Up @@ -193,8 +193,8 @@ func toJob(req router.Request, appInstance *v1.AppInstance, pullSecrets *PullSec
Annotations: labels.Merge(getDependencyAnnotations(appInstance, name, container.Dependencies), baseAnnotations),
},
Spec: batchv1.CronJobSpec{
FailedJobsHistoryLimit: z.P[int32](3),
SuccessfulJobsHistoryLimit: z.P[int32](1),
FailedJobsHistoryLimit: z.Pointer[int32](3),
SuccessfulJobsHistoryLimit: z.Pointer[int32](1),
ConcurrencyPolicy: batchv1.ReplaceConcurrent,
Schedule: toCronJobSchedule(container.Schedule),
JobTemplate: batchv1.JobTemplateSpec{
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/appdefinition/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func toRouter(appInstance *v1.AppInstance, routerName string, router v1.Router)
Annotations: deploymentAnnotations,
},
Spec: corev1.PodSpec{
TerminationGracePeriodSeconds: z.P[int64](5),
TerminationGracePeriodSeconds: z.Pointer[int64](5),
EnableServiceLinks: new(bool),
Containers: []corev1.Container{
{
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/eventinstance/eventinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func (h handler) gcExpired(
if err := req.Client.Delete(req.Ctx, req.Object, kclient.Preconditions{
// Adding these preconditions prevents us from deleting an event based on old information.
// e.g. The observed time has been updated and the event is no longer expired.
UID: z.P(e.GetUID()),
ResourceVersion: z.P(e.GetResourceVersion()),
UID: z.Pointer(e.GetUID()),
ResourceVersion: z.Pointer(e.GetResourceVersion()),
}); err != nil && !apierrors.IsNotFound(err) {
// Assume any error other than not found is transient, return error to requeue w/ backoff
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/networkpolicy/networkpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func ForIngress(req router.Request, resp router.Response) error {
if (svcPort.Name != "" && svcPort.Name == port.Name) || svcPort.Port == port.Number {
targetPort := svcPort.TargetPort
netPolPorts = append(netPolPorts, networkingv1.NetworkPolicyPort{
Protocol: z.P(corev1.ProtocolTCP),
Protocol: z.Pointer(corev1.ProtocolTCP),
Port: &targetPort,
})
netPolName = name.SafeConcatName(netPolName, strconv.Itoa(int(targetPort.IntVal)))
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/scheduling/scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func ResourceRequirements(req router.Request, app *v1.AppInstance, containerName
if err != nil {
return nil, err
}
memMax = z.P(maxQuantity.Value())
memMax = z.Pointer(maxQuantity.Value())
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func createApp(ctx context.Context, client client.Client, hash clientHash, image

runArgs := opts.Run
runArgs.DeployArgs = deployArgs
runArgs.Stop = z.P(true)
runArgs.Stop = z.Pointer(true)

app, err := rulerequest.PromptRun(ctx, client, opts.Dangerous, image, runArgs)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/encryption/nacl/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func generateNewKeys(ctx context.Context, c kclient.Client, namespace string, ex

naclKey.acornNamespaceUID = string(ns.UID)
if existing == nil {
naclKey.Primary = z.P(true)
naclKey.Primary = z.Pointer(true)
}

return naclKey, createOrUpdateNaclKeySecret(ctx, c, naclKey, existing)
Expand Down
2 changes: 1 addition & 1 deletion pkg/imagesystem/buildertemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func BuilderObjects(name, namespace, forNamespace, buildKitImage, pub, privKey,
PeriodSeconds: 30,
},
SecurityContext: &corev1.SecurityContext{
Privileged: z.P(true),
Privileged: z.Pointer(true),
},
Ports: []corev1.ContainerPort{
{
Expand Down
Loading

0 comments on commit a3eaed4

Please sign in to comment.