mirror of https://github.com/docker/docker-py.git
				
				
				
			Merge pull request #2608 from ulyssessouza/4.2.2-release
Bump 4.2.2 release
This commit is contained in:
		
						commit
						7f11cd4179
					
				|  | @ -17,7 +17,7 @@ def buildImage = { name, buildargs, pyTag -> | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| def buildImages = { -> | def buildImages = { -> | ||||||
|   wrappedNode(label: "ubuntu && !zfs && amd64", cleanWorkspace: true) { |   wrappedNode(label: "amd64 && ubuntu-1804 && overlay2", cleanWorkspace: true) { | ||||||
|     stage("build image") { |     stage("build image") { | ||||||
|       checkout(scm) |       checkout(scm) | ||||||
| 
 | 
 | ||||||
|  | @ -32,7 +32,7 @@ def buildImages = { -> | ||||||
| 
 | 
 | ||||||
| def getDockerVersions = { -> | def getDockerVersions = { -> | ||||||
|   def dockerVersions = ["19.03.5"] |   def dockerVersions = ["19.03.5"] | ||||||
|   wrappedNode(label: "ubuntu && !zfs && amd64") { |   wrappedNode(label: "amd64 && ubuntu-1804 && overlay2") { | ||||||
|     def result = sh(script: """docker run --rm \\ |     def result = sh(script: """docker run --rm \\ | ||||||
|         --entrypoint=python \\ |         --entrypoint=python \\ | ||||||
|         ${imageNamePy3} \\ |         ${imageNamePy3} \\ | ||||||
|  | @ -73,7 +73,7 @@ def runTests = { Map settings -> | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   { -> |   { -> | ||||||
|     wrappedNode(label: "ubuntu && !zfs && amd64", cleanWorkspace: true) { |     wrappedNode(label: "amd64 && ubuntu-1804 && overlay2", cleanWorkspace: true) { | ||||||
|       stage("test python=${pythonVersion} / docker=${dockerVersion}") { |       stage("test python=${pythonVersion} / docker=${dockerVersion}") { | ||||||
|         checkout(scm) |         checkout(scm) | ||||||
|         def dindContainerName = "dpy-dind-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}" |         def dindContainerName = "dpy-dind-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}" | ||||||
|  |  | ||||||
|  | @ -16,30 +16,42 @@ class Context: | ||||||
|         if not name: |         if not name: | ||||||
|             raise Exception("Name not provided") |             raise Exception("Name not provided") | ||||||
|         self.name = name |         self.name = name | ||||||
|  |         self.context_type = None | ||||||
|         self.orchestrator = orchestrator |         self.orchestrator = orchestrator | ||||||
|  |         self.endpoints = {} | ||||||
|  |         self.tls_cfg = {} | ||||||
|  |         self.meta_path = "IN MEMORY" | ||||||
|  |         self.tls_path = "IN MEMORY" | ||||||
|  | 
 | ||||||
|         if not endpoints: |         if not endpoints: | ||||||
|  |             # set default docker endpoint if no endpoint is set | ||||||
|             default_endpoint = "docker" if ( |             default_endpoint = "docker" if ( | ||||||
|                 not orchestrator or orchestrator == "swarm" |                 not orchestrator or orchestrator == "swarm" | ||||||
|                 ) else orchestrator |                 ) else orchestrator | ||||||
|  | 
 | ||||||
|             self.endpoints = { |             self.endpoints = { | ||||||
|                 default_endpoint: { |                 default_endpoint: { | ||||||
|                     "Host": get_context_host(host, tls), |                     "Host": get_context_host(host, tls), | ||||||
|                     "SkipTLSVerify": not tls |                     "SkipTLSVerify": not tls | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         else: |             return | ||||||
|             for k, v in endpoints.items(): |  | ||||||
|                 ekeys = v.keys() |  | ||||||
|                 for param in ["Host", "SkipTLSVerify"]: |  | ||||||
|                     if param not in ekeys: |  | ||||||
|                         raise ContextException( |  | ||||||
|                             "Missing parameter {} from endpoint {}".format( |  | ||||||
|                                 param, k)) |  | ||||||
|             self.endpoints = endpoints |  | ||||||
| 
 | 
 | ||||||
|         self.tls_cfg = {} |         # check docker endpoints | ||||||
|         self.meta_path = "IN MEMORY" |         for k, v in endpoints.items(): | ||||||
|         self.tls_path = "IN MEMORY" |             if not isinstance(v, dict): | ||||||
|  |                 # unknown format | ||||||
|  |                 raise ContextException("""Unknown endpoint format for | ||||||
|  |                     context {}: {}""".format(name, v)) | ||||||
|  | 
 | ||||||
|  |             self.endpoints[k] = v | ||||||
|  |             if k != "docker": | ||||||
|  |                 continue | ||||||
|  | 
 | ||||||
|  |             self.endpoints[k]["Host"] = v.get("Host", get_context_host( | ||||||
|  |                 host, tls)) | ||||||
|  |             self.endpoints[k]["SkipTLSVerify"] = bool(v.get( | ||||||
|  |                 "SkipTLSVerify", not tls)) | ||||||
| 
 | 
 | ||||||
|     def set_endpoint( |     def set_endpoint( | ||||||
|             self, name="docker", host=None, tls_cfg=None, |             self, name="docker", host=None, tls_cfg=None, | ||||||
|  | @ -59,9 +71,13 @@ class Context: | ||||||
| 
 | 
 | ||||||
|     @classmethod |     @classmethod | ||||||
|     def load_context(cls, name): |     def load_context(cls, name): | ||||||
|         name, orchestrator, endpoints = Context._load_meta(name) |         meta = Context._load_meta(name) | ||||||
|         if name: |         if meta: | ||||||
|             instance = cls(name, orchestrator, endpoints=endpoints) |             instance = cls( | ||||||
|  |                 meta["Name"], | ||||||
|  |                 orchestrator=meta["Metadata"].get("StackOrchestrator", None), | ||||||
|  |                 endpoints=meta.get("Endpoints", None)) | ||||||
|  |             instance.context_type = meta["Metadata"].get("Type", None) | ||||||
|             instance._load_certs() |             instance._load_certs() | ||||||
|             instance.meta_path = get_meta_dir(name) |             instance.meta_path = get_meta_dir(name) | ||||||
|             return instance |             return instance | ||||||
|  | @ -69,26 +85,30 @@ class Context: | ||||||
| 
 | 
 | ||||||
|     @classmethod |     @classmethod | ||||||
|     def _load_meta(cls, name): |     def _load_meta(cls, name): | ||||||
|         metadata = {} |  | ||||||
|         meta_file = get_meta_file(name) |         meta_file = get_meta_file(name) | ||||||
|         if os.path.isfile(meta_file): |         if not os.path.isfile(meta_file): | ||||||
|             with open(meta_file) as f: |             return None | ||||||
|                 try: |  | ||||||
|                     with open(meta_file) as f: |  | ||||||
|                         metadata = json.load(f) |  | ||||||
|                     for k, v in metadata["Endpoints"].items(): |  | ||||||
|                         metadata["Endpoints"][k]["SkipTLSVerify"] = bool( |  | ||||||
|                             v["SkipTLSVerify"]) |  | ||||||
|                 except (IOError, KeyError, ValueError) as e: |  | ||||||
|                     # unknown format |  | ||||||
|                     raise Exception("""Detected corrupted meta file for |  | ||||||
|                         context {} : {}""".format(name, e)) |  | ||||||
| 
 | 
 | ||||||
|             return ( |         metadata = {} | ||||||
|                 metadata["Name"], |         try: | ||||||
|                 metadata["Metadata"].get("StackOrchestrator", None), |             with open(meta_file) as f: | ||||||
|                 metadata["Endpoints"]) |                 metadata = json.load(f) | ||||||
|         return None, None, None |         except (IOError, KeyError, ValueError) as e: | ||||||
|  |             # unknown format | ||||||
|  |             raise Exception("""Detected corrupted meta file for | ||||||
|  |                 context {} : {}""".format(name, e)) | ||||||
|  | 
 | ||||||
|  |         # for docker endpoints, set defaults for | ||||||
|  |         # Host and SkipTLSVerify fields | ||||||
|  |         for k, v in metadata["Endpoints"].items(): | ||||||
|  |             if k != "docker": | ||||||
|  |                 continue | ||||||
|  |             metadata["Endpoints"][k]["Host"] = v.get( | ||||||
|  |                 "Host", get_context_host(None, False)) | ||||||
|  |             metadata["Endpoints"][k]["SkipTLSVerify"] = bool( | ||||||
|  |                 v.get("SkipTLSVerify", True)) | ||||||
|  | 
 | ||||||
|  |         return metadata | ||||||
| 
 | 
 | ||||||
|     def _load_certs(self): |     def _load_certs(self): | ||||||
|         certs = {} |         certs = {} | ||||||
|  | @ -157,6 +177,9 @@ class Context: | ||||||
|         result.update(self.Storage) |         result.update(self.Storage) | ||||||
|         return result |         return result | ||||||
| 
 | 
 | ||||||
|  |     def is_docker_host(self): | ||||||
|  |         return self.context_type is None | ||||||
|  | 
 | ||||||
|     @property |     @property | ||||||
|     def Name(self): |     def Name(self): | ||||||
|         return self.name |         return self.name | ||||||
|  | @ -164,8 +187,12 @@ class Context: | ||||||
|     @property |     @property | ||||||
|     def Host(self): |     def Host(self): | ||||||
|         if not self.orchestrator or self.orchestrator == "swarm": |         if not self.orchestrator or self.orchestrator == "swarm": | ||||||
|             return self.endpoints["docker"]["Host"] |             endpoint = self.endpoints.get("docker", None) | ||||||
|         return self.endpoints[self.orchestrator]["Host"] |             if endpoint: | ||||||
|  |                 return endpoint.get("Host", None) | ||||||
|  |             return None | ||||||
|  | 
 | ||||||
|  |         return self.endpoints[self.orchestrator].get("Host", None) | ||||||
| 
 | 
 | ||||||
|     @property |     @property | ||||||
|     def Orchestrator(self): |     def Orchestrator(self): | ||||||
|  |  | ||||||
|  | @ -1,2 +1,2 @@ | ||||||
| version = "4.2.1" | version = "4.2.2" | ||||||
| version_info = tuple([int(d) for d in version.split("-")[0].split(".")]) | version_info = tuple([int(d) for d in version.split("-")[0].split(".")]) | ||||||
|  |  | ||||||
|  | @ -1,6 +1,15 @@ | ||||||
| Change log | Change log | ||||||
| ========== | ========== | ||||||
| 
 | 
 | ||||||
|  | 4.2.2 | ||||||
|  | ----- | ||||||
|  | 
 | ||||||
|  | [List of PRs / issues for this release](https://github.com/docker/docker-py/milestone/66?closed=1) | ||||||
|  | 
 | ||||||
|  | ### Bugfixes | ||||||
|  | 
 | ||||||
|  | - Fix context load for non-docker endpoints | ||||||
|  | 
 | ||||||
| 4.2.1 | 4.2.1 | ||||||
| ----- | ----- | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue