Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added new int64ToPtr method to api/util to avoid pulling in other pac…
Browse files Browse the repository at this point in the history
…kages
cgbaker committed Mar 23, 2020
1 parent bf7b5d0 commit da3c2a4
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 1 addition & 3 deletions api/jobs.go
Original file line number Diff line number Diff line change
@@ -8,8 +8,6 @@ import (
"time"

"github.com/gorhill/cronexpr"

"github.com/hashicorp/nomad/helper"
)

const (
@@ -161,7 +159,7 @@ func (j *Jobs) Scale(jobID, group string, count *int,
reason, error *string, meta map[string]interface{}, q *WriteOptions) (*JobRegisterResponse, *WriteMeta, error) {
var count64 *int64
if count != nil {
count64 = helper.Int64ToPtr(int64(*count))
count64 = int64ToPtr(int64(*count))
}
req := &ScalingRequest{
Count: count64,
9 changes: 2 additions & 7 deletions api/util_test.go
Original file line number Diff line number Diff line change
@@ -52,8 +52,8 @@ func testJobWithScalingPolicy() *Job {
job := testJob()
job.TaskGroups[0].Scaling = &ScalingPolicy{
Policy: map[string]interface{}{},
Min: int64ToPtr(1),
Max: 1,
Min: int64ToPtr(1),
Max: 1,
Enabled: boolToPtr(true),
}
return job
@@ -94,11 +94,6 @@ func testQuotaSpec() *QuotaSpec {
// conversions utils only used for testing
// added here to avoid linter warning

// int64ToPtr returns the pointer to an int
func int64ToPtr(i int64) *int64 {
return &i
}

// float64ToPtr returns the pointer to an float64
func float64ToPtr(f float64) *float64 {
return &f
5 changes: 5 additions & 0 deletions api/utils.go
Original file line number Diff line number Diff line change
@@ -26,6 +26,11 @@ func uint64ToPtr(u uint64) *uint64 {
return &u
}

// int64ToPtr returns the pointer to a int64
func int64ToPtr(u int64) *int64 {
return &u
}

// stringToPtr returns the pointer to a string
func stringToPtr(str string) *string {
return &str

0 comments on commit da3c2a4

Please sign in to comment.