Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support task-schema refactor #217

Merged
merged 1 commit into from
Jan 20, 2017

Conversation

yyscamper
Copy link
Contributor

Change including:
(1) Task-Definition: replace schemaRef with optionsSchema, optionsSchema can be either string or object, so set its type to json.
(2) add removeSchema API for JSON schema validator;

@RackHD/corecommitters @iceiilin @pengz1 @cgx027 @lanchongyizu @amymullins

@brianparry
Copy link
Contributor

Hi @yyscamper. I'm curious where this PR stands at the moment. Do you intend to make any additional changes such as those we discussed during your visit?

@yyscamper
Copy link
Contributor Author

@brianparry No additional change, I was trying to resolve the conflict and rebase my code to make sure the dependency Jenkins passes, then I will base on this code to do stress testing. This is the reason why you see the Jenkins becomes active again.

@cgx027
Copy link
Contributor

cgx027 commented Dec 5, 2016

Looks good to me. 👍

@JenkinsRHD
Copy link
Contributor

BUILD on-core #964 : FAILURE

@changev
Copy link
Member

changev commented Dec 26, 2016

test this please

@JenkinsRHD
Copy link
Contributor

BUILD on-core #966 : FAILURE

@PengTian0
Copy link
Contributor

test this please

1 similar comment
@changev
Copy link
Member

changev commented Dec 27, 2016

test this please

@brianparry
Copy link
Contributor

@yyscamper The change looks good, so 👍 , but I think we should consider adding parameter constraints inline with task definition properties rather than defining a seperate schema property. One way to think about this is that the task definitions themselves would be a kind of schema. I think this would make writing task definitions easier for users.

@yyscamper
Copy link
Contributor Author

yyscamper commented Jan 6, 2017

@brianparry : Thanks for your review. But I don't quite understand your comment, whether you mean the schema should go along with each option rather than put together in a separate property? Something like below?

{
    injectableName: 'Task.InstallCentOS',
    friendlyName: 'CentOS install',
    options: {
        version: {
            type: 'string',
            required: true
        },
        repo: {
            type: 'string',
            required: true,
            default: '{{api.server}}/centos/{{options.version}}'
        }
    }
}

I did think about this, the challenge is it cannot or hard meet some complex case, for example, for LinuxCommand task, the command can either be a string or an object, so it should look like

options: {
  command: {
     oneOf:[
        { 
           type: 'string'
        },
        { 
           type: 'object',
           properties: {
              ...
           }
        }
     ]
  }
}

It just like one task definition contains multiple sub json schema. For my case, all sub json schemas are contained in the seperated key optionsSchema.

Another reason is for some complex required case, for example, the CreateMegaRaid task can either be choosed to create default RAID or create user customized RAID, the required looks like:

oneOf: [
    { 'required': ['controllerId', 'createDefault'] }
    { 'required': ['controllerId', 'raidConfig'] }
]

This kind of constraint applies for the whole of options rather than a single option.

Put all constraints together gives us the flexibility to use all JSON schema capability. Split the whole schema into multiple sub schemas does have some constraints to handle some complex case.

If you have better solution to resolve above complex case that will be very welcome.

@iceiilin
Copy link
Member

+1

@anhou anhou merged commit 2f25ac2 into RackHD:master Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
9 participants