Skip to content

Instantly share code, notes, and snippets.

View Praveen005's full-sized avatar
🎯
Focusing

Praveen Kumar Praveen005

🎯
Focusing
View GitHub Profile
@Praveen005
Praveen005 / errors.go
Created July 22, 2024 14:12
extracting json part from the error message.
// CustomError stores a part of the complete API error
type CustomError struct {
Code string `json:"code"`
Reason string `json:"reason"`
}
// Error implements the error interface
func (e *CustomError) Error() string {
return fmt.Sprintf("%s - %s", e.Code, e.Reason)
}
@Praveen005
Praveen005 / error.go
Last active July 22, 2024 12:41
Improving retries and error handling in Civo TF Provider, Issue: #263
package utils
import "strings"
// IsRetryableError determines if an error is retryable
func IsRetryableError(err error) bool {
for _, error := range RetryableErrors {
if strings.Contains(err.Error(), error) {
return true
}
@Praveen005
Praveen005 / provider.go
Last active July 8, 2024 08:47
Feature requested in #246 for terraform-provider-civo
package civo
import (
"encoding/json"
"fmt"
"log"
"os"
"path/filepath"
"github.com/civo/civogo"
@Praveen005
Praveen005 / color_util.go
Created June 23, 2024 18:28
Use ANSI color codes in place of third party library for Console Colors
package utility
import (
"fmt"
"os"
"github.com/civo/cli/common"
)
const (