Skip to content

feat: Added New schema for CCCO(HPCC) for contract validation#213

Merged
Sashwat-K merged 1 commit intoibm-hyper-protect:mainfrom
Rohit-Singh43-1:coco-schema-update
Apr 1, 2026
Merged

feat: Added New schema for CCCO(HPCC) for contract validation#213
Sashwat-K merged 1 commit intoibm-hyper-protect:mainfrom
Rohit-Singh43-1:coco-schema-update

Conversation

@Rohit-Singh43-1
Copy link
Copy Markdown
Contributor

  • confidential-container section will be validated in case of CCCO (HPCC) using new json schema.

Description

contract with confidential container parameter under env or workload section will be validated against new schema.

Related Issue

Fixes #191

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactor (no functional changes)
  • CI/CD or build changes

Target Platform

  • HPVS (IBM Confidential Computing Container Runtime)
  • HPCR-RHVS (IBM Confidential Computing Container Runtime for Red Hat Virtualization Solutions)
  • HPCC-PeerPod (IBM Confidential Computing Containers for Red Hat OpenShift Container Platform)
  • All platforms
  • Not platform-specific

Testing

  • make test passes
  • make fmt applied (no formatting changes needed)
  • New tests added for new functionality (if applicable)

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my code
  • I have added/updated GoDoc comments for public functions
  • I have updated documentation (README, docs/README.md) if needed
  • All new and existing tests pass (make test)
  • I have verified there are no breaking changes (or documented them above)

Comment thread common/general/general.go
Comment thread common/general/general_test.go Outdated

func TestVerifyContractWithSchemaValidConfidentialContainers(t *testing.T) {
// Contract with ALL required fields for confidential-containers
contract := `workload: |
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

keep sample contract in samples folder
samples -> hpcc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@vikas-sharma24 Thanks for the review , So you can see there are multiple test case for validation of both-ve and +ve cases if i move each contract file under samples , there will be more files under that So i have created string type of contract for validation at runtime .
Thanks.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Sashwat-K any suggestion here
I feel keeping contract sample in samples -> hpcc folder make more sense then keeping contract sample in testcases

Can you suggest what can we do here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would agree with @vikas-sharma24 . If you check the existing repo, we have created files instead of defining it in const

Comment thread common/general/general_test.go Outdated
assert.Error(t, err)
}

func TestVerifyContractWithSchemaValidConfidentialContainers(t *testing.T) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

add testcase description

Comment thread common/general/general_test.go Outdated
// This SHOULD pass because all required fields are present
err := VerifyContractWithSchema(contract, "hpcc-peerpod")

// Assert that validation passes
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I dont think this is needed as it will add extra log statements in console when we run testcases
@Sashwat-K any suggestion here

Comment thread common/general/general_test.go Outdated
// NEGATIVE TEST 1: Testcase to verify validation fails when regoValidator is missing
func TestVerifyContractWithSchemaMissingRegoValidator(t *testing.T) {
// Contract with confidential-containers but missing regoValidator
contract := `workload: |
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same keep sample in samples -> hpcc folder

Comment thread common/general/general_test.go Outdated
}

// NEGATIVE TEST 2: Testcase to verify validation fails when only config is provided
func TestVerifyContractWithSchemaMinimalConfidentialContainers(t *testing.T) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is TestVerifyContractWithSchemaMissingRegoValidator and TestVerifyContractWithSchemaMinimalConfidentialContainers verifying same case?

Copy link
Copy Markdown
Contributor Author

@Rohit-Singh43-1 Rohit-Singh43-1 Mar 31, 2026

Choose a reason for hiding this comment

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

No
In TestVerifyContractWithSchemaMissingRegoValidator --> regovalidator parameter is missing which will cause the validation failure
In TestVerifyContractWithSchemaMinimalConfidentialContainers --> regovalidator field is present what policy which is required under regovalidator is missing , its one of the test case which validates the instead fields.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

sure Thanks @Rohit-Singh43-1

@vikas-sharma24 vikas-sharma24 mentioned this pull request Apr 1, 2026
20 tasks
@Sashwat-K
Copy link
Copy Markdown
Collaborator

Hey @Rohit-Singh43-1 , there are some conflicts due to latest changes. Please fix them.

Signed-off-by: Rohit.Singh43@ibm.com <Rohit.Singh43@ibm.com>
Copy link
Copy Markdown
Collaborator

@vikas-sharma24 vikas-sharma24 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Collaborator

@Sashwat-K Sashwat-K left a comment

Choose a reason for hiding this comment

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

Nice work @Rohit-Singh43-1

@Sashwat-K
Copy link
Copy Markdown
Collaborator

Thank you @Rohit-Singh43-1 for adding this feature

@Sashwat-K Sashwat-K merged commit 9e69605 into ibm-hyper-protect:main Apr 1, 2026
3 checks passed
@Sashwat-K Sashwat-K added the enhancement New feature or request label Apr 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

🎉 This PR is included in version 2.17.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add schema for HPCC contracts

3 participants