utils

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package utils provides utility functions and structures for command-line argument parsing, version management, and common helper functions for the ARMV application.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# Name: jsonutils - helper functions to get the Powerstation Data from the API # Author: Aaron Saikovski - asaikovski@outlook.com

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	// AppDescription is the application description
	AppDescription = `` /* 181-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func CheckExists added in v1.2.0

func CheckExists(filePath string) bool

CheckExists checks if a file or folder exists at the specified filePath.

It returns a boolean indicating the existence of the file.

Parameters: - filePath: the path to the file to check.

Returns: - a boolean indicating whether the file exists or not.

func CheckValidSubscriptionID

func CheckValidSubscriptionID(subscriptionID string) bool

CheckValidSubscriptionID checks if the provided subscription ID is valid.

subscriptionID: a string representing a subscription ID bool: returns true if the subscription ID is valid, false otherwise

func CheckValidTenantID

func CheckValidTenantID(tenantID string) bool

CheckValidTenantID checks if the provided tenant ID is valid.

tenantID: a string representing a tenant ID bool: returns true if the tenant ID is valid, false otherwise

func GetVersion added in v1.2.2

func GetVersion() string

GetVersion returns the formatted version string

func HandleError

func HandleError(err error)

HandleError - Generic error handler

func MakeFolder added in v1.2.0

func MakeFolder(folderName string) error

MakeFolder creates a new folder with the specified folderName.

folderName: the name of the folder to be created. Returns an error if folder creation fails.

func MarshalStructToJSON added in v0.1.0

func MarshalStructToJSON(targetStruct interface{}) ([]byte, error)

MarshalStructToJSON marshals the struct to JSON.

Parameters: - targetStruct: the struct to be marshaled.

Returns: - []byte: the JSON representation of the struct. - error: an error if the marshaling process fails.

func OutputFail

func OutputFail(ErrorDetails string)

OutputFail prints an error message with the specified ErrorDetails.

Parameters: - ErrorDetails: details about the error that occurred.

No return value.

func OutputSuccess

func OutputSuccess(respStatus string)

OutputSuccess prints a success message indicating no Azure Resource Move Validation issues found.

Parameters: - respStatus: the status of the response.

No return value.

func PrettyJsonString added in v0.1.0

func PrettyJsonString(str string) (string, error)

PrettyJsonString takes a JSON string and returns a pretty-printed version of it.

Parameters: - str: the JSON string to be pretty-printed.

Returns: - string: the pretty-printed JSON string. - error: an error if the pretty-printing process fails.

func SetVersion added in v1.2.2

func SetVersion(version string)

SetVersion sets the package-level version string

func UnmarshalDataToStruct added in v0.1.0

func UnmarshalDataToStruct(respBody []byte, targetStruct interface{}) error

UnmarshalDataToStruct unmarshals the JSON data from the `respBody` byte slice into the `targetStruct` interface.

Parameters: - respBody: a byte slice containing the JSON data to be unmarshaled. - targetStruct: an interface{} to store the unmarshaled JSON data.

Returns: - error: an error if the unmarshaling process fails.

func WriteOutputFile added in v1.2.0

func WriteOutputFile(outputPath string, filename string, output string) error

WriteOutputFile writes the output to a file with the specified filename.

filename: the name of the file to write the output to. output: the content to be written to the file. Returns an error if writing fails.

Types

type Args

type Args struct {
	SourceSubscriptionId string
	SourceResourceGroup  string
	TargetSubscriptionId string
	TargetResourceGroup  string
	Debug                bool
	OutputPath           string
}

Args holds the command-line arguments

Jump to

Keyboard shortcuts

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