Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for kfaas availability in a region #325

Merged
merged 2 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cmd/kfcluster/kfcluster_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ var kfcCreateCmd = &cobra.Command{
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
utility.EnsureCurrentRegion()

check, region, err := utility.CheckAvailability("kfaas", common.RegionSet)
if err != nil {
utility.Error("Error checking availability %s", err)
os.Exit(1)
}

if !check {
utility.Error("Sorry you can't create a kubernetes cluster in the %s region", region)
os.Exit(1)
}

client, err := config.CivoAPIClient()
if err != nil {
utility.Error("Creating the connection to Civo's API failed with %s", err)
Expand Down Expand Up @@ -73,7 +85,6 @@ var kfcCreateCmd = &cobra.Command{
NetworkID: network.ID,
Size: size,
FirewallID: firewallID,
Region: client.Region,
RealHarshThakur marked this conversation as resolved.
Show resolved Hide resolved
}

kfc, err := client.CreateKfCluster(kfCluster)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
github.com/briandowns/spinner v1.11.1
github.com/c4milo/unpackit v0.0.0-20170704181138-4ed373e9ef1c // indirect
github.com/civo/civogo v0.3.38
github.com/civo/civogo v0.3.39
github.com/dsnet/compress v0.0.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/google/go-github v17.0.0+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/civo/civogo v0.3.38 h1:ZqGtAfAOB+J3ZgDgMruNEEi1wXHzMtrDi/4mhYPefAg=
github.com/civo/civogo v0.3.38/go.mod h1:54lv/FOf7gh6wE9ZwVdw4yBehk8V1CvU9aWa4v6dvW0=
github.com/civo/civogo v0.3.39 h1:oo9MlLaP9+iDdibFlgacCVd9771BOnOF1vt6G3PeQGg=
github.com/civo/civogo v0.3.39/go.mod h1:54lv/FOf7gh6wE9ZwVdw4yBehk8V1CvU9aWa4v6dvW0=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down
6 changes: 6 additions & 0 deletions utility/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ func CheckAvailability(resource string, regionSet string) (bool, string, error)
}
}

if resource == "kfaas" {
if defaultRegion.Features.KFaaS && !defaultRegion.OutOfCapacity {
return true, "", nil
}
}

return false, defaultRegion.Code, nil
}

Expand Down