utils

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Copyright 2023 KubeAGI.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License 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

View Source
const (
	KB = 1024
	MB = KB * 1024
	GB = MB * 1024
)
View Source
const (
	EnvNamespaceKey = "POD_NAMESPACE"
)

Variables

This section is empty.

Functions

func AddOrSwapString

func AddOrSwapString(strings []string, str string) (bool, []string)

AddOrSwapString Add an element to the string array, swap it with the last element if it is in the array, or append it directly to the end if it does not exist. Gives whether the array has changed

Example:
[], "a" -> true, []string{"a"}
["a"], "b" -> true, []string{"a", "b"}
["a", "b"], "a" -> true, []string{"b", "a"}
["a", "b", "a"], "a" -> false, []string{"a", "b", "a"}

func AddString

func AddString(finalizers []string, f string) []string

func BytesToSizedStr

func BytesToSizedStr(bytes int64) string

BytesToSize converts size(byte as the unit) to string with appropriate unit ending

func ContainString

func ContainString(finalizers []string, f string) bool

func GetCurrentNamespace

func GetCurrentNamespace() string

func ParseBase64ImageBytes added in v0.2.2

func ParseBase64ImageBytes(img string) ([]byte, error)

func RFC3339Time

func RFC3339Time(timeStr string) (time.Time, error)

RFC3339Time parses a time string to a Time with RFC3339 format

func RemoveString

func RemoveString(finalizers []string, f string) []string

Types

This section is empty.

Jump to

Keyboard shortcuts

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