Skip to content
Open
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
4 changes: 2 additions & 2 deletions engine/graph/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ func (obj *Engine) Worker(vertex pgraph.Vertex) error {

var err error
var retry = res.MetaParams().Retry // lookup the retry value
var delay uint64
var delay uint
for { // retry loop
// a retry-delay was requested, wait, but don't block events!
if delay > 0 {
Expand Down Expand Up @@ -706,7 +706,7 @@ Loop:
// retry...
var err error
//var retry = res.MetaParams().Retry // lookup the retry value
var delay uint64
var delay uint
RetryLoop:
for { // retry loop
if delay > 0 {
Expand Down
2 changes: 1 addition & 1 deletion engine/metaparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type MetaParams struct {

// Delay is the number of milliseconds to wait between retries. This
// value is used for both Watch and CheckApply.
Delay uint64 `yaml:"delay"`
Delay uint `yaml:"delay"`

// Poll is the number of seconds between poll intervals. Use 0 to Watch.
Poll uint32 `yaml:"poll"`
Expand Down
2 changes: 1 addition & 1 deletion engine/resources/docker_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ type DockerContainerRes struct {
// Ports is a map of port bindings. E.g. {"tcp" => {8080 => 80},}. The
// key is the host port, and the val is the inner service port to
// forward to.
Ports map[string]map[int64]int64 `lang:"ports" yaml:"ports"`
Ports map[string]map[int]int `lang:"ports" yaml:"ports"`

// APIVersion allows you to override the host's default client API
// version.
Expand Down
2 changes: 1 addition & 1 deletion engine/resources/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type ExecRes struct {
// Timeout is the number of seconds to wait before sending a Kill to the
// running command. If the Kill is received before the process exits,
// then this be treated as an error.
Timeout uint64 `lang:"timeout" yaml:"timeout"`
Timeout uint `lang:"timeout" yaml:"timeout"`

// Env allows the user to specify environment variables for script
// execution. These are taken using a map of format of VAR_KEY -> value.
Expand Down
4 changes: 2 additions & 2 deletions engine/resources/gsettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ func (obj *GsettingsRes) value() (string, error) {
}

if obj.Type == "int" {
v, ok := obj.Value.(int64)
v, ok := obj.Value.(int)
if !ok {
return "", fmt.Errorf("invalid int, got: %T", obj.Value)
}
return strconv.FormatInt(v, 10), nil
return strconv.Itoa(v), nil
}

if obj.Type == "custom" {
Expand Down
20 changes: 10 additions & 10 deletions engine/resources/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,19 @@ type HTTPServerRes struct {
// the value for the other *Timeout values when they aren't used. Put
// another way, this makes it easy to set all the different timeouts
// with a single parameter.
Timeout *uint64 `lang:"timeout" yaml:"timeout"`
Timeout *uint `lang:"timeout" yaml:"timeout"`

// ReadTimeout is the maximum duration in seconds for reading during the
// http request. If it is zero, then there is no timeout. If this is
// unspecified, then the value of Timeout is used instead if it is set.
// For more information, see the golang net/http Server documentation.
ReadTimeout *uint64 `lang:"read_timeout" yaml:"read_timeout"`
ReadTimeout *uint `lang:"read_timeout" yaml:"read_timeout"`

// WriteTimeout is the maximum duration in seconds for writing during
// the http request. If it is zero, then there is no timeout. If this is
// unspecified, then the value of Timeout is used instead if it is set.
// For more information, see the golang net/http Server documentation.
WriteTimeout *uint64 `lang:"write_timeout" yaml:"write_timeout"`
WriteTimeout *uint `lang:"write_timeout" yaml:"write_timeout"`

// ShutdownTimeout is the maximum duration in seconds to wait for the
// server to shutdown gracefully before calling Close. By default it is
Expand All @@ -141,7 +141,7 @@ type HTTPServerRes struct {
// indefinitely. The shutdown process can also be cancelled by the
// interrupt handler which this resource supports. If this is
// unspecified, then the value of Timeout is used instead if it is set.
ShutdownTimeout *uint64 `lang:"shutdown_timeout" yaml:"shutdown_timeout"`
ShutdownTimeout *uint `lang:"shutdown_timeout" yaml:"shutdown_timeout"`

// Root is the root directory that we should serve files from. If it is
// not specified, then it is not used. Any http file resources will have
Expand Down Expand Up @@ -175,7 +175,7 @@ func (obj *HTTPServerRes) getAddress() string {

// getReadTimeout determines the value for ReadTimeout, because if unspecified,
// this will default to the value of Timeout.
func (obj *HTTPServerRes) getReadTimeout() *uint64 {
func (obj *HTTPServerRes) getReadTimeout() *uint {
if obj.ReadTimeout != nil {
return obj.ReadTimeout
}
Expand All @@ -184,7 +184,7 @@ func (obj *HTTPServerRes) getReadTimeout() *uint64 {

// getWriteTimeout determines the value for WriteTimeout, because if
// unspecified, this will default to the value of Timeout.
func (obj *HTTPServerRes) getWriteTimeout() *uint64 {
func (obj *HTTPServerRes) getWriteTimeout() *uint {
if obj.WriteTimeout != nil {
return obj.WriteTimeout
}
Expand All @@ -193,7 +193,7 @@ func (obj *HTTPServerRes) getWriteTimeout() *uint64 {

// getShutdownTimeout determines the value for ShutdownTimeout, because if
// unspecified, this will default to the value of Timeout.
func (obj *HTTPServerRes) getShutdownTimeout() *uint64 {
func (obj *HTTPServerRes) getShutdownTimeout() *uint {
if obj.ShutdownTimeout != nil {
return obj.ShutdownTimeout
}
Expand Down Expand Up @@ -407,11 +407,11 @@ func (obj *HTTPServerRes) Watch(ctx context.Context) error {
// essentially having our own "router" API with AcceptHTTP.
obj.serveMux.HandleFunc("/", obj.handler())

readTimeout := uint64(0)
readTimeout := uint(0)
if i := obj.getReadTimeout(); i != nil {
readTimeout = *i
}
writeTimeout := uint64(0)
writeTimeout := uint(0)
if i := obj.getWriteTimeout(); i != nil {
writeTimeout = *i
}
Expand Down Expand Up @@ -664,7 +664,7 @@ func (obj *HTTPServerRes) Interrupt() error {
// Copy copies the resource. Don't call it directly, use engine.ResCopy instead.
// TODO: should this copy internal state?
func (obj *HTTPServerRes) Copy() engine.CopyableRes {
var timeout, readTimeout, writeTimeout, shutdownTimeout *uint64
var timeout, readTimeout, writeTimeout, shutdownTimeout *uint
if obj.Timeout != nil {
x := *obj.Timeout
timeout = &x
Expand Down
2 changes: 1 addition & 1 deletion engine/resources/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func FileOwnerExpect(p, o string) Step { // path & owner
if err != nil {
return err
}
if i != uint64(stat.Uid) {
if uint32(i) != stat.Uid {
return fmt.Errorf("file uid did not match in %s", p)
}
return nil
Expand Down
8 changes: 4 additions & 4 deletions engine/resources/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@ func init() {
"format": {
"unknown": func() interfaces.Var {
return &types.IntValue{
V: int64(tar.FormatUnknown),
V: int(tar.FormatUnknown),
}
},
"ustar": func() interfaces.Var {
return &types.IntValue{
V: int64(tar.FormatUSTAR),
V: int(tar.FormatUSTAR),
}
},
"pax": func() interfaces.Var {
return &types.IntValue{
V: int64(tar.FormatPAX),
V: int(tar.FormatPAX),
}
},
"gnu": func() interfaces.Var {
return &types.IntValue{
V: int64(tar.FormatGNU),
V: int(tar.FormatGNU),
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion engine/resources/tftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type TFTPServerRes struct {
Address string `lang:"address" yaml:"address"`

// Timeout is the timeout in seconds to use for server connections.
Timeout uint64 `lang:"timeout" yaml:"timeout"`
Timeout uint `lang:"timeout" yaml:"timeout"`

// Root is the root directory that we should serve files from. If it is
// not specified, then it is not used. Any tftp file resources will have
Expand Down
3 changes: 2 additions & 1 deletion examples/dhcp_client/dhcp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"log"
"net"
"os"
"strconv"

"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/insomniacslk/dhcp/dhcpv4/nclient4"
Expand All @@ -39,7 +40,7 @@ func main() {
return
}

port := string(nclient4.ServerPort) // the default is 67
port := strconv.Itoa(int(nclient4.ServerPort)) // the default is 67
if len(os.Args) >= 3 {
port = os.Args[1]
}
Expand Down
4 changes: 2 additions & 2 deletions lang/ast/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3988,7 +3988,7 @@ func (obj *StmtFor) Graph(env *interfaces.Env) (*pgraph.Graph, error) {
Textarea: obj.Textarea, // XXX: advance by `for ` chars?

Value: &types.IntValue{
V: int64(index),
V: index,
},
NameHint: obj.Index, // XXX: is this right?
}
Expand Down Expand Up @@ -7718,7 +7718,7 @@ type ExprInt struct {
data *interfaces.Data
scope *interfaces.Scope // store for referencing this later

V int64
V int
}

// String returns a short representation of this expression.
Expand Down
4 changes: 1 addition & 3 deletions lang/core/convert/str_to_int.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ func StrToInt(ctx context.Context, input []types.Value) (types.Value, error) {
return nil, fmt.Errorf("not enough args")
}

base := 10
bits := 64 // TODO: get from runtime?
x, err := strconv.ParseInt(input[0].Str(), base, bits)
x, err := strconv.Atoi(input[0].Str())
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion lang/core/convert/to_float_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/purpleidea/mgmt/lang/types"
)

func testToFloat(t *testing.T, input int64, expected float64) {
func testToFloat(t *testing.T, input int, expected float64) {
got, err := ToFloat(context.Background(), []types.Value{&types.IntValue{V: input}})
if err != nil {
t.Error(err)
Expand Down
2 changes: 1 addition & 1 deletion lang/core/convert/to_int.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ func init() {
// ToInt converts a float to an integer.
func ToInt(ctx context.Context, input []types.Value) (types.Value, error) {
return &types.IntValue{
V: int64(input[0].Float()),
V: int(input[0].Float()),
}, nil
}
2 changes: 1 addition & 1 deletion lang/core/convert/to_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/purpleidea/mgmt/lang/types"
)

func testToInt(t *testing.T, input float64, expected int64) {
func testToInt(t *testing.T, input float64, expected int) {

got, err := ToInt(context.Background(), []types.Value{&types.FloatValue{V: input}})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion lang/core/datetime/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func Format(ctx context.Context, input []types.Value) (types.Value, error) {
}
format := input[1].Str()

v := time.Unix(epochDelta, 0).Format(format)
v := time.Unix(int64(epochDelta), 0).Format(format)
return &types.StrValue{
V: v,
}, nil
Expand Down
4 changes: 2 additions & 2 deletions lang/core/datetime/hour.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func Hour(ctx context.Context, input []types.Value) (types.Value, error) {
return nil, fmt.Errorf("epoch delta must be positive")
}

hour := time.Unix(epochDelta, 0).Hour()
hour := time.Unix(int64(epochDelta), 0).Hour()
return &types.IntValue{
V: int64(hour),
V: hour,
}, nil
}
2 changes: 1 addition & 1 deletion lang/core/datetime/now.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@ func (obj *Now) Stream(ctx context.Context) error {
// Call this fact and return the value if it is possible to do so at this time.
func (obj *Now) Call(ctx context.Context, args []types.Value) (types.Value, error) {
return &types.IntValue{ // seconds since 1970...
V: time.Now().Unix(), // .UTC() not necessary
V: int(time.Now().Unix()), // .UTC() not necessary
}, nil
}
2 changes: 1 addition & 1 deletion lang/core/datetime/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ func Print(ctx context.Context, input []types.Value) (types.Value, error) {
return nil, fmt.Errorf("epoch delta must be positive")
}
return &types.StrValue{
V: time.Unix(epochDelta, 0).String(),
V: time.Unix(int64(epochDelta), 0).String(),
}, nil
}
2 changes: 1 addition & 1 deletion lang/core/datetime/weekday.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func Weekday(ctx context.Context, input []types.Value) (types.Value, error) {
return nil, fmt.Errorf("epoch delta must be positive")
}

weekday := time.Unix(epochDelta, 0).Weekday()
weekday := time.Unix(int64(epochDelta), 0).Weekday()
return &types.StrValue{
V: strings.ToLower(weekday.String()),
}, nil
Expand Down
4 changes: 2 additions & 2 deletions lang/core/example/str2int.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func init() {
// Str2Int takes an str, and returns it as an int. If it can't convert it, it
// returns 0.
func Str2Int(ctx context.Context, input []types.Value) (types.Value, error) {
var i int64
if val, err := strconv.ParseInt(input[0].Str(), 10, 64); err == nil {
var i int
if val, err := strconv.Atoi(input[0].Str()); err == nil {
i = val
}
return &types.IntValue{
Expand Down
6 changes: 3 additions & 3 deletions lang/core/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ type HistoryFunc struct {

init *interfaces.Init

input chan int64
delay *int64
input chan int
delay *int

value types.Value // last value
buffer []*valueWithTimestamp
Expand Down Expand Up @@ -187,7 +187,7 @@ func (obj *HistoryFunc) Info() *interfaces.Info {
// Init runs some startup code for this function.
func (obj *HistoryFunc) Init(init *interfaces.Init) error {
obj.init = init
obj.input = make(chan int64)
obj.input = make(chan int)
obj.mutex = &sync.Mutex{}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion lang/core/iter/range.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (obj *RangeFunc) Call(ctx context.Context, args []types.Value) (types.Value

// loop is the private helper function that calculates the range according to
// the inputs provided.
func (obj *RangeFunc) loop(ctx context.Context, start, stop, step int64) (types.Value, error) {
func (obj *RangeFunc) loop(ctx context.Context, start, stop, step int) (types.Value, error) {
if step == 0 {
return nil, fmt.Errorf("step value cannot be 0")
}
Expand Down
2 changes: 1 addition & 1 deletion lang/core/len.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ func Len(ctx context.Context, input []types.Value) (types.Value, error) {
}

return &types.IntValue{
V: int64(length),
V: length,
}, nil
}
2 changes: 1 addition & 1 deletion lang/core/local/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,6 @@ func (obj *PoolFunc) Call(ctx context.Context, args []types.Value) (types.Value,
return nil, err
}
return &types.IntValue{
V: int64(result),
V: result,
}, nil
}
2 changes: 1 addition & 1 deletion lang/core/math/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ func Mod(ctx context.Context, input []types.Value) (types.Value, error) {
}, nil
}
return &types.IntValue{
V: int64(z), // XXX: does this truncate?
V: int(z), // XXX: does this truncate?
}, nil
}
Loading
Loading