Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Dat 3230 validate k8s (wip) #34

Merged
merged 51 commits into from
May 20, 2021
Merged

Dat 3230 validate k8s (wip) #34

merged 51 commits into from
May 20, 2021

Conversation

noaabarki
Copy link
Contributor

No description provided.

PrintSummaryTable(summary printer.Summary)
}

// url := "https://app.datree.io/login?cliId=" + cliId
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment


// url := "https://app.datree.io/login?cliId=" + cliId
func PrintResults(results *EvaluationResults, loginURL string, outputFormat string, printer Printer) error {
switch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love this!!

"sync"

"github.com/datreeio/datree/bl/files"
kubeconformValidator "github.com/yannh/kubeconform/pkg/validator"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to specify specific commit here? to try and keep it more stable

}

func version(ctx *VersionCommandContext) {
messageChannel := bl.PopulateVersionMessageChan(ctx.VersionMessageClient, ctx.CliVersion)
messages := make(chan *messager.VersionMessage, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can only have one message. I think this assumes that each version supports multiple messages which we don't at the moment.
Not a big issue, just pointing it out

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as much as I know this is the best way to handle 1 buffered channels (the last argument 1 indicates that this channel is allocated to only one member)

}

func (c *CliClient) CreateEvaluation(request *CreateEvaluationRequest) (int, error) {
httpRes, err := c.httpClient.Request(http.MethodPost, "/cli/evaluate/create", request, nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request url is cli/evaluation/create
Yishay's fix

type UpdateEvaluationValidationRequest struct {
EvaluationId int `json:"evaluationId"`
InvalidFiles []*string `json:"failedFiles"`
StopEvaluation bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing json expected value stopEvaluation

cmd/test/main.go Outdated

config, err := ctx.LocalConfig.GetConfiguration()
validPaths, invalidPaths, _ := ctx.Validator.Validate(paths)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kubeconform step is performed before the createEvaluation request. although it doesn't make much difference right now because they are unrelated steps, I feel like conseptually we should run the validation step after we create an evaluation.
In case there's a panic inside validate or whatever, this might break the flow without any record of it being run.
also, we will later add another step (yamlValidation) and I think we should keep the step 0 -> 1 -> 2 -> 3 structure

cmd/test/main.go Outdated
if err != nil {
fmt.Println(err.Error())
return err
}

evaluationResponse, fileParsingErrors, err := ctx.Evaluator.Evaluate(paths, config.CliId, 50, ctx.CliVersion)
results, errors, err := ctx.Evaluator.Evaluate(validPaths, invalidPaths, evaluationId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you chose here to forward the invalidPaths array into the evaluate function and let the evaluator deal with it.
note that if we're giving the evaluator the 'power' to handle invalid files, we will need to later enhance it once we add the second validation - yaml validation (step 1).
not a deal breaker, just pointing that out.

@alexfedin alexfedin merged commit eb7bf00 into staging May 20, 2021
@delete-merged-branch delete-merged-branch bot deleted the DAT-3230-validate-k8s branch May 20, 2021 08:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants