package io.renren.modules.kubesphere.controller;

import io.renren.modules.kubesphere.service.S2iService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author chenrj
 * @email 1412736935@qq.com
 * @since 2021/7/29
 * <p>
 * 关于镜像制作的api接口
 */

@RestController
@RequestMapping("kubeSphere ")
public class S2iController {

    @Autowired
    S2iService s2iService;

    /**
     * 镜像制作其他参数
     *
     * @param jsonData
     * @return
     * @throws IOException
     */
    @PostMapping("/s2iBuilder")
    public String s2iBuilder(@RequestBody String jsonData) throws IOException {
        return s2iService.s2iBuilder(jsonData);
    }

    /**
     * 镜像制作上传的文件
     *
     * @param file
     * @return
     * @throws IOException
     */
    @PutMapping("/s2iBuilderUpLoadFile")
    public String s2iBuilderUpLoadFile(@RequestParam("s2ibinary") MultipartFile file) throws IOException {
        System.out.println("debug:" + file.getOriginalFilename());
        return s2iService.uploadFile(file);
    }


}
