-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: addition of getting machine pools and hitting the register clus…
…ter endpoint in KFM
- Loading branch information
Showing
4 changed files
with
281 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package kafkacmdutil | ||
|
||
import ( | ||
"fmt" | ||
"github.com/redhat-developer/app-services-cli/pkg/core/errors" | ||
"github.com/redhat-developer/app-services-cli/pkg/core/localize" | ||
"github.com/redhat-developer/app-services-cli/pkg/shared/factory" | ||
"strconv" | ||
) | ||
|
||
// Validator is a type for validating Kafka configuration values | ||
type Validator struct { | ||
Localizer localize.Localizer | ||
Connection factory.ConnectionFunc | ||
} | ||
|
||
func ValidateMachinePoolCount(count int) bool { | ||
// check if the count is a multiple of 3 and greater than or equal to 3 | ||
if count%3 == 0 && count >= 3 { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
func (v *Validator) ValidatorForMachinePoolNodes(val interface{}) error { | ||
value := fmt.Sprintf("%v", val) | ||
if val == "" { | ||
return errors.NewCastError(val, "emtpy string") | ||
} | ||
value1, err := strconv.Atoi(value) | ||
if err != nil { | ||
return errors.NewCastError(val, "integer") | ||
} | ||
if !ValidateMachinePoolCount(value1) { | ||
return fmt.Errorf("invalid input, machine pool node count must be greater than or equal to 3 and it " + | ||
"must be a is a multiple of 3") | ||
} | ||
return nil | ||
} |
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