From 998e0388b27c4800821f5f4a53f0a86ba4ea7338 Mon Sep 17 00:00:00 2001 From: Steve Hawkins Date: Sun, 19 Dec 2021 12:14:22 -0500 Subject: [PATCH 1/6] creating an api module with new interfaces creates interfaces for metrics, sharedinformerfactory, runoperations removes operationcontext from sharedinformerfactory removes rawoperation... completely moving the mifmif dependency to openshift-client removes duplicate patch objectmetamixin --- kubernetes-client-api/pom.xml | 327 ++++++ .../io/fabric8/kubernetes/client/Version.java | 25 + .../client/APIGroupExtensionAdapter.java | 0 .../client/APIGroupNotAvailableException.java | 0 .../fabric8/kubernetes/client/Adapters.java | 0 .../AdmissionRegistrationAPIGroupDSL.java | 0 .../io/fabric8/kubernetes/client/Client.java | 0 .../kubernetes/client/ClientContext.java | 0 .../io/fabric8/kubernetes/client/Config.java | 0 .../kubernetes/client/ConfigAware.java | 0 .../kubernetes/client/CustomResource.java | 0 .../kubernetes/client/CustomResourceList.java | 0 .../kubernetes/client/ExtensionAdapter.java | 0 .../client/ExtensionAdapterSupport.java | 0 .../kubernetes/client/FromServerGettable.java | 0 .../client/GenericKubernetesClient.java | 0 .../client/GracePeriodConfigurable.java | 0 .../kubernetes/client/HttpClientAware.java | 0 .../kubernetes/client/KubernetesClient.java | 73 +- .../client/KubernetesClientException.java | 0 .../KubernetesClientTimeoutException.java | 0 .../kubernetes/client/LocalPortForward.java | 0 .../client/NamespacedKubernetesClient.java | 0 .../kubernetes/client/OAuthTokenProvider.java | 0 .../kubernetes/client/OperationInfo.java | 0 .../kubernetes/client/PortForward.java | 0 .../client/PropagationPolicyConfigurable.java | 0 .../kubernetes/client/RequestConfig.java | 0 .../client/RequestConfigHolder.java | 0 .../client/ResourceNotFoundException.java | 0 .../client/ServiceToURLProvider.java | 0 .../client/SimpleClientContext.java | 0 .../V1AdmissionRegistrationAPIGroupDSL.java | 0 .../client/V1ApiextensionAPIGroupDSL.java | 0 .../client/V1AuthorizationAPIGroupDSL.java | 0 .../client/V1AutoscalingAPIGroupDSL.java | 0 .../client/V1NetworkAPIGroupDSL.java | 0 ...beta1AdmissionRegistrationAPIGroupDSL.java | 0 .../V1beta1ApiextensionAPIGroupDSL.java | 0 .../V1beta1AuthorizationAPIGroupDSL.java | 0 .../client/V1beta1NetworkAPIGroupDSL.java | 0 .../client/V2beta1AutoscalingAPIGroupDSL.java | 0 .../client/V2beta2AutoscalingAPIGroupDSL.java | 0 .../kubernetes/client/VersionInfo.java | 0 .../io/fabric8/kubernetes/client/Watch.java | 0 .../io/fabric8/kubernetes/client/Watcher.java | 0 .../kubernetes/client/WatcherException.java | 0 .../client/WithRequestCallable.java | 0 .../client/dsl/AnyNamespaceable.java | 0 .../client/dsl/ApiextensionsAPIGroupDSL.java | 0 .../kubernetes/client/dsl/Applicable.java | 0 .../kubernetes/client/dsl/ApplicableAnd.java | 0 .../kubernetes/client/dsl/Approvable.java | 0 .../client/dsl/AppsAPIGroupDSL.java | 0 .../client/dsl/AuthorizationAPIGroupDSL.java | 0 .../client/dsl/AutoscalingAPIGroupDSL.java | 0 .../client/dsl/BatchAPIGroupDSL.java | 0 ...sLimitTerminateTimeTailPrettyLoggable.java | 0 .../kubernetes/client/dsl/BytesLimitable.java | 0 .../kubernetes/client/dsl/Cascading.java | 0 .../client/dsl/CascadingDeletable.java | 0 .../CascadingEditReplacePatchDeletable.java | 0 .../CertificateSigningRequestResource.java | 0 .../client/dsl/CertificatesAPIGroupDSL.java | 0 .../client/dsl/ContainerResource.java | 0 .../kubernetes/client/dsl/Containerable.java | 0 .../kubernetes/client/dsl/Copiable.java | 0 .../kubernetes/client/dsl/CopyOrReadable.java | 0 .../client/dsl/CreateFromServerGettable.java | 0 .../client/dsl/CreateListFromLoadable.java | 0 .../client/dsl/CreateOrDeleteable.java | 0 .../client/dsl/CreateOrReplaceable.java | 0 .../kubernetes/client/dsl/Createable.java | 0 .../kubernetes/client/dsl/Deletable.java | 0 .../kubernetes/client/dsl/Deniable.java | 0 .../client/dsl/DiscoveryAPIGroupDSL.java | 0 .../kubernetes/client/dsl/DryRunable.java | 0 .../client/dsl/EditReplacePatchDeletable.java | 0 .../client/dsl/EditReplacePatchable.java | 0 .../kubernetes/client/dsl/Editable.java | 0 .../client/dsl/ErrorChannelable.java | 0 .../kubernetes/client/dsl/Errorable.java | 0 .../client/dsl/EventingAPIGroupDSL.java | 0 .../kubernetes/client/dsl/Evictable.java | 0 .../kubernetes/client/dsl/ExecListenable.java | 0 .../kubernetes/client/dsl/ExecListener.java | 0 .../kubernetes/client/dsl/ExecWatch.java | 0 .../kubernetes/client/dsl/Execable.java | 0 .../client/dsl/ExtensionsAPIGroupDSL.java | 0 .../kubernetes/client/dsl/FileSelector.java | 0 .../kubernetes/client/dsl/FilterNested.java | 0 .../client/dsl/FilterWatchListDeletable.java | 0 .../dsl/FilterWatchListMultiDeletable.java | 0 .../kubernetes/client/dsl/Filterable.java | 0 .../client/dsl/FlowControlAPIGroupDSL.java | 0 .../kubernetes/client/dsl/FromServerable.java | 0 .../client/dsl/FunctionCallable.java | 0 .../client/dsl/GetListFromLoadable.java | 0 .../kubernetes/client/dsl/Gettable.java | 0 .../client/dsl/ImageEditReplacePatchable.java | 0 .../client/dsl/InOutCreateable.java | 0 .../kubernetes/client/dsl/Informable.java | 0 .../kubernetes/client/dsl/Inputable.java | 0 .../dsl/KubernetesListMixedOperation.java | 0 .../KubernetesListNonNamespaceOperation.java | 0 .../client/dsl/KubernetesListOperation.java | 0 ...ServerGetDeleteRecreateWaitApplicable.java | 0 .../dsl/ListVisitFromServerWritable.java | 0 .../kubernetes/client/dsl/Listable.java | 0 .../kubernetes/client/dsl/Listenable.java | 0 .../kubernetes/client/dsl/Loadable.java | 0 .../kubernetes/client/dsl/Lockable.java | 0 .../kubernetes/client/dsl/LogWatch.java | 0 .../kubernetes/client/dsl/Loggable.java | 0 .../client/dsl/MetricAPIGroupDSL.java | 6 +- .../client/dsl/MetricOperation.java | 57 ++ .../kubernetes/client/dsl/MixedOperation.java | 0 .../client/dsl/MultiDeleteable.java | 0 .../kubernetes/client/dsl/Nameable.java | 0 ...ServerGetDeleteRecreateWaitApplicable.java | 0 ...rGetWatchDeleteRecreateWaitApplicable.java | 0 .../kubernetes/client/dsl/Namespaceable.java | 0 .../client/dsl/NamespacedInOutCreateable.java | 0 .../client/dsl/NetworkAPIGroupDSL.java | 0 .../client/dsl/NodeMetricOperation.java | 38 + .../client/dsl/NonNamespaceOperation.java | 0 .../kubernetes/client/dsl/Operation.java | 0 .../kubernetes/client/dsl/Outputable.java | 0 .../client/dsl/ParameterMixedOperation.java | 0 ...ServerGetDeleteRecreateWaitApplicable.java | 0 .../client/dsl/Parameterizable.java | 0 .../kubernetes/client/dsl/Patchable.java | 0 .../client/dsl/PodMetricOperation.java | 47 + .../kubernetes/client/dsl/PodResource.java | 0 .../client/dsl/PolicyAPIGroupDSL.java | 0 .../client/dsl/PortForwardable.java | 0 .../kubernetes/client/dsl/PrettyLoggable.java | 0 .../kubernetes/client/dsl/Prettyable.java | 0 .../client/dsl/RbacAPIGroupDSL.java | 0 .../kubernetes/client/dsl/Readable.java | 0 .../kubernetes/client/dsl/Readiable.java | 0 .../client/dsl/RecreateApplicable.java | 0 .../client/dsl/RecreateCreateable.java | 0 .../dsl/RecreateFromServerGettable.java | 0 .../kubernetes/client/dsl/Recreateable.java | 0 .../client/dsl/ReplaceDeletable.java | 0 .../kubernetes/client/dsl/Replaceable.java | 0 .../client/dsl/RequestConfigurable.java | 0 .../kubernetes/client/dsl/Requirable.java | 0 .../kubernetes/client/dsl/Resource.java | 0 .../kubernetes/client/dsl/Rollable.java | 0 .../client/dsl/RollableScalableResource.java | 0 .../client/dsl/ScalableResource.java | 0 .../kubernetes/client/dsl/Scaleable.java | 0 .../client/dsl/SchedulingAPIGroupDSL.java | 0 .../kubernetes/client/dsl/Secretable.java | 0 .../client/dsl/ServiceResource.java | 0 .../kubernetes/client/dsl/StatusEditable.java | 0 .../client/dsl/StatusPatchable.java | 0 .../client/dsl/StatusReplaceable.java | 0 .../client/dsl/StatusUpdatable.java | 0 .../client/dsl/StorageAPIGroupDSL.java | 0 .../client/dsl/TailPrettyLoggable.java | 0 .../kubernetes/client/dsl/Tailable.java | 0 .../dsl/TerminateTimeTailPrettyLoggable.java | 0 .../kubernetes/client/dsl/Terminateable.java | 0 .../client/dsl/TimeTailPrettyLoggable.java | 0 .../kubernetes/client/dsl/Timeable.java | 0 .../dsl/TimeoutImageEditReplacePatchable.java | 0 .../kubernetes/client/dsl/Timeoutable.java | 0 ...sLimitTerminateTimeTailPrettyLoggable.java | 0 .../kubernetes/client/dsl/Timestampable.java | 0 .../kubernetes/client/dsl/Triggerable.java | 0 .../client/dsl/TtyExecErrorChannelable.java | 0 .../client/dsl/TtyExecErrorable.java | 0 .../dsl/TtyExecInputOutputErrorable.java | 0 .../client/dsl/TtyExecOutputErrorable.java | 0 .../kubernetes/client/dsl/TtyExecable.java | 0 .../kubernetes/client/dsl/Ttyable.java | 0 .../kubernetes/client/dsl/Typeable.java | 0 .../kubernetes/client/dsl/Uploadable.java | 0 .../kubernetes/client/dsl/V1APIGroupDSL.java | 0 .../client/dsl/V1BatchAPIGroupDSL.java | 0 .../client/dsl/V1CertificatesAPIGroupDSL.java | 0 .../client/dsl/V1DiscoveryAPIGroupDSL.java | 0 .../client/dsl/V1EventingAPIGroupDSL.java | 0 .../client/dsl/V1PolicyAPIGroupDSL.java | 0 .../client/dsl/V1SchedulingAPIGroupDSL.java | 0 .../client/dsl/V1beta1BatchAPIGroupDSL.java | 0 .../dsl/V1beta1CertificatesAPIGroupDSL.java | 0 .../dsl/V1beta1DiscoveryAPIGroupDSL.java | 0 .../dsl/V1beta1EventingAPIGroupDSL.java | 0 .../dsl/V1beta1FlowControlAPIGroupDSL.java | 0 .../client/dsl/V1beta1PolicyAPIGroupDSL.java | 0 .../dsl/V1beta1SchedulingAPIGroupDSL.java | 0 .../client/dsl/VersionWatchAndWaitable.java | 0 .../kubernetes/client/dsl/Versionable.java | 0 ...rGetWatchDeleteRecreateWaitApplicable.java | 0 .../client/dsl/VisitFromServerWritable.java | 0 .../kubernetes/client/dsl/Waitable.java | 0 .../client/dsl/WatchAndWaitable.java | 0 .../client/dsl/WatchListDeletable.java | 0 .../kubernetes/client/dsl/Watchable.java | 0 .../client/dsl/WritableOperation.java | 0 .../base/CustomResourceDefinitionContext.java | 0 .../client/dsl/base/PatchContext.java | 0 .../kubernetes/client/dsl/base/PatchType.java | 10 +- .../dsl/base/ResourceDefinitionContext.java | 0 .../leaderelection/LeaderCallbacks.java | 0 .../leaderelection/LeaderElectionConfig.java | 0 .../leaderelection/LeaderElector.java | 0 .../leaderelection/LeaderElectorBuilder.java | 0 .../resourcelock/ConfigMapLock.java | 0 .../resourcelock/LeaderElectionRecord.java | 0 .../resourcelock/LeaseLock.java | 0 .../leaderelection/resourcelock/Lock.java | 0 .../resourcelock/LockException.java | 0 .../client/extended/run/RunConfig.java | 0 .../client/extended/run/RunConfigUtil.java | 0 .../client/extended/run/RunOperations.java | 61 ++ .../kubernetes/client/http/BasicBuilder.java | 0 .../kubernetes/client/http/HttpClient.java | 0 .../kubernetes/client/http/HttpHeaders.java | 0 .../kubernetes/client/http/HttpRequest.java | 0 .../kubernetes/client/http/HttpResponse.java | 0 .../client/http/HttpStatusMessage.java | 0 .../kubernetes/client/http/Interceptor.java | 0 .../kubernetes/client/http/TlsVersion.java | 0 .../kubernetes/client/http/WebSocket.java | 0 .../http/WebSocketHandshakeException.java | 0 .../client/informers/ListerWatcher.java | 0 .../informers/ResourceEventHandler.java | 0 .../client/informers/SharedIndexInformer.java | 0 .../client/informers/SharedInformer.java | 0 .../SharedInformerEventListener.java | 0 .../informers/SharedInformerFactory.java | 163 +++ .../client/informers/cache/Cache.java | 93 ++ .../client/informers/cache/Indexer.java | 0 .../client/informers/cache/Lister.java | 0 .../client/informers/cache/Store.java | 0 .../kubernetes/client/internal/CertUtils.java | 0 .../client/internal/KubeConfigUtils.java | 0 .../kubernetes/client/internal/PKCS1Util.java | 0 .../kubernetes/client/internal/SSLUtils.java | 0 .../client/internal/readiness/Readiness.java | 0 .../kubernetes/client/lib/FileSystem.java | 0 .../kubernetes/client/lib/FilenameUtils.java | 0 .../client/utils/ApiVersionUtil.java | 0 .../BackwardsCompatibilityInterceptor.java | 23 +- .../utils/CachedSingleThreadScheduler.java | 0 .../client/utils/HttpClientUtils.java | 66 +- .../kubernetes/client/utils/IOHelpers.java | 0 .../client/utils/ImpersonatorInterceptor.java | 0 .../client/utils/InputStreamPumper.java | 0 .../client/utils/IpAddressMatcher.java | 0 .../client/utils/KubernetesResourceUtil.java | 0 .../utils/KubernetesVersionFactory.java | 0 .../utils/KubernetesVersionPriority.java | 0 .../client/utils/OpenIDConnectionUtils.java | 0 .../utils/OptionalDependencyWrapper.java | 0 .../client/utils/PodStatusUtil.java | 0 .../kubernetes/client/utils/ReflectUtils.java | 0 .../client/utils/ReplaceValueStream.java | 0 .../client/utils/ResourceCompare.java | 0 .../client/utils/Serialization.java | 0 .../client/utils/TokenRefreshInterceptor.java | 0 .../client/utils/URLFromServiceUtil.java | 0 .../kubernetes/client/utils/URLUtils.java | 0 .../kubernetes/client/utils/Utils.java | 0 .../BeanPropertyWriterDelegate.java | 0 .../SettableBeanPropertyDelegate.java | 0 .../UnmatchedFieldTypeModule.java | 0 .../fabric8/kubernetes/client/ConfigTest.java | 52 +- .../io/fabric8/kubernetes/client/Custom.java | 0 .../kubernetes/client/CustomResourceTest.java | 0 .../io/fabric8/kubernetes/client/Good.java | 0 .../CustomResourceDefinitionContextTest.java | 0 .../base/ResourceDefinitionContextTest.java | 0 .../internal/readiness/ReadinessTest.java | 0 .../SettableBeanPropertyDelegateTest.java | 0 .../UnmatchedFieldTypeModuleTest.java | 0 .../src/test/resources/test-ec-kubeconfig | 0 .../src/test/resources/test-kubeconfig | 44 + .../src/test/resources/test-kubeconfig-exec | 0 .../test/resources/test-kubeconfig-exec-win | 0 .../test-kubeconfig-nocurrentctxt.yml | 0 .../src/test/resources/test-namespace | 0 .../src/test/resources/token-generator | 0 .../test/resources/token-generator-win.bat | 0 kubernetes-client/pom.xml | 111 +- .../client/BaseKubernetesClient.java | 17 +- .../dsl/internal/MetricOperationsImpl.java | 53 +- .../internal/NodeMetricOperationsImpl.java | 39 +- .../dsl/internal/PodMetricOperationsImpl.java | 49 +- .../RawCustomResourceOperationsImpl.java | 965 ------------------ .../extended/leaderelection/package-info.java | 56 - ...Operations.java => RunOperationsImpl.java} | 17 +- ...ry.java => SharedInformerFactoryImpl.java} | 20 +- .../cache/{Cache.java => CacheImpl.java} | 6 +- .../informers/cache/ProcessorStore.java | 4 +- .../impl/DefaultSharedIndexInformer.java | 6 +- .../client/internal/PatchUtils.java | 2 +- .../internal/patchmixins/ObjectMetaMixIn.java | 53 - .../client/osgi/ManagedKubernetesClient.java | 9 +- .../client/DefaultKubernetesClientTest.java | 54 + .../client/dsl/base/BaseOperationTest.java | 1 - .../RawCustomResourceOperationsImplTest.java | 881 ---------------- .../extended/run/RunOperationsTest.java | 2 +- .../informers/SharedInformerFactoryTest.java | 54 +- .../client/informers/cache/CacheTest.java | 4 +- .../client/informers/cache/ListerTest.java | 2 +- .../informers/cache/ProcessorStoreTest.java | 4 +- ... => GenericKubernetesResourceExample.java} | 38 +- .../CustomResourceCreateDemoTypeless.java | 22 +- ...GenericClusterScopedCustomResourceIT.java} | 27 +- .../kubernetes/GenericCustomResourceIT.java | 260 +++++ .../kubernetes/RawCustomResourceIT.java | 305 ------ .../KubernetesAttributesExtractorTest.java | 9 +- .../client/mock/CustomResourceCrudTest.java | 31 - .../client/mock/CustomResourceTest.java | 151 ++- .../mock/DefaultSharedIndexInformerTest.java | 89 +- .../client/mock/PropagationPolicyTest.java | 6 +- openshift-client/pom.xml | 7 +- .../client/osgi/ManagedOpenShiftClient.java | 7 - pom.xml | 20 + 325 files changed, 1533 insertions(+), 2933 deletions(-) create mode 100644 kubernetes-client-api/pom.xml create mode 100644 kubernetes-client-api/src/main/java-templates/io/fabric8/kubernetes/client/Version.java rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/APIGroupExtensionAdapter.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/APIGroupNotAvailableException.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/Adapters.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/AdmissionRegistrationAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/Client.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/ClientContext.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/Config.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/ConfigAware.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/CustomResource.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/CustomResourceList.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapter.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapterSupport.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/FromServerGettable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/GenericKubernetesClient.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/GracePeriodConfigurable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/HttpClientAware.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/KubernetesClient.java (92%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/KubernetesClientException.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/KubernetesClientTimeoutException.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/LocalPortForward.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/NamespacedKubernetesClient.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/OAuthTokenProvider.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/OperationInfo.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/PortForward.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/PropagationPolicyConfigurable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/RequestConfig.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/RequestConfigHolder.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/ResourceNotFoundException.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/ServiceToURLProvider.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/SimpleClientContext.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/V1AdmissionRegistrationAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/V1ApiextensionAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/V1AuthorizationAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/V1AutoscalingAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/V1NetworkAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/V1beta1AdmissionRegistrationAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/V1beta1ApiextensionAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/V1beta1AuthorizationAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/V1beta1NetworkAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/V2beta1AutoscalingAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/V2beta2AutoscalingAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/VersionInfo.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/Watch.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/Watcher.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/WatcherException.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/WithRequestCallable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/AnyNamespaceable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ApiextensionsAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Applicable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ApplicableAnd.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Approvable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/AppsAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/AuthorizationAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/AutoscalingAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/BatchAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/BytesLimitTerminateTimeTailPrettyLoggable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/BytesLimitable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Cascading.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/CascadingDeletable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/CascadingEditReplacePatchDeletable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/CertificateSigningRequestResource.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/CertificatesAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ContainerResource.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Containerable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Copiable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/CopyOrReadable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/CreateFromServerGettable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/CreateListFromLoadable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/CreateOrDeleteable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/CreateOrReplaceable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Createable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Deletable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Deniable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/DiscoveryAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/DryRunable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/EditReplacePatchDeletable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/EditReplacePatchable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Editable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ErrorChannelable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Errorable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/EventingAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Evictable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ExecListenable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ExecListener.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ExecWatch.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Execable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ExtensionsAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/FileSelector.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/FilterNested.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/FilterWatchListDeletable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/FilterWatchListMultiDeletable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Filterable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/FlowControlAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/FromServerable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/FunctionCallable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/GetListFromLoadable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Gettable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ImageEditReplacePatchable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/InOutCreateable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Informable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Inputable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/KubernetesListMixedOperation.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/KubernetesListNonNamespaceOperation.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/KubernetesListOperation.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ListVisitFromServerGetDeleteRecreateWaitApplicable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ListVisitFromServerWritable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Listable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Listenable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Loadable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Lockable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/LogWatch.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Loggable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/MetricAPIGroupDSL.java (77%) create mode 100644 kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/MetricOperation.java rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/MixedOperation.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/MultiDeleteable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Nameable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Namespaceable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/NamespacedInOutCreateable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/NetworkAPIGroupDSL.java (100%) create mode 100644 kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NodeMetricOperation.java rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/NonNamespaceOperation.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Operation.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Outputable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ParameterMixedOperation.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Parameterizable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Patchable.java (100%) create mode 100644 kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/PodMetricOperation.java rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/PodResource.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/PolicyAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/PortForwardable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/PrettyLoggable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Prettyable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/RbacAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Readable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Readiable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateApplicable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateCreateable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateFromServerGettable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Recreateable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ReplaceDeletable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Replaceable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/RequestConfigurable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Requirable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Resource.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Rollable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/RollableScalableResource.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ScalableResource.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Scaleable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/SchedulingAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Secretable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/ServiceResource.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/StatusEditable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/StatusPatchable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/StatusReplaceable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/StatusUpdatable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/StorageAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/TailPrettyLoggable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Tailable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/TerminateTimeTailPrettyLoggable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Terminateable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/TimeTailPrettyLoggable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Timeable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/TimeoutImageEditReplacePatchable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Timeoutable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/TimestampBytesLimitTerminateTimeTailPrettyLoggable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Timestampable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Triggerable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecErrorChannelable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecErrorable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecInputOutputErrorable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecOutputErrorable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Ttyable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Typeable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Uploadable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1APIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1BatchAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1CertificatesAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1DiscoveryAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1EventingAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1PolicyAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1SchedulingAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1BatchAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1CertificatesAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1DiscoveryAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1EventingAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1FlowControlAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1PolicyAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1SchedulingAPIGroupDSL.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/VersionWatchAndWaitable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Versionable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/VisitFromServerGetWatchDeleteRecreateWaitApplicable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/VisitFromServerWritable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Waitable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/WatchAndWaitable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/WatchListDeletable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/Watchable.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/WritableOperation.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/base/CustomResourceDefinitionContext.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchContext.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchType.java (71%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/dsl/base/ResourceDefinitionContext.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderCallbacks.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectionConfig.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElector.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorBuilder.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLock.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaderElectionRecord.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaseLock.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/Lock.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LockException.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/extended/run/RunConfig.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/extended/run/RunConfigUtil.java (100%) create mode 100644 kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/run/RunOperations.java rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/http/BasicBuilder.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/http/HttpClient.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/http/HttpHeaders.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/http/HttpRequest.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/http/HttpResponse.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/http/HttpStatusMessage.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/http/Interceptor.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/http/TlsVersion.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/http/WebSocket.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/http/WebSocketHandshakeException.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/informers/ListerWatcher.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/informers/ResourceEventHandler.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/informers/SharedIndexInformer.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformer.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerEventListener.java (100%) create mode 100644 kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactory.java create mode 100644 kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Cache.java rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/informers/cache/Indexer.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/informers/cache/Lister.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/informers/cache/Store.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/internal/CertUtils.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/internal/KubeConfigUtils.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/internal/PKCS1Util.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/internal/SSLUtils.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/internal/readiness/Readiness.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/lib/FileSystem.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/lib/FilenameUtils.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/ApiVersionUtil.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/BackwardsCompatibilityInterceptor.java (97%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/CachedSingleThreadScheduler.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java (86%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/IOHelpers.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/ImpersonatorInterceptor.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/InputStreamPumper.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/IpAddressMatcher.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesVersionFactory.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesVersionPriority.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/OpenIDConnectionUtils.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/OptionalDependencyWrapper.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/PodStatusUtil.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/ReflectUtils.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/ReplaceValueStream.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/ResourceCompare.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/TokenRefreshInterceptor.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/URLFromServiceUtil.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/URLUtils.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/Utils.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/serialization/BeanPropertyWriterDelegate.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/serialization/SettableBeanPropertyDelegate.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/main/java/io/fabric8/kubernetes/client/utils/serialization/UnmatchedFieldTypeModule.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/java/io/fabric8/kubernetes/client/ConfigTest.java (92%) rename {kubernetes-client => kubernetes-client-api}/src/test/java/io/fabric8/kubernetes/client/Custom.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/java/io/fabric8/kubernetes/client/CustomResourceTest.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/java/io/fabric8/kubernetes/client/Good.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/java/io/fabric8/kubernetes/client/dsl/base/CustomResourceDefinitionContextTest.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/java/io/fabric8/kubernetes/client/dsl/base/ResourceDefinitionContextTest.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/java/io/fabric8/kubernetes/client/internal/readiness/ReadinessTest.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/java/io/fabric8/kubernetes/client/utils/serialization/SettableBeanPropertyDelegateTest.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/java/io/fabric8/kubernetes/client/utils/serialization/UnmatchedFieldTypeModuleTest.java (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/resources/test-ec-kubeconfig (100%) create mode 100644 kubernetes-client-api/src/test/resources/test-kubeconfig rename {kubernetes-client => kubernetes-client-api}/src/test/resources/test-kubeconfig-exec (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/resources/test-kubeconfig-exec-win (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/resources/test-kubeconfig-nocurrentctxt.yml (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/resources/test-namespace (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/resources/token-generator (100%) rename {kubernetes-client => kubernetes-client-api}/src/test/resources/token-generator-win.bat (100%) delete mode 100644 kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImpl.java delete mode 100644 kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/package-info.java rename kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/run/{RunOperations.java => RunOperationsImpl.java} (82%) rename kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/{SharedInformerFactory.java => SharedInformerFactoryImpl.java} (97%) rename kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/{Cache.java => CacheImpl.java} (98%) delete mode 100644 kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/patchmixins/ObjectMetaMixIn.java delete mode 100644 kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImplTest.java rename kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/{RawCustomResourceExample.java => GenericKubernetesResourceExample.java} (64%) rename kubernetes-itests/src/test/java/io/fabric8/kubernetes/{RawClusterScopedCustomResourceIT.java => GenericClusterScopedCustomResourceIT.java} (68%) create mode 100644 kubernetes-itests/src/test/java/io/fabric8/kubernetes/GenericCustomResourceIT.java delete mode 100644 kubernetes-itests/src/test/java/io/fabric8/kubernetes/RawCustomResourceIT.java diff --git a/kubernetes-client-api/pom.xml b/kubernetes-client-api/pom.xml new file mode 100644 index 00000000000..62512872f8c --- /dev/null +++ b/kubernetes-client-api/pom.xml @@ -0,0 +1,327 @@ + + + + 4.0.0 + + io.fabric8 + kubernetes-client-project + 5.12-SNAPSHOT + + + kubernetes-client-api + jar + Fabric8 :: Kubernetes :: Java Client API + + + + osgi.extender; + filter:="(osgi.extender=osgi.serviceloader.processor)", + + + !android.util*, + *, + + + io.fabric8.kubernetes.client*;-noimport:=true, + io.fabric8.kubernetes.internal;-noimport:=true, + + + io.fabric8.kubernetes.client.internal + + + + + + io.fabric8 + kubernetes-model-core + + + io.fabric8 + kubernetes-model-rbac + + + io.fabric8 + kubernetes-model-admissionregistration + + + io.fabric8 + kubernetes-model-apps + + + io.fabric8 + kubernetes-model-autoscaling + + + io.fabric8 + kubernetes-model-apiextensions + + + io.fabric8 + kubernetes-model-batch + + + io.fabric8 + kubernetes-model-certificates + + + io.fabric8 + kubernetes-model-coordination + + + io.fabric8 + kubernetes-model-discovery + + + io.fabric8 + kubernetes-model-events + + + io.fabric8 + kubernetes-model-extensions + + + io.fabric8 + kubernetes-model-flowcontrol + + + io.fabric8 + kubernetes-model-networking + + + io.fabric8 + kubernetes-model-metrics + + + io.fabric8 + kubernetes-model-policy + + + io.fabric8 + kubernetes-model-scheduling + + + io.fabric8 + kubernetes-model-storageclass + + + io.fabric8 + kubernetes-model-node + + + + org.slf4j + slf4j-api + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + + + + org.bouncycastle + bcprov-ext-jdk15on + ${bouncycastle.version} + true + + + org.bouncycastle + bcpkix-jdk15on + ${bouncycastle.version} + true + + + + + io.sundr + builder-annotations + + + io.sundr + transform-annotations + + + org.projectlombok + lombok + + + org.apache.felix + org.apache.felix.scr.annotations + ${scr.annotations.version} + compile + true + + + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.junit.jupiter + junit-jupiter-migrationsupport + test + + + org.slf4j + slf4j-simple + ${slf4j.version} + test + + + org.mockito + mockito-inline + test + + + org.assertj + assertj-core + test + + + org.awaitility + awaitility + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + 1 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + resource-*.vm + + + + + + test-jar + + + + + + org.apache.felix + maven-scr-plugin + ${maven.scr.plugin.version} + + + + scr + + + 1.2 + true + + + + + + org.apache.felix + maven-bundle-plugin + ${maven.bundle.plugin.version} + + + bundle + package + + bundle + + + + ${project.name} + ${project.groupId}.${project.artifactId} + ${osgi.export} + ${osgi.import} + ${osgi.dynamic.import} + ${osgi.require-capability} + ${osgi.provide-capability} + ${osgi.private} + ${osgi.bundles} + ${osgi.activator} + ${osgi.export.service} + + bundle + + + + + + org.codehaus.mojo + templating-maven-plugin + 1.0.0 + + + + filter-sources + + + + + + + + diff --git a/kubernetes-client-api/src/main/java-templates/io/fabric8/kubernetes/client/Version.java b/kubernetes-client-api/src/main/java-templates/io/fabric8/kubernetes/client/Version.java new file mode 100644 index 00000000000..094affe7c4d --- /dev/null +++ b/kubernetes-client-api/src/main/java-templates/io/fabric8/kubernetes/client/Version.java @@ -0,0 +1,25 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.kubernetes.client; + +public final class Version { + public static String clientVersion() { + return "${project.version}"; + } + + private Version() { + } +} diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/APIGroupExtensionAdapter.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/APIGroupExtensionAdapter.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/APIGroupExtensionAdapter.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/APIGroupExtensionAdapter.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/APIGroupNotAvailableException.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/APIGroupNotAvailableException.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/APIGroupNotAvailableException.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/APIGroupNotAvailableException.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Adapters.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Adapters.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Adapters.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Adapters.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AdmissionRegistrationAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/AdmissionRegistrationAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AdmissionRegistrationAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/AdmissionRegistrationAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Client.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Client.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ClientContext.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ClientContext.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ClientContext.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ClientContext.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Config.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Config.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Config.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Config.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ConfigAware.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ConfigAware.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ConfigAware.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ConfigAware.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/CustomResource.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/CustomResource.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/CustomResource.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/CustomResource.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/CustomResourceList.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/CustomResourceList.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/CustomResourceList.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/CustomResourceList.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapter.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapter.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapter.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapter.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapterSupport.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapterSupport.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapterSupport.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapterSupport.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/FromServerGettable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/FromServerGettable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/FromServerGettable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/FromServerGettable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/GenericKubernetesClient.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/GenericKubernetesClient.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/GenericKubernetesClient.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/GenericKubernetesClient.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/GracePeriodConfigurable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/GracePeriodConfigurable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/GracePeriodConfigurable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/GracePeriodConfigurable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/HttpClientAware.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/HttpClientAware.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/HttpClientAware.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/HttpClientAware.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/KubernetesClient.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/KubernetesClient.java similarity index 92% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/KubernetesClient.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/KubernetesClient.java index 3c01b5e3de4..b9ff02a98a3 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/KubernetesClient.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/KubernetesClient.java @@ -19,16 +19,16 @@ import io.fabric8.kubernetes.api.model.APIService; import io.fabric8.kubernetes.api.model.APIServiceList; import io.fabric8.kubernetes.api.model.Binding; -import io.fabric8.kubernetes.api.model.HasMetadata; -import io.fabric8.kubernetes.api.model.KubernetesResourceList; -import io.fabric8.kubernetes.api.model.ConfigMap; -import io.fabric8.kubernetes.api.model.ConfigMapList; import io.fabric8.kubernetes.api.model.ComponentStatus; import io.fabric8.kubernetes.api.model.ComponentStatusList; +import io.fabric8.kubernetes.api.model.ConfigMap; +import io.fabric8.kubernetes.api.model.ConfigMapList; import io.fabric8.kubernetes.api.model.Endpoints; import io.fabric8.kubernetes.api.model.EndpointsList; import io.fabric8.kubernetes.api.model.GenericKubernetesResource; import io.fabric8.kubernetes.api.model.GenericKubernetesResourceList; +import io.fabric8.kubernetes.api.model.HasMetadata; +import io.fabric8.kubernetes.api.model.KubernetesResourceList; import io.fabric8.kubernetes.api.model.LimitRange; import io.fabric8.kubernetes.api.model.LimitRangeList; import io.fabric8.kubernetes.api.model.Namespace; @@ -36,9 +36,9 @@ import io.fabric8.kubernetes.api.model.Node; import io.fabric8.kubernetes.api.model.NodeList; import io.fabric8.kubernetes.api.model.PersistentVolume; -import io.fabric8.kubernetes.api.model.PersistentVolumeList; import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; import io.fabric8.kubernetes.api.model.PersistentVolumeClaimList; +import io.fabric8.kubernetes.api.model.PersistentVolumeList; import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodList; import io.fabric8.kubernetes.api.model.ReplicationController; @@ -48,20 +48,47 @@ import io.fabric8.kubernetes.api.model.Secret; import io.fabric8.kubernetes.api.model.SecretList; import io.fabric8.kubernetes.api.model.Service; -import io.fabric8.kubernetes.api.model.ServiceList; import io.fabric8.kubernetes.api.model.ServiceAccount; import io.fabric8.kubernetes.api.model.ServiceAccountList; +import io.fabric8.kubernetes.api.model.ServiceList; +import io.fabric8.kubernetes.api.model.authentication.TokenReview; import io.fabric8.kubernetes.api.model.certificates.v1beta1.CertificateSigningRequest; import io.fabric8.kubernetes.api.model.certificates.v1beta1.CertificateSigningRequestList; -import io.fabric8.kubernetes.api.model.authentication.TokenReview; import io.fabric8.kubernetes.api.model.coordination.v1.Lease; import io.fabric8.kubernetes.api.model.coordination.v1.LeaseList; import io.fabric8.kubernetes.api.model.node.v1beta1.RuntimeClass; import io.fabric8.kubernetes.api.model.node.v1beta1.RuntimeClassList; -import io.fabric8.kubernetes.client.dsl.*; +import io.fabric8.kubernetes.client.dsl.ApiextensionsAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.AppsAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.AuthorizationAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.AutoscalingAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.BatchAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.CertificatesAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.DiscoveryAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.EventingAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.ExtensionsAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.FlowControlAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.InOutCreateable; +import io.fabric8.kubernetes.client.dsl.KubernetesListMixedOperation; +import io.fabric8.kubernetes.client.dsl.MetricAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.MixedOperation; +import io.fabric8.kubernetes.client.dsl.NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable; +import io.fabric8.kubernetes.client.dsl.NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable; +import io.fabric8.kubernetes.client.dsl.Namespaceable; +import io.fabric8.kubernetes.client.dsl.NetworkAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; +import io.fabric8.kubernetes.client.dsl.ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable; +import io.fabric8.kubernetes.client.dsl.PodResource; +import io.fabric8.kubernetes.client.dsl.PolicyAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.RbacAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.Resource; +import io.fabric8.kubernetes.client.dsl.RollableScalableResource; +import io.fabric8.kubernetes.client.dsl.SchedulingAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.ServiceResource; +import io.fabric8.kubernetes.client.dsl.StorageAPIGroupDSL; +import io.fabric8.kubernetes.client.dsl.V1APIGroupDSL; import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; import io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext; -import io.fabric8.kubernetes.client.dsl.internal.RawCustomResourceOperationsImpl; import io.fabric8.kubernetes.client.extended.leaderelection.LeaderElectorBuilder; import io.fabric8.kubernetes.client.extended.run.RunOperations; import io.fabric8.kubernetes.client.informers.SharedInformerFactory; @@ -117,7 +144,7 @@ public interface KubernetesClient extends Client { */ @Deprecated MixedOperation, Resource> customResources(Class resourceType); - + /** * Typed API for managing resources. Any properly annotated POJO can be utilized as a resource. * @@ -134,7 +161,7 @@ public interface KubernetesClient extends Client { default MixedOperation, Resource> resources(Class resourceType) { return resources(resourceType, null); } - + /** * Typed API for managing resources. Any properly annotated POJO can be utilized as a resource. * @@ -196,7 +223,7 @@ default MixedOperation, Res */ @Deprecated > MixedOperation> customResources(ResourceDefinitionContext context, Class resourceType, Class listClass); - + /** * Semi-Typed API for managing {@link GenericKubernetesResource}s which can represent any resource. * @@ -207,13 +234,13 @@ default MixedOperation { + + String METRIC_ENDPOINT_URL = "apis/metrics.k8s.io/v1beta1/"; + + MetricOperation withName(String name); + + /** + * Filter metrics via labels. + * + * @param labels labels as HashMap + * @return {@link MetricOperation} with which you can call metrics() for getting filtered Metrics + */ + MetricOperation withLabels(Map labels); + + /** + * Get a list of metrics + * + * @return a list object for metrics + */ + L metrics(); + + /** + * Get a single metric. name needs to be provided. + * + * @return a single metric + */ + T metric(); + + /** + * Returns a list of metrics matching specified labels + * + * @param labelsMap labels as HashMap + * @return list of metrics found matching provided label + */ + L metrics(Map labelsMap); + +} diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/MixedOperation.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/MixedOperation.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/MixedOperation.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/MixedOperation.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/MultiDeleteable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/MultiDeleteable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/MultiDeleteable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/MultiDeleteable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Nameable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Nameable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Nameable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Nameable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Namespaceable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Namespaceable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Namespaceable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Namespaceable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/NamespacedInOutCreateable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NamespacedInOutCreateable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/NamespacedInOutCreateable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NamespacedInOutCreateable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/NetworkAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NetworkAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/NetworkAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NetworkAPIGroupDSL.java diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NodeMetricOperation.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NodeMetricOperation.java new file mode 100644 index 00000000000..d991ae394ab --- /dev/null +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NodeMetricOperation.java @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fabric8.kubernetes.client.dsl; + +import io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetrics; +import io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsList; + +import java.util.Map; + +public interface NodeMetricOperation + extends MetricOperation, Nameable { + + @Override + NodeMetricOperation withLabels(Map labels); + + /** + * Get NodeMetric with specified name + * + * @param nodeName name of the node + * @return NodeMetric fetched from ApiServer + */ + NodeMetrics metrics(String nodeName); + +} diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/NonNamespaceOperation.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NonNamespaceOperation.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/NonNamespaceOperation.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NonNamespaceOperation.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Operation.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Operation.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Operation.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Operation.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Outputable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Outputable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Outputable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Outputable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/ParameterMixedOperation.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/ParameterMixedOperation.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/ParameterMixedOperation.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/ParameterMixedOperation.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Parameterizable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Parameterizable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Parameterizable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Parameterizable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Patchable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Patchable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Patchable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Patchable.java diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/PodMetricOperation.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/PodMetricOperation.java new file mode 100644 index 00000000000..18f0118a2bb --- /dev/null +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/PodMetricOperation.java @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fabric8.kubernetes.client.dsl; + +import io.fabric8.kubernetes.api.model.metrics.v1beta1.PodMetrics; +import io.fabric8.kubernetes.api.model.metrics.v1beta1.PodMetricsList; + +import java.util.Map; + +public interface PodMetricOperation extends MetricOperation, Nameable, + Namespaceable { + + @Override + PodMetricOperation withLabels(Map labels); + + /** + * Get PodMetricsList for a namespace. + * + * @param namespace namespace for which PodMetrics are queries + * @return PodMetricsList for all pods in specified namespace + */ + PodMetricsList metrics(String namespace); + + /** + * Get PodMetrics in a namespace with a name. + * + * @param namespace namespace of pod + * @param podName name of pod + * @return PodMetric corresponding to specified Pod + */ + PodMetrics metrics(String namespace, String podName); + +} diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/PodResource.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/PodResource.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/PodResource.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/PodResource.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/PolicyAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/PolicyAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/PolicyAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/PolicyAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/PortForwardable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/PortForwardable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/PortForwardable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/PortForwardable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/PrettyLoggable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/PrettyLoggable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/PrettyLoggable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/PrettyLoggable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Prettyable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Prettyable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Prettyable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Prettyable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/RbacAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/RbacAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/RbacAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/RbacAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Readable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Readable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Readable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Readable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Readiable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Readiable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Readiable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Readiable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateApplicable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateApplicable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateApplicable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateApplicable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateCreateable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateCreateable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateCreateable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateCreateable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateFromServerGettable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateFromServerGettable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateFromServerGettable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/RecreateFromServerGettable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Recreateable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Recreateable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Recreateable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Recreateable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/ReplaceDeletable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/ReplaceDeletable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/ReplaceDeletable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/ReplaceDeletable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Replaceable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Replaceable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Replaceable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Replaceable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/RequestConfigurable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/RequestConfigurable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/RequestConfigurable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/RequestConfigurable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Requirable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Requirable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Requirable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Requirable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Resource.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Resource.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Resource.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Resource.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Rollable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Rollable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Rollable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Rollable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/RollableScalableResource.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/RollableScalableResource.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/RollableScalableResource.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/RollableScalableResource.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/ScalableResource.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/ScalableResource.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/ScalableResource.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/ScalableResource.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Scaleable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Scaleable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Scaleable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Scaleable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/SchedulingAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/SchedulingAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/SchedulingAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/SchedulingAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Secretable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Secretable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Secretable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Secretable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/ServiceResource.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/ServiceResource.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/ServiceResource.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/ServiceResource.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/StatusEditable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/StatusEditable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/StatusEditable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/StatusEditable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/StatusPatchable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/StatusPatchable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/StatusPatchable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/StatusPatchable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/StatusReplaceable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/StatusReplaceable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/StatusReplaceable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/StatusReplaceable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/StatusUpdatable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/StatusUpdatable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/StatusUpdatable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/StatusUpdatable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/StorageAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/StorageAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/StorageAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/StorageAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TailPrettyLoggable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TailPrettyLoggable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TailPrettyLoggable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TailPrettyLoggable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Tailable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Tailable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Tailable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Tailable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TerminateTimeTailPrettyLoggable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TerminateTimeTailPrettyLoggable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TerminateTimeTailPrettyLoggable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TerminateTimeTailPrettyLoggable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Terminateable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Terminateable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Terminateable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Terminateable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TimeTailPrettyLoggable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TimeTailPrettyLoggable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TimeTailPrettyLoggable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TimeTailPrettyLoggable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Timeable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Timeable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Timeable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Timeable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TimeoutImageEditReplacePatchable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TimeoutImageEditReplacePatchable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TimeoutImageEditReplacePatchable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TimeoutImageEditReplacePatchable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Timeoutable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Timeoutable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Timeoutable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Timeoutable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TimestampBytesLimitTerminateTimeTailPrettyLoggable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TimestampBytesLimitTerminateTimeTailPrettyLoggable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TimestampBytesLimitTerminateTimeTailPrettyLoggable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TimestampBytesLimitTerminateTimeTailPrettyLoggable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Timestampable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Timestampable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Timestampable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Timestampable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Triggerable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Triggerable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Triggerable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Triggerable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecErrorChannelable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecErrorChannelable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecErrorChannelable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecErrorChannelable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecErrorable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecErrorable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecErrorable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecErrorable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecInputOutputErrorable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecInputOutputErrorable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecInputOutputErrorable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecInputOutputErrorable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecOutputErrorable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecOutputErrorable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecOutputErrorable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecOutputErrorable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/TtyExecable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Ttyable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Ttyable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Ttyable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Ttyable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Typeable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Typeable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Typeable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Typeable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Uploadable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Uploadable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Uploadable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Uploadable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1APIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1APIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1APIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1APIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1BatchAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1BatchAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1BatchAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1BatchAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1CertificatesAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1CertificatesAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1CertificatesAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1CertificatesAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1DiscoveryAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1DiscoveryAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1DiscoveryAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1DiscoveryAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1EventingAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1EventingAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1EventingAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1EventingAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1PolicyAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1PolicyAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1PolicyAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1PolicyAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1SchedulingAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1SchedulingAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1SchedulingAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1SchedulingAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1BatchAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1BatchAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1BatchAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1BatchAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1CertificatesAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1CertificatesAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1CertificatesAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1CertificatesAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1DiscoveryAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1DiscoveryAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1DiscoveryAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1DiscoveryAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1EventingAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1EventingAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1EventingAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1EventingAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1FlowControlAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1FlowControlAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1FlowControlAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1FlowControlAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1PolicyAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1PolicyAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1PolicyAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1PolicyAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1SchedulingAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1SchedulingAPIGroupDSL.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1SchedulingAPIGroupDSL.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/V1beta1SchedulingAPIGroupDSL.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/VersionWatchAndWaitable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/VersionWatchAndWaitable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/VersionWatchAndWaitable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/VersionWatchAndWaitable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Versionable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Versionable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Versionable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Versionable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/VisitFromServerGetWatchDeleteRecreateWaitApplicable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/VisitFromServerGetWatchDeleteRecreateWaitApplicable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/VisitFromServerGetWatchDeleteRecreateWaitApplicable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/VisitFromServerGetWatchDeleteRecreateWaitApplicable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/VisitFromServerWritable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/VisitFromServerWritable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/VisitFromServerWritable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/VisitFromServerWritable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Waitable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Waitable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Waitable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Waitable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/WatchAndWaitable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/WatchAndWaitable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/WatchAndWaitable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/WatchAndWaitable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/WatchListDeletable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/WatchListDeletable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/WatchListDeletable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/WatchListDeletable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Watchable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Watchable.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Watchable.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Watchable.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/WritableOperation.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/WritableOperation.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/WritableOperation.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/WritableOperation.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/CustomResourceDefinitionContext.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/base/CustomResourceDefinitionContext.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/CustomResourceDefinitionContext.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/base/CustomResourceDefinitionContext.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchContext.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchContext.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchContext.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchContext.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchType.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchType.java similarity index 71% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchType.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchType.java index 57e5867d8e5..0c6ebfb9136 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchType.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchType.java @@ -15,17 +15,13 @@ */ package io.fabric8.kubernetes.client.dsl.base; -import static io.fabric8.kubernetes.client.dsl.base.OperationSupport.JSON_PATCH; -import static io.fabric8.kubernetes.client.dsl.base.OperationSupport.JSON_MERGE_PATCH; -import static io.fabric8.kubernetes.client.dsl.base.OperationSupport.STRATEGIC_MERGE_JSON_PATCH; - /** * Enum for different Patch types supported by Patch */ public enum PatchType { - JSON(JSON_PATCH), - JSON_MERGE(JSON_MERGE_PATCH), - STRATEGIC_MERGE(STRATEGIC_MERGE_JSON_PATCH); + JSON("application/json-patch+json"), + JSON_MERGE("application/merge-patch+json"), + STRATEGIC_MERGE("application/strategic-merge-patch+json"); private final String contentType; diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/ResourceDefinitionContext.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/base/ResourceDefinitionContext.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/ResourceDefinitionContext.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/base/ResourceDefinitionContext.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderCallbacks.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderCallbacks.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderCallbacks.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderCallbacks.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectionConfig.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectionConfig.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectionConfig.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectionConfig.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElector.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElector.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElector.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElector.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorBuilder.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorBuilder.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorBuilder.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/LeaderElectorBuilder.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLock.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLock.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLock.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLock.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaderElectionRecord.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaderElectionRecord.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaderElectionRecord.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaderElectionRecord.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaseLock.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaseLock.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaseLock.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LeaseLock.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/Lock.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/Lock.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/Lock.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/Lock.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LockException.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LockException.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LockException.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/resourcelock/LockException.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/run/RunConfig.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/run/RunConfig.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/run/RunConfig.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/run/RunConfig.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/run/RunConfigUtil.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/run/RunConfigUtil.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/run/RunConfigUtil.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/run/RunConfigUtil.java diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/run/RunOperations.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/run/RunOperations.java new file mode 100644 index 00000000000..de8177d7097 --- /dev/null +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extended/run/RunOperations.java @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.kubernetes.client.extended.run; + +import io.fabric8.kubernetes.api.model.Pod; + +public interface RunOperations { + + /** + * Specify namespace for the operation + * + * @param namespace namespace in which resource needs to be created + * @return {@link RunOperations} with injected namespace + */ + RunOperations inNamespace(String namespace); + + /** + * Specify image for the Pod + * + * @param image image as a string + * @return {@link RunOperations} with image injected into {@link RunConfig} + */ + RunOperations withImage(String image); + + /** + * Specify name for the Pod + * + * @param name name of the pod to be created + * @return {@link RunOperations} with name injected into {@link RunConfig} + */ + RunOperations withName(String name); + + /** + * Specify complex configuration for Pod creating using {@link RunConfig} + * + * @param generatorRunConfig {@link RunConfig} which allows to provide configuring environment variables, labels, resources, ports etc + * @return {@link RunOperations} with specified configuration + */ + RunOperations withRunConfig(RunConfig generatorRunConfig); + + /** + * Apply the {@link RunConfig} onto the cluster and create Pod + * + * @return Pod which got created from the operation + */ + Pod done(); + +} diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/BasicBuilder.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/BasicBuilder.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/BasicBuilder.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/BasicBuilder.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/HttpClient.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpClient.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/HttpClient.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpClient.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/HttpHeaders.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpHeaders.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/HttpHeaders.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpHeaders.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/HttpRequest.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpRequest.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/HttpRequest.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpRequest.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/HttpResponse.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpResponse.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/HttpResponse.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpResponse.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/HttpStatusMessage.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpStatusMessage.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/HttpStatusMessage.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpStatusMessage.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/Interceptor.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/Interceptor.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/Interceptor.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/Interceptor.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/TlsVersion.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/TlsVersion.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/TlsVersion.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/TlsVersion.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/WebSocket.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/WebSocket.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/WebSocket.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/WebSocket.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/WebSocketHandshakeException.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/WebSocketHandshakeException.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/http/WebSocketHandshakeException.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/WebSocketHandshakeException.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/ListerWatcher.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/ListerWatcher.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/ListerWatcher.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/ListerWatcher.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/ResourceEventHandler.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/ResourceEventHandler.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/ResourceEventHandler.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/ResourceEventHandler.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedIndexInformer.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/SharedIndexInformer.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedIndexInformer.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/SharedIndexInformer.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformer.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformer.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformer.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformer.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerEventListener.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerEventListener.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerEventListener.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerEventListener.java diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactory.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactory.java new file mode 100644 index 00000000000..d93d7575cf6 --- /dev/null +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactory.java @@ -0,0 +1,163 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fabric8.kubernetes.client.informers; + +import io.fabric8.kubernetes.api.model.GenericKubernetesResource; +import io.fabric8.kubernetes.api.model.HasMetadata; +import io.fabric8.kubernetes.api.model.KubernetesResourceList; +import io.fabric8.kubernetes.client.CustomResource; +import io.fabric8.kubernetes.client.dsl.Informable; +import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; +import io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext; + +import java.util.concurrent.Future; + +public interface SharedInformerFactory { + + /** + * Configure Namespace for {@link SharedInformerFactory} + * + * @param namespace namespace to configure + * @return {@link SharedInformerFactory} with namespace configured + * @deprecated use {@link Informable} instead + */ + @Deprecated + SharedInformerFactory inNamespace(String namespace); + + /** + * Configure Name for {@link SharedInformerFactory} + * + * @param name name to be configured + * @return {@link SharedInformerFactory} with name configured + * @deprecated use {@link Informable} instead + */ + @Deprecated + SharedInformerFactory withName(String name); + + /** + * Constructs and returns a shared index informer with resync period specified. And the + * informer cache will be overwritten. + * + * Note:It watches for events in ALL NAMESPACES. + * + * @param apiTypeClass apiType class + * @param resyncPeriodInMillis resync period in milliseconds + * @param the type parameter (should extend {@link io.fabric8.kubernetes.api.model.HasMetadata} and implement {@link io.fabric8.kubernetes.api.model.Namespaced}) if Namespace scoped resource + * @return the shared index informer + */ + SharedIndexInformer sharedIndexInformerFor(Class apiTypeClass, + long resyncPeriodInMillis); + + /** + * Constructs and returns a shared index informer with resync period specified for custom resources. + * + * Note:It watches for events in ALL NAMESPACES. + * + * @param customResourceContext basic information about the Custom Resource Definition corresponding to that custom resource + * @param apiTypeClass apiType class + * @param apiListTypeClass api list type class + * @param resyncPeriodInMillis resync period in milliseconds + * @param the type parameter (should extend {@link io.fabric8.kubernetes.api.model.HasMetadata} and implement {@link io.fabric8.kubernetes.api.model.Namespaced}) + * @param the type's list parameter (should extend {@link io.fabric8.kubernetes.api.model.KubernetesResourceList} + * @return the shared index informer + * @deprecated Since 5.x versions of client {@link CustomResourceDefinitionContext} are configured via annotations in CustomResource implementations, please use any of the alternative sharedIndexInformerForCustomResource methods + */ + @Deprecated + , L extends KubernetesResourceList> SharedIndexInformer sharedIndexInformerForCustomResource( + CustomResourceDefinitionContext customResourceContext, Class apiTypeClass, Class apiListTypeClass, + long resyncPeriodInMillis); + + /** + * Constructs and returns a shared index informer with resync period specified for a Custom Resource. You + * can use it for scenarios where you don't have a POJO for your custom type by specifying group, version and plural in + * {@link CustomResourceDefinitionContext} + * + * Note:It watches for events in ALL NAMESPACES. + * + * @param genericResourceContext object containing details about resource like apiGroup, version and plural, etc. + * @param resyncPeriodInMillis resync period in milliseconds. + * @return {@link SharedIndexInformer} for GenericKubernetesResource + * @deprecated use {@link #sharedIndexInformerFor(Class, long)} + */ + @Deprecated + SharedIndexInformer sharedIndexInformerForCustomResource( + ResourceDefinitionContext genericResourceContext, long resyncPeriodInMillis); + + /** + * Constructs and returns a shared index informer with resync period specified for custom resources. + * POJO + * + * @param apiTypeClass apiType class + * @param resyncPeriodInMillis resync period in milliseconds + * @param the type parameter (should extend {@link io.fabric8.kubernetes.api.model.HasMetadata} and implement {@link io.fabric8.kubernetes.api.model.Namespaced}) + * @return the shared index informer + * @deprecated use {@link #sharedIndexInformerFor(Class, long)} instead + */ + @Deprecated + > SharedIndexInformer sharedIndexInformerForCustomResource( + Class apiTypeClass, long resyncPeriodInMillis); + + /** + * Constructs and returns a shared index informer with resync period specified for custom resources. + * + * Note:It watches for events in ALL NAMESPACES. + * + * @param apiTypeClass apiType class + * @param apiListTypeClass api list type class + * @param resyncPeriodInMillis resync period in milliseconds + * @param the type parameter (should extend {@link io.fabric8.kubernetes.api.model.HasMetadata} and implement {@link io.fabric8.kubernetes.api.model.Namespaced}) + * @param the type's list parameter (should extend {@link io.fabric8.kubernetes.api.model.KubernetesResourceList} + * @return the shared index informer + * @deprecated use {@link #sharedIndexInformerFor(Class, long)} + */ + @Deprecated + , L extends KubernetesResourceList> SharedIndexInformer sharedIndexInformerForCustomResource( + Class apiTypeClass, Class apiListTypeClass, long resyncPeriodInMillis); + + /** + * Gets existing shared index informer, return null if the requesting informer + * is never constructed. If there are multiple SharedIndexInformer objects corresponding + * to a Kubernetes resource, then it returns the first one + * + * @param apiTypeClass API type class + * @param type of API type + * @return SharedIndexInformer object + */ + SharedIndexInformer getExistingSharedIndexInformer(Class apiTypeClass); + + /** + * Starts all registered informers in an asynchronous fashion. + * + * @return {@link Future} for status of all started informer tasks. + */ + Future startAllRegisteredInformers(); + + /** + * Stop all registered informers and shut down thread pool. + */ + void stopAllRegisteredInformers(); + + /** + * Stop all registered informers + * + * @param shutDownThreadPool Whether to shut down thread pool or not. + */ + void stopAllRegisteredInformers(boolean shutDownThreadPool); + + void addSharedInformerEventListener(SharedInformerEventListener event); + +} diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Cache.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Cache.java new file mode 100644 index 00000000000..7e66aca03fe --- /dev/null +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Cache.java @@ -0,0 +1,93 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.kubernetes.client.informers.cache; + +import io.fabric8.kubernetes.api.model.ObjectMeta; +import io.fabric8.kubernetes.client.utils.ReflectUtils; +import io.fabric8.kubernetes.client.utils.Utils; + +import java.util.Collections; +import java.util.List; + +/** + * It basically saves and indexes all the entries. + * + * @param type for cache object + */ +public interface Cache extends Indexer { + + // NAMESPACE_INDEX is the default index function for caching objects + public static final String NAMESPACE_INDEX = "namespace"; + + /** + * It's is a convenient default KeyFunc which know show to make keys for API + * objects which implement HasMetadata interface. The key uses the format + * namespace/name unless namespace is empty, then it's just name + * + * @param obj specific object + * @return the key + */ + public static String metaNamespaceKeyFunc(Object obj) { + try { + if( obj == null ) { + return ""; + } + ObjectMeta metadata; + if(obj instanceof String) { + return (String) obj; + } else if (obj instanceof ObjectMeta) { + metadata = (ObjectMeta) obj; + } else { + metadata = ReflectUtils.objectMetadata(obj); + if (metadata == null) { + throw new RuntimeException("Object is bad :" + obj); + } + } + + return namespaceKeyFunc(metadata.getNamespace(), metadata.getName()); + } catch (ReflectiveOperationException e) { + throw new RuntimeException(e); + } + } + + /** + * Default index function that indexes based on an object's namespace and name. + * + * @see #metaNamespaceKeyFunc + */ + public static String namespaceKeyFunc(String objectNamespace, String objectName) { + if (Utils.isNullOrEmpty(objectNamespace)) { + return objectName; + } + return objectNamespace + "/" + objectName; + } + + /** + * It is a default index function that indexes based on an object's namespace + * + * @param obj the specific object + * @return the indexed value + */ + public static List metaNamespaceIndexFunc(Object obj) { + try { + ObjectMeta metadata = ReflectUtils.objectMetadata(obj); + return metadata == null ? Collections.emptyList() : Collections.singletonList(metadata.getNamespace()); + } catch (ReflectiveOperationException e) { + throw new RuntimeException(e); + } + } +} + diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/Indexer.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Indexer.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/Indexer.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Indexer.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/Lister.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Lister.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/Lister.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Lister.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/Store.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Store.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/Store.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Store.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/CertUtils.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/CertUtils.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/CertUtils.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/CertUtils.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/KubeConfigUtils.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/KubeConfigUtils.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/KubeConfigUtils.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/KubeConfigUtils.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/PKCS1Util.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/PKCS1Util.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/PKCS1Util.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/PKCS1Util.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/SSLUtils.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/SSLUtils.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/SSLUtils.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/SSLUtils.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/readiness/Readiness.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/readiness/Readiness.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/readiness/Readiness.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/internal/readiness/Readiness.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/lib/FileSystem.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/lib/FileSystem.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/lib/FileSystem.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/lib/FileSystem.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/lib/FilenameUtils.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/lib/FilenameUtils.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/lib/FilenameUtils.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/lib/FilenameUtils.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ApiVersionUtil.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ApiVersionUtil.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ApiVersionUtil.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ApiVersionUtil.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/BackwardsCompatibilityInterceptor.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/BackwardsCompatibilityInterceptor.java similarity index 97% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/BackwardsCompatibilityInterceptor.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/BackwardsCompatibilityInterceptor.java index be4dbc10b32..386ca1de89c 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/BackwardsCompatibilityInterceptor.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/BackwardsCompatibilityInterceptor.java @@ -16,23 +16,24 @@ package io.fabric8.kubernetes.client.utils; import io.fabric8.kubernetes.api.model.HasMetadata; -import io.fabric8.kubernetes.client.dsl.base.OperationSupport; import io.fabric8.kubernetes.client.http.BasicBuilder; import io.fabric8.kubernetes.client.http.HttpRequest; +import io.fabric8.kubernetes.client.http.HttpRequest.Builder; import io.fabric8.kubernetes.client.http.HttpResponse; import io.fabric8.kubernetes.client.http.Interceptor; -import io.fabric8.kubernetes.client.http.HttpRequest.Builder; import java.net.HttpURLConnection; import java.net.URI; import java.util.HashMap; import java.util.Map; import java.util.Objects; -import java.util.regex.Pattern; import java.util.regex.Matcher; +import java.util.regex.Pattern; public class BackwardsCompatibilityInterceptor implements Interceptor { - + + public static final String JSON = "application/json"; + public static final String NAME = "BACKWARDS"; private static final int API_GROUP = 1; @@ -129,14 +130,14 @@ public int hashCode() { openshiftOAPITransformations.put("imagestreamtags", new ResourceKey("ImageStream", "imagestreamtags", "image.openshift.io", "v1")); openshiftOAPITransformations.put("securitycontextconstraints", new ResourceKey("SecurityContextConstraints", "securitycontextconstraints", "security.openshift.io", "v1")); } - + @Override public boolean afterFailure(Builder builder, HttpResponse response) { ResourceKey target = findNewTarget(builder, response); if (target == null) { return false; } - + HttpRequest request = response.request(); if (request.bodyString() != null && !request.method().equalsIgnoreCase(PATCH)) { Object object = Serialization.unmarshal(request.bodyString()); @@ -145,13 +146,13 @@ public boolean afterFailure(Builder builder, HttpResponse response) { h.setApiVersion(target.group + "/" + target.version); switch (request.method()) { case "POST": - builder.post(OperationSupport.JSON, Serialization.asJson(h)); + builder.post(JSON, Serialization.asJson(h)); break; case "PUT": - builder.put(OperationSupport.JSON, Serialization.asJson(h)); + builder.put(JSON, Serialization.asJson(h)); break; case "DELETE": - builder.delete(OperationSupport.JSON, Serialization.asJson(h)); + builder.delete(JSON, Serialization.asJson(h)); break; default: return false; @@ -161,7 +162,7 @@ public boolean afterFailure(Builder builder, HttpResponse response) { return true; } - + public ResourceKey findNewTarget(BasicBuilder basicBuilder, HttpResponse response) { HttpRequest request = response.request(); if (isDeprecatedOpenshiftOapiRequest(request)) { @@ -182,7 +183,7 @@ public ResourceKey findNewTarget(BasicBuilder basicBuilder, HttpResponse resp } return null; } - + @Override public boolean afterFailure(BasicBuilder basicBuilder, HttpResponse response) { return findNewTarget(basicBuilder, response) != null; diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/CachedSingleThreadScheduler.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/CachedSingleThreadScheduler.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/CachedSingleThreadScheduler.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/CachedSingleThreadScheduler.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java similarity index 86% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java index 3cc0020f57e..8bd0d8f434b 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java @@ -22,15 +22,12 @@ import io.fabric8.kubernetes.client.http.HttpHeaders; import io.fabric8.kubernetes.client.http.Interceptor; import io.fabric8.kubernetes.client.internal.SSLUtils; -import io.fabric8.kubernetes.client.okhttp.OkHttpClientFactory; -import io.fabric8.kubernetes.client.okhttp.OkHttpClientImpl; -import okhttp3.OkHttpClient; -import okhttp3.OkHttpClient.Builder; import javax.net.ssl.KeyManager; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; +import java.lang.reflect.InvocationTargetException; import java.net.InetSocketAddress; import java.net.MalformedURLException; import java.net.URL; @@ -40,15 +37,14 @@ import java.util.Locale; import java.util.Map; import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; public class HttpClientUtils { - + public static final String HEADER_INTERCEPTOR = "HEADER"; - + private HttpClientUtils() { } private static Pattern VALID_IPV4_PATTERN = null; @@ -62,25 +58,6 @@ private HttpClientUtils() { } throw KubernetesClientException.launderThrowable("Unable to compile ipv4address pattern.", e); } } - - /** - * Creates an HTTP client configured to access the Kubernetes API. - * @param config Kubernetes API client config - * @param additionalConfig a consumer that allows overriding HTTP client properties - * @return returns an HTTP client - * @deprecated subclass {@link OkHttpClientFactory} and implement the additionalConfig method - */ - @Deprecated - public static OkHttpClientImpl createHttpClient(final Config config, final Consumer additionalConfig) { - return new OkHttpClientFactory() { - @Override - protected void additionalConfig(Builder builder) { - if (additionalConfig != null) { - additionalConfig.accept(builder); - } - } - }.createHttpClient(config); - } public static URL getProxyUrl(Config config) throws MalformedURLException { URL master = new URL(config.getMasterUrl()); @@ -115,10 +92,10 @@ private static boolean isIpAddress(String ipAddress) { public static Map createApplicableInterceptors(Config config, HttpClient.Factory factory) { Map interceptors = new LinkedHashMap<>(); - + // Header Interceptor interceptors.put(HEADER_INTERCEPTOR, new Interceptor() { - + @Override public void before(BasicBuilder builder, HttpHeaders headers) { if (Utils.isNotNullOrEmpty(config.getUsername()) && Utils.isNotNullOrEmpty(config.getPassword())) { @@ -148,7 +125,7 @@ public void before(BasicBuilder builder, HttpHeaders headers) { return interceptors; } - + public static String basicCredentials(String username, String password) { String usernameAndPassword = username + ":" + password; String encoded = Base64.getEncoder().encodeToString(usernameAndPassword.getBytes(StandardCharsets.ISO_8859_1)); @@ -156,13 +133,20 @@ public static String basicCredentials(String username, String password) { } public static HttpClient createHttpClient(Config config) { - // TODO: replace with reflection / service load and factory interface - return new OkHttpClientFactory().createHttpClient(config); + // TODO: replace with service load + try { + return ((HttpClient.Factory) Class.forName("io.fabric8.kubernetes.client.okhttp.OkHttpClientFactory") + .getDeclaredConstructor() + .newInstance()).createHttpClient(config); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException + | NoSuchMethodException | SecurityException | ClassNotFoundException e) { + throw KubernetesClientException.launderThrowable(e); + } } - + public static void applyCommonConfiguration(Config config, HttpClient.Builder builder, HttpClient.Factory factory) { builder.followAllRedirects(); - + if (config.getConnectionTimeout() > 0) { builder.connectTimeout(config.getConnectionTimeout(), TimeUnit.MILLISECONDS); } @@ -170,13 +154,13 @@ public static void applyCommonConfiguration(Config config, HttpClient.Builder bu if (config.getRequestTimeout() > 0) { builder.readTimeout(config.getRequestTimeout(), TimeUnit.MILLISECONDS); } - + if (config.isHttp2Disable()) { builder.preferHttp11(); } - + try { - + // Only check proxy if it's a full URL with protocol if (config.getMasterUrl().toLowerCase(Locale.ROOT).startsWith(Config.HTTP_PROTOCOL_PREFIX) || config.getMasterUrl().startsWith(Config.HTTPS_PROTOCOL_PREFIX)) { @@ -195,21 +179,21 @@ public static void applyCommonConfiguration(Config config, HttpClient.Builder bu throw new KubernetesClientException("Invalid proxy server configuration", e); } } - + TrustManager[] trustManagers = SSLUtils.trustManagers(config); KeyManager[] keyManagers = SSLUtils.keyManagers(config); - + SSLContext sslContext = SSLUtils.sslContext(keyManagers, trustManagers); builder.sslContext(sslContext, trustManagers); - + if (config.getTlsVersions() != null && config.getTlsVersions().length > 0) { builder.tlsVersions(config.getTlsVersions()); } - + } catch (Exception e) { KubernetesClientException.launderThrowable(e); } HttpClientUtils.createApplicableInterceptors(config, factory).forEach(builder::addOrReplaceInterceptor); } - + } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/IOHelpers.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/IOHelpers.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/IOHelpers.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/IOHelpers.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ImpersonatorInterceptor.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ImpersonatorInterceptor.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ImpersonatorInterceptor.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ImpersonatorInterceptor.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/InputStreamPumper.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/InputStreamPumper.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/InputStreamPumper.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/InputStreamPumper.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/IpAddressMatcher.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/IpAddressMatcher.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/IpAddressMatcher.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/IpAddressMatcher.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesResourceUtil.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesVersionFactory.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesVersionFactory.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesVersionFactory.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesVersionFactory.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesVersionPriority.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesVersionPriority.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesVersionPriority.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesVersionPriority.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/OpenIDConnectionUtils.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/OpenIDConnectionUtils.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/OpenIDConnectionUtils.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/OpenIDConnectionUtils.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/OptionalDependencyWrapper.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/OptionalDependencyWrapper.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/OptionalDependencyWrapper.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/OptionalDependencyWrapper.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/PodStatusUtil.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/PodStatusUtil.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/PodStatusUtil.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/PodStatusUtil.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ReflectUtils.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReflectUtils.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ReflectUtils.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReflectUtils.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ReplaceValueStream.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReplaceValueStream.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ReplaceValueStream.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReplaceValueStream.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ResourceCompare.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ResourceCompare.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/ResourceCompare.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ResourceCompare.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/TokenRefreshInterceptor.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/TokenRefreshInterceptor.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/TokenRefreshInterceptor.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/TokenRefreshInterceptor.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/URLFromServiceUtil.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/URLFromServiceUtil.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/URLFromServiceUtil.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/URLFromServiceUtil.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/URLUtils.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/URLUtils.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/URLUtils.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/URLUtils.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Utils.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/Utils.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/Utils.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/Utils.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/serialization/BeanPropertyWriterDelegate.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/serialization/BeanPropertyWriterDelegate.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/serialization/BeanPropertyWriterDelegate.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/serialization/BeanPropertyWriterDelegate.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/serialization/SettableBeanPropertyDelegate.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/serialization/SettableBeanPropertyDelegate.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/serialization/SettableBeanPropertyDelegate.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/serialization/SettableBeanPropertyDelegate.java diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/serialization/UnmatchedFieldTypeModule.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/serialization/UnmatchedFieldTypeModule.java similarity index 100% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/utils/serialization/UnmatchedFieldTypeModule.java rename to kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/serialization/UnmatchedFieldTypeModule.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/ConfigTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/ConfigTest.java similarity index 92% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/ConfigTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/ConfigTest.java index 28d89c696b5..089f7d79862 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/ConfigTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/ConfigTest.java @@ -20,7 +20,6 @@ import io.fabric8.kubernetes.api.model.ExecConfigBuilder; import io.fabric8.kubernetes.client.http.TlsVersion; import io.fabric8.kubernetes.client.lib.FileSystem; -import io.fabric8.kubernetes.client.utils.Serialization; import io.fabric8.kubernetes.client.utils.Utils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; @@ -28,9 +27,7 @@ import org.junit.jupiter.api.Test; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; @@ -47,7 +44,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; public class ConfigTest { @@ -55,15 +51,13 @@ public class ConfigTest { private static final String TEST_EC_KUBECONFIG_FILE = Utils.filePath(ConfigTest.class.getResource("/test-ec-kubeconfig")); private static final String TEST_NAMESPACE_FILE = Utils.filePath(ConfigTest.class.getResource("/test-namespace")); - private static final String TEST_CONFIG_YML_FILE = Utils.filePath(ConfigTest.class.getResource("/test-config.yml")); - private static final String TEST_KUBECONFIG_EXEC_FILE = Utils.filePath(ConfigTest.class.getResource("/test-kubeconfig-exec")); private static final String TEST_TOKEN_GENERATOR_FILE = Utils.filePath(ConfigTest.class.getResource("/token-generator")); private static final String TEST_KUBECONFIG_EXEC_WIN_FILE = Utils.filePath(ConfigTest.class.getResource("/test-kubeconfig-exec-win")); private static final String TEST_KUBECONFIG_NO_CURRENT_CONTEXT_FILE = Utils.filePath(ConfigTest.class.getResource("/test-kubeconfig-nocurrentctxt.yml")); - + @BeforeEach public void setUp() { System.getProperties().remove(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY); @@ -435,50 +429,6 @@ void shouldSetImpersonateUsernameAndGroupFromSystemProperty() { } - @Test - void shouldInstantiateClientUsingYaml() { - File configYml = new File(TEST_CONFIG_YML_FILE); - try (InputStream is = new FileInputStream(configYml)){ - KubernetesClient client = DefaultKubernetesClient.fromConfig(is); - assertEquals("http://some.url", client.getMasterUrl().toString()); - } catch (Exception e) { - fail(); - } - } - - @Test - void shouldInstantiateClientUsingSerializeDeserialize() { - DefaultKubernetesClient original = new DefaultKubernetesClient(); - String json = Serialization.asJson(original.getConfiguration()); - DefaultKubernetesClient copy = DefaultKubernetesClient.fromConfig(json); - - assertEquals(original.getConfiguration().getMasterUrl(), copy.getConfiguration().getMasterUrl()); - assertEquals(original.getConfiguration().getOauthToken(), copy.getConfiguration().getOauthToken()); - assertEquals(original.getConfiguration().getNamespace(), copy.getConfiguration().getNamespace()); - assertEquals(original.getConfiguration().getUsername(), copy.getConfiguration().getUsername()); - assertEquals(original.getConfiguration().getPassword(), copy.getConfiguration().getPassword()); - } - - @Test - void shouldPropagateImpersonateSettings() { - - final Map> extras = new HashMap<>(); - extras.put("c", Collections.singletonList("d")); - - final Config config = new ConfigBuilder() - .withImpersonateUsername("a") - .withImpersonateGroup("b") - .withImpersonateExtras(extras) - .build(); - - final DefaultKubernetesClient client = new DefaultKubernetesClient(config); - final Config currentConfig = client.getConfiguration(); - - assertEquals("a", currentConfig.getImpersonateUsername()); - assertArrayEquals(new String[]{"b"}, currentConfig.getImpersonateGroups()); - assertEquals(Collections.singletonList("d"), currentConfig.getImpersonateExtras().get("c")); - } - @Test void honorClientAuthenticatorCommands() throws Exception { switch (FileSystem.getCurrent()) { diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/Custom.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/Custom.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/Custom.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/Custom.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/CustomResourceTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/CustomResourceTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/CustomResourceTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/CustomResourceTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/Good.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/Good.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/Good.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/Good.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/base/CustomResourceDefinitionContextTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/dsl/base/CustomResourceDefinitionContextTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/base/CustomResourceDefinitionContextTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/dsl/base/CustomResourceDefinitionContextTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/base/ResourceDefinitionContextTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/dsl/base/ResourceDefinitionContextTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/base/ResourceDefinitionContextTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/dsl/base/ResourceDefinitionContextTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/internal/readiness/ReadinessTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/readiness/ReadinessTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/internal/readiness/ReadinessTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/readiness/ReadinessTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/serialization/SettableBeanPropertyDelegateTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/serialization/SettableBeanPropertyDelegateTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/serialization/SettableBeanPropertyDelegateTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/serialization/SettableBeanPropertyDelegateTest.java diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/serialization/UnmatchedFieldTypeModuleTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/serialization/UnmatchedFieldTypeModuleTest.java similarity index 100% rename from kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/serialization/UnmatchedFieldTypeModuleTest.java rename to kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/serialization/UnmatchedFieldTypeModuleTest.java diff --git a/kubernetes-client/src/test/resources/test-ec-kubeconfig b/kubernetes-client-api/src/test/resources/test-ec-kubeconfig similarity index 100% rename from kubernetes-client/src/test/resources/test-ec-kubeconfig rename to kubernetes-client-api/src/test/resources/test-ec-kubeconfig diff --git a/kubernetes-client-api/src/test/resources/test-kubeconfig b/kubernetes-client-api/src/test/resources/test-kubeconfig new file mode 100644 index 00000000000..79ad054744f --- /dev/null +++ b/kubernetes-client-api/src/test/resources/test-kubeconfig @@ -0,0 +1,44 @@ +apiVersion: v1 +clusters: +- cluster: + certificate-authority: testns/ca.pem + insecure-skip-tls-verify: true + server: https://172.28.128.4:8443 + name: 172-28-128-4:8443 +contexts: +- context: + cluster: 172-28-128-4:8443 + namespace: testns + user: user/172-28-128-4:8443 + name: testns/172-28-128-4:8443/user +- context: + cluster: 172-28-128-4:8443 + namespace: production + user: root/172-28-128-4:8443 + name: production/172-28-128-4:8443/root +- context: + cluster: 172-28-128-4:8443 + namespace: production + user: mmosley + name: production/172-28-128-4:8443/mmosley +current-context: testns/172-28-128-4:8443/user +kind: Config +preferences: {} +users: +- name: user/172-28-128-4:8443 + user: + token: token +- name: root/172-28-128-4:8443 + user: + token: supertoken +- name: mmosley + user: + auth-provider: + config: + client-id: kubernetes + client-secret: 1db158f6-177d-4d9c-8a8b-d36869918ec5 + id-token: eyJraWQiOiJDTj1vaWRjaWRwLnRyZW1vbG8ubGFuLCBPVT1EZW1vLCBPPVRybWVvbG8gU2VjdXJpdHksIEw9QXJsaW5ndG9uLCBTVD1WaXJnaW5pYSwgQz1VUy1DTj1rdWJlLWNhLTEyMDIxNDc5MjEwMzYwNzMyMTUyIiwiYWxnIjoiUlMyNTYifQ.eyJpc3MiOiJodHRwczovL29pZGNpZHAudHJlbW9sby5sYW46ODQ0My9hdXRoL2lkcC9PaWRjSWRQIiwiYXVkIjoia3ViZXJuZXRlcyIsImV4cCI6MTQ4MzU0OTUxMSwianRpIjoiMm96US15TXdFcHV4WDlHZUhQdy1hZyIsImlhdCI6MTQ4MzU0OTQ1MSwibmJmIjoxNDgzNTQ5MzMxLCJzdWIiOiI0YWViMzdiYS1iNjQ1LTQ4ZmQtYWIzMC0xYTAxZWU0MWUyMTgifQ.w6p4J_6qQ1HzTG9nrEOrubxIMb9K5hzcMPxc9IxPx2K4xO9l-oFiUw93daH3m5pluP6K7eOE6txBuRVfEcpJSwlelsOsW8gb8VJcnzMS9EnZpeA0tW_p-mnkFc3VcfyXuhe5R3G7aa5d8uHv70yJ9Y3-UhjiN9EhpMdfPAoEB9fYKKkJRzF7utTTIPGrSaSU6d2pcpfYKaxIwePzEkT4DfcQthoZdy9ucNvvLoi1DIC-UocFD8HLs8LYKEqSxQvOcvnThbObJ9af71EwmuE21fO5KzMW20KtAeget1gnldOosPtz1G5EwvaQ401-RPQzPGMVBld0_zMCAwZttJ4knw + idp-certificate-authority: /root/ca.pem + idp-issuer-url: https://oidcidp.tremolo.lan:8443/auth/idp/OidcIdP + refresh-token: q1bKLFOyUiosTfawzA93TzZIDzH2TNa2SMm0zEiPKTUwME6BkEo6Sql5yUWVBSWpKUGphaWpxSVAfekBOZbBhaEW+VlFUeVRGcluyVF5JT4+haZmPsluFoFu5XkpXk5BXq + name: oidc diff --git a/kubernetes-client/src/test/resources/test-kubeconfig-exec b/kubernetes-client-api/src/test/resources/test-kubeconfig-exec similarity index 100% rename from kubernetes-client/src/test/resources/test-kubeconfig-exec rename to kubernetes-client-api/src/test/resources/test-kubeconfig-exec diff --git a/kubernetes-client/src/test/resources/test-kubeconfig-exec-win b/kubernetes-client-api/src/test/resources/test-kubeconfig-exec-win similarity index 100% rename from kubernetes-client/src/test/resources/test-kubeconfig-exec-win rename to kubernetes-client-api/src/test/resources/test-kubeconfig-exec-win diff --git a/kubernetes-client/src/test/resources/test-kubeconfig-nocurrentctxt.yml b/kubernetes-client-api/src/test/resources/test-kubeconfig-nocurrentctxt.yml similarity index 100% rename from kubernetes-client/src/test/resources/test-kubeconfig-nocurrentctxt.yml rename to kubernetes-client-api/src/test/resources/test-kubeconfig-nocurrentctxt.yml diff --git a/kubernetes-client/src/test/resources/test-namespace b/kubernetes-client-api/src/test/resources/test-namespace similarity index 100% rename from kubernetes-client/src/test/resources/test-namespace rename to kubernetes-client-api/src/test/resources/test-namespace diff --git a/kubernetes-client/src/test/resources/token-generator b/kubernetes-client-api/src/test/resources/token-generator similarity index 100% rename from kubernetes-client/src/test/resources/token-generator rename to kubernetes-client-api/src/test/resources/token-generator diff --git a/kubernetes-client/src/test/resources/token-generator-win.bat b/kubernetes-client-api/src/test/resources/token-generator-win.bat similarity index 100% rename from kubernetes-client/src/test/resources/token-generator-win.bat rename to kubernetes-client-api/src/test/resources/token-generator-win.bat diff --git a/kubernetes-client/pom.xml b/kubernetes-client/pom.xml index 5923d292a7f..ab26b7f39ff 100644 --- a/kubernetes-client/pom.xml +++ b/kubernetes-client/pom.xml @@ -53,79 +53,13 @@ io.fabric8 - kubernetes-model-core + kubernetes-client-api io.fabric8 - kubernetes-model-rbac - - - io.fabric8 - kubernetes-model-admissionregistration - - - io.fabric8 - kubernetes-model-apps - - - io.fabric8 - kubernetes-model-autoscaling - - - io.fabric8 - kubernetes-model-apiextensions - - - io.fabric8 - kubernetes-model-batch - - - io.fabric8 - kubernetes-model-certificates - - - io.fabric8 - kubernetes-model-coordination - - - io.fabric8 - kubernetes-model-discovery - - - io.fabric8 - kubernetes-model-events - - - io.fabric8 - kubernetes-model-extensions - - - io.fabric8 - kubernetes-model-flowcontrol - - - io.fabric8 - kubernetes-model-networking - - - io.fabric8 - kubernetes-model-metrics - - - io.fabric8 - kubernetes-model-policy - - - io.fabric8 - kubernetes-model-scheduling - - - io.fabric8 - kubernetes-model-storageclass - - - io.fabric8 - kubernetes-model-node + kubernetes-client-api + test-jar + test com.squareup.okhttp3 @@ -137,26 +71,6 @@ logging-interceptor ${okhttp.version} - - org.slf4j - slf4j-api - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-core - io.fabric8 @@ -164,18 +78,6 @@ ${zjsonpatch.version} - - org.bouncycastle - bcprov-ext-jdk15on - ${bouncycastle.version} - true - - - org.bouncycastle - bcpkix-jdk15on - ${bouncycastle.version} - true - commons-codec commons-codec @@ -188,11 +90,6 @@ ${commons-compress.version} true - - com.github.mifmif - generex - ${generex.version} - diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseKubernetesClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseKubernetesClient.java index 92f40febeff..e979a37f26f 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseKubernetesClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseKubernetesClient.java @@ -103,7 +103,6 @@ import io.fabric8.kubernetes.client.dsl.internal.KubernetesListOperationsImpl; import io.fabric8.kubernetes.client.dsl.internal.NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl; import io.fabric8.kubernetes.client.dsl.internal.NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl; -import io.fabric8.kubernetes.client.dsl.internal.RawCustomResourceOperationsImpl; import io.fabric8.kubernetes.client.dsl.internal.core.v1.BindingOperationsImpl; import io.fabric8.kubernetes.client.dsl.internal.core.v1.ComponentStatusOperationsImpl; import io.fabric8.kubernetes.client.dsl.internal.core.v1.PodOperationsImpl; @@ -112,8 +111,10 @@ import io.fabric8.kubernetes.client.dsl.internal.certificates.v1.CertificateSigningRequestOperationsImpl; import io.fabric8.kubernetes.client.extended.run.RunConfigBuilder; import io.fabric8.kubernetes.client.extended.run.RunOperations; +import io.fabric8.kubernetes.client.extended.run.RunOperationsImpl; import io.fabric8.kubernetes.client.http.HttpClient; import io.fabric8.kubernetes.client.informers.SharedInformerFactory; +import io.fabric8.kubernetes.client.informers.SharedInformerFactoryImpl; import io.fabric8.kubernetes.client.utils.Serialization; import java.io.InputStream; @@ -451,14 +452,6 @@ public > HasMetadataO return new HasMetadataOperationsImpl<>(this, rdContext, resourceType, listClass); } - /** - * {@inheritDoc} - */ - @Override - public RawCustomResourceOperationsImpl customResource(CustomResourceDefinitionContext customResourceDefinition) { - return new RawCustomResourceOperationsImpl(this, customResourceDefinition); - } - @Override public DiscoveryAPIGroupDSL discovery() { return adapt(DiscoveryAPIGroupClient.class); @@ -576,7 +569,7 @@ public AutoscalingAPIGroupDSL autoscaling() { */ @Override public SharedInformerFactory informers() { - return new SharedInformerFactory(this); + return new SharedInformerFactoryImpl(this); } /** @@ -584,7 +577,7 @@ public SharedInformerFactory informers() { */ @Override public SharedInformerFactory informers(ExecutorService executorService) { - return new SharedInformerFactory(this, executorService); + return new SharedInformerFactoryImpl(this, executorService); } /** @@ -600,7 +593,7 @@ public MixedOperation> leases() { */ @Override public RunOperations run() { - return new RunOperations(this, getNamespace(), new RunConfigBuilder()); + return new RunOperationsImpl(this, getNamespace(), new RunConfigBuilder()); } /** diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/MetricOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/MetricOperationsImpl.java index f338d53959c..70ce9408642 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/MetricOperationsImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/MetricOperationsImpl.java @@ -15,49 +15,27 @@ */ package io.fabric8.kubernetes.client.dsl.internal; -import io.fabric8.kubernetes.client.ClientContext; import io.fabric8.kubernetes.client.KubernetesClientException; -import io.fabric8.kubernetes.client.dsl.Nameable; +import io.fabric8.kubernetes.client.dsl.MetricOperation; +import io.fabric8.kubernetes.client.dsl.base.OperationContext; import io.fabric8.kubernetes.client.dsl.base.OperationSupport; import io.fabric8.kubernetes.client.utils.URLUtils; +import io.fabric8.kubernetes.client.utils.Utils; import io.fabric8.kubernetes.client.utils.URLUtils.URLBuilder; import java.io.IOException; import java.util.HashMap; import java.util.Map; -public class MetricOperationsImpl extends OperationSupport implements Nameable> { +public abstract class MetricOperationsImpl extends OperationSupport implements MetricOperation { public static final String METRIC_ENDPOINT_URL = "apis/metrics.k8s.io/v1beta1/"; private final Class apiTypeListClass; private final Class apiTypeClass; - private final String plural; - private final String configuredNamespace; - private final String configuredName; - private final Map configuredLabels; - public MetricOperationsImpl(ClientContext client, String configuredName, String configuredNamespace, String plural, Map configuredLabels, Class apiTypeClass, Class apiTypeListClass) { - super(HasMetadataOperationsImpl.defaultContext(client)); - this.plural = plural; + public MetricOperationsImpl(OperationContext operationContext, Class apiTypeClass, Class apiTypeListClass) { + super(operationContext); this.apiTypeClass = apiTypeClass; this.apiTypeListClass = apiTypeListClass; - this.configuredNamespace = configuredNamespace; - this.configuredName = configuredName; - this.configuredLabels = configuredLabels; - } - - @Override - public MetricOperationsImpl withName(String name) { - return new MetricOperationsImpl<>(context, name, configuredNamespace, plural, configuredLabels, apiTypeClass, apiTypeListClass); - } - - /** - * Filter metrics via labels. - * - * @param labels labels as HashMap - * @return {@link MetricOperationsImpl} with which you can call metrics() for getting filtered Metrics - */ - public MetricOperationsImpl withLabels(Map labels) { - return new MetricOperationsImpl<>(context, name, configuredNamespace, plural, labels, apiTypeClass, apiTypeListClass); } /** @@ -65,6 +43,7 @@ public MetricOperationsImpl withLabels(Map labels) { * * @return a list object for metrics */ + @Override public L metrics() { try { return handleMetric(getMetricEndpointUrl(), apiTypeListClass); @@ -81,6 +60,7 @@ public L metrics() { * * @return a single metric */ + @Override public T metric() { try { return handleMetric(getMetricEndpointUrl(), apiTypeClass); @@ -98,6 +78,7 @@ public T metric() { * @param labelsMap labels as HashMap * @return list of metrics found matching provided label */ + @Override public L metrics(Map labelsMap) { Map labels = new HashMap<>(); labelsMap.forEach((k, v) -> labels.put(k, v.toString())); @@ -107,21 +88,21 @@ public L metrics(Map labelsMap) { protected String getMetricEndpointUrlWithPlural(String plural) { String result = URLUtils.join(config.getMasterUrl(), METRIC_ENDPOINT_URL); - if (configuredNamespace != null) { - result += "namespaces/" + configuredNamespace + "/"; + if (isResourceNamespaced() && namespace != null) { + result += "namespaces/" + namespace + "/"; } result += plural; - if (configuredName != null) { - result += "/" + configuredName; + if (context.getName() != null) { + result += "/" + context.getName(); } - if (configuredLabels != null) { - result = getUrlWithLabels(result, configuredLabels); + if (Utils.isNotNullOrEmpty(context.getLabels())) { + result = getUrlWithLabels(result, context.getLabels()); } return result; } private String getMetricEndpointUrl() { - return getMetricEndpointUrlWithPlural(plural); + return getMetricEndpointUrlWithPlural(context.getPlural()); } private String getUrlWithLabels(String baseUrl, Map labels) { @@ -134,5 +115,5 @@ private String getUrlWithLabels(String baseUrl, Map labels) { httpUrlBuilder.addQueryParameter("labelSelector", sb.substring(0, sb.toString().length() - 1)); return httpUrlBuilder.toString(); } - + } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NodeMetricOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NodeMetricOperationsImpl.java index 5c8f7739b6e..dc63c4ac0e9 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NodeMetricOperationsImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NodeMetricOperationsImpl.java @@ -18,19 +18,38 @@ import io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetrics; import io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsList; import io.fabric8.kubernetes.client.ClientContext; +import io.fabric8.kubernetes.client.dsl.NodeMetricOperation; +import io.fabric8.kubernetes.client.dsl.base.OperationContext; -public class NodeMetricOperationsImpl extends MetricOperationsImpl { - public NodeMetricOperationsImpl(ClientContext clientContext) { - super(clientContext, null, null, "nodes", null, NodeMetrics.class, NodeMetricsList.class); - } +import java.util.Map; - /** - * Get NodeMetric with specified name - * - * @param nodeName name of the node - * @return NodeMetric fetched from ApiServer - */ +public class NodeMetricOperationsImpl extends MetricOperationsImpl implements NodeMetricOperation { + + public NodeMetricOperationsImpl(ClientContext clientContext) { + this(HasMetadataOperationsImpl.defaultContext(clientContext)); + } + + public NodeMetricOperationsImpl(OperationContext context) { + super(context.withPlural("nodes"), NodeMetrics.class, NodeMetricsList.class); + } + + @Override public NodeMetrics metrics(String nodeName) { return withName(nodeName).metric(); } + + @Override + public NodeMetricOperation withLabels(Map labels) { + return new NodeMetricOperationsImpl(context.withLabels(labels)); + } + + @Override + public NodeMetricOperation withName(String name) { + return new NodeMetricOperationsImpl(context.withName(name)); + } + + @Override + public boolean isResourceNamespaced() { + return false; // workaround until the class metadata is fixed + } } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/PodMetricOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/PodMetricOperationsImpl.java index 00397e0a13c..6410bda80a8 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/PodMetricOperationsImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/PodMetricOperationsImpl.java @@ -18,40 +18,47 @@ import io.fabric8.kubernetes.api.model.metrics.v1beta1.PodMetrics; import io.fabric8.kubernetes.api.model.metrics.v1beta1.PodMetricsList; import io.fabric8.kubernetes.client.ClientContext; -import io.fabric8.kubernetes.client.dsl.Namespaceable; +import io.fabric8.kubernetes.client.ConfigBuilder; +import io.fabric8.kubernetes.client.dsl.PodMetricOperation; +import io.fabric8.kubernetes.client.dsl.base.OperationContext; -public class PodMetricOperationsImpl extends MetricOperationsImpl implements Namespaceable { +import java.util.Map; + +public class PodMetricOperationsImpl extends MetricOperationsImpl implements PodMetricOperation { + public PodMetricOperationsImpl(ClientContext clientContext) { - super(clientContext, null, null, "pods", null, PodMetrics.class, PodMetricsList.class); + // default to any namespace + this(HasMetadataOperationsImpl.defaultContext(clientContext) + .withConfig(new ConfigBuilder(clientContext.getConfiguration()).withNamespace(null).build()) + .withNamespace(null)); } - - private PodMetricOperationsImpl(ClientContext clientContext, String name, String namespace) { - super(clientContext, name, namespace, "pods", null, PodMetrics.class, PodMetricsList.class); + + public PodMetricOperationsImpl(OperationContext context) { + super(context.withPlural("pods"), PodMetrics.class, PodMetricsList.class); } - - /** - * Get PodMetrics in a namespace with a name. - * - * @param namespace namespace of pod - * @param podName name of pod - * @return PodMetric corresponding to specified Pod - */ + + @Override public PodMetrics metrics(String namespace, String podName) { return inNamespace(namespace).withName(podName).metric(); } - /** - * Get PodMetricsList for a namespace. - * - * @param namespace namespace for which PodMetrics are queries - * @return PodMetricsList for all pods in specified namespace - */ + @Override public PodMetricsList metrics(String namespace) { return inNamespace(namespace).metrics(); } @Override public PodMetricOperationsImpl inNamespace(String namespace) { - return new PodMetricOperationsImpl(context, null, namespace); + return new PodMetricOperationsImpl(context.withNamespace(namespace)); + } + + @Override + public PodMetricOperation withName(String name) { + return new PodMetricOperationsImpl(context.withName(name)); + } + + @Override + public PodMetricOperation withLabels(Map labels) { + return new PodMetricOperationsImpl(context.withLabels(labels)); } } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImpl.java deleted file mode 100644 index 162812ebb2e..00000000000 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImpl.java +++ /dev/null @@ -1,965 +0,0 @@ -/** - * Copyright (C) 2015 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.fabric8.kubernetes.client.dsl.internal; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import io.fabric8.kubernetes.api.model.DeleteOptions; -import io.fabric8.kubernetes.api.model.DeletionPropagation; -import io.fabric8.kubernetes.api.model.GenericKubernetesResource; -import io.fabric8.kubernetes.api.model.GenericKubernetesResourceList; -import io.fabric8.kubernetes.api.model.ListOptions; -import io.fabric8.kubernetes.api.model.ListOptionsBuilder; -import io.fabric8.kubernetes.client.ClientContext; -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.GracePeriodConfigurable; -import io.fabric8.kubernetes.client.PropagationPolicyConfigurable; -import io.fabric8.kubernetes.client.Watch; -import io.fabric8.kubernetes.client.Watcher; -import io.fabric8.kubernetes.client.WatcherException; -import io.fabric8.kubernetes.client.dsl.AnyNamespaceable; -import io.fabric8.kubernetes.client.dsl.Deletable; -import io.fabric8.kubernetes.client.dsl.DryRunable; -import io.fabric8.kubernetes.client.dsl.Gettable; -import io.fabric8.kubernetes.client.dsl.Listable; -import io.fabric8.kubernetes.client.dsl.Nameable; -import io.fabric8.kubernetes.client.dsl.Namespaceable; -import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; -import io.fabric8.kubernetes.client.dsl.base.OperationContext; -import io.fabric8.kubernetes.client.utils.Serialization; -import io.fabric8.kubernetes.client.utils.Utils; -import io.fabric8.kubernetes.model.Scope; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.Locale; -import java.util.Map; -import java.util.stream.Stream; - -import static io.fabric8.kubernetes.client.dsl.base.HasMetadataOperation.DEFAULT_PROPAGATION_POLICY; - -/** - * This class simple does basic operations for custom defined resources without - * demanding the POJOs for custom resources. It is serializing/deserializing - * objects to plain hash map(String, Object). - * - * Right now it supports basic operations like GET, POST, PUT, DELETE. - * - */ -public class RawCustomResourceOperationsImpl implements Nameable, - Namespaceable, - AnyNamespaceable, - Listable>, - Gettable>, - GracePeriodConfigurable, - PropagationPolicyConfigurable, - DryRunable, - Deletable { - - private final GenericKubernetesResourceOperationsImpl delegate; - private final CustomResourceDefinitionContext customResourceDefinition; - - private RawCustomResourceOperationsImpl(GenericKubernetesResourceOperationsImpl delegate, CustomResourceDefinitionContext crdContext) { - this.delegate = delegate; - this.customResourceDefinition = crdContext; - } - - public RawCustomResourceOperationsImpl(ClientContext clientContext, CustomResourceDefinitionContext customResourceDefinition) { - this( - new GenericKubernetesResourceOperationsImpl( - new OperationContext() - .withHttpClient(clientContext.getHttpClient()) - .withConfig(clientContext.getConfiguration()) - .withNamespace(null) - .withName(null) - .withGracePeriodSeconds(-1L) - .withCascading(false) - .withDryRun(false) - .withPropagationPolicy(DEFAULT_PROPAGATION_POLICY) - .withApiGroupName(customResourceDefinition.getGroup()) - .withApiGroupVersion(customResourceDefinition.getVersion()) - .withPlural(customResourceDefinition.getPlural()), - Scope.NAMESPACED.value().equals(customResourceDefinition.getScope()) - ), - customResourceDefinition - ); - } - - @Override - public RawCustomResourceOperationsImpl withName(String name) { - return new RawCustomResourceOperationsImpl((GenericKubernetesResourceOperationsImpl) delegate.withName(name), customResourceDefinition); - } - - @Override - public RawCustomResourceOperationsImpl inNamespace(String namespace) { - return new RawCustomResourceOperationsImpl((GenericKubernetesResourceOperationsImpl) delegate.inNamespace(namespace), customResourceDefinition); - } - - @Override - public RawCustomResourceOperationsImpl inAnyNamespace() { - return new RawCustomResourceOperationsImpl((GenericKubernetesResourceOperationsImpl) delegate.inAnyNamespace(), customResourceDefinition); - } - - @Override - public RawCustomResourceOperationsImpl withGracePeriod(long gracePeriodSeconds) { - return new RawCustomResourceOperationsImpl((GenericKubernetesResourceOperationsImpl) delegate.withGracePeriod(gracePeriodSeconds), customResourceDefinition); - } - - @Override - public RawCustomResourceOperationsImpl withPropagationPolicy(DeletionPropagation propagationPolicy) { - return new RawCustomResourceOperationsImpl((GenericKubernetesResourceOperationsImpl) delegate.withPropagationPolicy(propagationPolicy), customResourceDefinition); - } - - @Override - public RawCustomResourceOperationsImpl dryRun(boolean isDryRun) { - return new RawCustomResourceOperationsImpl((GenericKubernetesResourceOperationsImpl) delegate.dryRun(isDryRun), customResourceDefinition); - } - - public Config getConfig() { - return delegate.getConfig(); - } - - private RawCustomResourceOperationsImpl withDeleteOptions(DeleteOptions deleteOptions) { - return new RawCustomResourceOperationsImpl((GenericKubernetesResourceOperationsImpl) delegate.withGracePeriod(resolveGracePeriod(deleteOptions.getGracePeriodSeconds())).withPropagationPolicy(resolvePropagationPolicy(deleteOptions.getPropagationPolicy())), customResourceDefinition); - } - - /** - * Load a custom resource object from an InputStream into a HashMap - * - * @param inputStream input stream - * @return custom resource as HashMap - * @throws IOException exception in case any read operation fails. - */ - public Map load(InputStream inputStream) throws IOException { - return toMap(delegate.load(inputStream).get()); - } - - /** - * Load a custom resource object from a JSON string into a HashMap - * - * @param objectAsJsonString object as JSON string - * @return custom resource as HashMap - * @throws IOException exception in case any problem in reading json. - */ - public Map load(String objectAsJsonString) throws IOException { - return toMap(delegate.load(new ByteArrayInputStream(objectAsJsonString.getBytes(StandardCharsets.UTF_8))).get()); - } - - /** - * Create a custom resource which is a non-namespaced object. - * - * @param objectAsString object as JSON string - * @return Object as HashMap - * @throws IOException exception in case of any network/read problems - */ - public Map create(String objectAsString) throws IOException { - return toMap(delegate.create( - Serialization.jsonMapper().readValue(objectAsString, GenericKubernetesResource.class))); - } - - /** - * Create a custom resource which is non-namespaced. - * - * @param object object a HashMap - * @return Object as HashMap - * @throws IOException in case of problems while reading HashMap - */ - public Map create(Map object) throws IOException { - return toMap(delegate.create(Serialization.jsonMapper().convertValue(object, GenericKubernetesResource.class))); - } - - /** - * Create a custom resource which is a namespaced object. - * - * @param namespace namespace in which we want object to be created. - * @param objectAsString Object as JSON string - * @return Object as HashMap - * @throws IOException in case of problems while reading JSON object - * @deprecated Use {@link #inNamespace(String)}.{@link #create(String)} instead. - */ - @Deprecated - public Map create(String namespace, String objectAsString) throws IOException { - return toMap(delegate.inNamespace(namespace) - .create(Serialization.unmarshal(objectAsString, GenericKubernetesResource.class))); - } - - /** - * Create a custom resource which is non-namespaced object. - * - * @param objectAsStream object as a file input stream - * @return Object as HashMap - * @throws IOException in case of problems while reading file - */ - public Map create(InputStream objectAsStream) throws IOException { - return toMap(delegate - .create(Serialization.unmarshal(objectAsStream, GenericKubernetesResource.class))); - } - - /** - * Create a custom resource which is a namespaced object. - * - * @param namespace namespace in which we want object to be created - * @param objectAsStream object as file input stream - * @return Object as HashMap - * @throws IOException in case of problems while reading file - * @deprecated Use {@link #inNamespace(String)}.{@link #create(InputStream)} instead. - */ - @Deprecated - public Map create(String namespace, InputStream objectAsStream) throws IOException { - return toMap(delegate.inNamespace(namespace) - .create(Serialization.unmarshal(objectAsStream, GenericKubernetesResource.class))); - } - - /** - * Create a custom resource which is a namespaced object. - * - * @param namespace namespace in which we want object to be created. - * @param object object as a HashMap - * @return Object as HashMap - * @throws IOException in case of problems faced while serializing HashMap - * @deprecated Use {@link #inNamespace(String)}.{@link #create(Map)} instead. - */ - @Deprecated - public Map create(String namespace, Map object) throws IOException { - return toMap(delegate.inNamespace(namespace) - .create(Serialization.jsonMapper().convertValue(object, GenericKubernetesResource.class))); - } - - /** - * Create or replace a custom resource which is a non-namespaced object. - * - * @param objectAsString object as JSON string - * @return Object as HashMap - * @throws IOException in case of network/serialization failures or failures from Kubernetes API - */ - public Map createOrReplace(String objectAsString) throws IOException { - return toMap(delegate - .createOrReplace(Serialization.unmarshal(objectAsString, GenericKubernetesResource.class))); - } - - /** - * Create or replace a custom resource which is a non-namespced object. - * - * @param customResourceObject object as HashMap - * @return Object as HashMap - * @throws IOException in case of network/serialization failures or failures from Kubernetes API - */ - public Map createOrReplace(Map customResourceObject) throws IOException { - return toMap(delegate - .createOrReplace(Serialization.jsonMapper().convertValue(customResourceObject, GenericKubernetesResource.class))); - } - - /** - * Create or replace a custom resource which is non-namespaced object. - * - * @param inputStream object as file input stream - * @return Object as HashMap - * @throws IOException in case of network/serialization failures or failures from Kubernetes API - */ - public Map createOrReplace(InputStream inputStream) throws IOException { - return toMap(delegate.createOrReplace(Serialization.unmarshal(inputStream, GenericKubernetesResource.class))); - } - - /** - * Create or replace a custom resource which is namespaced object. - * - * @param namespace desired namespace - * @param objectAsString object as JSON String - * @return Object as HashMap - * @throws IOException in case of network/serialization failures or failures from Kubernetes API - * @deprecated Use {@link #inNamespace(String)}.{@link #createOrReplace(String)} instead. - */ - @Deprecated - public Map createOrReplace(String namespace, String objectAsString) throws IOException { - return toMap(delegate.inNamespace(namespace) - .createOrReplace(Serialization.unmarshal(objectAsString, GenericKubernetesResource.class))); - } - - /** - * Create or replace a custom resource which is namespaced object. - * - * @param namespace desired namespace - * @param customResourceObject object as HashMap - * @return Object as HashMap - * @throws IOException in case of network/serialization failures or failures from Kubernetes API - * @deprecated Use {@link #inNamespace(String)}.{@link #createOrReplace(Map)} instead. - */ - @Deprecated - public Map createOrReplace(String namespace, Map customResourceObject) throws IOException { - return toMap(delegate.inNamespace(namespace) - .createOrReplace(Serialization.jsonMapper().convertValue(customResourceObject, GenericKubernetesResource.class))); - } - - /** - * Create or replace a custom resource which is namespaced object. - * - * @param namespace desired namespace - * @param objectAsStream object as file input stream - * @return Object as HashMap - * @throws IOException in case of network/serialization failures or failures from Kubernetes API - * @deprecated Use {@link #inNamespace(String)}.{@link #createOrReplace(InputStream)} instead. - */ - @Deprecated - public Map createOrReplace(String namespace, InputStream objectAsStream) throws IOException { - return toMap(delegate.inNamespace(namespace) - .createOrReplace(Serialization.unmarshal(objectAsStream, GenericKubernetesResource.class))); - } - - /** - * Edit a custom resource object which is a non-namespaced object. - * - * @param name name of the custom resource - * @param object new object as a HashMap - * @return Object as HashMap - * @throws IOException in case of network/serialization failures or failures from Kubernetes API - * @deprecated Use {@link #withName(String)}.{@link #edit(Map)} instead. - */ - @Deprecated - public Map edit(String name, Map object) throws IOException { - return toMap(delegate.withName(name) - .edit(gkr -> Serialization.jsonMapper().convertValue(object, GenericKubernetesResource.class))); - } - - /** - * Edit a custom resource object which is a non-namespaced object. - * - * @param name name of the custom resource - * @param objectAsString new object as a JSON String - * @return Object as HashMap - * @throws IOException in case of network/serialization failures or failures from Kubernetes API - * @deprecated Use {@link #withName(String)}.{@link #edit(String)} instead. - */ - @Deprecated - public Map edit(String name, String objectAsString) throws IOException { - final GenericKubernetesResource edited = Serialization.jsonMapper() - .readValue(objectAsString, GenericKubernetesResource.class); - return toMap(delegate.withName(name).edit(gkr -> edited)); - } - - /** - * Edit a custom resource object which is a namespaced object. - * - * @param namespace desired namespace - * @param name name of the custom resource - * @param object new object as a HashMap - * @return Object as HashMap - * @throws IOException in case of network/serialization failures or failures from Kubernetes API - * @deprecated Use {@link #inNamespace(String)}.{@link #withName(String)}.{@link #edit(Map)} instead. - */ - @Deprecated - public Map edit(String namespace, String name, Map object) throws IOException { - return toMap(delegate.inNamespace(namespace).withName(name) - .edit(gkr -> Serialization.jsonMapper().convertValue(object, GenericKubernetesResource.class))); - } - - /** - * Edit a custom resource object which is a namespaced object. - * - * @param namespace desired namespace - * @param name name of the custom resource - * @param objectAsString new object as a JSON string - * @return Object as HashMap - * @throws IOException in case of network/serialization failures or failures from Kubernetes API - * @deprecated Use {@link #inNamespace(String)}.{@link #withName(String)}.{@link #edit(String)} instead. - */ - @Deprecated - public Map edit(String namespace, String name, String objectAsString) throws IOException { - final GenericKubernetesResource edited = Serialization.jsonMapper() - .readValue(objectAsString, GenericKubernetesResource.class); - return toMap(delegate.inNamespace(namespace).withName(name).edit(gkr -> edited)); - } - - /** - * Edit a custom resource object. - * - * @param objectAsString new object as JSON string - * @return Object as HashMap - * @throws IOException in case of network/serialization failures or failures from Kubernetes API - */ - public Map edit(String objectAsString) throws IOException { - final GenericKubernetesResource edited = Serialization.jsonMapper() - .readValue(objectAsString, GenericKubernetesResource.class); - return toMap(delegate.edit(gkr -> edited)); - } - - /** - * Edit a custom resource object. - * - * @param object new object as Map - * @return Object as HashMap - * @throws IOException in case of network/serialization failures or failures from Kubernetes API - */ - public Map edit(Map object) throws IOException { - return toMap(delegate - .edit(gkr -> Serialization.jsonMapper().convertValue(object, GenericKubernetesResource.class))); - } - - /** - * Update status related to a CustomResource, this method does a PATCH request on /status endpoint related - * to the CustomResource - * - * @param name name of custom resource - * @param objectAsMap custom resource as a HashMap - * @return updated CustomResource as HashMap - * @throws IOException in case any failure to parse Map - * @deprecated Use {@link #withName(String)}.{@link #updateStatus(Map)} instead. - */ - @Deprecated - public Map updateStatus(String name, Map objectAsMap) throws IOException { - return toMap(delegate.withName(name) - .updateStatus(Serialization.jsonMapper().convertValue(objectAsMap, GenericKubernetesResource.class))); - } - - /** - * Update status related to a CustomResource, this method does a PATCH request on /status endpoint related - * to the CustomResource - * - * @param name name of CustomResource - * @param objectAsJsonString CustomResource as a JSON string - * @return updated CustomResource as a HashMap - * @throws IOException in case any failure to parse Map - * @deprecated Use {@link #withName(String)}.{@link #updateStatus(String)} instead. - */ - @Deprecated - public Map updateStatus(String name, String objectAsJsonString) throws IOException { - return toMap(delegate.withName(name) - .updateStatus(Serialization.unmarshal(objectAsJsonString, GenericKubernetesResource.class))); - } - - /** - * Update status related to a CustomResource, this method does a PATCH request on /status endpoint related - * to the CustomResource - * - * @param namespace namespace of CustomResource - * @param name name of CustomResource - * @param objectAsMap CustomResource as a HashMap - * @return updated CustomResource as a HashMap - * @throws IOException in case any failure to parse Map - * @deprecated Use {@link #inNamespace(String)}.{@link #withName(String)}.{@link #updateStatus(Map)} instead. - */ - @Deprecated - public Map updateStatus(String namespace, String name, Map objectAsMap) throws IOException { - return toMap(delegate.inNamespace(namespace).withName(name) - .updateStatus(Serialization.jsonMapper().convertValue(objectAsMap, GenericKubernetesResource.class))); - } - - /** - * Update status related to a CustomResource, this method does a PATCH request on /status endpoint related - * to the CustomResource - * - * @param name name of CustomResource - * @param objectAsStream stream pointing to CustomResource - * @return updated CustomResource as a HashMap - * @throws IOException in case any failure to parse Map - * @deprecated Use {@link #withName(String)}.{@link #updateStatus(InputStream)} instead. - */ - @Deprecated - public Map updateStatus(String name, InputStream objectAsStream) throws IOException { - return toMap(delegate.withName(name) - .updateStatus(Serialization.unmarshal(objectAsStream, GenericKubernetesResource.class))); - } - - /** - * Update status related to a CustomResource, this method does a PATCH request on /status endpoint related - * to the CustomResource - * - * @param namespace namespace of CustomResource - * @param name name of CustomResource - * @param objectAsStream CustomResource object as a stream - * @return updated CustomResource as a HashMap - * @throws IOException in case any failure to parse Map - * @deprecated Use {@link #inNamespace(String)}.{@link #withName(String)}.{@link #updateStatus(InputStream)} instead. - */ - @Deprecated - public Map updateStatus(String namespace, String name, InputStream objectAsStream) throws IOException { - return toMap(delegate.inNamespace(namespace).withName(name) - .updateStatus(Serialization.unmarshal(objectAsStream, GenericKubernetesResource.class))); - } - - /** - * Update status related to a CustomResource, this method does a PATCH request on /status endpoint related - * to the CustomResource - * - * @param namespace namespace of CustomResource - * @param name name of CustomResource - * @param objectAsJsonString CustomResource object as a JSON string - * @return updated CustomResource as a HashMap - * @throws IOException in case any failure to parse Map - * @deprecated Use {@link #inNamespace(String)}.{@link #withName(String)}.{@link #updateStatus(String)} instead. - */ - @Deprecated - public Map updateStatus(String namespace, String name, String objectAsJsonString) throws IOException { - return toMap(delegate.inNamespace(namespace).withName(name) - .updateStatus(Serialization.unmarshal(objectAsJsonString, GenericKubernetesResource.class))); - } - - /** - * Update status related to a CustomResource, this method does a PATCH request on /status endpoint related - * to the CustomResource - * - * @param objectAsJsonString CustomResource object as a JSON string - * @return updated CustomResource as HashMap - * @throws IOException in case any failures to parse provided object or failure from Kubernetes API - */ - public Map updateStatus(String objectAsJsonString) throws IOException { - return toMap(delegate - .updateStatus(Serialization.unmarshal(objectAsJsonString, GenericKubernetesResource.class))); - } - - /** - * Update status related to a CustomResource, this method does a PATCH request on /status endpoint related - * to the CustomResource - * - * @param objectAsMap CustomResource object as a HashMap - * @return updated CustomResource as HashMap - * @throws IOException in case any failures to parse provided object or failure from Kubernetes API - */ - public Map updateStatus(Map objectAsMap) throws IOException { - return toMap(delegate - .updateStatus(Serialization.jsonMapper().convertValue(objectAsMap, GenericKubernetesResource.class))); - } - - /** - * Update status related to a CustomResource, this method does a PATCH request on /status endpoint related - * to the CustomResource - * - * @param objectAsInputStream CustomResource object as a InputStream - * @return updated CustomResource as HashMap - * @throws IOException in case any failures to parse provided object or failure from Kubernetes API - */ - public Map updateStatus(InputStream objectAsInputStream) throws IOException { - return toMap(delegate - .updateStatus(Serialization.unmarshal(objectAsInputStream, GenericKubernetesResource.class))); - } - - @Override - public Map get() { - return toMap(delegate.get()); - } - - /** - * Get a custom resource from the cluster which is non-namespaced. - * - * @param name name of custom resource - * @return Object as HashMap - * @deprecated Use {@link #withName(String)}.{@link #get()} instead. - */ - @Deprecated - public Map get(String name) { - return toMap(delegate.withName(name).get()); - } - - /** - * Get a custom resource from the cluster which is namespaced. - * - * @param namespace desired namespace - * @param name name of custom resource - * @return Object as HashMap - * @deprecated Use {@link #inNamespace(String)}.{@link #withName(String)}.{@link #get()} instead. - */ - @Deprecated - public Map get(String namespace, String name) { - return toMap(delegate.inNamespace(namespace).withName(name).get()); - } - - /** - * List all custom resources in all namespaces - * - * @return list of custom resources as HashMap - */ - @Override - public Map list() { - return toMap(delegate.list()); - } - - @Override - public Map list(Integer limitVal, String continueVal) { - return toMap(delegate - .list(new ListOptionsBuilder().withLimit(limitVal.longValue()).withContinue(continueVal).build())); - } - - @Override - public Map list(ListOptions listOptions) { - return toMap(delegate.list(listOptions)); - } - - /** - * List all custom resources in a specific namespace - * - * @param namespace desired namespace - * @return list of custom resources as HashMap - */ - public Map list(String namespace) { - return toMap(delegate.inNamespace(namespace).list()); - } - - /** - * List all custom resources in a specific namespace with some labels - * - * @param namespace desired namespace - * @param labels labels as a HashMap - * @return list of custom resources as HashMap - */ - public Map list(String namespace, Map labels) { - return toMap(delegate.inNamespace(namespace) - .list(new ListOptionsBuilder().withLabelSelector(getLabelsQueryParam(labels)).build())); - } - - /** - * Delete all Namespaced Scoped Custom Resources in a specified namespace - * OR - * Delete a Cluster Scoped Custom Resource with specified name - * - *

- * Note: This method behaves differently based on the scope of CRD: - *

- * If specified CRD is of Namespaced scope, this method would delete all Custom Resources in namespace which is - * specified as parameter. - * If specified CRD is of Cluster scope, this method would delete a Custom Resource matching the name which is - * specified as parameter - *

- * - * @param namespaceOrName desired namespace(if CRD is Namespaced) or name(If CRD is Cluster) - * @return deleted objects as HashMap - * @deprecated Use {@link #inNamespace(String)}.{@link #delete()} or {@link #withName(String)}.{@link #delete()} instead. - */ - @Deprecated - public boolean delete(String namespaceOrName) { - if (delegate.isResourceNamespaced()) { - return delegate.inNamespace(namespaceOrName).delete(); - } - return delegate.withName(namespaceOrName).delete(); - } - - /** - * Delete all Namespaced Scoped Custom Resources in a specified namespace - * OR - * Delete a Cluster Scoped Custom Resource with specified name - * - *

- * Note: This method behaves differently based on the scope of CRD: - *

- * If specified CRD is of Namespaced scope, this method would delete all Custom Resources in namespace which is - * specified as parameter. - * If specified CRD is of Cluster scope, this method would delete a Custom Resource matching the name which is - * specified as parameter - *

- * - * @param namespaceOrName desired namespace(If CRD is Namespaced) or name(If CRD is Cluster) - * @param cascading whether dependent object need to be orphaned or not. If true/false, the "orphan" - * finalizer will be added to/removed from the object's finalizers list. - * @return a boolean value whether item was deleted or item didn't exist in server - * @throws IOException in case of any network/parsing exception - */ - public boolean delete(String namespaceOrName, boolean cascading) throws IOException { - if (delegate.isResourceNamespaced()) { - return delegate.inNamespace(namespaceOrName).delete(); - } - return delegate.withName(namespaceOrName).cascading(cascading).delete(); - } - - /** - * Delete all Namespaced Scoped Custom Resources in a specified namespace - * OR - * Delete a Cluster Scoped Custom Resource with specified name - * - *

- * Note: This method behaves differently based on the scope of CRD: - *

- * If specified CRD is of Namespaced scope, this method would delete all Custom Resources in namespace which is - * specified as parameter. - * If specified CRD is of Cluster scope, this method would delete a Custom Resource matching the name which is - * specified as parameter - *

- * - * @param namespaceOrName desired namespace(If CRD is Namespaced) or name(If CRD is Cluster) - * @param deleteOptions object provided by Kubernetes API for more fine grained control over deletion. - * For more information please see https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#deleteoptions-v1-meta - * @return a boolean value whether item was deleted or item didn't exist in server - * @throws IOException in case of any network/object parse problems - */ - public boolean delete(String namespaceOrName, DeleteOptions deleteOptions) throws IOException { - if (delegate.isResourceNamespaced()) { - return withDeleteOptions(deleteOptions).inNamespace(namespaceOrName).delete(); - } - return withDeleteOptions(deleteOptions).withName(namespaceOrName).delete(); - } - - /** - * Delete a custom resource in a specific namespace - * - * @param namespace desired namespace - * @param name custom resource's name - * @return a boolean value whether item was deleted or item didn't exist in server - * @throws IOException in case of any network/object parse problems - * @deprecated Use {@link #inNamespace(String)}.{@link #withName(String)}.{@link #delete()} instead. - */ - @Deprecated - public boolean delete(String namespace, String name) throws IOException { - return delegate.inNamespace(namespace).withName(name).delete(); - } - - /** - * Delete a custom resource in a specific namespace - * - * @param namespace required namespace - * @param name required name of custom resource - * @param cascading whether dependent object need to be orphaned or not. If true/false, the "orphan" - * finalizer will be added to/removed from the object's finalizers list. - * @return a boolean value whether item was deleted or item didn't exist in server - * @throws IOException exception related to network/object parsing - */ - public boolean delete(String namespace, String name, boolean cascading) throws IOException { - return delegate.inNamespace(namespace).withName(name).cascading(cascading).delete(); - } - - /** - * Delete a custom resource in a specific namespace - * - * @param namespace required namespace - * @param name required name of custom resource - * @param propagationPolicy Whether and how garbage collection will be performed. Either this field or OrphanDependents - * may be set, but not both. The default policy is decided by the existing finalizer set in - * the metadata.finalizers and the resource-specific default policy. - * Acceptable values are: - * 'Orphan' - orphan the dependents; - * 'Background' - allow the garbage collector to delete the dependents in the background; - * 'Foreground' - a cascading policy that deletes all dependents in the foreground. - * @return a boolean value whether item was deleted or item didn't exist in server - * @throws IOException in case of network/object parse exception - */ - public boolean delete(String namespace, String name, String propagationPolicy) throws IOException { - return delegate.inNamespace(namespace).withName(name) - .withPropagationPolicy(resolveDeletionPropagation(propagationPolicy)).delete(); - } - - /** - * Delete a custom resource in a specific namespace - * - * @param namespace required namespace - * @param name name of custom resource - * @param deleteOptions object provided by Kubernetes API for more fine grained control over deletion. - * For more information please see https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#deleteoptions-v1-meta - * @return a boolean value whether item was deleted or item didn't exist in server - * @throws IOException in case of any network/object parse exception - */ - public boolean delete(String namespace, String name, DeleteOptions deleteOptions) throws IOException { - return withDeleteOptions(deleteOptions).inNamespace(namespace).withName(name).delete(); - } - - @Override - public Boolean delete() { - return delegate.delete(); - } - - - /** - * Watch custom resources across all namespaces. Here watcher is provided - * for string type only. User has to deserialize object itself. - * - * @param watcher watcher object which reports events - * @return watch object for watching resource - * @throws IOException in case of network error - */ - public Watch watch(Watcher watcher) throws IOException { - return delegate.watch(new DelegateWatcher(watcher)); - } - - /** - * Watch custom resources in the parameters specified. - *

- * Most of the parameters except watcher are optional, they would be - * skipped if passed null. Here watcher is provided for string type - * only. User has to deserialize the object itself. - * - * @param namespace namespace to watch (optional - * @param name name of custom resource (optional) - * @param labels HashMap containing labels (optional) - * @param options {@link ListOptions} list options for watch - * @param watcher watcher object which reports events - * @return watch object for watching resource - * @throws IOException in case of network error - */ - public Watch watch(String namespace, String name, Map labels, ListOptions options, Watcher watcher) throws IOException { - GenericKubernetesResourceOperationsImpl ops = delegate; - if (Utils.isNotNullOrEmpty(namespace)) { - ops = (GenericKubernetesResourceOperationsImpl) ops.inNamespace(namespace); - } - if (Utils.isNotNullOrEmpty(name)) { - ops = (GenericKubernetesResourceOperationsImpl) ops.withName(name); - } - return ops.watch( - listOptionsBuilder(options).withLabelSelector(getLabelsQueryParam(labels)).build(), - new DelegateWatcher(watcher)); - } - - /** - * Watch custom resources in the parameters specified. - *

- * Most of the parameters except watcher are optional, they would be - * skipped if passed null. Here watcher is provided for string type - * only. User has to deserialize the object itself. - * - * @param namespace namespace to watch (optional - * @param name name of custom resource (optional) - * @param labels HashMap containing labels (optional) - * @param resourceVersion resource version to start watch from - * @param watcher watcher object which reports events - * @return watch object for watching resource - * @throws IOException in case of network error - */ - public Watch watch(String namespace, String name, Map labels, String resourceVersion, Watcher watcher) throws IOException { - return watch(namespace, name, labels, new ListOptionsBuilder().withResourceVersion(resourceVersion).build(), watcher); - } - - /** - * Watch custom resources in a specific namespace. Here Watcher is provided - * for string type only. User has to deserialize object itself. - * - * @param namespace namespace to watch - * @param watcher watcher object which reports updates with object - * @return watch object for watching resource - * @throws IOException in case of network error - */ - public Watch watch(String namespace, Watcher watcher) throws IOException { - return watch(namespace, null, null, (ListOptions) null, watcher); - } - - /** - * Watch a custom resource in a specific namespace with some resourceVersion. Here - * watcher is provided from string type only. User has to deserialize object itself. - * - * @param namespace namespace to watch - * @param resourceVersion resource version since when to watch - * @param watcher watcher object which reports updates - * @return watch object for watching resource - * @throws IOException in case of network error - */ - public Watch watch(String namespace, String resourceVersion, Watcher watcher) throws IOException { - return watch(namespace, null, null, resourceVersion, watcher); - } - - /** - * Watch a custom resource in a specific namespace with some resourceVersion. Here - * watcher is provided from string type only. User has to deserialize object itself. - * - * @param namespace namespace to watch - * @param options {@link ListOptions} list options for watching - * @param watcher watcher object which reports updates - * @return watch object for watching resource - * @throws IOException in case of network error - */ - public Watch watch(String namespace, ListOptions options, Watcher watcher) throws IOException { - return watch(namespace, null, null, options, watcher); - } - - /** - * Watch custom resources in the parameters specified. - *

- * Most of the parameters except watcher are optional, they would be - * skipped if passed null. Here watcher is provided for string type - * only. User has to deserialize the object itself. - * - * @param labels HashMap containing labels (optional) - * @param options {@link ListOptions} list options for watch - * @param watcher watcher object which reports events - * @return watch object for watching resource - * @throws IOException in case of network error - */ - public Watch watch(Map labels, ListOptions options, Watcher watcher) throws IOException { - return delegate.watch( - listOptionsBuilder(options).withLabelSelector(getLabelsQueryParam(labels)).build(), - new DelegateWatcher(watcher)); - } - - private String getLabelsQueryParam(Map labels) { - if (labels == null) { - return null; - } - StringBuilder labelQueryBuilder = new StringBuilder(); - for (Map.Entry entry : labels.entrySet()) { - if (labelQueryBuilder.length() > 0) { - labelQueryBuilder.append(","); - } - labelQueryBuilder.append(entry.getKey()).append("=").append(entry.getValue()); - } - return labelQueryBuilder.toString(); - } - - private static DeletionPropagation resolveDeletionPropagation(String propagationPolicy) { - return Stream.of(DeletionPropagation.values()) - .filter(dp -> dp.name().toUpperCase(Locale.ENGLISH).equals(propagationPolicy.toUpperCase(Locale.ENGLISH))) - .findFirst() - .orElse(DEFAULT_PROPAGATION_POLICY); - } - - private long resolveGracePeriod(Long gracePeriodInSeconds) { - return gracePeriodInSeconds != null ? gracePeriodInSeconds : delegate.getGracePeriodSeconds(); - } - - private DeletionPropagation resolvePropagationPolicy(String deletionPropagation) { - return deletionPropagation != null ? resolveDeletionPropagation(deletionPropagation) : delegate.getPropagationPolicy(); - } - - private static ListOptionsBuilder listOptionsBuilder(ListOptions options) { - return options == null ? new ListOptionsBuilder() : new ListOptionsBuilder(options); - } - - private static Map toMap(GenericKubernetesResource gkr) { - return Serialization.jsonMapper().convertValue(gkr, new TypeReference>() { - }); - } - - private static Map toMap(GenericKubernetesResourceList gkrl) { - return Serialization.jsonMapper().convertValue(gkrl, new TypeReference>() { - }); - } - - private static final class DelegateWatcher implements Watcher { - - private final Watcher delegate; - - public DelegateWatcher(Watcher delegate) { - this.delegate = delegate; - } - - @Override - public boolean reconnecting() { - return delegate.reconnecting(); - } - - @Override - public void eventReceived(Action action, GenericKubernetesResource resource) { - try { - delegate.eventReceived(action, Serialization.jsonMapper().writeValueAsString(resource)); - } catch (JsonProcessingException e) { - delegate.eventReceived(action, resource.toString()); - } - } - - @Override - public void onClose() { - delegate.onClose(); - } - - @Override - public void onClose(WatcherException cause) { - delegate.onClose(cause); - } - } -} diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/package-info.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/package-info.java deleted file mode 100644 index 0cb10840c48..00000000000 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/leaderelection/package-info.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (C) 2015 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Package leaderelection implements leader election of a set of endpoints. - * - *

It uses an annotation in the endpoints object to store the record of the - * election state. This implementation does not guarantee that only one - * client is acting as a leader (a.k.a. fencing). - * - *

A client only acts on timestamps captured locally to infer the state of the - * leader election. The client does not consider timestamps in the leader - * election record to be accurate because these timestamps may not have been - * produced by a local clock. The implementation does not depend on their - * accuracy and only uses their change to indicate that another client has - * renewed the leader lease. Thus the implementation is tolerant to arbitrary - * clock skew, but is not tolerant to arbitrary clock skew rate. - * - *

However the level of tolerance to skew rate can be configured by setting - * RenewDeadline and LeaseDuration appropriately. The tolerance expressed as a - * maximum tolerated ratio of time passed on the fastest node to time passed on - * the slowest node can be approximately achieved with a configuration that sets - * the same ratio of LeaseDuration to RenewDeadline. For example if a user wanted - * to tolerate some nodes progressing forward in time twice as fast as other nodes, - * the user could set LeaseDuration to 60 seconds and RenewDeadline to 30 seconds. - * - *

While not required, some method of clock synchronization between nodes in the - * cluster is highly recommended. It's important to keep in mind when configuring - * this client that the tolerance to skew rate varies inversely to master - * availability. - * - *

Larger clusters often have a more lenient SLA for API latency. This should be - * taken into account when configuring the client. The rate of leader transitions - * should be monitored and RetryPeriod and LeaseDuration should be increased - * until the rate is stable and acceptably low. It's important to keep in mind - * when configuring this client that the tolerance to API latency varies inversely - * to master availability. - * - *

DISCLAIMER: This is a port of leaderelection package in client-go: - * github.com/kubernetes/client-go - * - * @since 4.7.1 - */ -package io.fabric8.kubernetes.client.extended.leaderelection; diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/run/RunOperations.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/run/RunOperationsImpl.java similarity index 82% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/run/RunOperations.java rename to kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/run/RunOperationsImpl.java index 87987d3a004..1702e268a74 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/run/RunOperations.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/extended/run/RunOperationsImpl.java @@ -20,12 +20,12 @@ import io.fabric8.kubernetes.client.ClientContext; import io.fabric8.kubernetes.client.dsl.internal.core.v1.PodOperationsImpl; -public class RunOperations { +public class RunOperationsImpl implements RunOperations { private final ClientContext clientContext; private final String namespace; private final RunConfigBuilder runConfigBuilder; - public RunOperations(ClientContext clientContext, String namespace, RunConfigBuilder runConfigBuilder) { + public RunOperationsImpl(ClientContext clientContext, String namespace, RunConfigBuilder runConfigBuilder) { this.clientContext = clientContext; this.namespace = namespace; this.runConfigBuilder = runConfigBuilder; @@ -37,8 +37,9 @@ public RunOperations(ClientContext clientContext, String namespace, RunConfigBui * @param namespace namespace in which resource needs to be created * @return {@link RunOperations} with injected namespace */ + @Override public RunOperations inNamespace(String namespace) { - return new RunOperations(clientContext, namespace, runConfigBuilder); + return new RunOperationsImpl(clientContext, namespace, runConfigBuilder); } /** @@ -47,8 +48,9 @@ public RunOperations inNamespace(String namespace) { * @param image image as a string * @return {@link RunOperations} with image injected into {@link RunConfig} */ + @Override public RunOperations withImage(String image) { - return new RunOperations(clientContext, namespace, runConfigBuilder.withImage(image)); + return new RunOperationsImpl(clientContext, namespace, runConfigBuilder.withImage(image)); } /** @@ -57,8 +59,9 @@ public RunOperations withImage(String image) { * @param name name of the pod to be created * @return {@link RunOperations} with name injected into {@link RunConfig} */ + @Override public RunOperations withName(String name) { - return new RunOperations(clientContext, namespace, runConfigBuilder.withName(name)); + return new RunOperationsImpl(clientContext, namespace, runConfigBuilder.withName(name)); } /** @@ -67,8 +70,9 @@ public RunOperations withName(String name) { * @param generatorRunConfig {@link RunConfig} which allows to provide configuring environment variables, labels, resources, ports etc * @return {@link RunOperations} with specified configuration */ + @Override public RunOperations withRunConfig(RunConfig generatorRunConfig) { - return new RunOperations(clientContext, namespace, new RunConfigBuilder(generatorRunConfig)); + return new RunOperationsImpl(clientContext, namespace, new RunConfigBuilder(generatorRunConfig)); } /** @@ -76,6 +80,7 @@ public RunOperations withRunConfig(RunConfig generatorRunConfig) { * * @return Pod which got created from the operation */ + @Override public Pod done() { return new PodOperationsImpl(clientContext, namespace).create(convertRunConfigIntoPod()); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactory.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryImpl.java similarity index 97% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactory.java rename to kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryImpl.java index ca0e3b8f2cb..3010482f97a 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactory.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryImpl.java @@ -47,8 +47,8 @@ * This has been taken from https://github.com/kubernetes-client/java/blob/master/util/src/main/java/io/kubernetes/client/informer/SharedInformerFactory.java * which is ported from official go client https://github.com/kubernetes/client-go/blob/master/informers/factory.go */ -public class SharedInformerFactory { - private static final Logger log = LoggerFactory.getLogger(SharedInformerFactory.class); +public class SharedInformerFactoryImpl implements SharedInformerFactory { + private static final Logger log = LoggerFactory.getLogger(SharedInformerFactoryImpl.class); private final List> informers = new ArrayList<>(); @@ -63,7 +63,7 @@ public class SharedInformerFactory { private BaseKubernetesClient client; - public SharedInformerFactory(BaseKubernetesClient client) { + public SharedInformerFactoryImpl(BaseKubernetesClient client) { // ideally this should be bounded. The current implication is that there // can be 1 thread used (not dedicated to) per informer - which // could be problematic for a large number of informers. however @@ -75,7 +75,7 @@ public SharedInformerFactory(BaseKubernetesClient client) { * Constructor with thread pool specified. * @param threadPool specified thread pool. */ - public SharedInformerFactory(BaseKubernetesClient client, ExecutorService threadPool) { + public SharedInformerFactoryImpl(BaseKubernetesClient client, ExecutorService threadPool) { this.informerExecutor = threadPool; this.client = client; } @@ -87,6 +87,7 @@ public SharedInformerFactory(BaseKubernetesClient client, ExecutorService thr * @return {@link SharedInformerFactory} with namespace configured * @deprecated use {@link Informable} instead */ + @Override @Deprecated public SharedInformerFactory inNamespace(String namespace) { this.namespace = namespace; @@ -100,6 +101,7 @@ public SharedInformerFactory inNamespace(String namespace) { * @return {@link SharedInformerFactory} with name configured * @deprecated use {@link Informable} instead */ + @Override @Deprecated public SharedInformerFactory withName(String name) { this.name = name; @@ -117,6 +119,7 @@ public SharedInformerFactory withName(String name) { * @param the type parameter (should extend {@link io.fabric8.kubernetes.api.model.HasMetadata} and implement {@link io.fabric8.kubernetes.api.model.Namespaced}) if Namespace scoped resource * @return the shared index informer */ + @Override public synchronized SharedIndexInformer sharedIndexInformerFor(Class apiTypeClass, long resyncPeriodInMillis) { return sharedIndexInformerFor(apiTypeClass, null, null, resyncPeriodInMillis, ResourceDefinitionContext.fromResourceType(apiTypeClass)); } @@ -152,6 +155,7 @@ public synchronized SharedIndexInformer sharedIndexIn * @return the shared index informer * @deprecated Since 5.x versions of client {@link CustomResourceDefinitionContext} are configured via annotations in CustomResource implementations, please use any of the alternative sharedIndexInformerForCustomResource methods */ + @Override @Deprecated public synchronized , L extends KubernetesResourceList> SharedIndexInformer sharedIndexInformerForCustomResource( CustomResourceDefinitionContext customResourceContext, Class apiTypeClass, Class apiListTypeClass, long resyncPeriodInMillis) { @@ -170,6 +174,7 @@ public synchronized SharedIndexInformer sharedIndexIn * @return {@link SharedIndexInformer} for GenericKubernetesResource * @deprecated use {@link #sharedIndexInformerFor(Class, long)} */ + @Override @Deprecated public synchronized SharedIndexInformer sharedIndexInformerForCustomResource(ResourceDefinitionContext genericResourceContext, long resyncPeriodInMillis) { return sharedIndexInformerFor(GenericKubernetesResource.class, GenericKubernetesResourceList.class, null, resyncPeriodInMillis, genericResourceContext); @@ -200,6 +205,7 @@ public synchronized > SharedIndexInformer share * @return the shared index informer * @deprecated use {@link #sharedIndexInformerFor(Class, long)} instead */ + @Override @Deprecated public synchronized > SharedIndexInformer sharedIndexInformerForCustomResource( Class apiTypeClass, long resyncPeriodInMillis) { @@ -219,6 +225,7 @@ public synchronized > SharedIndexInformer share * @return the shared index informer * @deprecated use {@link #sharedIndexInformerFor(Class, Class, OperationContext, long, ResourceDefinitionContext)} */ + @Override @Deprecated public synchronized , L extends KubernetesResourceList> SharedIndexInformer sharedIndexInformerForCustomResource(Class apiTypeClass, Class apiListTypeClass, long resyncPeriodInMillis) { return sharedIndexInformerFor(apiTypeClass, apiListTypeClass, null, resyncPeriodInMillis, ResourceDefinitionContext.fromResourceType(apiTypeClass)); @@ -292,6 +299,7 @@ private > HasMetadata * @param type of API type * @return SharedIndexInformer object */ + @Override public synchronized SharedIndexInformer getExistingSharedIndexInformer(Class apiTypeClass) { for (Map.Entry entry : this.informers) { if (entry.getValue().getApiTypeClass().equals(apiTypeClass)) { @@ -318,6 +326,7 @@ public List> getExistingSharedI * * @return {@link Future} for status of all started informer tasks. */ + @Override public synchronized Future startAllRegisteredInformers() { List> startInformerTasks = new ArrayList<>(); @@ -332,6 +341,7 @@ public synchronized Future startAllRegisteredInformers() { /** * Stop all registered informers and shut down thread pool. */ + @Override public synchronized void stopAllRegisteredInformers() { stopAllRegisteredInformers(true); } @@ -341,6 +351,7 @@ public synchronized void stopAllRegisteredInformers() { * * @param shutDownThreadPool Whether to shut down thread pool or not. */ + @Override public synchronized void stopAllRegisteredInformers(boolean shutDownThreadPool) { informers.forEach(e -> e.getValue().stop()); if (shutDownThreadPool && allowShutdown) { @@ -348,6 +359,7 @@ public synchronized void stopAllRegisteredInformers(boolean shutDownThreadPool) } } + @Override public void addSharedInformerEventListener(SharedInformerEventListener event) { this.eventListeners.add(event); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/Cache.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/CacheImpl.java similarity index 98% rename from kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/Cache.java rename to kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/CacheImpl.java index d08dbd17097..dcc95e7c5c2 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/Cache.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/CacheImpl.java @@ -36,7 +36,7 @@ * * @param type for cache object */ -public class Cache implements Indexer { +public class CacheImpl implements Cache { // Defines how to map objects into indices private Function keyFunc; @@ -54,11 +54,11 @@ public class Cache implements Indexer { private BooleanSupplier isRunning = () -> false; - public Cache() { + public CacheImpl() { this(NAMESPACE_INDEX, Cache::metaNamespaceIndexFunc, Cache::metaNamespaceKeyFunc); } - public Cache(String indexName, Function> indexFunc, Function keyFunc) { + public CacheImpl(String indexName, Function> indexFunc, Function keyFunc) { this.indexers.put(indexName, indexFunc); this.keyFunc = keyFunc; this.indices.put(indexName, new HashMap<>()); diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/ProcessorStore.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/ProcessorStore.java index efeb979cdac..368d8578e8e 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/ProcessorStore.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/cache/ProcessorStore.java @@ -28,10 +28,10 @@ */ public class ProcessorStore implements SyncableStore { - private Cache cache; + private CacheImpl cache; private SharedProcessor processor; - public ProcessorStore(Cache cache, SharedProcessor processor) { + public ProcessorStore(CacheImpl cache, SharedProcessor processor) { this.cache = cache; this.processor = processor; } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/impl/DefaultSharedIndexInformer.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/impl/DefaultSharedIndexInformer.java index 931e2e9f9e5..877aa4be84f 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/impl/DefaultSharedIndexInformer.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/impl/DefaultSharedIndexInformer.java @@ -21,7 +21,7 @@ import io.fabric8.kubernetes.client.informers.ResourceEventHandler; import io.fabric8.kubernetes.client.informers.ResyncRunnable; import io.fabric8.kubernetes.client.informers.SharedIndexInformer; -import io.fabric8.kubernetes.client.informers.cache.Cache; +import io.fabric8.kubernetes.client.informers.cache.CacheImpl; import io.fabric8.kubernetes.client.informers.cache.Indexer; import io.fabric8.kubernetes.client.informers.cache.ProcessorStore; import io.fabric8.kubernetes.client.informers.cache.Reflector; @@ -58,7 +58,7 @@ public class DefaultSharedIndexInformer reflector; private final Class apiTypeClass; private final ProcessorStore processorStore; - private final Cache indexer; + private final CacheImpl indexer; private final SharedProcessor processor; private final Executor informerExecutor; @@ -78,7 +78,7 @@ public DefaultSharedIndexInformer(Class apiTypeClass, ListerWatcher lis this.informerExecutor = informerExecutor; // reuse the informer executor, but ensure serial processing this.processor = new SharedProcessor<>(new SerialExecutor(informerExecutor)); - this.indexer = new Cache<>(); + this.indexer = new CacheImpl<>(); this.indexer.setIsRunning(this::isRunning); processorStore = new ProcessorStore<>(this.indexer, this.processor); diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/PatchUtils.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/PatchUtils.java index 1cc6483fcec..e2bbc46998d 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/PatchUtils.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/PatchUtils.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import io.fabric8.kubernetes.api.model.ObjectMeta; -import io.fabric8.kubernetes.client.internal.patchmixins.ObjectMetaMixIn; +import io.fabric8.kubernetes.client.internal.serializationmixins.ObjectMetaMixIn; public class PatchUtils { private PatchUtils() { } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/patchmixins/ObjectMetaMixIn.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/patchmixins/ObjectMetaMixIn.java deleted file mode 100644 index 5a3085b430a..00000000000 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/internal/patchmixins/ObjectMetaMixIn.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (C) 2015 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.fabric8.kubernetes.client.internal.patchmixins; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.fabric8.kubernetes.api.model.ObjectMeta; - -public abstract class ObjectMetaMixIn extends ObjectMeta { - @JsonIgnore - private String creationTimestamp; - @JsonIgnore - private String deletionTimestamp; - @JsonIgnore - private Long generation; - @JsonIgnore - private String resourceVersion; - @JsonIgnore - private String selfLink; - @JsonIgnore - private String uid; - - @Override - @JsonIgnore - public abstract String getCreationTimestamp(); - @Override - @JsonIgnore - public abstract String getDeletionTimestamp(); - @Override - @JsonIgnore - public abstract Long getGeneration(); - @Override - @JsonIgnore - public abstract String getResourceVersion(); - @Override - @JsonIgnore - public abstract String getSelfLink(); - @Override - @JsonIgnore - public abstract String getUid(); -} diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/osgi/ManagedKubernetesClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/osgi/ManagedKubernetesClient.java index 4cffb6be9e5..b09222b39c6 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/osgi/ManagedKubernetesClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/osgi/ManagedKubernetesClient.java @@ -103,10 +103,10 @@ import io.fabric8.kubernetes.client.dsl.V1APIGroupDSL; import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; import io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext; -import io.fabric8.kubernetes.client.dsl.internal.RawCustomResourceOperationsImpl; import io.fabric8.kubernetes.client.extended.leaderelection.LeaderElectorBuilder; import io.fabric8.kubernetes.client.extended.run.RunConfigBuilder; import io.fabric8.kubernetes.client.extended.run.RunOperations; +import io.fabric8.kubernetes.client.extended.run.RunOperationsImpl; import io.fabric8.kubernetes.client.informers.SharedInformerFactory; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; @@ -479,11 +479,6 @@ public EventingAPIGroupDSL events() { return delegate.events(); } - @Override - public RawCustomResourceOperationsImpl customResource(CustomResourceDefinitionContext customResourceDefinition) { - return delegate.customResource(customResourceDefinition); - } - @Override public SharedInformerFactory informers() { return delegate.informers(); @@ -585,7 +580,7 @@ public FunctionCallable withRequestConfig(RequestCon @Override public RunOperations run() { - return new RunOperations(this, getNamespace(), new RunConfigBuilder()); + return new RunOperationsImpl(this, getNamespace(), new RunConfigBuilder()); } @Override diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/DefaultKubernetesClientTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/DefaultKubernetesClientTest.java index 5ee94dd29d7..a173d9d3b93 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/DefaultKubernetesClientTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/DefaultKubernetesClientTest.java @@ -21,6 +21,8 @@ import io.fabric8.kubernetes.client.http.BasicBuilder; import io.fabric8.kubernetes.client.http.HttpHeaders; import io.fabric8.kubernetes.client.utils.HttpClientUtils; +import io.fabric8.kubernetes.client.utils.Serialization; +import io.fabric8.kubernetes.client.utils.Utils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -29,18 +31,26 @@ import java.io.ByteArrayInputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @author wangyushuai2@jd.com */ class DefaultKubernetesClientTest { + + private static final String TEST_CONFIG_YML_FILE = Utils.filePath(DefaultKubernetesClientTest.class.getResource("/test-config.yml")); private DefaultKubernetesClient defaultKubernetesClient; @@ -93,4 +103,48 @@ void loadWithWindowsLineSeparatorsString() throws Exception { .hasAtLeastOneElementOfType(Service.class) .hasAtLeastOneElementOfType(Deployment.class); } + + @Test + void shouldInstantiateClientUsingYaml() { + File configYml = new File(TEST_CONFIG_YML_FILE); + try (InputStream is = new FileInputStream(configYml)){ + KubernetesClient client = DefaultKubernetesClient.fromConfig(is); + assertEquals("http://some.url", client.getMasterUrl().toString()); + } catch (Exception e) { + fail(); + } + } + + @Test + void shouldInstantiateClientUsingSerializeDeserialize() { + DefaultKubernetesClient original = new DefaultKubernetesClient(); + String json = Serialization.asJson(original.getConfiguration()); + DefaultKubernetesClient copy = DefaultKubernetesClient.fromConfig(json); + + assertEquals(original.getConfiguration().getMasterUrl(), copy.getConfiguration().getMasterUrl()); + assertEquals(original.getConfiguration().getOauthToken(), copy.getConfiguration().getOauthToken()); + assertEquals(original.getConfiguration().getNamespace(), copy.getConfiguration().getNamespace()); + assertEquals(original.getConfiguration().getUsername(), copy.getConfiguration().getUsername()); + assertEquals(original.getConfiguration().getPassword(), copy.getConfiguration().getPassword()); + } + + @Test + void shouldPropagateImpersonateSettings() { + + final Map> extras = new HashMap<>(); + extras.put("c", Collections.singletonList("d")); + + final Config config = new ConfigBuilder() + .withImpersonateUsername("a") + .withImpersonateGroup("b") + .withImpersonateExtras(extras) + .build(); + + final DefaultKubernetesClient client = new DefaultKubernetesClient(config); + final Config currentConfig = client.getConfiguration(); + + assertEquals("a", currentConfig.getImpersonateUsername()); + assertArrayEquals(new String[]{"b"}, currentConfig.getImpersonateGroups()); + assertEquals(Collections.singletonList("d"), currentConfig.getImpersonateExtras().get("c")); + } } diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/base/BaseOperationTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/base/BaseOperationTest.java index 105a130e0a1..e4db40835ac 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/base/BaseOperationTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/base/BaseOperationTest.java @@ -33,7 +33,6 @@ import io.fabric8.kubernetes.client.utils.Serialization; import io.fabric8.kubernetes.client.utils.URLUtils; import io.fabric8.kubernetes.client.utils.Utils; -import okhttp3.OkHttpClient; import org.junit.jupiter.api.Test; import org.mockito.Mockito; diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImplTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImplTest.java deleted file mode 100644 index e231074183d..00000000000 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/RawCustomResourceOperationsImplTest.java +++ /dev/null @@ -1,881 +0,0 @@ -/** - * Copyright (C) 2015 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.fabric8.kubernetes.client.dsl.internal; - -import io.fabric8.kubernetes.api.model.DeleteOptionsBuilder; -import io.fabric8.kubernetes.api.model.DeletionPropagation; -import io.fabric8.kubernetes.api.model.ListOptionsBuilder; -import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.ConfigBuilder; -import io.fabric8.kubernetes.client.SimpleClientContext; -import io.fabric8.kubernetes.client.Watch; -import io.fabric8.kubernetes.client.Watcher; -import io.fabric8.kubernetes.client.WatcherException; -import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; -import io.fabric8.kubernetes.client.http.HttpClient; -import io.fabric8.kubernetes.client.http.HttpRequest; -import io.fabric8.kubernetes.client.http.HttpResponse; -import io.fabric8.kubernetes.client.http.WebSocket; -import io.fabric8.kubernetes.client.utils.Serialization; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; - -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URL; -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Function; - -import static io.fabric8.kubernetes.client.MockHttpClientUtils.buildResponse; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -class RawCustomResourceOperationsImplTest { - private HttpClient mockClient; - private HttpRequest.Builder mockRequestBuilder; - private HttpRequest mockRequest; - private Config config; - private CustomResourceDefinitionContext namespacedCustomResourceDefinitionContext; - private RawCustomResourceOperationsImpl namespacedOperations; - private RawCustomResourceOperationsImpl clusterOperations; - private ArgumentCaptor requestCaptor; - private ArgumentCaptor urlCaptor; - private ArgumentCaptor bodyCaptor; - - @BeforeEach - public void setUp() throws IOException { - mockClient = Mockito.mock(HttpClient.class, Mockito.RETURNS_DEEP_STUBS); - mockRequestBuilder = Mockito.mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF); - mockRequest = Mockito.mock(HttpRequest.class); - when(mockRequest.uri()).thenAnswer(uri -> { - ArgumentCaptor urlCaptor = ArgumentCaptor.forClass(URL.class); - verify(mockRequestBuilder, atLeastOnce()).url(urlCaptor.capture()); - return urlCaptor.getValue().toURI(); - }); - when(mockRequestBuilder.build()).thenReturn(mockRequest); - when(mockClient.newHttpRequestBuilder()).thenReturn(mockRequestBuilder); - config = new ConfigBuilder().withMasterUrl("https://localhost:8443/").build(); - namespacedCustomResourceDefinitionContext = new CustomResourceDefinitionContext.Builder() - .withGroup("test.fabric8.io") - .withName("hellos.test.fabric8.io") - .withPlural("hellos") - .withScope("Namespaced") - .withVersion("v1alpha1") - .build(); - final CustomResourceDefinitionContext clusterCustomResourceDefinitionContext = new CustomResourceDefinitionContext.Builder() - .withGroup("test.fabric8.io") - .withName("hellos.test.fabric8.io") - .withPlural("hellos") - .withScope("Cluster") - .withVersion("v1alpha1") - .build(); - namespacedOperations = new RawCustomResourceOperationsImpl(new SimpleClientContext(config, mockClient), namespacedCustomResourceDefinitionContext); - clusterOperations = new RawCustomResourceOperationsImpl(new SimpleClientContext(config, mockClient), clusterCustomResourceDefinitionContext); - requestCaptor = ArgumentCaptor.forClass(HttpRequest.class); - urlCaptor = ArgumentCaptor.forClass(URL.class); - bodyCaptor = ArgumentCaptor.forClass(String.class); - } - - @Test - @DisplayName("load, with valid InputStream, should load a valid Map") - void loadWithInputStream() throws IOException { - // When - final Map result = namespacedOperations.load(RawCustomResourceOperationsImplTest.class - .getResourceAsStream("/raw-custom-resource-operations/custom-resource.yml")); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("metadata.name", "custom-resource-example") - .hasFieldOrPropertyWithValue("spec.field", "value"); - } - - @Test - @DisplayName("load, with valid object string, should load a valid Map") - void loadWithObjectString() throws IOException { - // When - final Map result = namespacedOperations.load( - "{\"metadata\":{\"name\":\"custom-resource-example\"}, \"spec\": {\"field\": \"value\"}}" - ); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("metadata.name", "custom-resource-example") - .hasFieldOrPropertyWithValue("spec.field", "value"); - } - - @Test - @DisplayName("create, with valid object string, should create") - void createFromObjectString() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_CREATED, - "{\"metadata\": {\"resourceVersion\": \"created\"}}") - ); - // When - final Map result = clusterOperations.create( - "{\"metadata\":{\"name\":\"custom-resource-example\"}}" - ); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("metadata.resourceVersion", "created"); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/hellos", "POST"); - } - - @Test - @DisplayName("create, with valid Map, should create") - void createFromMap() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_CREATED, - "{\"metadata\": {\"resourceVersion\": \"created\"}}") - ); - // When - final Map result = clusterOperations.create( - Collections.singletonMap("metadata", - Collections.singletonMap("name", "custom-resource-example")) - ); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("metadata.resourceVersion", "created"); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/hellos", "POST"); - } - - @Test - @DisplayName("create, with valid InputStream, should create") - void createFromInputStream() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_CREATED, - "{\"metadata\": {\"resourceVersion\": \"created\"}}") - ); - // When - final Map result = clusterOperations.create(RawCustomResourceOperationsImplTest.class - .getResourceAsStream("/raw-custom-resource-operations/custom-resource.yml")); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("metadata.resourceVersion", "created"); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/hellos", "POST"); - } - - @Test - @DisplayName("create, with namespace and valid InputStream, should create") - void createWithNamespaceFromInputStream() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_CREATED, - "{\"metadata\": {\"resourceVersion\": \"created\"}}") - ); - // When - final Map result = namespacedOperations.create("other-namespace", - RawCustomResourceOperationsImplTest.class.getResourceAsStream("/raw-custom-resource-operations/custom-resource.yml")); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("metadata.resourceVersion", "created"); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/other-namespace/hellos", "POST"); - } - - @Test - @DisplayName("create, with namespace and valid Map, should create") - void createWithNamespaceFromMap() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_CREATED, - "{\"metadata\": {\"resourceVersion\": \"created\"}}") - ); - // When - final Map result = namespacedOperations.create("other-namespace", - Collections.singletonMap("metadata", - Collections.singletonMap("name", "custom-resource-example")) - ); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("metadata.resourceVersion", "created"); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/other-namespace/hellos", "POST"); - } - - @Test - @DisplayName("createOrReplace, with valid object string, should create") - void createOrReplaceFromString() throws IOException { - // Given - String resourceAsString = "{\"metadata\":{\"name\":\"myresource\",\"namespace\":\"myns\",\"resourceVersion\":\"111\"}, \"kind\":\"raw\", \"apiVersion\":\"v1\"}"; - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_CREATED, - "{\"kind\": \"raw\", \"metadata\": {\"resourceVersion\": \"created\"}}") - ); - // When - final Map result = namespacedOperations.inNamespace("myns").createOrReplace(resourceAsString); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("metadata.resourceVersion", "created"); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos", "POST"); - } - - @Test - @DisplayName("createOrReplace, with valid Map, should create") - void createOrReplaceFromMap() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_CREATED, - "{\"metadata\": {\"resourceVersion\": \"created\"}}") - ); - // When - final Map result = clusterOperations.inNamespace("myns").createOrReplace( - Collections.singletonMap("metadata", - Collections.singletonMap("name", "custom-resource-example")) - ); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("metadata.resourceVersion", "created"); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/hellos", "POST"); - } - - @Test - void testCreateOrReplaceWithConflict() throws IOException { - // Given - String resourceAsString = "{\"metadata\":{\"name\":\"myresource\",\"namespace\":\"myns\",\"resourceVersion\":\"111\"}, \"kind\":\"raw\", \"apiVersion\":\"v1\"}"; - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_CONFLICT), - i -> buildResponse(HttpURLConnection.HTTP_OK, - "{\"kind\": \"raw\", \"metadata\": {\"resourceVersion\": \"replaced\"}}") - ); - // When - final Map result = namespacedOperations.inNamespace("myns").createOrReplace(resourceAsString); - // Then - assertThat(result) - .isNotNull() - .hasFieldOrPropertyWithValue("metadata.resourceVersion", "replaced"); - assertRequestCaptured(0, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos", "POST"); - assertRequestCaptured(1, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/myresource", "PUT"); - } - - @Test - void testDeleteWithNamespaceAndNameForNonExistentResource() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_NOT_FOUND, "{\"kind\":\"Status\",\"status\":\"Failure\"}"); - - // When - boolean result = namespacedOperations.delete("ns1", "foo"); - - // Then - assertFalse(result); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/foo", "DELETE"); - } - - @Test - void testDeleteWithNamespaceForNonExistentResource() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_OK, "{" + - "\"items\": [" + - "{\"metadata\": {\"name\": \"hello\", \"namespace\": \"ns1\"}}" + - "]" + - "}"), - i -> buildResponse(HttpURLConnection.HTTP_NOT_FOUND, "{\"kind\":\"Status\",\"status\":\"Failure\"}") - ); - - // When - boolean result = namespacedOperations.delete("ns1"); - - // Then - assertTrue(result); // delete()->deleteList() always returns true - assertRequestCaptured(0, "/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos", "GET"); - assertRequestCaptured(1, "/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/hello", "DELETE"); - } - - @Test - void testDeleteWithNamespaceAndCascadingForNonExistentResource() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_OK, "{" + - "\"items\": [" + - "{\"metadata\": {\"name\": \"hello\", \"namespace\": \"ns1\"}}" + - "]" + - "}"), - i -> buildResponse(HttpURLConnection.HTTP_NOT_FOUND, "{\"kind\":\"Status\",\"status\":\"Failure\"}") - ); - - // When - boolean result = namespacedOperations.delete("ns1", true); - - // Then - assertTrue(result); // delete()->deleteList() always returns true - assertRequestCaptured(0, "/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos", "GET"); - assertRequestCaptured(1, "/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/hello", "DELETE"); - } - - @Test - void testDeleteWithNamespaceAndDeleteOptionsForNonExistentResource() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_OK, "{" + - "\"items\": [" + - "{\"metadata\": {\"name\": \"hello\", \"namespace\": \"ns1\"}}" + - "]" + - "}"), - i -> buildResponse(HttpURLConnection.HTTP_NOT_FOUND, "{\"kind\":\"Status\",\"status\":\"Failure\"}") - ); - - // When - boolean result = namespacedOperations.delete("ns1", new DeleteOptionsBuilder().withOrphanDependents(true).build()); - - // Then - assertTrue(result); // delete()->deleteList() always returns true - assertRequestCaptured(0, "/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos", "GET"); - assertRequestCaptured(1, "/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/hello", "DELETE"); - } - - @Test - void testDeleteWithNamespaceNameAndCascading() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK, "{\"kind\":\"Hello\",\"metadata\":{\"name\":\"Failure\"}}"); - - // When - boolean result = namespacedOperations.delete("ns1", "foo", true); - - // Then - assertTrue(result); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/foo", "DELETE"); - } - - @Test - void testDeleteWithNamespaceNameAndCascadingForNonExistentResource() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_NOT_FOUND, "{\"kind\":\"Status\",\"status\":\"Failure\"}"); - - // When - boolean result = namespacedOperations.delete("ns1", "foo", true); - - // Then - assertFalse(result); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/foo", "DELETE"); - } - - @Test - void testDeleteWithNamespaceNameAndPropagationPolicyForNonExistentResource() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_NOT_FOUND, "{\"kind\":\"Status\",\"status\":\"Failure\"}"); - - // When - boolean result = namespacedOperations.delete("ns1", "foo", DeletionPropagation.BACKGROUND.toString()); - - // Then - assertFalse(result); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/foo", "DELETE"); - } - - @Test - void testDeleteWithNamespaceNameAndDeleteOptionsForNonExistentResource() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_NOT_FOUND, "{\"kind\":\"Status\",\"status\":\"Failure\"}"); - - // When - boolean result = namespacedOperations.delete("ns1", "foo", new DeleteOptionsBuilder().withPropagationPolicy(DeletionPropagation.FOREGROUND.toString()).build()); - - // Then - assertFalse(result); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/foo", "DELETE"); - } - - @Test - void testGetUrl() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK, "{}"); - - // When - namespacedOperations.get("myns", "myresource"); - - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/myresource", "GET"); - } - - @Test - void testDeleteUrl() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK, "{\"kind\":\"Status\",\"status\":\"Success\"}"); - - // When - boolean result = namespacedOperations.delete("myns", "myresource"); - - // Then - assertTrue(result); - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/myresource", "DELETE"); - } - - @Test - void testGetConfigShouldNotReturnNull() { - // Given - Config config = new ConfigBuilder() - .withRequestTimeout(5) - .withWebsocketTimeout(10L) - .withWebsocketPingInterval(10L) - .withConnectionTimeout(10) - .withWatchReconnectLimit(1) - .withWatchReconnectInterval(10) - .build(); - RawCustomResourceOperationsImpl rawOp = new RawCustomResourceOperationsImpl(new SimpleClientContext(config, mockClient), namespacedCustomResourceDefinitionContext); - - // When - Config configFromRawOp = rawOp.getConfig(); - - // Then - assertThat(configFromRawOp) - .isNotNull() - .hasFieldOrPropertyWithValue("requestTimeout", 5) - .hasFieldOrPropertyWithValue("websocketTimeout", 10L) - .hasFieldOrPropertyWithValue("websocketPingInterval", 10L) - .hasFieldOrPropertyWithValue("connectionTimeout", 10) - .hasFieldOrPropertyWithValue("watchReconnectInterval", 10) - .hasFieldOrPropertyWithValue("watchReconnectLimit", 1); - } - - @Test - void testDryRunDelete() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK); - - // When - namespacedOperations.dryRun().delete("myns", "myresource"); - - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/myresource", "DELETE"); - assertEquals("dryRun=All", urlCaptor.getValue().getQuery()); - } - - @Test - @DisplayName("delete, with valid namespace and name and grace period, should delete") - void deleteWithGracePeriod() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK); - // When - namespacedOperations.inNamespace("myns").withName("myresource").withGracePeriod(1337L).delete(); - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/myresource", "DELETE"); - assertThat(bodyCaptor.getValue()).contains("\"gracePeriodSeconds\":1337"); - } - - @Test - @DisplayName("delete, with valid namespace and name and propagation policy should delete") - void deleteWithPropagationPolicy() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK); - // When - namespacedOperations.inNamespace("myns").withName("myresource") - .withPropagationPolicy(DeletionPropagation.FOREGROUND).delete(); - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/myresource", "DELETE"); - assertThat(bodyCaptor.getValue()).contains("\"propagationPolicy\":\"Foreground\""); - } - - @Test - void testDryRunCreate() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK); - - // When - namespacedOperations.dryRun().create("myns", "{\"apiVersion\":\"test.fabric8.io/v1alpha1\"}"); - - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos", "POST"); - assertEquals("dryRun=All", urlCaptor.getValue().getQuery()); - } - - @Test - void testDeleteWithNamespaceAndName() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK); - - // When - namespacedOperations.inNamespace("myns").withName("myresource").delete(); - - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/myresource", "DELETE"); - } - - @Test - void testGet() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK, "{}"); - - // When - namespacedOperations.inNamespace("myns").withName("myresource").get(); - - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/myresource", "GET"); - } - - @Test - void testListWithLimitAndContinue() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK, "{\"kind\":\"List\"}"); - - // When - namespacedOperations.inNamespace("myns").list(4, "eyJ2IjoibWV0YS5rOHMuaW8vdj"); - - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos", "GET"); - assertEquals("limit=4&continue=eyJ2IjoibWV0YS5rOHMuaW8vdj", urlCaptor.getValue().getQuery()); - } - - @Test - void testListWithListOptions() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK, "{\"kind\":\"List\"}"); - - // When - namespacedOperations.inNamespace("myns").list(new ListOptionsBuilder().withLimit(4L).build()); - - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos", "GET"); - assertEquals("limit=4", urlCaptor.getValue().getQuery()); - } - - @Test - void testListWithLabels() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK, "{\"kind\":\"List\"}"); - - // When - namespacedOperations.list("myns", Collections.singletonMap("foo", "bar")); - - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos", "GET"); - assertEquals("labelSelector=foo%3Dbar", urlCaptor.getValue().getQuery()); - } - - @Test - void testDeleteInSpecifiedNamespace() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_OK, "{" + - "\"items\": [" + - "{\"metadata\": {\"name\": \"one\"}}," + - "{\"metadata\": {\"name\": \"two\"}}" + - "]" + - "}"), - i -> buildResponse(HttpURLConnection.HTTP_OK) - ); - - // When - namespacedOperations.inNamespace("myns").delete(); - - // Then - assertRequestCaptured(0, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos", "GET"); - assertRequestCaptured(1, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/one", "DELETE"); - assertRequestCaptured(2, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/two", "DELETE"); - } - - @Test - void testDeleteInAllNamespaces() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_OK, "{" + - "\"items\": [" + - "{\"metadata\": {\"name\": \"one\", \"namespace\": \"myns\"}}," + - "{\"metadata\": {\"name\": \"two\", \"namespace\": \"myns\"}}" + - "]" + - "}"), - i -> buildResponse(HttpURLConnection.HTTP_OK) - ); - - // When - namespacedOperations.inAnyNamespace().delete(); - - // Then - assertRequestCaptured(0, "/apis/test.fabric8.io/v1alpha1/hellos", "GET"); - assertRequestCaptured(1, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/one", "DELETE"); - assertRequestCaptured(2, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/two", "DELETE"); - } - - @Test - void testClusterScopedDeletionWithName() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK); - - // When - clusterOperations.withName("myresource").delete(); - - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/hellos/myresource", "DELETE"); - } - - @Test - void testClusterScopeDeletionAll() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_OK, "{" + - "\"items\": [" + - "{\"metadata\": {\"name\": \"one\"}}," + - "{\"metadata\": {\"name\": \"two\"}}" + - "]" + - "}"), - i -> buildResponse(HttpURLConnection.HTTP_OK) - ); - - // When - clusterOperations.delete(); - - // Then - assertRequestCaptured(0, "/apis/test.fabric8.io/v1alpha1/hellos", "GET"); - assertRequestCaptured(1, "/apis/test.fabric8.io/v1alpha1/hellos/one", "DELETE"); - assertRequestCaptured(2, "/apis/test.fabric8.io/v1alpha1/hellos/two", "DELETE"); - } - - @Test - void testDeleteByNamespaceOrNameWithNamespacedScopedCRD() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_OK, "{" + - "\"items\": [" + - "{\"metadata\": {\"name\": \"one\", \"namespace\": \"myns\"}}," + - "{\"metadata\": {\"name\": \"two\", \"namespace\": \"myns\"}}" + - "]" + - "}"), - i -> buildResponse(HttpURLConnection.HTTP_OK) - ); - - // When - namespacedOperations.delete("myns"); - - // Then - assertRequestCaptured(0, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos", "GET"); - assertRequestCaptured(1, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/one", "DELETE"); - assertRequestCaptured(2, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/two", "DELETE"); - } - - @Test - void testDeleteByNamespaceOrNameWithCascadingWithNamespacedScopedCRD() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_OK, "{" + - "\"items\": [" + - "{\"metadata\": {\"name\": \"one\", \"namespace\": \"myns\"}}," + - "{\"metadata\": {\"name\": \"two\", \"namespace\": \"myns\"}}" + - "]" + - "}"), - i -> buildResponse(HttpURLConnection.HTTP_OK) - ); - - // When - namespacedOperations.delete("myns", true); - - // Then - assertRequestCaptured(0, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos", "GET"); - assertRequestCaptured(1, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/one", "DELETE"); - assertRequestCaptured(2, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/two", "DELETE"); - } - - @Test - void testDeleteByNamespaceOrNameWithDeleteOptionsWithNamespacedScopedCRD() throws IOException { - // Given - mockCallWithResponse( - i -> buildResponse(HttpURLConnection.HTTP_OK, "{" + - "\"items\": [" + - "{\"metadata\": {\"name\": \"one\", \"namespace\": \"myns\"}}," + - "{\"metadata\": {\"name\": \"two\", \"namespace\": \"myns\"}}" + - "]" + - "}"), - i -> buildResponse(HttpURLConnection.HTTP_OK) - ); - - // When - namespacedOperations.delete("myns", new DeleteOptionsBuilder() - .withPropagationPolicy(DeletionPropagation.BACKGROUND.toString()).build()); - - // Then - assertRequestCaptured(0, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos", "GET"); - assertRequestCaptured(1, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/one", "DELETE"); - assertRequestCaptured(2, "/apis/test.fabric8.io/v1alpha1/namespaces/myns/hellos/two", "DELETE"); - } - - @Test - void testDeleteByNamespaceOrNameWithClusterScopedCRD() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK); - - // When - clusterOperations.delete("myresource"); - - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/hellos/myresource", "DELETE"); - } - - @Test - void testDeleteByNamespaceOrNameWithCascadingWithClusterScopedCRD() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK); - - // When - clusterOperations.delete("myresource", true); - - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/hellos/myresource", "DELETE"); - } - - @Test - void testDeleteByNamespaceOrNameWithDeleteOptionsWithClusterScopedCRD() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK); - - // When - clusterOperations.delete("myresource", new DeleteOptionsBuilder() - .withPropagationPolicy(DeletionPropagation.BACKGROUND.toString()).build()); - - // Then - assertRequestCaptured("/apis/test.fabric8.io/v1alpha1/hellos/myresource", "DELETE"); - } - - @Test - void testGetConfigmap() throws IOException { - // Given - mockCallWithResponse(HttpURLConnection.HTTP_OK, "{\"kind\": \"ConfigMap\"}"); - CustomResourceDefinitionContext configMapContext = new CustomResourceDefinitionContext.Builder() - .withGroup(null) - .withVersion("v1") - .withPlural("configmaps") - .withScope("Namespaced") - .withKind("ConfigMap") - .build(); - RawCustomResourceOperationsImpl rawOp = new RawCustomResourceOperationsImpl(new SimpleClientContext(config, mockClient), configMapContext); - - // When - Map unstructuredConfigMap = rawOp.inNamespace("default").withName("game-config").get(); - - // Then - assertThat(unstructuredConfigMap).isNotNull(); - assertRequestCaptured("/api/v1/namespaces/default/configmaps/game-config", "GET"); - } - - @Test - void testEditCR() throws IOException { - // Given - mockCallWithResponse(i -> buildResponse(HttpURLConnection.HTTP_OK, "{\"kind\": \"Hello\"}")); - String jsonString = "{ \"metadata\": " + Serialization.jsonMapper().writeValueAsString(new ObjectMetaBuilder().withName("myresource").withNamespace("mynamespace").build()) + "}"; - - // When - Map res = clusterOperations.edit(jsonString); - - // Then - assertNotNull(res); - } - - @Test - @DisplayName("watch, with valid Watcher, should connect and receive event") - void watch() throws IOException { - // Given - final AtomicReference eventReceived = new AtomicReference<>(); - WebSocket.Builder builder = Mockito.mock(WebSocket.Builder.class, Mockito.RETURNS_SELF); - when(mockClient.newBuilder().readTimeout(anyLong(), any()).build().newWebSocketBuilder()).thenReturn(builder); - when(builder.buildAsync(any())).thenAnswer(i -> { - final WebSocket webSocket = mock(WebSocket.class); - ((WebSocket.Listener)i.getArguments()[0]).onOpen(webSocket); - ((WebSocket.Listener)i.getArguments()[0]) - .onMessage(webSocket, "{\"type\":\"ADDED\", \"object\":{\"kind\": \"Hello\", \"metadata\": {\"name\": \"test\"}}}"); - return CompletableFuture.completedFuture(webSocket); - }); - // When - final Watch result = clusterOperations.watch(new Watcher() { - @Override - public void eventReceived(Action action, String resource) { - eventReceived.set(resource); - } - - @Override - public void onClose(WatcherException cause) { - - } - }); - // Then - assertThat(eventReceived).hasValue("{\"kind\":\"Hello\",\"metadata\":{\"name\":\"test\"}}"); - assertThat(result).isNotNull(); - verify(builder, Mockito.times(1)).uri(URI.create("https://localhost:8443/apis/test.fabric8.io/v1alpha1/hellos?allowWatchBookmarks=true&watch=true")); - } - - private void mockCallWithResponse(int code) throws IOException { - mockCallWithResponse(code, "{\"kind\":\"Status\",\"status\":\"Success\"}"); - } - - private void mockCallWithResponse(int code, String body) throws IOException { - mockCallWithResponse(i -> buildResponse(code, body)); - } - - @SafeVarargs - private final void mockCallWithResponse( - Function> response, Function>... responses) - throws IOException { - final AtomicInteger invocationCount = new AtomicInteger(-1); - when(mockClient.send(any(), any())).thenAnswer(invocation -> { - final int current = invocationCount.getAndIncrement(); - if (current == -1 || responses.length == 0){ - return response.apply(invocation); - } else if (current < responses.length) { - return responses[current].apply(invocation); - } - return responses[responses.length - 1].apply(invocation); - }); - } - - private void assertRequestCaptured(int order, String url, String method) throws IOException { - verify(mockClient, atLeastOnce()).send(requestCaptor.capture(), any()); - switch (method) { - case "PUT": - verify(mockRequestBuilder, atLeastOnce()).put(any(), bodyCaptor.capture()); - break; - case "POST": - verify(mockRequestBuilder, atLeastOnce()).post(any(), bodyCaptor.capture()); - break; - case "GET": - break; - case "DELETE": - verify(mockRequestBuilder, atLeastOnce()).delete(any(), bodyCaptor.capture()); - break; - default: - throw new AssertionError(); - } - verify(mockRequestBuilder, atLeastOnce()).url(urlCaptor.capture()); - assertEquals(url, urlCaptor.getAllValues().get(order).getPath()); - } - - private void assertRequestCaptured(String url, String method) throws IOException { - assertRequestCaptured(0, url, method); - } -} diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/run/RunOperationsTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/run/RunOperationsTest.java index 4d7420f52f3..6de7e1f6bc6 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/run/RunOperationsTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/extended/run/RunOperationsTest.java @@ -65,7 +65,7 @@ void testConvertRunConfigIntoPod() { .withPort(5701) .withLimits(limits) .withRequests(requests); - RunOperations deploymentGenerator = new RunOperations(new SimpleClientContext(config, mockClient), "ns1", generatorRunConfig); + RunOperationsImpl deploymentGenerator = new RunOperationsImpl(new SimpleClientContext(config, mockClient), "ns1", generatorRunConfig); // When Pod pod = deploymentGenerator.convertRunConfigIntoPod(); diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryTest.java index 8cac50f71ee..77835bfadea 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/SharedInformerFactoryTest.java @@ -17,14 +17,12 @@ import io.fabric8.kubernetes.api.model.GenericKubernetesResource; import io.fabric8.kubernetes.api.model.Pod; -import io.fabric8.kubernetes.api.model.Secret; import io.fabric8.kubernetes.api.model.Service; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.fabric8.kubernetes.client.BaseKubernetesClient; import io.fabric8.kubernetes.client.CustomResource; import io.fabric8.kubernetes.client.DefaultKubernetesClient; import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; -import io.fabric8.kubernetes.client.dsl.base.OperationContext; import io.fabric8.kubernetes.model.annotation.Group; import io.fabric8.kubernetes.model.annotation.Kind; import io.fabric8.kubernetes.model.annotation.Plural; @@ -34,8 +32,6 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import java.util.List; -import java.util.Map; import java.util.concurrent.ExecutorService; import static org.assertj.core.api.Assertions.assertThat; @@ -94,28 +90,10 @@ void init() { this.executorService = Mockito.mock(ExecutorService.class, Mockito.RETURNS_DEEP_STUBS); } - @Test - void testInformersCreatedWithSameNameButDifferentCRDContext() { - // Given - SharedInformerFactory sharedInformerFactory = new SharedInformerFactory(mockBaseClient, executorService); - - // When - sharedInformerFactory.sharedIndexInformerForCustomResource(TestCustomResource.class, new OperationContext() - .withApiGroupVersion("v1") - .withPlural("testcustomresources"), RESYNC_PERIOD); - sharedInformerFactory.sharedIndexInformerForCustomResource(TestCustomResource.class, new OperationContext() - .withApiGroupVersion("v1beta1") - .withPlural("testcustomresources"), RESYNC_PERIOD); - - // Then - assertThat(sharedInformerFactory.getExistingSharedIndexInformers()) - .hasSize(2); - } - @Test void testSharedIndexInformerForCustomResourceNoType() { // Given - SharedInformerFactory sharedInformerFactory = new SharedInformerFactory(mockBaseClient, executorService); + SharedInformerFactory sharedInformerFactory = new SharedInformerFactoryImpl(mockBaseClient, executorService); CustomResourceDefinitionContext context = new CustomResourceDefinitionContext.Builder() .withKind("Dummy") .withScope("Namespaced") @@ -129,13 +107,12 @@ void testSharedIndexInformerForCustomResourceNoType() { // Then assertThat(informer).isNotNull(); - assertThat(sharedInformerFactory.getExistingSharedIndexInformers()).hasSize(1); } @Test void testGetExistingSharedIndexInformer() { // Given - SharedInformerFactory sharedInformerFactory = new SharedInformerFactory(mockBaseClient, executorService); + SharedInformerFactory sharedInformerFactory = new SharedInformerFactoryImpl(mockBaseClient, executorService); // When sharedInformerFactory.sharedIndexInformerFor(Deployment.class, RESYNC_PERIOD); @@ -149,7 +126,7 @@ void testGetExistingSharedIndexInformer() { @Test void testGetExistingSharedIndexInformerWithKindDifferentFromClassName() { // Given - SharedInformerFactory sharedInformerFactory = new SharedInformerFactory(mockBaseClient, executorService); + SharedInformerFactory sharedInformerFactory = new SharedInformerFactoryImpl(mockBaseClient, executorService); // When SharedIndexInformer createdInformer = sharedInformerFactory.sharedIndexInformerFor(MyAppCustomResource.class, RESYNC_PERIOD); @@ -164,7 +141,7 @@ void testGetExistingSharedIndexInformerWithKindDifferentFromClassName() { @Test void testGetExistingSharedIndexInformerWithTwoClassesSimilarNames() { // Given - SharedInformerFactory sharedInformerFactory = new SharedInformerFactory(mockBaseClient, executorService); + SharedInformerFactory sharedInformerFactory = new SharedInformerFactoryImpl(mockBaseClient, executorService); sharedInformerFactory.sharedIndexInformerFor(VirtualService.class, RESYNC_PERIOD); sharedInformerFactory.sharedIndexInformerFor(Service.class, RESYNC_PERIOD); @@ -177,27 +154,4 @@ void testGetExistingSharedIndexInformerWithTwoClassesSimilarNames() { assertThat(sharedIndexInformerVSvc.getApiTypeClass()).isEqualTo(VirtualService.class); } - @Test - void testGetExistingSharedIndexInformersReturnsListOfOperationContextAndSharedIndexInformerEntries() { - // Given - SharedInformerFactory sharedInformerFactory = new SharedInformerFactory(mockBaseClient, executorService); - sharedInformerFactory.sharedIndexInformerFor(MyAppCustomResource.class, RESYNC_PERIOD); - sharedInformerFactory.sharedIndexInformerFor(Secret.class, RESYNC_PERIOD); - sharedInformerFactory.sharedIndexInformerFor(MyAppCustomResourceCopy.class, RESYNC_PERIOD); - - // When - List> existingInformers = sharedInformerFactory.getExistingSharedIndexInformers(); - - // Then - assertThat(existingInformers) - .isNotNull() - .hasSize(3); - assertThat(existingInformers.get(0).getKey().getPlural()) - .isEqualTo("myapps"); - assertThat(existingInformers.get(1).getKey().getPlural()) - .isEqualTo("secrets"); - assertThat(existingInformers.get(2).getKey().getPlural()) - .isEqualTo("myapps"); - } - } diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/cache/CacheTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/cache/CacheTest.java index 0810e03cc38..b5314af151a 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/cache/CacheTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/cache/CacheTest.java @@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; class CacheTest { - private static Cache cache = new Cache("mock", CacheTest::mockIndexFunction, CacheTest::mockKeyFunction); + private static CacheImpl cache = new CacheImpl("mock", CacheTest::mockIndexFunction, CacheTest::mockKeyFunction); @Test void testCacheIndex() { @@ -105,7 +105,7 @@ void testEmptyNamespaceKey() { @Test void testAddIndexers() { - Cache podCache = new Cache<>(); + CacheImpl podCache = new CacheImpl<>(); String nodeIndex = "node-index"; String clusterIndex = "cluster-index"; diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/cache/ListerTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/cache/ListerTest.java index 2ae9bff3d1a..f5c3aacb313 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/cache/ListerTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/cache/ListerTest.java @@ -27,7 +27,7 @@ class ListerTest { @Test void testListerBasic() { - Cache podCache = new Cache<>(); + CacheImpl podCache = new CacheImpl<>(); Lister namespacedPodLister = new Lister<>(podCache, "default"); List emptyPodList = namespacedPodLister.list(); diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/cache/ProcessorStoreTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/cache/ProcessorStoreTest.java index a79eed8ce5a..a425cf7cbf9 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/cache/ProcessorStoreTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/informers/cache/ProcessorStoreTest.java @@ -38,7 +38,7 @@ public class ProcessorStoreTest { public void testEvents() { ArgumentCaptor> notificationCaptor = ArgumentCaptor.forClass(Notification.class); ArgumentCaptor syncCaptor = ArgumentCaptor.forClass(Boolean.class); - Cache podCache = Mockito.mock(Cache.class); + CacheImpl podCache = Mockito.mock(CacheImpl.class); SharedProcessor processor = Mockito.mock(SharedProcessor.class); ProcessorStore processorStore = new ProcessorStore<>(podCache, processor); @@ -77,7 +77,7 @@ public void testEvents() { public void testSyncEvents() { ArgumentCaptor> notificationCaptor = ArgumentCaptor.forClass(Notification.class); ArgumentCaptor syncCaptor = ArgumentCaptor.forClass(Boolean.class); - Cache podCache = new Cache<>(); + CacheImpl podCache = new CacheImpl<>(); SharedProcessor processor = Mockito.mock(SharedProcessor.class); ProcessorStore processorStore = new ProcessorStore<>(podCache, processor); diff --git a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/RawCustomResourceExample.java b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/GenericKubernetesResourceExample.java similarity index 64% rename from kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/RawCustomResourceExample.java rename to kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/GenericKubernetesResourceExample.java index 4fd8fc81d71..a19aa318e28 100644 --- a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/RawCustomResourceExample.java +++ b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/GenericKubernetesResourceExample.java @@ -15,6 +15,9 @@ */ package io.fabric8.kubernetes.examples; +import io.fabric8.kubernetes.api.model.GenericKubernetesResource; +import io.fabric8.kubernetes.api.model.GenericKubernetesResourceList; +import io.fabric8.kubernetes.api.model.ObjectMeta; import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition; import io.fabric8.kubernetes.client.ConfigBuilder; import io.fabric8.kubernetes.client.DefaultKubernetesClient; @@ -22,18 +25,20 @@ import io.fabric8.kubernetes.client.KubernetesClientException; import io.fabric8.kubernetes.client.Watcher; import io.fabric8.kubernetes.client.WatcherException; +import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; +import io.fabric8.kubernetes.client.dsl.Resource; import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; +import io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List; -import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -public class RawCustomResourceExample { +public class GenericKubernetesResourceExample { - private static final Logger logger = LoggerFactory.getLogger(RawCustomResourceExample.class); + private static final Logger logger = LoggerFactory.getLogger(GenericKubernetesResourceExample.class); public static void main(String[] args) throws Exception { @@ -44,33 +49,36 @@ public static void main(String[] args) throws Exception { String namespace = "default"; CustomResourceDefinition prometheousRuleCrd = client.apiextensions().v1beta1().customResourceDefinitions() - .load(RawCustomResourceExample.class.getResourceAsStream("/prometheous-rule-crd.yml")).get(); + .load(GenericKubernetesResourceExample.class.getResourceAsStream("/prometheous-rule-crd.yml")).get(); client.apiextensions().v1beta1().customResourceDefinitions().createOrReplace(prometheousRuleCrd); logger.info("Successfully created Prometheous custom resource definition"); // Creating Custom Resources Now: - CustomResourceDefinitionContext crdContext = CustomResourceDefinitionContext.fromCrd(prometheousRuleCrd); + ResourceDefinitionContext crdContext = CustomResourceDefinitionContext.fromCrd(prometheousRuleCrd); - client.customResource(crdContext) - .createOrReplace(namespace, RawCustomResourceExample.class.getResourceAsStream("/prometheous-rule-cr.yml")); + client.load(GenericKubernetesResourceExample.class.getResourceAsStream("/prometheous-rule-cr.yml")) + .inNamespace(namespace) + .createOrReplace(); logger.info("Created Custom Resource successfully too"); // Listing all custom resources in given namespace: - Map list = client.customResource(crdContext).list(namespace); - List> items = (List>) list.get("items"); + NonNamespaceOperation> resourcesInNamespace = + client.genericKubernetesResources(crdContext).inNamespace(namespace); + GenericKubernetesResourceList list = resourcesInNamespace.list(); + List items = list.getItems(); logger.info("Custom Resources :- "); - for(Map customResource : items) { - Map metadata = (Map) customResource.get("metadata"); - final String name = metadata.get("name").toString(); + for(GenericKubernetesResource customResource : items) { + ObjectMeta metadata = customResource.getMetadata(); + final String name = metadata.getName(); logger.info(name); } // Watching custom resources now logger.info("Watching custom resources now"); final CountDownLatch closeLatch = new CountDownLatch(1); - client.customResource(crdContext).watch(namespace, new Watcher() { + resourcesInNamespace.watch(new Watcher() { @Override - public void eventReceived(Action action, String resource) { + public void eventReceived(Action action, GenericKubernetesResource resource) { logger.info("{}: {}", action, resource); } @@ -87,7 +95,7 @@ public void onClose(WatcherException e) { // Cleanup logger.info("Deleting custom resources..."); - client.customResource(crdContext).delete(namespace, "prometheus-example-rules"); + resourcesInNamespace.withName("prometheus-example-rules").delete(); client.apiextensions().v1beta1().customResourceDefinitions() .withName(prometheousRuleCrd.getMetadata().getName()).delete(); } catch (KubernetesClientException e) { diff --git a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/kubectl/equivalents/CustomResourceCreateDemoTypeless.java b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/kubectl/equivalents/CustomResourceCreateDemoTypeless.java index c54a7c6e350..d35697e2902 100644 --- a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/kubectl/equivalents/CustomResourceCreateDemoTypeless.java +++ b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/kubectl/equivalents/CustomResourceCreateDemoTypeless.java @@ -15,41 +15,37 @@ */ package io.fabric8.kubernetes.examples.kubectl.equivalents; +import io.fabric8.kubernetes.api.model.GenericKubernetesResource; import io.fabric8.kubernetes.client.DefaultKubernetesClient; import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; - -import java.io.IOException; -import java.util.Map; +import io.fabric8.kubernetes.client.dsl.Resource; +import io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext; /** * This example is Java equivalent to `kubectl create -f test-customresource.yaml`. It applies - * the specified Custom Resource. It assumes that CustomResourceDefinition for the particular + * the specified Resource. It assumes that CustomResourceDefinition for the particular * CustomResource is already created. Note that with this approach, you don't need to provide * POJOs for your custom types but you're also losing type safety since it would be upto the - * user to manipulate raw CustomResource as HashMaps. + * user to manipulate raw Resources as GenericKubernetesResource. */ public class CustomResourceCreateDemoTypeless { public static void main(String[] args) { try (final KubernetesClient k8s = new DefaultKubernetesClient()) { // Create Custom Resource Context - CustomResourceDefinitionContext context = new CustomResourceDefinitionContext + ResourceDefinitionContext context = new ResourceDefinitionContext .Builder() .withGroup("demo.fabric8.io") .withKind("Dummy") - .withName("dummies.demo.fabric8.io") .withPlural("dummies") - .withScope("Namespaced") + .withNamespaced(true) .withVersion("v1") .build(); // Load from Yaml - Map dummyObject = k8s.customResource(context) + Resource dummyObject = k8s.genericKubernetesResources(context) .load(CustomResourceCreateDemoTypeless.class.getResourceAsStream("/test-customresource.yaml")); // Create Custom Resource - k8s.customResource(context).create("default", dummyObject); - } catch (IOException e) { - e.printStackTrace(); + dummyObject.create(); } } } diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RawClusterScopedCustomResourceIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/GenericClusterScopedCustomResourceIT.java similarity index 68% rename from kubernetes-itests/src/test/java/io/fabric8/kubernetes/RawClusterScopedCustomResourceIT.java rename to kubernetes-itests/src/test/java/io/fabric8/kubernetes/GenericClusterScopedCustomResourceIT.java index 52a133b1d15..15c52e0e86b 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RawClusterScopedCustomResourceIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/GenericClusterScopedCustomResourceIT.java @@ -17,8 +17,11 @@ import io.fabric8.commons.AssumingK8sVersionAtLeast; import io.fabric8.commons.ClusterEntity; +import io.fabric8.kubernetes.api.model.GenericKubernetesResource; +import io.fabric8.kubernetes.api.model.GenericKubernetesResourceList; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; +import io.fabric8.kubernetes.clnt.v4_0.utils.Serialization; import org.arquillian.cube.kubernetes.api.Session; import org.arquillian.cube.kubernetes.impl.requirement.RequiresKubernetes; import org.arquillian.cube.requirement.ArquillianConditionalRunner; @@ -30,7 +33,6 @@ import org.junit.runner.RunWith; import java.io.IOException; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -39,7 +41,7 @@ @RunWith(ArquillianConditionalRunner.class) @RequiresKubernetes -public class RawClusterScopedCustomResourceIT { +public class GenericClusterScopedCustomResourceIT { @ArquillianResource public KubernetesClient client; @@ -59,41 +61,40 @@ public class RawClusterScopedCustomResourceIT { @BeforeClass public static void initCrd() { // Create a Custom Resource Definition Animals: - ClusterEntity.apply(RawCustomResourceIT.class.getResourceAsStream("/rawclusterscopedcustomresource-it.yml")); + ClusterEntity.apply(GenericClusterScopedCustomResourceIT.class.getResourceAsStream("/rawclusterscopedcustomresource-it.yml")); } @Test public void testCrud() throws IOException { // Create - Map satellite = createSatellite("moon", "earth", "1.7371e+3", "7.34767309e+22"); - Map createdSatellite = client.customResource(customResourceDefinitionContext).create(satellite); + GenericKubernetesResource satellite = createSatellite("moon", "earth", "1.7371e+3", "7.34767309e+22"); + GenericKubernetesResource createdSatellite = client.genericKubernetesResources(customResourceDefinitionContext).create(satellite); assertThat(createdSatellite) .isNotNull() .hasFieldOrPropertyWithValue("metadata.name", "moon"); // Get - Map satelliteFromServer = client.customResource(customResourceDefinitionContext).withName("moon").get(); + GenericKubernetesResource satelliteFromServer = client.genericKubernetesResources(customResourceDefinitionContext).withName("moon").get(); assertThat(satelliteFromServer).isNotNull() .hasFieldOrPropertyWithValue("metadata.name", "moon"); // List - Map satellites = client.customResource(customResourceDefinitionContext).list(); + GenericKubernetesResourceList satellites = client.genericKubernetesResources(customResourceDefinitionContext).list(); assertThat(satellites).isNotNull(); - assertThat(satellites.get("items")).isInstanceOfAny(ArrayList.class); - assertThat((ArrayList)satellites.get("items")).hasSize(1); + assertThat(satellites.getItems()).hasSize(1); // Delete - Boolean isDeleted = client.customResource(customResourceDefinitionContext).withName("moon").delete(); + Boolean isDeleted = client.genericKubernetesResources(customResourceDefinitionContext).withName("moon").delete(); assertThat(isDeleted).isTrue(); } @AfterClass public static void cleanup() { - ClusterEntity.remove(RawCustomResourceIT.class.getResourceAsStream("/rawclusterscopedcustomresource-it.yml")); + ClusterEntity.remove(GenericClusterScopedCustomResourceIT.class.getResourceAsStream("/rawclusterscopedcustomresource-it.yml")); } - private Map createSatellite(String name, String planet, String radius, String mass) { + private GenericKubernetesResource createSatellite(String name, String planet, String radius, String mass) { Map crAsMap = new HashMap<>(); crAsMap.put("apiVersion", "demos.fabric8.io/v1alpha1"); crAsMap.put("kind", "Satellite"); @@ -109,6 +110,6 @@ private Map createSatellite(String name, String planet, String r crAsMap.put("metadata", crMetadata); crAsMap.put("spec", crSpec); - return crAsMap; + return Serialization.jsonMapper().convertValue(crAsMap, GenericKubernetesResource.class); } } diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/GenericCustomResourceIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/GenericCustomResourceIT.java new file mode 100644 index 00000000000..457709c88d8 --- /dev/null +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/GenericCustomResourceIT.java @@ -0,0 +1,260 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.kubernetes; + +import io.fabric8.commons.AssumingK8sVersionAtLeast; +import io.fabric8.commons.ClusterEntity; +import io.fabric8.kubernetes.api.model.GenericKubernetesResource; +import io.fabric8.kubernetes.api.model.GenericKubernetesResourceList; +import io.fabric8.kubernetes.client.KubernetesClient; +import io.fabric8.kubernetes.client.Watcher; +import io.fabric8.kubernetes.client.WatcherException; +import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; +import io.fabric8.kubernetes.client.dsl.Resource; +import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; +import io.fabric8.kubernetes.client.utils.Serialization; +import org.arquillian.cube.kubernetes.api.Session; +import org.arquillian.cube.kubernetes.impl.requirement.RequiresKubernetes; +import org.arquillian.cube.requirement.ArquillianConditionalRunner; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +@RunWith(ArquillianConditionalRunner.class) +@RequiresKubernetes +public class GenericCustomResourceIT { + @ArquillianResource + public KubernetesClient client; + + @ArquillianResource + public Session session; + + @ClassRule + public static final AssumingK8sVersionAtLeast assumingK8sVersion = + new AssumingK8sVersionAtLeast("1", "16"); + + private String currentNamespace; + + private CustomResourceDefinitionContext customResourceDefinitionContext; + + private NonNamespaceOperation> resourceClient; + + @BeforeClass + public static void initCrd() { + // Create a Custom Resource Definition Animals: + ClusterEntity.apply(GenericCustomResourceIT.class.getResourceAsStream("/test-rawcustomresource-definition.yml")); + } + + @Before + public void initCustomResourceDefinitionContextAndNamespace() { + currentNamespace = session.getNamespace(); + + customResourceDefinitionContext = new CustomResourceDefinitionContext.Builder() + .withName("animals.jungle.example.com") + .withGroup("jungle.example.com") + .withVersion("v1") + .withPlural("animals") + .withScope("Namespaced") + .build(); + + this.resourceClient = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace(currentNamespace); + } + + @Test + public void testCrud() throws IOException { + // Test Create via file + GenericKubernetesResource object = resourceClient.load(getClass().getResourceAsStream("/test-rawcustomresource.yml")).create(); + assertThat(object.getMetadata().getName()).isEqualTo("otter"); + + // Test Create via raw json string + String rawJsonCustomResourceObj = "{\"apiVersion\":\"jungle.example.com/v1\"," + + "\"kind\":\"Animal\",\"metadata\": {\"name\": \"walrus\"}," + + "\"spec\": {\"image\": \"my-awesome-walrus-image\"}}"; + object = resourceClient.createOrReplace(Serialization.unmarshal(rawJsonCustomResourceObj, GenericKubernetesResource.class)); + assertAnimal(object, "walrus", "my-awesome-walrus-image"); + + // Test replace with object + ((HashMap)object.get("spec")).put("image", "new-walrus-image"); + object = resourceClient.createOrReplace(object); + assertAnimal(object, "walrus", "new-walrus-image"); + + // Test Get: + object = resourceClient.withName("otter").get(); + assertThat(object.getMetadata().getName()).isEqualTo("otter"); + + // Test List: + GenericKubernetesResourceList list = resourceClient.list(); + assertThat(list.getItems().size()).isGreaterThanOrEqualTo(2); + + // List with labels: + list = resourceClient.withLabel("foo", "bar").list(); + assertThat(list.getItems().size()).isGreaterThanOrEqualTo(1); + + // Test Update + GenericKubernetesResource updated = resourceClient.withName("walrus").get(); + ((HashMap)updated.get("spec")).put("image", "my-updated-awesome-walrus-image"); + object = resourceClient.withName("walrus").edit(r->updated); + assertAnimal(object, "walrus", "my-updated-awesome-walrus-image"); + + // Test Delete: + resourceClient.withName("otter").delete(); + resourceClient.delete(); + } + + @Test + public void testCreateReadDeleteUsingInputStream() throws IOException { + // Create + String name = "hippo"; + InputStream hippoInputStream = getClass().getResourceAsStream("/rawcustomresourceit-crud-inputstream.yml"); + GenericKubernetesResource hippoCr = resourceClient.load(hippoInputStream).create(); + assertAnimal(hippoCr, name, "Hippopotamidae"); + + // Read + hippoCr = resourceClient.withName(name).get(); + assertAnimal(hippoCr, name, "Hippopotamidae"); + + // Delete + boolean isDeleted = resourceClient.withName(name).delete(); + assertTrue(isDeleted); + } + + @Test + public void testWatch() throws IOException, InterruptedException { + // Given + String name = "chital"; + GenericKubernetesResource deer = createNewAnimal(name, "spotted-deer"); + CountDownLatch creationEventReceived = new CountDownLatch(1); + + // When + resourceClient.watch(new Watcher() { + @Override + public void eventReceived(Action action, GenericKubernetesResource resource) { + if (resource.getMetadata().getName().equals(name)) { + creationEventReceived.countDown(); + } + } + + @Override + public void onClose(WatcherException cause) { } + }); + resourceClient.create(deer); + + // Then + assertTrue(creationEventReceived.await(1, TimeUnit.SECONDS)); + } + + @Test + public void testUpdateStatus() throws IOException { + // Given + String name = "black-buck"; + GenericKubernetesResource deer = createNewAnimal(name, "indian-antelope"); + Map status = new HashMap<>(); + status.put("conservationStatus", "endangered"); + + // When + deer = resourceClient.create(deer); + await().atMost(10, TimeUnit.SECONDS) + .until(() -> resourceClient.withName(name) != null); + deer.getAdditionalProperties().put("status", status); + GenericKubernetesResource updatedDeer = resourceClient.withName(name).updateStatus(deer); + + // Then + assertNotNull(updatedDeer); + assertEquals("endangered", deer.get("status", "conservationStatus")); + } + + @Test + public void testDeleteNonExistingResource() throws IOException { + boolean isDeleted = resourceClient.withName("idontexist").delete(); + assertFalse(isDeleted); + } + + @Test + public void testDryRunCreate() throws IOException { + // Given + GenericKubernetesResource elephant = createNewAnimal("elephant", "indian-elephant"); + + // When + GenericKubernetesResource createdElephant = resourceClient.dryRun().create(elephant); + + // Then + assertNotNull(createdElephant); + assertNull(resourceClient.withName("elephant").get()); + } + + @Test + public void testDryRunDelete() throws IOException { + // Given + GenericKubernetesResource dhole = createNewAnimal("dhole", "indian-wild-dog"); + GenericKubernetesResource createdDhole = resourceClient.create(dhole); + + // When + boolean deletionStatus = resourceClient.withName("dhole").dryRun().delete(); + + // Then + assertTrue(deletionStatus); + GenericKubernetesResource dholeFromServer = resourceClient.withName("dhole").get(); + assertNotNull(dholeFromServer); + } + + @AfterClass + public static void cleanup() { + ClusterEntity.remove(GenericCustomResourceIT.class.getResourceAsStream("/test-rawcustomresource-definition.yml")); + } + + private void assertAnimal(GenericKubernetesResource animal, String name, String image) { + assertNotNull(animal); + assertThat(animal.getMetadata().getName()).isEqualTo(name); + assertThat((String)animal.get("spec", "image")).isEqualTo(image); + } + + private GenericKubernetesResource createNewAnimal(String name, String image) { + Map crAsMap = new HashMap<>(); + crAsMap.put("apiVersion", "jungle.example.com/v1"); + crAsMap.put("kind", "Animal"); + + Map crMetadata = new HashMap<>(); + crMetadata.put("name", name); + crMetadata.put("labels", Collections.singletonMap("foo", "bar")); + Map crSpec = new HashMap<>(); + crSpec.put("image", image); + + crAsMap.put("metadata", crMetadata); + crAsMap.put("spec", crSpec); + + return Serialization.jsonMapper().convertValue(crAsMap, GenericKubernetesResource.class); + } +} diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RawCustomResourceIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RawCustomResourceIT.java deleted file mode 100644 index 0103fff3e2f..00000000000 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RawCustomResourceIT.java +++ /dev/null @@ -1,305 +0,0 @@ -/** - * Copyright (C) 2015 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.fabric8.kubernetes; - -import com.fasterxml.jackson.databind.ObjectMapper; -import io.fabric8.commons.AssumingK8sVersionAtLeast; -import io.fabric8.commons.ClusterEntity; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.Watcher; -import io.fabric8.kubernetes.client.WatcherException; -import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; -import io.fabric8.kubernetes.client.dsl.internal.RawCustomResourceOperationsImpl; -import io.fabric8.kubernetes.client.utils.Serialization; -import org.arquillian.cube.kubernetes.api.Session; -import org.arquillian.cube.kubernetes.impl.requirement.RequiresKubernetes; -import org.arquillian.cube.requirement.ArquillianConditionalRunner; -import org.jboss.arquillian.test.api.ArquillianResource; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.awaitility.Awaitility.await; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -@RunWith(ArquillianConditionalRunner.class) -@RequiresKubernetes -public class RawCustomResourceIT { - @ArquillianResource - public KubernetesClient client; - - @ArquillianResource - public Session session; - - @ClassRule - public static final AssumingK8sVersionAtLeast assumingK8sVersion = - new AssumingK8sVersionAtLeast("1", "16"); - - private String currentNamespace; - - private CustomResourceDefinitionContext customResourceDefinitionContext; - - @BeforeClass - public static void initCrd() { - // Create a Custom Resource Definition Animals: - ClusterEntity.apply(RawCustomResourceIT.class.getResourceAsStream("/test-rawcustomresource-definition.yml")); - } - - @Before - public void initCustomResourceDefinitionContextAndNamespace() { - currentNamespace = session.getNamespace(); - - customResourceDefinitionContext = new CustomResourceDefinitionContext.Builder() - .withName("animals.jungle.example.com") - .withGroup("jungle.example.com") - .withVersion("v1") - .withPlural("animals") - .withScope("Namespaced") - .build(); - } - - @Test - public void testCrud() throws IOException { - // Test Create via file - Map object = client.customResource(customResourceDefinitionContext).create(currentNamespace, getClass().getResourceAsStream("/test-rawcustomresource.yml")); - assertThat(((HashMap)object.get("metadata")).get("name")).isEqualTo("otter"); - - // Test Create via raw json string - String rawJsonCustomResourceObj = "{\"apiVersion\":\"jungle.example.com/v1\"," + - "\"kind\":\"Animal\",\"metadata\": {\"name\": \"walrus\"}," + - "\"spec\": {\"image\": \"my-awesome-walrus-image\"}}"; - object = client.customResource(customResourceDefinitionContext).createOrReplace(currentNamespace, rawJsonCustomResourceObj); - assertAnimal(object, "walrus", "my-awesome-walrus-image"); - - // Test replace with object - ((HashMap)object.get("spec")).put("image", "new-walrus-image"); - object = client.customResource(customResourceDefinitionContext).createOrReplace(currentNamespace, object); - assertAnimal(object, "walrus", "new-walrus-image"); - - // Test Get: - object = client.customResource(customResourceDefinitionContext).get(currentNamespace, "otter"); - assertThat(((HashMap)object.get("metadata")).get("name")).isEqualTo("otter"); - - // Test List: - Map list = client.customResource(customResourceDefinitionContext).list(currentNamespace); - assertThat(((ArrayList)list.get("items")).size()).isGreaterThanOrEqualTo(2); - - // List with labels: - list = client.customResource(customResourceDefinitionContext).list(currentNamespace, Collections.singletonMap("foo", "bar")); - assertThat(((ArrayList)list.get("items")).size()).isGreaterThanOrEqualTo(1); - - // Test Update - object = client.customResource(customResourceDefinitionContext).get(currentNamespace, "walrus"); - ((HashMap)object.get("spec")).put("image", "my-updated-awesome-walrus-image"); - object = client.customResource(customResourceDefinitionContext).edit(currentNamespace, "walrus", new ObjectMapper().writeValueAsString(object)); - assertAnimal(object, "walrus", "my-updated-awesome-walrus-image"); - - // Test Delete: - client.customResource(customResourceDefinitionContext).delete(currentNamespace, "otter"); - client.customResource(customResourceDefinitionContext).delete(currentNamespace); - } - - @Test - public void testCrudUsingMap() throws IOException { - // Create - String name = "bison"; - Map bison = createNewAnimal(name, "wisent"); - bison = client.customResource(customResourceDefinitionContext).create(currentNamespace, bison); - assertAnimal(bison, "bison", "wisent"); - - // Read - bison = client.customResource(customResourceDefinitionContext).get(currentNamespace, name); - assertAnimal(bison, "bison", "wisent"); - - // Update - ((Map)bison.get("spec")).put("image", "bison-bonasus"); - bison = client.customResource(customResourceDefinitionContext).edit(currentNamespace, name, bison); - assertAnimal(bison, "bison", "bison-bonasus"); - - // Delete - boolean isDeleted = client.customResource(customResourceDefinitionContext).delete(currentNamespace, name); - assertTrue(isDeleted); - } - - @Test - public void testCreateReadDeleteUsingInputStream() throws IOException { - // Create - String name = "hippo"; - InputStream hippoInputStream = getClass().getResourceAsStream("/rawcustomresourceit-crud-inputstream.yml"); - Map hippoCr = client.customResource(customResourceDefinitionContext).create(currentNamespace, hippoInputStream); - assertAnimal(hippoCr, name, "Hippopotamidae"); - - // Read - hippoCr = client.customResource(customResourceDefinitionContext).get(currentNamespace, name); - assertAnimal(hippoCr, name, "Hippopotamidae"); - - // Delete - boolean isDeleted = client.customResource(customResourceDefinitionContext).delete(currentNamespace, name); - assertTrue(isDeleted); - } - - @Test - public void testCrudUsingString() throws IOException { - // Create - String name = "rhino"; - String rhino = "{\"apiVersion\": \"jungle.example.com/v1\"," + - " \"kind\": \"Animal\"," + - " \"metadata\": {\"name\": \"rhino\"}," + - " \"spec\": {\"image\": \"Rhinocerotidae\"}}"; - Map rhinoCr = client.customResource(customResourceDefinitionContext).create(currentNamespace, rhino); - assertAnimal(rhinoCr, name, "Rhinocerotidae"); - - // Read - rhinoCr = client.customResource(customResourceDefinitionContext).get(currentNamespace, name); - assertAnimal(rhinoCr, name, "Rhinocerotidae"); - - // Update - ((Map)rhinoCr.get("spec")).put("image", "rhinoceros"); - String rhinoCrAsStr = Serialization.jsonMapper().writeValueAsString(rhinoCr); - rhinoCr = client.customResource(customResourceDefinitionContext).edit(currentNamespace, name, rhinoCrAsStr); - assertAnimal(rhinoCr, name, "rhinoceros"); - - // Delete - boolean isDeleted = client.customResource(customResourceDefinitionContext).delete(currentNamespace, name); - assertTrue(isDeleted); - } - - @Test - public void testWatch() throws IOException, InterruptedException { - // Given - String name = "chital"; - Map deer = createNewAnimal(name, "spotted-deer"); - CountDownLatch creationEventReceived = new CountDownLatch(1); - - // When - client.customResource(customResourceDefinitionContext).watch(currentNamespace, new Watcher() { - @Override - public void eventReceived(Action action, String resource) { - if (resource.contains(name)) { - creationEventReceived.countDown(); - } - } - - @Override - public void onClose(WatcherException cause) { } - }); - client.customResource(customResourceDefinitionContext).create(currentNamespace, deer); - - // Then - assertTrue(creationEventReceived.await(1, TimeUnit.SECONDS)); - } - - @Test - public void testUpdateStatus() throws IOException { - // Given - String name = "black-buck"; - Map deer = createNewAnimal(name, "indian-antelope"); - Map status = new HashMap<>(); - status.put("conservationStatus", "endangered"); - - // When - deer = client.customResource(customResourceDefinitionContext).create(currentNamespace, deer); - await().atMost(10, TimeUnit.SECONDS) - .until(() -> client.customResource(customResourceDefinitionContext).get(currentNamespace, name) != null); - deer.put("status", status); - Map updatedDeer = client.customResource(customResourceDefinitionContext).updateStatus(currentNamespace, name, deer); - - // Then - assertNotNull(updatedDeer); - assertEquals("endangered", ((Map)deer.get("status")).get("conservationStatus").toString()); - } - - @Test - public void testDeleteNonExistingResource() throws IOException { - boolean isDeleted = client.customResource(customResourceDefinitionContext).delete(currentNamespace, "idontexist"); - assertFalse(isDeleted); - } - - @Test - public void testDryRunCreate() throws IOException { - // Given - Map elephant = createNewAnimal("elephant", "indian-elephant"); - RawCustomResourceOperationsImpl rawCustomResourceOperations = client.customResource(customResourceDefinitionContext); - - // When - Map createdElephant = rawCustomResourceOperations.dryRun().create(currentNamespace, elephant); - - // Then - assertNotNull(createdElephant); - assertNull(rawCustomResourceOperations.get(currentNamespace, "elephant")); - } - - @Test - public void testDryRunDelete() throws IOException { - // Given - Map dhole = createNewAnimal("dhole", "indian-wild-dog"); - Map createdDhole = client.customResource(customResourceDefinitionContext).create(currentNamespace, dhole); - - // When - boolean deletionStatus = client.customResource(customResourceDefinitionContext).dryRun().delete(currentNamespace, "dhole"); - - // Then - assertTrue(deletionStatus); - Map dholeFromServer = client.customResource(customResourceDefinitionContext).get(currentNamespace, "dhole"); - assertNotNull(dholeFromServer); - } - - @AfterClass - public static void cleanup() { - ClusterEntity.remove(RawCustomResourceIT.class.getResourceAsStream("/test-rawcustomresource-definition.yml")); - } - - private void assertAnimal(Map animal, String name, String image) { - assertNotNull(animal); - assertFalse(animal.isEmpty()); - assertThat(((HashMap)animal.get("metadata")).get("name")).isEqualTo(name); - assertThat(((HashMap)animal.get("spec")).get("image")).isEqualTo(image); - } - - private Map createNewAnimal(String name, String image) { - Map crAsMap = new HashMap<>(); - crAsMap.put("apiVersion", "jungle.example.com/v1"); - crAsMap.put("kind", "Animal"); - - Map crMetadata = new HashMap<>(); - crMetadata.put("name", name); - crMetadata.put("labels", Collections.singletonMap("foo", "bar")); - Map crSpec = new HashMap<>(); - crSpec.put("image", image); - - crAsMap.put("metadata", crMetadata); - crAsMap.put("spec", crSpec); - - return crAsMap; - } -} diff --git a/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractorTest.java b/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractorTest.java index 0fe186eb441..940fcd11d9e 100644 --- a/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractorTest.java +++ b/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractorTest.java @@ -27,7 +27,6 @@ import java.util.Map; import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; -import io.fabric8.kubernetes.client.utils.Serialization; import org.junit.jupiter.api.Test; import io.fabric8.kubernetes.api.model.GenericKubernetesResource; import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; @@ -566,12 +565,12 @@ private void helpTestMultipleCrdVersions(boolean registered) throws IOException gkr.setKind("CustomDatabase"); gkr.setApiVersion("demo.fabric8.io/v1"); - kubernetesClient.customResource(crdContextV1).create(Serialization.asJson(gkr)); + kubernetesClient.genericKubernetesResources(crdContextV1).create(gkr); gkr.setApiVersion("demo.fabric8.io/v1alpha1"); - kubernetesClient.customResource(crdContextV1Alpha1).create(Serialization.asJson(gkr)); + kubernetesClient.genericKubernetesResources(crdContextV1Alpha1).create(gkr); - assertEquals(1, (((List)kubernetesClient.customResource(crdContextV1).list().get("items")).size())); - assertEquals(1, (((List)kubernetesClient.customResource(crdContextV1Alpha1).list().get("items")).size())); + assertEquals(1, kubernetesClient.genericKubernetesResources(crdContextV1).list().getItems().size()); + assertEquals(1, kubernetesClient.genericKubernetesResources(crdContextV1Alpha1).list().getItems().size()); } } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudTest.java index 7fdccb7d28d..841d92f89ac 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudTest.java @@ -22,8 +22,6 @@ import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; import io.fabric8.kubernetes.client.dsl.Resource; -import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; -import io.fabric8.kubernetes.client.dsl.internal.RawCustomResourceOperationsImpl; import io.fabric8.kubernetes.client.mock.crd.CronTab; import io.fabric8.kubernetes.client.mock.crd.CronTabSpec; import io.fabric8.kubernetes.client.mock.crd.CronTabStatus; @@ -32,18 +30,14 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import java.io.IOException; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; @EnableKubernetesMockClient(crud = true) class CustomResourceCrudTest { @@ -96,31 +90,6 @@ void testCrud() { assertEquals(2, cronTabList.getItems().size()); } - @Test - void testCreateOrReplaceRaw() throws IOException { - RawCustomResourceOperationsImpl raw = client.customResource(CustomResourceDefinitionContext.fromCrd(cronTabCrd)); - - Map object = new HashMap<>(); - Map metadata = new HashMap<>(); - metadata.put("name", "foo"); - - object.put("apiVersion", "stable.example.com/v1"); - object.put("kind", "CronTab"); - object.put("metadata", metadata); - object.put("spec", new HashMap<>()); - - Map created = raw.createOrReplace(object); - - assertEquals(Collections.emptyMap(), created.get("spec")); - assertTrue(((Map)created.get("metadata")).entrySet().containsAll(metadata.entrySet())); - - object.put("spec", Collections.singletonMap("image", "value")); - - Map updated = raw.createOrReplace(object); - assertNotEquals(created, updated); - assertEquals(Collections.singletonMap("image", "value"), updated.get("spec")); - } - @Test void testCrudWithDashSymbolInCRDName() { CronTab cronTab1 = createCronTab("my-new-cron-object", "* * * * */5", 3, "my-awesome-cron-image"); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceTest.java index c33a1e60550..14fe843effd 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceTest.java @@ -17,7 +17,9 @@ package io.fabric8.kubernetes.client.mock; import io.fabric8.kubernetes.api.model.DeleteOptions; -import io.fabric8.kubernetes.api.model.ListOptions; +import io.fabric8.kubernetes.api.model.DeletionPropagation; +import io.fabric8.kubernetes.api.model.GenericKubernetesResource; +import io.fabric8.kubernetes.api.model.GenericKubernetesResourceList; import io.fabric8.kubernetes.api.model.ListOptionsBuilder; import io.fabric8.kubernetes.api.model.Status; import io.fabric8.kubernetes.api.model.StatusBuilder; @@ -39,7 +41,6 @@ import java.io.IOException; import java.net.HttpURLConnection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -69,7 +70,7 @@ class CustomResourceTest { @Test void testLoad() throws IOException { - Map customResource = client.customResource(customResourceDefinitionContext).load(getClass().getResourceAsStream("/test-hello-cr.yml")); + GenericKubernetesResource customResource = client.genericKubernetesResources(customResourceDefinitionContext).load(getClass().getResourceAsStream("/test-hello-cr.yml")).get(); assertThat(customResource) .isNotNull() .hasFieldOrPropertyWithValue("metadata.name", "example-hello"); @@ -84,13 +85,13 @@ void testCreate() throws IOException { final String newCrdObject = "{\"apiVersion\": \"test.fabric8.io/v1alpha1\",\"kind\": \"Hello\"," + "\"metadata\": {\"name\": \"example-hello\"},\"spec\": {\"size\": 3}}"; - Map resource = client.customResource(customResourceDefinitionContext).create("ns1", newCrdObject); + GenericKubernetesResource resource = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1").create(Serialization.unmarshal(newCrdObject, GenericKubernetesResource.class)); assertThat(resource) .isNotNull() .hasFieldOrPropertyWithValue("metadata.name", "example-hello") .hasFieldOrPropertyWithValue("metadata.resourceVersion", "1") - .hasFieldOrPropertyWithValue("spec.creationTimestamp", "19851026T090000Z"); + .hasFieldOrPropertyWithValue("additionalProperties.spec.creationTimestamp", "19851026T090000Z"); } @Test @@ -104,11 +105,11 @@ void testCreateOrReplace() throws IOException { server.expect().put().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, jsonObject).once(); server.expect().get().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, jsonObject).once(); - Map resource = client.customResource(customResourceDefinitionContext).createOrReplace("ns1", jsonObject); - assertEquals("example-hello", ((Map)resource.get("metadata")).get("name").toString()); + GenericKubernetesResource resource = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1").createOrReplace(Serialization.unmarshal(jsonObject, GenericKubernetesResource.class)); + assertEquals("example-hello", resource.getMetadata().getName()); - resource = client.customResource(customResourceDefinitionContext).createOrReplace("ns1", jsonObject); - assertEquals("example-hello", ((Map)resource.get("metadata")).get("name").toString()); + resource = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1").createOrReplace(Serialization.unmarshal(jsonObject, GenericKubernetesResource.class)); + assertEquals("example-hello", resource.getMetadata().getName()); } @Test @@ -118,8 +119,8 @@ void testList() { server.expect().get().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos").andReturn(HttpURLConnection.HTTP_CREATED, jsonObject).once(); - Map list = client.customResource(customResourceDefinitionContext).list("ns1"); - List> items = (List>)list.get("items"); + GenericKubernetesResourceList list = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1").list(); + List items = list.getItems(); assertNotNull(items); assertEquals(1, items.size()); } @@ -135,8 +136,8 @@ void testListWithLabels() { Map labels = new HashMap<>(); labels.put("org", "fabric8"); labels.put("scope", "test"); - Map list = client.customResource(customResourceDefinitionContext).list("ns1", labels); - List> items = (List>)list.get("items"); + GenericKubernetesResourceList list = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1").withLabels(labels).list(); + List items = list.getItems(); assertNotNull(items); assertEquals(1, items.size()); } @@ -169,9 +170,9 @@ void testGet() { "\"metadata\": {\"name\": \"example-hello\"},\"spec\": {\"size\": 3}}"; server.expect().get().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, jsonObject).once(); - Map customResource = client.customResource(customResourceDefinitionContext).get("ns1", "example-hello"); + GenericKubernetesResource customResource = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1").withName("example-hello").get(); assertNotNull(customResource); - assertEquals("example-hello", ((Map)customResource.get("metadata")).get("name").toString()); + assertEquals("example-hello", customResource.getMetadata().getName()); } @Test @@ -184,7 +185,7 @@ void testEdit() throws IOException { server.expect().get().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, jsonObject).once(); server.expect().get().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, jsonObjectNew).once(); - Map customResource = client.customResource(customResourceDefinitionContext).edit("ns1", "example-hello", jsonObjectNew); + GenericKubernetesResource customResource = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1").withName("example-hello").edit(g->Serialization.unmarshal(jsonObjectNew, GenericKubernetesResource.class)); assertNotNull(customResource); assertEquals(4, ((Map)customResource.get("spec")).get("size")); } @@ -195,7 +196,7 @@ void testDelete() throws IOException { server.expect().delete().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, "{\"metadata\":{},\"apiVersion\":\"v1\",\"kind\":\"Status\",\"details\":{\"name\":\"prometheus-example-rules\",\"group\":\"monitoring.coreos.com\",\"kind\":\"prometheusrules\",\"uid\":\"b3d085bd-6a5c-11e9-8787-525400b18c1d\"},\"status\":\"Success\"}").once(); // When - boolean result = client.customResource(customResourceDefinitionContext).delete("ns1", "example-hello"); + boolean result = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1").withName("example-hello").delete(); // Then assertTrue(result); @@ -214,7 +215,7 @@ void testDeleteNonExistentItem() throws IOException { server.expect().delete().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/idontexist").andReturn(HttpURLConnection.HTTP_NOT_FOUND, Serialization.jsonMapper().writeValueAsString(notFoundStatus)).once(); // When - boolean isDeleted = client.customResource(customResourceDefinitionContext).delete("ns1", "idontexist"); + boolean isDeleted = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1").withName("idontexist").delete(); // Then assertFalse(isDeleted); @@ -226,8 +227,8 @@ void testCascadingDeletion() throws IOException, InterruptedException { server.expect().delete().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, "{\"metadata\":{},\"apiVersion\":\"v1\",\"kind\":\"Status\",\"details\":{\"name\":\"prometheus-example-rules\",\"group\":\"monitoring.coreos.com\",\"kind\":\"prometheusrules\",\"uid\":\"b3d085bd-6a5c-11e9-8787-525400b18c1d\"},\"status\":\"Success\"}").once(); // When - boolean result = client.customResource(customResourceDefinitionContext) - .delete("ns1", "example-hello", true); + boolean result = client.genericKubernetesResources(customResourceDefinitionContext) + .inNamespace("ns1").withName("example-hello").cascading(true).delete(); // Then assertTrue(result); @@ -244,8 +245,8 @@ void testPropagationPolicy() throws IOException, InterruptedException { server.expect().delete().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, "{\"metadata\":{},\"apiVersion\":\"v1\",\"kind\":\"Status\",\"details\":{\"name\":\"prometheus-example-rules\",\"group\":\"monitoring.coreos.com\",\"kind\":\"prometheusrules\",\"uid\":\"b3d085bd-6a5c-11e9-8787-525400b18c1d\"},\"status\":\"Success\"}").once(); // When - boolean result = client.customResource(customResourceDefinitionContext) - .delete("ns1", "example-hello", "Orphan"); + boolean result = client.genericKubernetesResources(customResourceDefinitionContext) + .inNamespace("ns1").withName("example-hello").withPropagationPolicy(DeletionPropagation.ORPHAN).delete(); // Then assertTrue(result); @@ -265,15 +266,19 @@ void testDeleteOptions() throws InterruptedException, IOException { deleteOptions.setPropagationPolicy("Orphan"); // When - boolean result = client.customResource(customResourceDefinitionContext) - .delete("ns1", "example-hello", deleteOptions); + boolean result = client.genericKubernetesResources(customResourceDefinitionContext) + .inNamespace("ns1") + .withName("example-hello") + .withPropagationPolicy(DeletionPropagation.ORPHAN) + .withGracePeriod(0L) + .delete(); // Then assertTrue(result); RecordedRequest request = server.getLastRequest(); assertEquals("DELETE", request.getMethod()); assertEquals("{\"apiVersion\":\"v1\",\"kind\":\"DeleteOptions\",\"gracePeriodSeconds\":0,\"propagationPolicy\":\"Orphan\"}", - request.getBody().readUtf8());; + request.getBody().readUtf8()); } @Test @@ -282,20 +287,20 @@ void testDeleteWithEmptyResponse() throws InterruptedException, IOException { server.expect().delete().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, "").once(); // When - boolean result = client.customResource(customResourceDefinitionContext) - .delete("ns1", "example-hello", "Orphan"); + boolean result = client.genericKubernetesResources(customResourceDefinitionContext) + .inNamespace("ns1").withName("example-hello").withPropagationPolicy(DeletionPropagation.ORPHAN).delete(); // Then assertTrue(result); RecordedRequest request = server.getLastRequest(); assertEquals("DELETE", request.getMethod()); assertEquals("{\"apiVersion\":\"v1\",\"kind\":\"DeleteOptions\",\"propagationPolicy\":\"Orphan\"}", - request.getBody().readUtf8());; + request.getBody().readUtf8()); } @Test void testDeleteWithNonExistentResource() throws IOException { - assertThat(client.customResource(customResourceDefinitionContext).delete("ns2", "example-hello")) + assertThat(client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns2").withName("example-hello").delete()) .isFalse(); } @@ -304,7 +309,7 @@ void testStatusUpdate() throws IOException { String objectAsJsonString = "{\"metadata\":{},\"apiVersion\":\"v1\",\"kind\":\"Status\",\"details\":{\"name\":\"prometheus-example-rules\",\"group\":\"monitoring.coreos.com\",\"kind\":\"prometheusrules\",\"uid\":\"b3d085bd-6a5c-11e9-8787-525400b18c1d\"},\"status\":\"Success\"}"; server.expect().put().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello/status").andReturn(HttpURLConnection.HTTP_OK, objectAsJsonString).once(); - Map result = client.customResource(customResourceDefinitionContext).updateStatus("ns1", "example-hello", objectAsJsonString); + GenericKubernetesResource result = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1").withName("example-hello").updateStatus(Serialization.unmarshal(objectAsJsonString, GenericKubernetesResource.class)); assertEquals("Success", result.get("status")); } @@ -322,11 +327,10 @@ void testWatchAllResource() throws IOException, InterruptedException { CountDownLatch anyEventReceived = new CountDownLatch(1); // When - Watch watch = client.customResource(customResourceDefinitionContext) - .watch("ns1", null, null, (ListOptions)null, - new Watcher() { + Watch watch = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1") + .watch(new Watcher() { @Override - public void eventReceived(Action action, String resource) { anyEventReceived.countDown(); } + public void eventReceived(Action action, GenericKubernetesResource resource) { anyEventReceived.countDown(); } @Override public void onClose(WatcherException cause) { } }); @@ -350,12 +354,10 @@ void testWatchAllResourceInNamespace() throws IOException, InterruptedException CountDownLatch anyEventReceived = new CountDownLatch(1); // When - Watch watch = client.customResource(customResourceDefinitionContext) - .watch( - "ns1", - new Watcher() { + Watch watch = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1") + .watch(new Watcher() { @Override - public void eventReceived(Action action, String resource) { anyEventReceived.countDown(); } + public void eventReceived(Action action, GenericKubernetesResource resource) { anyEventReceived.countDown(); } @Override public void onClose(WatcherException cause) { } }); @@ -379,11 +381,10 @@ void testWatchSingleResource() throws IOException, InterruptedException { CountDownLatch anyEventReceieved = new CountDownLatch(1); // When - Watch watch = client.customResource(customResourceDefinitionContext) - .watch("ns1", "example-hello", null, (ListOptions)null, - new Watcher() { + Watch watch = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1").withName("example-hello") + .watch(new Watcher() { @Override - public void eventReceived(Action action, String resource) { anyEventReceieved.countDown(); } + public void eventReceived(Action action, GenericKubernetesResource resource) { anyEventReceieved.countDown(); } @Override public void onClose(WatcherException cause) { } }); @@ -407,11 +408,10 @@ void testWatchWithLabels() throws IOException, InterruptedException { CountDownLatch anyEventReceived = new CountDownLatch(1); // When - Watch watch = client.customResource(customResourceDefinitionContext) - .watch("ns1", null, Collections.singletonMap("foo", "bar"), (ListOptions)null, - new Watcher() { + Watch watch = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1") + .withLabel("foo", "bar").watch(new Watcher() { @Override - public void eventReceived(Action action, String resource) { anyEventReceived.countDown(); } + public void eventReceived(Action action, GenericKubernetesResource resource) { anyEventReceived.countDown(); } @Override public void onClose(WatcherException cause) { } }); @@ -437,11 +437,10 @@ void testWatchSomeResourceVersion() throws IOException, InterruptedException { CountDownLatch anyEventReceived = new CountDownLatch(1); // When - Watch watch = client.customResource(customResourceDefinitionContext) - .watch("ns1", null, null, watchResourceVersion, - new Watcher() { + Watch watch = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1").withResourceVersion(watchResourceVersion) + .watch(new Watcher() { @Override - public void eventReceived(Action action, String resource) { anyEventReceived.countDown(); } + public void eventReceived(Action action, GenericKubernetesResource resource) { anyEventReceived.countDown(); } @Override public void onClose(WatcherException cause) { } }); @@ -451,38 +450,6 @@ public void onClose(WatcherException cause) { } watch.close(); } - @Test - @DisplayName("Should be able to test watch with namespace and some specific resourceVersion") - void testWatchNamespaceAndSomeResourceVersion() throws IOException, InterruptedException { - // Given - String watchResourceVersion = "1001"; - server.expect().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos?resourceVersion=" + watchResourceVersion + "&allowWatchBookmarks=true&watch=true") - .andUpgradeToWebSocket() - .open() - .waitFor(WATCH_EVENT_PERIOD) - .andEmit("{\"type\":\"ADDED\", \"object\":{\"kind\": \"Hello\", \"metadata\": {\"resourceVersion\": 1001}}}") - .done().always(); - - - CountDownLatch anyEventReceived = new CountDownLatch(1); - - // When - Watch watch = client.customResource(customResourceDefinitionContext) - .watch( - "ns1", - watchResourceVersion, - new Watcher() { - @Override - public void eventReceived(Action action, String resource) { anyEventReceived.countDown(); } - @Override - public void onClose(WatcherException cause) { } - }); - - // Then - assertTrue(anyEventReceived.await(1, TimeUnit.SECONDS)); - watch.close(); - } - @Test @DisplayName("Should be able to test watch with ListOptions provided") void testWatchWithListOptions() throws IOException, InterruptedException { @@ -497,15 +464,15 @@ void testWatchWithListOptions() throws IOException, InterruptedException { CountDownLatch anyEventReceived = new CountDownLatch(1); // When - Watch watch = client.customResource(customResourceDefinitionContext) - .watch("ns1", null, null, new ListOptionsBuilder() + Watch watch = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1") + .watch(new ListOptionsBuilder() .withTimeoutSeconds(30L) .withResourceVersion("1003") .withAllowWatchBookmarks(true) .build(), - new Watcher() { + new Watcher() { @Override - public void eventReceived(Action action, String resource) { anyEventReceived.countDown(); } + public void eventReceived(Action action, GenericKubernetesResource resource) { anyEventReceived.countDown(); } @Override public void onClose(WatcherException cause) { } }); @@ -529,17 +496,15 @@ void testWatchWithNamespaceAndListOptions() throws IOException, InterruptedExcep CountDownLatch anyEventReceived = new CountDownLatch(1); // When - Watch watch = client.customResource(customResourceDefinitionContext) - .watch( - "ns1", - new ListOptionsBuilder() + Watch watch = client.genericKubernetesResources(customResourceDefinitionContext).inNamespace("ns1") + .watch(new ListOptionsBuilder() .withTimeoutSeconds(30L) .withResourceVersion("1003") .withAllowWatchBookmarks(true) .build(), - new Watcher() { + new Watcher() { @Override - public void eventReceived(Action action, String resource) { anyEventReceived.countDown(); } + public void eventReceived(Action action, GenericKubernetesResource resource) { anyEventReceived.countDown(); } @Override public void onClose(WatcherException cause) { } }); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DefaultSharedIndexInformerTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DefaultSharedIndexInformerTest.java index ba5eea720d2..f5c2b3c57f7 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DefaultSharedIndexInformerTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DefaultSharedIndexInformerTest.java @@ -26,8 +26,6 @@ import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; import io.fabric8.kubernetes.api.model.PodListBuilder; -import io.fabric8.kubernetes.api.model.ServiceAccount; -import io.fabric8.kubernetes.api.model.ServiceAccountBuilder; import io.fabric8.kubernetes.api.model.Status; import io.fabric8.kubernetes.api.model.StatusBuilder; import io.fabric8.kubernetes.api.model.WatchEvent; @@ -39,7 +37,7 @@ import io.fabric8.kubernetes.client.CustomResourceList; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; -import io.fabric8.kubernetes.client.dsl.base.OperationContext; +import io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext; import io.fabric8.kubernetes.client.informers.ResourceEventHandler; import io.fabric8.kubernetes.client.informers.SharedIndexInformer; import io.fabric8.kubernetes.client.informers.SharedInformerFactory; @@ -463,46 +461,6 @@ void testWithClusterBindingInformer() throws InterruptedException { assertEquals(0, foundExistingClusterRoleBinding.getCount()); } - @Test - void testServiceAccountInformerWatchAllNamespacesWithLabels() throws InterruptedException { - // Given - setupMockServerExpectations(ServiceAccount.class, null, this::getList, r -> new WatchEvent(new ServiceAccountBuilder() - .withNewMetadata().withName("sa1") - .withResourceVersion(r).endMetadata().build(), "ADDED"), Utils.toUrlEncoded("foo=bar"), null); - CountDownLatch serviceAccountEventReceived = new CountDownLatch(1); - - // When - SharedIndexInformer serviceAccountInformer = factory.sharedIndexInformerFor(ServiceAccount.class, - new OperationContext().withLabels(Collections.singletonMap("foo", "bar")), - 60 * WATCH_EVENT_EMIT_TIME); - serviceAccountInformer.addEventHandler(new TestResourceHandler<>(serviceAccountEventReceived, "sa1")); - factory.startAllRegisteredInformers(); - serviceAccountEventReceived.await(LATCH_AWAIT_PERIOD_IN_SECONDS, TimeUnit.SECONDS); - - // Then - assertEquals(0, serviceAccountEventReceived.getCount()); - } - - @Test - void testServiceAccountInformerWatchSingleNamespacesWithLabels() throws InterruptedException { - // Given - setupMockServerExpectations(ServiceAccount.class, "ns1", this::getList, r -> new WatchEvent(new ServiceAccountBuilder() - .withNewMetadata().withName("sa1") - .withResourceVersion(r).endMetadata().build(), "ADDED"), Utils.toUrlEncoded("foo=bar"), null); - CountDownLatch serviceAccountEventReceived = new CountDownLatch(1); - - // When - SharedIndexInformer serviceAccountInformer = factory.inNamespace("ns1").sharedIndexInformerFor(ServiceAccount.class, - new OperationContext().withLabels(Collections.singletonMap("foo", "bar")), - 60 * WATCH_EVENT_EMIT_TIME); - serviceAccountInformer.addEventHandler(new TestResourceHandler<>(serviceAccountEventReceived, "sa1")); - factory.startAllRegisteredInformers(); - serviceAccountEventReceived.await(LATCH_AWAIT_PERIOD_IN_SECONDS, TimeUnit.SECONDS); - - // Then - assertEquals(0, serviceAccountEventReceived.getCount()); - } - @Test @DisplayName("Should create informer for Deployment resource") void testWithDeploymentInformer() throws InterruptedException { @@ -541,41 +499,6 @@ void testWithOperationContextArgument() throws InterruptedException { assertEquals(0, foundExistingPod.getCount()); } - @Test - @DisplayName("PodSet Informer should filter watch with labels provided") - void testPodSetInformerShouldWatchWithLabelSelectors() throws InterruptedException { - // Given - setupMockServerExpectations(PodSet.class, "ns1", this::getList, r -> new WatchEvent(getPodSet("podset1", r), "ADDED"), Utils.toUrlEncoded("foo=bar"), null); - - // When - SharedIndexInformer podSetSharedIndexInformer = factory.inNamespace("ns1").sharedIndexInformerForCustomResource(PodSet.class, - new OperationContext().withLabels(Collections.singletonMap("foo", "bar")), 100L); - CountDownLatch foundExistingPod = new CountDownLatch(1); - podSetSharedIndexInformer.addEventHandler(new TestResourceHandler<>(foundExistingPod, "podset1")); - factory.startAllRegisteredInformers(); - foundExistingPod.await(LATCH_AWAIT_PERIOD_IN_SECONDS, TimeUnit.SECONDS); - - // Then - assertEquals(0, foundExistingPod.getCount()); - } - - @Test - @DisplayName("PodSet Informer with List type provided should filter watch with labels provided") - void testPodSetInformerWithListTypeShouldWatchWithLabelSelectors() throws InterruptedException { - // Given - setupMockServerExpectations(PodSet.class, "ns1", this::getList, r -> new WatchEvent(getPodSet("podset1", r), "ADDED"), Utils.toUrlEncoded("foo=bar"), null); - - // When - SharedIndexInformer podSetSharedIndexInformer = factory.inNamespace("ns1").sharedIndexInformerForCustomResource(PodSet.class, new OperationContext().withLabels(Collections.singletonMap("foo", "bar")), 100L); - CountDownLatch foundExistingPod = new CountDownLatch(1); - podSetSharedIndexInformer.addEventHandler(new TestResourceHandler<>(foundExistingPod, "podset1")); - factory.startAllRegisteredInformers(); - foundExistingPod.await(LATCH_AWAIT_PERIOD_IN_SECONDS, TimeUnit.SECONDS); - - // Then - assertEquals(0, foundExistingPod.getCount()); - } - @Test @DisplayName("PodSet Informer should watch in all namespaces") void testPodSetCustomResourceInformerShouldWatchInAllNamespaces() throws InterruptedException { @@ -810,8 +733,14 @@ void testCustomResourceInformerWithDifferentVersions() throws InterruptedExcepti // When SharedIndexInformer v1CronTabSharedIndexInformer = factory.inNamespace("default") .sharedIndexInformerForCustomResource(CronTab.class, 60 * WATCH_EVENT_EMIT_TIME); - SharedIndexInformer v1beta1CronTabSharedIndexInformer = factory.inNamespace("default") - .sharedIndexInformerForCustomResource(CronTab.class, new OperationContext().withApiGroupVersion("v1beta1"), 60 * WATCH_EVENT_EMIT_TIME); + ResourceDefinitionContext context = + new ResourceDefinitionContext.Builder().withPlural(HasMetadata.getPlural(CronTab.class)) + .withGroup(HasMetadata.getGroup(CronTab.class)) + .withVersion("v1beta1") + .withNamespaced(true) + .build(); + SharedIndexInformer v1beta1CronTabSharedIndexInformer = + client.genericKubernetesResources(context).inNamespace("default").inform(); v1CronTabSharedIndexInformer.addEventHandler(new TestResourceHandler<>(v1CronTabFound, "v1-crontab")); v1beta1CronTabSharedIndexInformer.addEventHandler(new TestResourceHandler<>(v1beta1CronTabFound, "v1beta1-crontab")); factory.startAllRegisteredInformers(); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PropagationPolicyTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PropagationPolicyTest.java index 79eea46657e..eaf4203ddf1 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PropagationPolicyTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PropagationPolicyTest.java @@ -45,8 +45,8 @@ import java.net.HttpURLConnection; import java.util.Collections; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; @EnableKubernetesMockClient class PropagationPolicyTest { @@ -415,14 +415,14 @@ void testDeleteRawCustomResource() throws InterruptedException, IOException { .andReturn(HttpURLConnection.HTTP_OK, "{\"metadata\":{},\"apiVersion\":\"v1\",\"kind\":\"Status\",\"details\":{\"name\":\"prometheus-example-rules\",\"group\":\"monitoring.coreos.com\",\"kind\":\"prometheusrules\",\"uid\":\"b3d085bd-6a5c-11e9-8787-525400b18c1d\"},\"status\":\"Success\"}").once(); // When - boolean result = client.customResource(new CustomResourceDefinitionContext.Builder() + boolean result = client.genericKubernetesResources(new CustomResourceDefinitionContext.Builder() .withGroup("test.fabric8.io") .withName("hellos.test.fabric8.io") .withPlural("hellos") .withScope("Namespaced") .withVersion("v1alpha1") .build()) - .delete("ns1", "example-hello"); + .inNamespace("ns1").withName("example-hello").delete(); // Then assertTrue(result); diff --git a/openshift-client/pom.xml b/openshift-client/pom.xml index 92de8f1d14f..2db5abe2002 100644 --- a/openshift-client/pom.xml +++ b/openshift-client/pom.xml @@ -100,7 +100,12 @@ io.fabric8 openshift-model-miscellaneous - + + com.github.mifmif + generex + ${generex.version} + + io.sundr diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java b/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java index 855104b2167..e49c8190f5f 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java @@ -100,9 +100,7 @@ import io.fabric8.kubernetes.client.dsl.ServiceResource; import io.fabric8.kubernetes.client.dsl.StorageAPIGroupDSL; import io.fabric8.kubernetes.client.dsl.V1APIGroupDSL; -import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; import io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext; -import io.fabric8.kubernetes.client.dsl.internal.RawCustomResourceOperationsImpl; import io.fabric8.kubernetes.client.extended.leaderelection.LeaderElectorBuilder; import io.fabric8.kubernetes.client.extended.run.RunOperations; import io.fabric8.kubernetes.client.informers.SharedInformerFactory; @@ -761,11 +759,6 @@ public InOutCreateable tokenReviews() { return delegate.tokenReviews(); } - @Override - public RawCustomResourceOperationsImpl customResource(CustomResourceDefinitionContext customResourceDefinition) { - return delegate.customResource(customResourceDefinition); - } - @Override public C adapt(Class type) { return delegate.adapt(type); diff --git a/pom.xml b/pom.xml index 4f6b6f3b935..82d271abb47 100644 --- a/pom.xml +++ b/pom.xml @@ -174,6 +174,7 @@ model-annotator kubernetes-model-generator + kubernetes-client-api kubernetes-client kubernetes-server-mock openshift-client @@ -354,6 +355,18 @@ openshift-model ${project.version} + + io.fabric8 + kubernetes-client-api + ${project.version} + + + io.fabric8 + kubernetes-client-api + ${project.version} + test-jar + test + io.fabric8 kubernetes-client @@ -532,6 +545,13 @@ ${mockito.version} test + + + org.mockito + mockito-inline + ${mockito.version} + test + From bb1573a232d78bc071d1a7cd93168ad3526f5845 Mon Sep 17 00:00:00 2001 From: Steve Hawkins Date: Wed, 22 Dec 2021 21:18:43 -0500 Subject: [PATCH 2/6] adding an openshift-client-api --- openshift-client-api/pom.xml | 259 ++++++++++++++++++ .../client/NamespacedOpenShiftClient.java | 0 .../openshift/client/OpenShiftAPIGroups.java | 0 .../openshift/client/OpenShiftClient.java | 0 .../openshift/client/OpenShiftConfig.java | 0 .../OpenShiftNotAvailableException.java | 0 .../client/OpenshiftClientContext.java | 0 .../openshift/client/ParameterValue.java | 0 .../client/dsl/BuildConfigOperation.java | 0 .../client/dsl/BuildConfigResource.java | 0 .../openshift/client/dsl/BuildResource.java | 0 .../openshift/client/dsl/Deployable.java | 0 .../dsl/DeployableScalableResource.java | 0 .../openshift/client/dsl/InputStreamable.java | 0 .../openshift/client/dsl/Instantiateable.java | 0 .../dsl/MachineConfigurationAPIGroupDSL.java | 0 .../dsl/NameableCreateOrDeleteable.java | 0 ...penShiftClusterAutoscalingAPIGroupDSL.java | 0 .../dsl/OpenShiftConfigAPIGroupDSL.java | 0 .../dsl/OpenShiftConsoleAPIGroupDSL.java | 0 .../dsl/OpenShiftMachineAPIGroupDSL.java | 0 .../dsl/OpenShiftMonitoringAPIGroupDSL.java | 0 .../dsl/OpenShiftOperatorAPIGroupDSL.java | 0 .../dsl/OpenShiftOperatorHubAPIGroupDSL.java | 0 .../client/dsl/OpenShiftQuotaAPIGroupDSL.java | 0 ...hiftStorageVersionMigratorApiGroupDSL.java | 0 .../client/dsl/OpenShiftTunedAPIGroupDSL.java | 0 .../dsl/OpenShiftWhereaboutsAPIGroupDSL.java | 0 .../openshift/client/dsl/Processable.java | 0 .../client/dsl/ProcessableResource.java | 0 .../client/dsl/ProjectOperation.java | 0 .../client/dsl/ProjectRequestOperation.java | 0 .../client/dsl/TemplateOperation.java | 0 .../client/dsl/TemplateResource.java | 0 .../client/dsl/TimeoutInputStreamable.java | 0 .../dsl/V1ClusterAutoscalingAPIGroupDSL.java | 0 .../V1beta1ClusterAutoscalingAPIGroupDSL.java | 0 .../AsFileTimeoutInputStreamable.java | 0 .../client/dsl/buildconfig/AsFileable.java | 0 .../dsl/buildconfig/AuthorEmailable.java | 0 ...orMessageAsFileTimeoutInputStreamable.java | 0 .../buildconfig/AuthorNameOrEmailable.java | 0 .../dsl/buildconfig/AuthorNameable.java | 0 .../client/dsl/buildconfig/Commitable.java | 0 ...orMessageAsFileTimeoutInputStreamable.java | 0 .../dsl/buildconfig/CommitterEmailable.java | 0 .../buildconfig/CommitterNameOrEmailable.java | 0 .../dsl/buildconfig/CommitterNameable.java | 0 .../MessageAsFileTimeoutInputStreamable.java | 0 .../client/dsl/buildconfig/Messageable.java | 0 .../readiness/OpenShiftReadiness.java | 0 .../client/dsl/base/TestUnmarshal.java | 38 +++ .../readiness/OpenShiftReadinessTest.java | 56 ++++ openshift-client/pom.xml | 47 +--- pom.xml | 6 + 55 files changed, 361 insertions(+), 45 deletions(-) create mode 100644 openshift-client-api/pom.xml rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClient.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/OpenShiftAPIGroups.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/OpenShiftClient.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/OpenShiftConfig.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/OpenShiftNotAvailableException.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/OpenshiftClientContext.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/ParameterValue.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/BuildConfigOperation.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/BuildConfigResource.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/BuildResource.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/Deployable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/DeployableScalableResource.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/InputStreamable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/Instantiateable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/MachineConfigurationAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/NameableCreateOrDeleteable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftClusterAutoscalingAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftConfigAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftConsoleAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftMachineAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftMonitoringAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftOperatorAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftOperatorHubAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftQuotaAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftStorageVersionMigratorApiGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftTunedAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftWhereaboutsAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/Processable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/ProcessableResource.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/ProjectOperation.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/ProjectRequestOperation.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/TemplateOperation.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/TemplateResource.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/TimeoutInputStreamable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/V1ClusterAutoscalingAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/V1beta1ClusterAutoscalingAPIGroupDSL.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AsFileTimeoutInputStreamable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AsFileable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorEmailable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorMessageAsFileTimeoutInputStreamable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorNameOrEmailable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorNameable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/Commitable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterAuthorMessageAsFileTimeoutInputStreamable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterEmailable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterNameOrEmailable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterNameable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/MessageAsFileTimeoutInputStreamable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/Messageable.java (100%) rename {openshift-client => openshift-client-api}/src/main/java/io/fabric8/openshift/client/internal/readiness/OpenShiftReadiness.java (100%) create mode 100644 openshift-client-api/src/test/java/io/fabric8/openshift/client/dsl/base/TestUnmarshal.java create mode 100644 openshift-client-api/src/test/java/io/fabric8/openshift/client/internal/readiness/OpenShiftReadinessTest.java diff --git a/openshift-client-api/pom.xml b/openshift-client-api/pom.xml new file mode 100644 index 00000000000..7463fddcc19 --- /dev/null +++ b/openshift-client-api/pom.xml @@ -0,0 +1,259 @@ + + + + 4.0.0 + + io.fabric8 + kubernetes-client-project + 5.12-SNAPSHOT + + + openshift-client-api + jar + Fabric8 :: Openshift :: Java Client API + + + + osgi.extender; + filter:="(osgi.extender=osgi.serviceloader.registrar)" + + + !org.junit*, + * + + + io.fabric8.openshift.client*;-noimport:=true + + + io.fabric8.openshift.client.internal, + io.fabric8.openshift.client.dsl.internal + + + + + + io.fabric8 + kubernetes-client-api + + + io.fabric8 + openshift-model + + + io.fabric8 + openshift-model-clusterautoscaling + + + io.fabric8 + openshift-model-operator + + + io.fabric8 + openshift-model-operatorhub + + + io.fabric8 + openshift-model-machine + + + io.fabric8 + openshift-model-whereabouts + + + io.fabric8 + openshift-model-monitoring + + + io.fabric8 + openshift-model-storageversionmigrator + + + io.fabric8 + openshift-model-tuned + + + io.fabric8 + openshift-model-console + + + io.fabric8 + openshift-model-machineconfig + + + io.fabric8 + openshift-model-miscellaneous + + + + + io.sundr + builder-annotations + + + + io.sundr + transform-annotations + + + + org.apache.felix + org.apache.felix.scr.annotations + ${scr.annotations.version} + compile + true + + + + + io.fabric8 + kubernetes-client + ${project.version} + test-jar + test + + + + io.fabric8 + mockwebserver + test + + + + org.slf4j + slf4j-simple + ${slf4j.version} + test + + + + org.junit.jupiter + junit-jupiter-engine + test + + + + org.junit.jupiter + junit-jupiter-migrationsupport + test + + + + org.mockito + mockito-core + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + resource-*.vm + + + + + + test-jar + + + + + + org.apache.felix + maven-scr-plugin + ${maven.scr.plugin.version} + + + + scr + + + 1.2 + true + + + + + + org.apache.felix + maven-bundle-plugin + + + bundle + package + + bundle + + + + ${project.name} + ${project.groupId}.${project.artifactId} + ${osgi.export} + ${osgi.import} + ${osgi.dynamic.import} + ${osgi.require-capability} + ${osgi.provide-capability} + ${osgi.private} + ${osgi.bundles} + ${osgi.activator} + ${osgi.export.service} + + bundle + + + + + + + + diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClient.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClient.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClient.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClient.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/OpenShiftAPIGroups.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftAPIGroups.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/OpenShiftAPIGroups.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftAPIGroups.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/OpenShiftClient.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftClient.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/OpenShiftClient.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftClient.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/OpenShiftConfig.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftConfig.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/OpenShiftConfig.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftConfig.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/OpenShiftNotAvailableException.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftNotAvailableException.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/OpenShiftNotAvailableException.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftNotAvailableException.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/OpenshiftClientContext.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenshiftClientContext.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/OpenshiftClientContext.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenshiftClientContext.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/ParameterValue.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/ParameterValue.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/ParameterValue.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/ParameterValue.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/BuildConfigOperation.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/BuildConfigOperation.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/BuildConfigOperation.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/BuildConfigOperation.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/BuildConfigResource.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/BuildConfigResource.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/BuildConfigResource.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/BuildConfigResource.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/BuildResource.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/BuildResource.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/BuildResource.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/BuildResource.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/Deployable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/Deployable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/Deployable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/Deployable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/DeployableScalableResource.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/DeployableScalableResource.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/DeployableScalableResource.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/DeployableScalableResource.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/InputStreamable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/InputStreamable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/InputStreamable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/InputStreamable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/Instantiateable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/Instantiateable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/Instantiateable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/Instantiateable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/MachineConfigurationAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/MachineConfigurationAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/MachineConfigurationAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/MachineConfigurationAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/NameableCreateOrDeleteable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/NameableCreateOrDeleteable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/NameableCreateOrDeleteable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/NameableCreateOrDeleteable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftClusterAutoscalingAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftClusterAutoscalingAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftClusterAutoscalingAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftClusterAutoscalingAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftConfigAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftConfigAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftConfigAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftConfigAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftConsoleAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftConsoleAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftConsoleAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftConsoleAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftMachineAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftMachineAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftMachineAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftMachineAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftMonitoringAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftMonitoringAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftMonitoringAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftMonitoringAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftOperatorAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftOperatorAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftOperatorAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftOperatorAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftOperatorHubAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftOperatorHubAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftOperatorHubAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftOperatorHubAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftQuotaAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftQuotaAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftQuotaAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftQuotaAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftStorageVersionMigratorApiGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftStorageVersionMigratorApiGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftStorageVersionMigratorApiGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftStorageVersionMigratorApiGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftTunedAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftTunedAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftTunedAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftTunedAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftWhereaboutsAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftWhereaboutsAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftWhereaboutsAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/OpenShiftWhereaboutsAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/Processable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/Processable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/Processable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/Processable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/ProcessableResource.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/ProcessableResource.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/ProcessableResource.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/ProcessableResource.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/ProjectOperation.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/ProjectOperation.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/ProjectOperation.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/ProjectOperation.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/ProjectRequestOperation.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/ProjectRequestOperation.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/ProjectRequestOperation.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/ProjectRequestOperation.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/TemplateOperation.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/TemplateOperation.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/TemplateOperation.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/TemplateOperation.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/TemplateResource.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/TemplateResource.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/TemplateResource.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/TemplateResource.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/TimeoutInputStreamable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/TimeoutInputStreamable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/TimeoutInputStreamable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/TimeoutInputStreamable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/V1ClusterAutoscalingAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/V1ClusterAutoscalingAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/V1ClusterAutoscalingAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/V1ClusterAutoscalingAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/V1beta1ClusterAutoscalingAPIGroupDSL.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/V1beta1ClusterAutoscalingAPIGroupDSL.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/V1beta1ClusterAutoscalingAPIGroupDSL.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/V1beta1ClusterAutoscalingAPIGroupDSL.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AsFileTimeoutInputStreamable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AsFileTimeoutInputStreamable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AsFileTimeoutInputStreamable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AsFileTimeoutInputStreamable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AsFileable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AsFileable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AsFileable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AsFileable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorEmailable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorEmailable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorEmailable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorEmailable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorMessageAsFileTimeoutInputStreamable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorMessageAsFileTimeoutInputStreamable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorMessageAsFileTimeoutInputStreamable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorMessageAsFileTimeoutInputStreamable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorNameOrEmailable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorNameOrEmailable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorNameOrEmailable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorNameOrEmailable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorNameable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorNameable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorNameable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/AuthorNameable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/Commitable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/Commitable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/Commitable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/Commitable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterAuthorMessageAsFileTimeoutInputStreamable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterAuthorMessageAsFileTimeoutInputStreamable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterAuthorMessageAsFileTimeoutInputStreamable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterAuthorMessageAsFileTimeoutInputStreamable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterEmailable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterEmailable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterEmailable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterEmailable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterNameOrEmailable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterNameOrEmailable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterNameOrEmailable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterNameOrEmailable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterNameable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterNameable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterNameable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/CommitterNameable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/MessageAsFileTimeoutInputStreamable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/MessageAsFileTimeoutInputStreamable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/MessageAsFileTimeoutInputStreamable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/MessageAsFileTimeoutInputStreamable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/Messageable.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/Messageable.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/Messageable.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/dsl/buildconfig/Messageable.java diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/internal/readiness/OpenShiftReadiness.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/internal/readiness/OpenShiftReadiness.java similarity index 100% rename from openshift-client/src/main/java/io/fabric8/openshift/client/internal/readiness/OpenShiftReadiness.java rename to openshift-client-api/src/main/java/io/fabric8/openshift/client/internal/readiness/OpenShiftReadiness.java diff --git a/openshift-client-api/src/test/java/io/fabric8/openshift/client/dsl/base/TestUnmarshal.java b/openshift-client-api/src/test/java/io/fabric8/openshift/client/dsl/base/TestUnmarshal.java new file mode 100644 index 00000000000..c3637294efa --- /dev/null +++ b/openshift-client-api/src/test/java/io/fabric8/openshift/client/dsl/base/TestUnmarshal.java @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.openshift.client.dsl.base; + +import io.fabric8.kubernetes.client.utils.Serialization; +import io.fabric8.openshift.api.model.Template; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class TestUnmarshal { + + @Test + void testUnmarshalJSONTemplate() { + Template t = Serialization.unmarshal(getClass().getResourceAsStream("/test-template.json"), Template.class); + assertEquals("eap6-basic-sti", t.getMetadata().getName()); + } + + @Test + void testUnmarshalYAMLTemplate() { + Template t = Serialization.unmarshal(getClass().getResourceAsStream("/test-template.yml"), Template.class); + assertEquals("eap6-basic-sti", t.getMetadata().getName()); + } + +} diff --git a/openshift-client-api/src/test/java/io/fabric8/openshift/client/internal/readiness/OpenShiftReadinessTest.java b/openshift-client-api/src/test/java/io/fabric8/openshift/client/internal/readiness/OpenShiftReadinessTest.java new file mode 100644 index 00000000000..d9ea7dea470 --- /dev/null +++ b/openshift-client-api/src/test/java/io/fabric8/openshift/client/internal/readiness/OpenShiftReadinessTest.java @@ -0,0 +1,56 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.fabric8.openshift.client.internal.readiness; + +import io.fabric8.kubernetes.client.internal.readiness.Readiness; +import io.fabric8.openshift.api.model.DeploymentConfig; +import io.fabric8.openshift.api.model.DeploymentConfigBuilder; +import io.fabric8.openshift.api.model.ImageStreamBuilder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class OpenShiftReadinessTest { + + private Readiness readiness; + + @BeforeEach + void setUp() { + readiness = OpenShiftReadiness.getInstance(); + } + + @Test + void testOpenShiftReadinessWithDeploymentConfig() { + DeploymentConfig dc = new DeploymentConfigBuilder() + .withNewSpec().withReplicas(2).endSpec() + .withNewStatus().withAvailableReplicas(2).withReplicas(2).endStatus() + .build(); + + assertTrue(readiness.isReady(dc)); + } + + @Test + void testOpenShiftReadinessWithNonReadinessApplicableResource() { + assertTrue(readiness.isReady(new ImageStreamBuilder().withNewMetadata().withName("is1").endMetadata().build())); + } + + @Test + void testOpenShiftReadinessWithNullResource() { + assertFalse(readiness.isReady(null)); + } +} diff --git a/openshift-client/pom.xml b/openshift-client/pom.xml index 2db5abe2002..1c78e432211 100644 --- a/openshift-client/pom.xml +++ b/openshift-client/pom.xml @@ -52,54 +52,11 @@ io.fabric8 kubernetes-client - - io.fabric8 - openshift-model - - - io.fabric8 - openshift-model-clusterautoscaling - - - io.fabric8 - openshift-model-operator - - - io.fabric8 - openshift-model-operatorhub - - - io.fabric8 - openshift-model-machine - - - io.fabric8 - openshift-model-whereabouts - - - io.fabric8 - openshift-model-monitoring - - - io.fabric8 - openshift-model-storageversionmigrator - - - io.fabric8 - openshift-model-tuned - - - io.fabric8 - openshift-model-console - - - io.fabric8 - openshift-model-machineconfig - io.fabric8 - openshift-model-miscellaneous + openshift-client-api + com.github.mifmif generex diff --git a/pom.xml b/pom.xml index 82d271abb47..023e2bd28a4 100644 --- a/pom.xml +++ b/pom.xml @@ -177,6 +177,7 @@ kubernetes-client-api kubernetes-client kubernetes-server-mock + openshift-client-api openshift-client extensions openshift-server-mock @@ -367,6 +368,11 @@ test-jar test + + io.fabric8 + openshift-client-api + ${project.version} + io.fabric8 kubernetes-client From 4abcd50b76fdea6a57775ed0d5f5f5468c1a1ae6 Mon Sep 17 00:00:00 2001 From: Steve Hawkins Date: Thu, 6 Jan 2022 07:45:35 -0500 Subject: [PATCH 3/6] correcting errant reference to customResource entry point --- doc/CHEATSHEET.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CHEATSHEET.md b/doc/CHEATSHEET.md index 0a7a05d93ba..33874e32e67 100644 --- a/doc/CHEATSHEET.md +++ b/doc/CHEATSHEET.md @@ -1792,7 +1792,7 @@ GenericKubernetesResource result = client.genericKubernetesResources(resourceDef ```java final CountDownLatch closeLatch = new CountDownLatch(1); -client.customResource(crdContext).inNamespace(namespace).watch(new Watcher() { +client.genericKubernetesResources(crdContext).inNamespace(namespace).watch(new Watcher() { @Override public void eventReceived(Action action, GenericKubernetesResource resource) { logger.info("{}: {}", action, resource); From 2d22886a71419d0fa5c35a20b752ade204973619 Mon Sep 17 00:00:00 2001 From: Steve Hawkins Date: Sun, 9 Jan 2022 17:06:47 -0500 Subject: [PATCH 4/6] adding a possible reflection based set of client builders --- .../client/BaseKubernetesClientBuilder.java | 75 +++++++++++++++++++ .../client/KubernetesClientBuilder.java | 25 +++++++ .../client/OpenShiftClientBuilder.java | 37 +++++++++ 3 files changed, 137 insertions(+) create mode 100644 kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/BaseKubernetesClientBuilder.java create mode 100644 kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/KubernetesClientBuilder.java create mode 100644 openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftClientBuilder.java diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/BaseKubernetesClientBuilder.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/BaseKubernetesClientBuilder.java new file mode 100644 index 00000000000..5e280c3792f --- /dev/null +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/BaseKubernetesClientBuilder.java @@ -0,0 +1,75 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fabric8.kubernetes.client; + +import io.fabric8.kubernetes.client.http.HttpClient; +import io.fabric8.kubernetes.client.utils.Serialization; + +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; + +public class BaseKubernetesClientBuilder> { + + private Config config; + private HttpClient.Factory factory; + private Class clazz; + + protected BaseKubernetesClientBuilder(String className) { + try { + this.clazz = (Class) Class.forName(className); + } catch (ClassNotFoundException e) { + throw KubernetesClientException.launderThrowable(e); + } + } + + public KubernetesClient build() { + if (config == null) { + config = new ConfigBuilder().build(); + } + try { + if (factory == null) { + return clazz.getConstructor(Config.class).newInstance(config); + } + HttpClient client = factory.createHttpClient(config); + return clazz.getConstructor(HttpClient.class, Config.class).newInstance(client, config); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException + | NoSuchMethodException | SecurityException e) { + throw KubernetesClientException.launderThrowable(e); + } + } + + public BaseKubernetesClientBuilder withConfig(Config config) { + this.config = config; + return this; + } + + public BaseKubernetesClientBuilder withConfig(String config) { + this.config = Serialization.unmarshal(config); + return this; + } + + public BaseKubernetesClientBuilder withConfig(InputStream config) { + this.config = Serialization.unmarshal(config); + return this; + } + + public BaseKubernetesClientBuilder withHttpClientFactory(HttpClient.Factory factory) { + this.factory = factory; + return this; + } + +} diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/KubernetesClientBuilder.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/KubernetesClientBuilder.java new file mode 100644 index 00000000000..dafd3aa1f9d --- /dev/null +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/KubernetesClientBuilder.java @@ -0,0 +1,25 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fabric8.kubernetes.client; + +public class KubernetesClientBuilder extends BaseKubernetesClientBuilder { + + public KubernetesClientBuilder() { + super("io.fabric8.kubernetes.client.DefaultKubernetesClient"); + } + +} diff --git a/openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftClientBuilder.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftClientBuilder.java new file mode 100644 index 00000000000..7991dc76b14 --- /dev/null +++ b/openshift-client-api/src/main/java/io/fabric8/openshift/client/OpenShiftClientBuilder.java @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fabric8.openshift.client; + +import io.fabric8.kubernetes.client.BaseKubernetesClientBuilder; + +public class OpenShiftClientBuilder extends BaseKubernetesClientBuilder { + + public OpenShiftClientBuilder() { + super("io.fabric8.openshift.client.DefaultOpenShiftClient"); + } + + public OpenShiftClientBuilder withOpenShiftConfig(OpenShiftConfig config) { + super.withConfig(config); + return this; + } + + @Override + public OpenShiftClient build() { + return (OpenShiftClient)super.build(); + } + +} From 4ab9a2b07fdb3d54239a620f2cfdd01b3588546a Mon Sep 17 00:00:00 2001 From: Steve Hawkins Date: Fri, 14 Jan 2022 13:30:37 -0500 Subject: [PATCH 5/6] adding a subprotocol method for jdk client support --- .../kubernetes/client/http/WebSocket.java | 30 ++++++++++--------- .../internal/core/v1/PodOperationsImpl.java | 2 +- .../dsl/internal/uploadable/PodUpload.java | 2 +- .../client/okhttp/OkHttpWebSocketImpl.java | 6 ++++ 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/WebSocket.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/WebSocket.java index 2b13292c024..51fe2d55536 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/WebSocket.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/WebSocket.java @@ -21,34 +21,36 @@ import java.util.concurrent.CompletableFuture; public interface WebSocket { - + public interface Listener { - + default void onOpen(WebSocket webSocket) { } - + default void onMessage(WebSocket webSocket, String text) {} - + default void onMessage(WebSocket webSocket, ByteBuffer bytes) {} - + default void onClose(WebSocket webSocket, int code, String reason) {} - + default void onError(WebSocket webSocket, Throwable error) {} - + } - + public interface Builder extends BasicBuilder { - + CompletableFuture buildAsync(Listener listener); + Builder subprotocol(String protocol); + @Override Builder header(String name, String value); - + @Override Builder setHeader(String k, String v); - + @Override Builder uri(URI uri); - + } /** @@ -56,7 +58,7 @@ public interface Builder extends BasicBuilder { * @return true if the message was successfully enqueued. */ boolean send(ByteBuffer buffer); - + /** * Send a close message * @return true if the message was successfully enqueued. @@ -68,5 +70,5 @@ public interface Builder extends BasicBuilder { * doesn't include framing overhead. */ long queueSize(); - + } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/PodOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/PodOperationsImpl.java index 79166879679..c3212c77b66 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/PodOperationsImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/PodOperationsImpl.java @@ -311,7 +311,7 @@ public ExecWatch exec(String... command) { HttpClient clone = httpClient.newBuilder().readTimeout(0, TimeUnit.MILLISECONDS).build(); final ExecWebSocketListener execWebSocketListener = new ExecWebSocketListener(in, out, err, errChannel, inPipe, outPipe, errPipe, errChannelPipe, execListener, bufferSize); CompletableFuture startedFuture = clone.newWebSocketBuilder() - .setHeader("Sec-WebSocket-Protocol", "v4.channel.k8s.io") + .subprotocol("v4.channel.k8s.io") .uri(url.toURI()) .buildAsync(execWebSocketListener); startedFuture.whenComplete((w, t) -> { diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/uploadable/PodUpload.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/uploadable/PodUpload.java index f8a956ea9be..a8baeae77a6 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/uploadable/PodUpload.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/uploadable/PodUpload.java @@ -166,7 +166,7 @@ private static PodUploadWebSocketListener initWebSocket(URL url, HttpClient clie final PodUploadWebSocketListener podUploadWebSocketListener = new PodUploadWebSocketListener(); final HttpClient clone = client.newBuilder().readTimeout(0, TimeUnit.MILLISECONDS).build(); CompletableFuture startedFuture = clone.newWebSocketBuilder() - .setHeader("Sec-WebSocket-Protocol", "v4.channel.k8s.io") + .subprotocol("v4.channel.k8s.io") .uri(URI.create(url.toString())) .buildAsync(podUploadWebSocketListener); startedFuture.whenComplete((w, t) -> { diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/okhttp/OkHttpWebSocketImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/okhttp/OkHttpWebSocketImpl.java index 64bcb774a9c..b006fdd64ee 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/okhttp/OkHttpWebSocketImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/okhttp/OkHttpWebSocketImpl.java @@ -117,6 +117,12 @@ public WebSocket.Builder setHeader(String k, String v) { return this; } + @Override + public Builder subprotocol(String protocol) { + builder.header("Sec-WebSocket-Protocol", protocol); + return this; + } + } private okhttp3.WebSocket webSocket; From 4ed2579d35fc06714f497584fbb0718c59b5780e Mon Sep 17 00:00:00 2001 From: Steve Hawkins Date: Thu, 27 Jan 2022 13:12:52 -0500 Subject: [PATCH 6/6] the jdk client will only share state if we explicitly share the instance so we need a specialized subbuilder that is safe only for methods that can be / are called after the client is already constructed --- .../kubernetes/client/http/HttpClient.java | 58 +++++++++++++------ .../client/dsl/base/BaseOperation.java | 3 +- .../client/dsl/internal/WatchHTTPManager.java | 7 +-- .../client/OpenshiftAdapterSupport.java | 2 +- .../internal/OpenShiftOAuthInterceptor.java | 2 +- 5 files changed, 46 insertions(+), 26 deletions(-) diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpClient.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpClient.java index 4607f9d5bc8..c1c9a47f903 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpClient.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/http/HttpClient.java @@ -27,53 +27,75 @@ import java.util.concurrent.TimeUnit; public interface HttpClient extends AutoCloseable { - + public interface Factory { - + HttpClient createHttpClient(Config config); - + HttpClient.Builder newBuilder(); } - - public interface Builder { + public interface DerivedClientBuilder { + + HttpClient build(); + + DerivedClientBuilder readTimeout(long readTimeout, TimeUnit unit); + + DerivedClientBuilder forStreaming(); + + DerivedClientBuilder authenticatorNone(); + + DerivedClientBuilder writeTimeout(long timeout, TimeUnit timeoutUnit); + + DerivedClientBuilder addOrReplaceInterceptor(String name, Interceptor interceptor); + } + + public interface Builder extends DerivedClientBuilder { + + @Override HttpClient build(); + @Override Builder readTimeout(long readTimeout, TimeUnit unit); Builder connectTimeout(long connectTimeout, TimeUnit unit); - + + @Override Builder forStreaming(); + @Override Builder writeTimeout(long timeout, TimeUnit timeoutUnit); - + + @Override Builder addOrReplaceInterceptor(String name, Interceptor interceptor); - + + @Override Builder authenticatorNone(); - + Builder sslContext(SSLContext context, TrustManager[] trustManagers); - + Builder followAllRedirects(); - + Builder proxyAddress(InetSocketAddress proxyAddress); Builder proxyAuthorization(String credentials); Builder tlsVersions(TlsVersion[] tlsVersions); - + Builder preferHttp11(); } @Override void close(); - + /** - * Create a builder that starts with the same state as this client + * Create a builder that starts with the same state as this client. + *
The client resources will be shared across derived instances. * @return a new builder */ - Builder newBuilder(); - + DerivedClientBuilder newBuilder(); + /** * Send a request an wait for the result * @param return type @@ -83,7 +105,7 @@ public interface Builder { * @throws IOException */ HttpResponse send(HttpRequest request, Class type) throws IOException; - + /** * Send an async request * @param return type @@ -94,7 +116,7 @@ public interface Builder { CompletableFuture> sendAsync(HttpRequest request, Class type); WebSocket.Builder newWebSocketBuilder(); - + HttpRequest.Builder newHttpRequestBuilder(); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java index 865b3d4dc3a..efa7bc0fd97 100755 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java @@ -600,8 +600,7 @@ public Watch watch(ListOptions options, final Watcher watcher) { options, watcher, config.getWatchReconnectInterval(), - config.getWatchReconnectLimit(), - config.getConnectionTimeout() + config.getWatchReconnectLimit() ); } catch (MalformedURLException e) { throw KubernetesClientException.launderThrowable(forOperationType(WATCH), e); diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/WatchHTTPManager.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/WatchHTTPManager.java index f6a3e2b3949..4c4e4f5beb5 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/WatchHTTPManager.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/WatchHTTPManager.java @@ -44,22 +44,21 @@ public class WatchHTTPManager baseOperation, final ListOptions listOptions, final Watcher watcher, final int reconnectInterval, - final int reconnectLimit, long connectTimeout) + final int reconnectLimit) throws MalformedURLException { // Default max 32x slowdown from base interval - this(client, baseOperation, listOptions, watcher, reconnectInterval, reconnectLimit, connectTimeout, 5); + this(client, baseOperation, listOptions, watcher, reconnectInterval, reconnectLimit, 5); } public WatchHTTPManager(final HttpClient client, final BaseOperation baseOperation, final ListOptions listOptions, final Watcher watcher, final int reconnectInterval, - final int reconnectLimit, long connectTimeout, int maxIntervalExponent) + final int reconnectLimit, int maxIntervalExponent) throws MalformedURLException { super( watcher, baseOperation, listOptions, reconnectLimit, reconnectInterval, maxIntervalExponent, () -> client.newBuilder() - .connectTimeout(connectTimeout, TimeUnit.MILLISECONDS) .readTimeout(0, TimeUnit.MILLISECONDS) .forStreaming() .build()); diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/OpenshiftAdapterSupport.java b/openshift-client/src/main/java/io/fabric8/openshift/client/OpenshiftAdapterSupport.java index 71973189dc0..6ec2b994500 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/OpenshiftAdapterSupport.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/OpenshiftAdapterSupport.java @@ -95,7 +95,7 @@ public static HttpClient adaptHttpClient(HttpClient httpClient, OpenShiftConfig if (httpClient == null) { httpClient = HttpClientUtils.createHttpClient(config); } - HttpClient.Builder builder = httpClient.newBuilder().authenticatorNone(); + HttpClient.DerivedClientBuilder builder = httpClient.newBuilder().authenticatorNone(); return builder.addOrReplaceInterceptor(TokenRefreshInterceptor.NAME, new OpenShiftOAuthInterceptor(httpClient, config)).build(); } } diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/internal/OpenShiftOAuthInterceptor.java b/openshift-client/src/main/java/io/fabric8/openshift/client/internal/OpenShiftOAuthInterceptor.java index 70a59b7bce8..5dabf56399d 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/internal/OpenShiftOAuthInterceptor.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/internal/OpenShiftOAuthInterceptor.java @@ -126,7 +126,7 @@ private void setAuthHeader(BasicBuilder builder, String token) { private String authorize() { try { - HttpClient.Builder builder = client.newBuilder(); + HttpClient.DerivedClientBuilder builder = client.newBuilder(); builder.addOrReplaceInterceptor(TokenRefreshInterceptor.NAME, null); HttpClient clone = builder.build();