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 ¶
Copyright (c) 2024 Aaron Saikovski ¶
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 ¶
Copyright (c) 2024 Aaron Saikovski ¶
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 ¶
Copyright (c) 2024 Aaron Saikovski ¶
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 ¶
Copyright (c) 2024 Aaron Saikovski ¶
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
- func CheckExists(filePath string) bool
- func CheckValidSubscriptionID(subscriptionID string) bool
- func CheckValidTenantID(tenantID string) bool
- func GetVersion() string
- func HandleError(err error)
- func MakeFolder(folderName string) error
- func MarshalStructToJSON(targetStruct interface{}) ([]byte, error)
- func OutputFail(ErrorDetails string)
- func OutputSuccess(respStatus string)
- func PrettyJsonString(str string) (string, error)
- func SetVersion(version string)
- func UnmarshalDataToStruct(respBody []byte, targetStruct interface{}) error
- func WriteOutputFile(outputPath string, filename string, output string) error
- type Args
Constants ¶
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
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 ¶
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 ¶
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 MakeFolder ¶ added in v1.2.0
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
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
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
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
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.