// upload_draft_worker will attempt to upload a "draft" version of a worker script if it does not
// already exist in the API (API error code 10007 is returned). The function returns None if this draft
// script was uploaded, or else returns Some (with a Result type so we can return a potential script upload error
// up the call chain).
upload_draft_worker will attempt to upload a "draft" version of a worker script if it does not
already exist in the API (API error code 10007 is returned). The function returns None if this draft
script was uploaded, or else returns Some (with a Result type so we can return a potential script upload error
up the call chain).
upload_draft_worker will attempt to upload a " draft " version of a worker script if it does not already exist in the API ( API error code 10007 is returned ) . The function returns None if this draft script was uploaded or else returns Some ( with a Result type so we can return a potential script upload error up the call chain ) .
pub fn upload_draft_worker(
    e: &ApiFailure,
    user: &GlobalUser,
    target: &Target,
) -> Option<Result<()>> {
    match e {
        ApiFailure::Error(_, api_errors) => {
            let error = &api_errors.errors[0];
            if error.code == 10007 {
                StdOut::working(&format!("Worker {} doesn't exist in the API yet. Creating a draft Worker so we can create new secret.", target.name));
                let upload_client = http::legacy_auth_client(user);
                Some(upload::script(&upload_client, target, None))
            } else {
                None
            }
        }
        ApiFailure::Invalid(_) => None,
    }
}
pub fn upload_draft_worker ( e : & ApiFailure , user : & GlobalUser , target : & Target , ) -> Option < Result < ( ) > > { match e { ApiFailure :: Error ( _ , api_errors ) => { let error = & api_errors . errors [ 0 ] ; if error . code == 10007 { StdOut :: working ( & format ! ( " " target name ) ) ; let upload_client = http :: legacy_auth_client ( user ) ; Some ( upload :: script ( & upload_client , target , None ) ) } else { None } } ApiFailure :: Invalid ( _ ) => None , } }
upload_draft_worker will attempt to upload a "draft" version of a worker script if it does not
already exist in the API (API error code 10007 is returned).
upload_draft_worker will attempt to upload a " draft " version of a worker script if it does not already exist in the API ( API error code 10007 is returned ) .
e
&ApiFailure
user
&GlobalUser
target
&Target