github.com/docker/compose-on-kubernetes@v0.5.0/internal/convert/duration.go (about)

     1  package convert
     2  
     3  import "time"
     4  
     5  // toSecondsOrDefault converts a duration string in seconds and defaults to a
     6  // given value if the duration is nil.
     7  // The supported units are us, ms, s, m and h.
     8  func toSecondsOrDefault(duration *time.Duration, defaultValue int32) int32 { //nolint: unparam
     9  	if duration == nil {
    10  		return defaultValue
    11  	}
    12  
    13  	return int32(duration.Seconds())
    14  }