Git Product home page Git Product logo

addon-metadata-operator's People

Contributors

ajpantuso avatar ankit152 avatar apahim avatar ashishmax31 avatar dependabot[bot] avatar erdii avatar garrettthomaskth avatar mayankshah1607 avatar rpriyanshu9 avatar sandhyadalavi avatar sugarraysam avatar yashvardhan-kukreja avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

addon-metadata-operator's Issues

Implement Metadata and Bundle Validation

Here is a list of metadata validation to be performed:

Metadata Validator

Design

Goals:

  • Unordered independent validators
  • Field level validation
  • Struct level validation (cross-field)

Proposal:

Was thinking about using go-playground/vaidator and the RegisterStructValidation interface. Go-playground provides an easy way to perform:

  1. Field level validation (using annotating tags)
  2. Struct-level validation (using RegisterStructValidation + validate.Struct(...))
// --- cross field validation ---
// type StructLevelFunc func(sl validator.StructLevel)
// func (v *Validate) RegisterStructValidation(fn StructLevelFunc, types ...interface{})

// Example: https://github.com/go-playground/validator/blob/master/_examples/struct-level/main.go

type AddonMetadata struct {
    // define fields and a validation tag for field-level validation
}

var validate *validator.Validate

func main() {
  validate = validator.New()
  for _, fn := range getAllValidationFuncs() {
    validate.RegisterStructValidation(fn, AddonMetadata{})
  }
  
  // perform struct level validation against instances of AddonMetadata{} type
  err := validate.Struct(<addon_struct>)
}

func getAllValidationFuncs() []validator.StructLevelFunc {
  res := make([]validator.StructLevelFunc)
  res = append(res, MetadataStructLevelValidation)
  // add more
  return res
}

func MetadataStructLevelValidation(sl validator.StructLevel) {
  addonMetadata := sl.Current().Interface().(AddonMetadata)
  // validate something at the struct level (get access to all fields)
}

Validation

  • Validate extra resources, against a schema, and document which CR are accepted (currently we only validate the extraResource path exists)
    • validates DeadmansSnitchIntegration field snitchNamePostFix is present and does not start with hive-
  • run all pattern checks (try to migrate regex to something better)
  • If a top-level key of the jsonschema is present twice should error (e.g.: addOnRequirements key was present twice without causing error)
    • tasks/check/01_test_duplicated.py <= why are there exceptions? why not all fields?
  • validate namespaces:
    • check the targetNamespace is present in the namespaces list
    • namespaces need to be prefixed by redhat-
    • tasks/check/09_test_namespaces.py <= why exceptions?
  • make sure all images exist in their repos tasks/check/10_test_harness.py
  • test icon is base64 encoded, and is valid tasks/check/20_test_icon.py
  • check the ocmQuotaName has an addon SKU in OCM tasks/check/30_test_metadata.py
  • validate addOnParameters with their provided validation field tasks/check/40_test_addon_parameters.py
  • validate k8s resources are DNS compliant (< 63 characters) and matches regex (use k8s libraries here)
  • validate Channels name are part of enum (alpha, beta, stable, edge, rc)
  • validate link points to a HTTP doc (exists)
  • look at: https://<gitlab_url>/service/managed-tenants/-/blob/main/docs/tenants/metadata_specification.md
  • validate relatedImages from imagesets:
    • are in supported registries (only quay.io for now -> make it extensible)
    • can be pulled by OSD <-- How do we confirm this? Need service account similar to devtools private CatalogSource.
  • validate that the defaultChannel is listed in the list of channels
  • validate that namespaces are given access to us through backplane (example for RHODS: https://github.com/openshift/managed-cluster-config/blob/master/deploy/backplane/mtsre/managed-odh/)

Bundle Validator

Design

  • Gets a temporary path where bundles are extracted
  • Also has access to metadata

Validation

# makes 1.0.0,1.0.1,1.0.2 uninstallable
metadata:
  name: myoperator.v1.0.3
  annotations:
    olm.skipRange: ">=1.0.0 <1.0.3"
  • targetNamespace should match namespace in CSV to make sure the OperatorGroup lives in same namespace as CSV
  • make sure the pkgName from the annotations.yaml file (operators.operatorframework.io.bundle.package.v1: <pkgName>) - matches the operatorName from the metadata. This is because the Subscription object that is created uses the operatorName to find the pkgname. (The template says {{ ADDON.metadata['id'] }} but it is patched by tasks/deploy/50_post_SelectorSyncSet.py) <-- probably should improve clarity of what gets templated here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.