Skip to content

Move desired_config validator out of WorkspaceAgentkStateCreator and into its own dedicated class

MR: Validate only kubernetes objects using JSON schema (!200985 - merged) • Ashvin Sharma • 18.4

Description

Introduce create desired_config chain in the "c... (!194589 - merged) introduced a new class called WorkspaceAgentkStateCreator that validates desired_config value object and saves desired_config in workspace_agentk_states table.

It makes more sense to create a new step in the ROP chain of creator.rb that only validates desired_config the comes from .map(DesiredConfig::Main.method(:main)) step.

In case of an error, the chain take the error path, otherwise the agentk state will be stored in .and_then(WorkspaceAgentkStateCreator.method(:create)) step.

Acceptance criteria

  • Create a step in the create.rb ROP chain that validates the desired_config
  • Ensure that the transaction is rolled back and the server returns an error to the client. Since this error might be a result of something went wrong in our own logic or devfile-gem. I would suggest we return 500 as the http response code.

Implementation plan

  • Create a new step in the ROP chain called DesiredConfigValidator
    • It should have a validate functions that calls DesiredConfig#valid? function.
    • In case of an error, wrap the error in Result#error and return this value
Edited by 🤖 GitLab Bot 🤖