utils

package
v0.0.0-...-37ff497 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2025 License: Apache-2.0 Imports: 18 Imported by: 8

Documentation

Overview

Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at

http://aws.amazon.com/apache2.0/

or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddScheme

func AddScheme(endpoint string) string

If the URL doesn't start with "http://" or "https://", prepends "https://" to the URL. Empty strings are returned as-is without modification

func FormatTime

func FormatTime(t time.Time) string

FormatTime returns a string value of the time. https://github.com/aws/aws-sdk-go/blob/main/private/protocol/timestamp.go#L55-L69

func GetNumCPU

func GetNumCPU() int

func Int32PtrToIntPtr

func Int32PtrToIntPtr(int32ptr *int32) *int

Int32PtrToIntPtr converts a *int32 to *int.

func Int64PtrToInt32Ptr

func Int64PtrToInt32Ptr(int64ptr *int64) *int32

Int64PtrToInt32Ptr converts a *int64 to *int32.

func MaxNum

func MaxNum[T constraints.Integer | constraints.Float](a, b T) T

MaxNum returns the maximum value between two numbers.

func ParseTime

func ParseTime(value string) (time.Time, error)

ParseTime attempts to parse the time given the format. Returns the time if it was able to be parsed, and fails otherwise. https://github.com/aws/aws-sdk-go/blob/main/private/protocol/timestamp.go#L73-L101

func SignHTTPRequest

func SignHTTPRequest(req *http.Request, region, service string, creds *aws.CredentialsCache, body io.ReadSeeker) error

SignHTTPRequest signs an http.Request struct with authv4 using the given region, service, and credentials.

func SignHTTPRequestV1

func SignHTTPRequestV1(req *http.Request, region, service string, creds *credentialsV1.Credentials, body io.ReadSeeker) error

SignHTTPRequestV1 signs an http.Request struct with authv4 using the given region, service, and credentials. TODO: Remove this once TCS adds support for AWS SDK v2 Credentials

func ToPtrSlice

func ToPtrSlice[V any](xs []V) []*V

ToPtrSlice converts a slices of values to a slice of pointers to those values.

func Uint16SliceToStringSlice

func Uint16SliceToStringSlice(slice []uint16) []string

Uint16SliceToStringSlice converts a slice of type uint16 to a slice of type string. It uses strconv.Itoa on each element

func ZeroOrNil

func ZeroOrNil(obj interface{}) bool

Types

type Timestamp

type Timestamp time.Time

type alias to workaround serializing time.Time into seconds UTC instead of RFC3339 example (original) timestamp: "2025-05-09T14:47:58.031Z" (customized) timestamp: "1746802078.031"

func (*Timestamp) MarshalJSON

func (t *Timestamp) MarshalJSON() ([]byte, error)

Follow aws-sdk-go (v1) behavior for time.Time serialization into UTC seconds (UnixTimeFormatName) https://github.com/aws/aws-sdk-go/blob/main/private/protocol/timestamp.go#L54-L69

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) error

Follow aws-sdk-go (v1) behavior for time.Time deserialization into UTC seconds (UnixTimeFormatName) https://github.com/aws/aws-sdk-go/blob/main/private/protocol/timestamp.go#L90-L97

Directories

Path Synopsis
Package cipher provides customized cipher configuration for agent client
Package cipher provides customized cipher configuration for agent client
mocks
Package mock_execwrapper is a generated GoMock package.
Package mock_execwrapper is a generated GoMock package.
Package httpproxy provides support for HTTP proxy determination based on environment variables, as provided by net/http's ProxyFromEnvironment function.
Package httpproxy provides support for HTTP proxy determination based on environment variables, as provided by net/http's ProxyFromEnvironment function.
mocks
Package mock_ioutilwrapper is a generated GoMock package.
Package mock_ioutilwrapper is a generated GoMock package.
mocks
Package mock_netlinkwrapper is a generated GoMock package.
Package mock_netlinkwrapper is a generated GoMock package.
mocks
Package mock_netwrapper is a generated GoMock package.
Package mock_netwrapper is a generated GoMock package.
mocks
Package mock_oswrapper is a generated GoMock package.
Package mock_oswrapper is a generated GoMock package.
mock
Package mock_retry is a generated GoMock package.
Package mock_retry is a generated GoMock package.
Package ttime implements a testable alternative to the Go "time" package.
Package ttime implements a testable alternative to the Go "time" package.
mocks
Package mock_ttime is a generated GoMock package.
Package mock_ttime is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL