-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(check): Failing checks and default location (#18)
* fix(check): Set MaxResponseTime correctly Previously we've been setting MaxResponseTime as the Frequency, MaxResponseTime is supposed to be in miliseconds, thus setting Frequency to 5, would make MaxResponseTime 5 miliseconds, the checklyhq backend didn't know what to do with this number so it was empty, created checks failed immediately. This fixes #17. * fix(check): Do not set location for checks Checks are tied to group, each group has location settings, we shouldn't set the default location to eu-west-1 anymore * test(debug): Add debug script for checkly checks
- Loading branch information
Showing
9 changed files
with
68 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# Ignore build and test binaries. | ||
bin/ | ||
testbin/ | ||
hack/ | ||
|
||
# direnv | ||
.envrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"flag" | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/checkly/checkly-go-sdk" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
) | ||
|
||
// The script returns the data for a specific checkly check from the checklyhq API, | ||
// it's meant to be used as a debug tool for issues with checks created. | ||
|
||
func main() { | ||
|
||
setupLog := ctrl.Log.WithName("setup") | ||
|
||
var checklyID string | ||
|
||
flag.StringVar(&checklyID, "c", "", "Specify the checkly check ID") | ||
flag.Parse() | ||
|
||
if checklyID == "" { | ||
setupLog.Error(errors.New("ChecklyID is empty"), "exiting due to missing information") | ||
os.Exit(1) | ||
} | ||
|
||
baseUrl := "https://api.checklyhq.com" | ||
apiKey := os.Getenv("CHECKLY_API_KEY") | ||
if apiKey == "" { | ||
setupLog.Error(errors.New("checklyhq.com API key environment variable is undefined"), "checklyhq.com credentials missing") | ||
os.Exit(1) | ||
} | ||
|
||
accountId := os.Getenv("CHECKLY_ACCOUNT_ID") | ||
if accountId == "" { | ||
setupLog.Error(errors.New("checklyhq.com Account ID environment variable is undefined"), "checklyhq.com credentials missing") | ||
os.Exit(1) | ||
} | ||
|
||
client := checkly.NewClient( | ||
baseUrl, | ||
apiKey, | ||
nil, //custom http client, defaults to http.DefaultClient | ||
nil, //io.Writer to output debug messages | ||
) | ||
|
||
client.SetAccountId(accountId) | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) | ||
defer cancel() | ||
|
||
returnedCheck, err := client.Get(ctx, checklyID) | ||
if err != nil { | ||
setupLog.Error(err, "failed to get check") | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Printf("%+v", returnedCheck) | ||
|
||
} |