Skip to content

Correct way to create a fix that always runs? #153

@rubberduck203

Description

@rubberduck203

According to the documentation

In the event there are no defined check [sic], the fix will always run.

https://oscope-dev.github.io/scope/docs/models/ScopeDoctorGroup#actions

but creating an action without a check results in a schema validation failure

apiVersion: scope.github.com/v1alpha
kind: ScopeDoctorGroup
metadata:
  name: mvce
spec:
  actions:
    - name: always-run
      fix:
        commands:
          - echo 'hello world!'
scope doctor run -v --progress plain
 WARN Resource 'ScopeDoctorGroup/mvce' didn't match the schema for ScopeDoctorGroup. "check" is a required property
 WARN Could not find any tasks to execute
Summary: 0 groups succeeded
 INFO More detailed logs at /tmp/scope/scope-root-20241015-oyOG.log

I tried various other ways of not specifying a check as well.

  actions:
    - name: always-run
      check:
      fix:
        commands:
          - echo 'hello world!'
 WARN Resource 'ScopeDoctorGroup/mvce' didn't match the schema for ScopeDoctorGroup. null is not of type "object"

Which led me to this config, which does work as expected.

apiVersion: scope.github.com/v1alpha
kind: ScopeDoctorGroup
metadata:
  name: mvce
spec:
  actions:
    - name: always-run
      check: {}
      fix:
        commands:
          - echo 'hello world!'
scope doctor run -v --progress plain
mvce/always-run:  hello world!
 INFO Fix ran successfully, group: "mvce", name: "always-run"
Summary: 1 groups succeeded

It feels like either check shouldn't be required or the documentation needs to be updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions