Skip to content

Commit

Permalink
Merge pull request #93 from JinTotonic/jindun
Browse files Browse the repository at this point in the history
 Fix array_filter which filters '0' or 0
  • Loading branch information
Jindun SHAO committed Aug 8, 2018
2 parents 0416ce8 + 8cda0e2 commit a7eaa4a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/Service/Environment/EnvVariable.php
Expand Up @@ -61,6 +61,8 @@ public function jsonSerialize(): array
'value' => $this->value,
'type' => $this->type,
'comment' => $this->comment
]);
], function ($v) {
return null !== $v;
});
}
}
4 changes: 3 additions & 1 deletion src/Service/Environment/SharedEnvVariable.php
Expand Up @@ -37,6 +37,8 @@ public function jsonSerialize(): array
'type' => $this->getType(),
'comment' => $this->getComment(),
'containerId' => $this->containerId
]);
], function ($v) {
return null !== $v;
});
}
}
11 changes: 7 additions & 4 deletions src/Service/Service.php
Expand Up @@ -168,11 +168,15 @@ public function jsonSerialize(): array
'memory' => $this->requestMemory,
'cpu' => $this->requestCpu,
'storage' => $this->requestStorage,
]),
], function ($v) {
return null !== $v;
}),
'limits' => array_filter([
'memory' => $this->limitMemory,
'cpu' => $this->limitCpu,
]),
], function ($v) {
return null !== $v;
}),
]);

if (!empty($resources)) {
Expand Down Expand Up @@ -456,7 +460,7 @@ public function addVirtualHostPrefix(?string $hostPrefix, int $port, ?string $co
$this->virtualHosts[] = $array;
}

/************************ environment adders & contains **********************/
/************************ environment adders & getters by type **********************/

/** @throws ServiceException */
private function addEnvVar(string $key, string $value, string $type, ?string $comment = null, ?string $containerId = null): void
Expand Down Expand Up @@ -623,7 +627,6 @@ public function removeVolumesBySource(string $source): void
$this->volumes = array_values(array_filter($this->volumes, $filterFunction));
}


/************************ destEnvTypes stuffs **********************/

public function addDestEnvType(string $envType, bool $keepTheOtherEnvTypes = true): void
Expand Down
4 changes: 3 additions & 1 deletion src/Service/Volume/TmpfsVolume.php
Expand Up @@ -27,6 +27,8 @@ public function jsonSerialize(): array
'type' => $this->getType(),
'source' => $this->source,
'comment' => $this->comment,
]);
], function ($v) {
return null !== $v;
});
}
}

0 comments on commit a7eaa4a

Please sign in to comment.