KubeSphereConfig.java 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package io.renren.modules.kubesphere.config;
  2. import org.springframework.beans.factory.annotation.Value;
  3. import org.springframework.boot.web.client.RestTemplateBuilder;
  4. import org.springframework.context.annotation.Bean;
  5. import org.springframework.context.annotation.Configuration;
  6. import org.springframework.web.client.RestTemplate;
  7. /**
  8. * @author chenrj
  9. * @email 1412736935@qq.com
  10. * @since 2021/7/29
  11. */
  12. @Configuration
  13. public class KubeSphereConfig {
  14. public static String kubesphereUrl;
  15. @Value("${kubesphereUrl}")
  16. public void setKubesphereUrl(String kubesphereUrl) {
  17. KubeSphereConfig.kubesphereUrl = kubesphereUrl;
  18. }
  19. public static class URL {
  20. private static final String host = "http://42.192.195.253:30881";
  21. // s2i相关url
  22. public static final String S2I_BUILDER_URL = host + "/apis/devops.kubesphere.io/v1alpha1/namespaces/mkcloud/s2ibuilders";
  23. public static final String S2I_CREATE_BINARY_QUERY_URL = host + "/apis/devops.kubesphere.io/v1alpha1/namespaces/mkcloud/s2ibinaries";
  24. public static final String S2I_UPLOAD_FILE_QUERY_URL = host + "/kapis/devops.kubesphere.io/v1alpha2/namespaces/mkcloud/s2ibinaries/%s/file";
  25. public static final String S2I_RUN = host + "/apis/devops.kubesphere.io/v1alpha1/namespaces/mkcloud/s2iruns";
  26. // 存储卷相关url
  27. public static final String STORAGE_VOLUME_CREATE = host + "/api/v1/namespaces/mkcloud/persistentvolumeclaims";
  28. // 应用相关
  29. public static final String APPLICATION_DRY_RUN = host + "/apis/app.k8s.io/v1beta1/namespaces/mkcloud/applications?dryRun=All";
  30. public static final String INGRESS_DRY_RUN = host + "/apis/extensions/v1beta1/namespaces/mkcloud/ingresses?dryRun=All";
  31. public static final String DEPLOYMENT_DRY_RUN = host + "/apis/apps/v1/namespaces/mkcloud/deployments?dryRun=All";
  32. public static final String SERVICE_DRY_RUN = host + "/api/v1/namespaces/mkcloud/services?dryRun=All";
  33. public static final String APPLICATION = host + "/apis/app.k8s.io/v1beta1/namespaces/mkcloud/applications";
  34. public static final String INGRESS = host + "/apis/extensions/v1beta1/namespaces/mkcloud/ingresses";
  35. public static final String DEPLOYMENT = host + "/apis/apps/v1/namespaces/mkcloud/deployments";
  36. public static final String SERVICE = host + "/api/v1/namespaces/mkcloud/services";
  37. // token
  38. public static final String OAUTH_TOKEN = host + "/oauth/token";
  39. }
  40. // public static final String ORIGIN = "http://42.192.195.253:30881";
  41. // public static final String UA = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36";
  42. // public static final String REFERER = "http://42.192.195.253:30881";
  43. // public static final String ACCEPT = "*/*";
  44. public static String ORIGIN;
  45. @Value("${kubesphereUrl}")
  46. public static void setORIGIN(String ORIGIN) {
  47. KubeSphereConfig.ORIGIN = ORIGIN;
  48. }
  49. public static final String UA = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36";
  50. public static String REFERER = KubeSphereConfig.kubesphereUrl;
  51. @Value("${kubesphereUrl}")
  52. public static void setREFERER(String REFERER) {
  53. KubeSphereConfig.REFERER = REFERER;
  54. }
  55. public static final String ACCEPT = "*/*";
  56. @Bean
  57. public RestTemplate restTemplate(RestTemplateBuilder builder) {
  58. // Do any additional configuration here
  59. return builder.build();
  60. }
  61. }