Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.24.4

require (
github.com/go-chi/chi/v5 v5.2.2
github.com/platformsh/cli v0.0.0-20250512110214-68e4962f0990
github.com/platformsh/cli v0.0.0-20250703103124-87b7ab372c7b
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.39.0
)
Expand Down
4 changes: 2 additions & 2 deletions go-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ github.com/go-chi/chi/v5 v5.2.2/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hH
github.com/oklog/ulid/v2 v2.1.1 h1:suPZ4ARWLOJLegGFiZZ1dFAkqzhMjL3J1TzI+5wHz8s=
github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/platformsh/cli v0.0.0-20250512110214-68e4962f0990 h1:0xJ3ftKO/9qB3KCMnGzEzKZizOEJgCGBfOQk1ts9szk=
github.com/platformsh/cli v0.0.0-20250512110214-68e4962f0990/go.mod h1:1OFXJCFPlXT4zSc1U/U3xSNh1UmuqOm9rz+FldYe8z8=
github.com/platformsh/cli v0.0.0-20250703103124-87b7ab372c7b h1:o0ykauvwRrRUKszPVLjaI2MaB9y276vlwYEaxzUfwXE=
github.com/platformsh/cli v0.0.0-20250703103124-87b7ab372c7b/go.mod h1:1OFXJCFPlXT4zSc1U/U3xSNh1UmuqOm9rz+FldYe8z8=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
Expand Down
5 changes: 5 additions & 0 deletions go-tests/project_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,9 @@ git [email protected]:mock-project.git`

// TODO --refresh should not be needed here
assert.Equal(t, "New Title\n", f.Run("pro:info", "-p", projectID, "title", "--refresh"))

// Test setting an attribute using dot notation
f.Run("pro:info", "-v", "-p", projectID, "attributes.foo", "bar")
// TODO --refresh should not be needed here
assert.Equal(t, "bar\n", f.Run("pro:info", "-p", projectID, "attributes.foo", "--refresh"))
}
20 changes: 17 additions & 3 deletions src/Command/Project/ProjectInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,19 @@ protected function listProperties(array $properties): int

protected function setProperty(string $property, string $value, Project $project, bool $noWait): int
{
$type = $this->getType($property);
$isMap = str_contains($property, '.');
if ($isMap) {
[$mapName, $mapKey] = explode('.', $property, 2);
$type = $this->getType($mapName . '.*');
$currentMap = $project->getProperty($mapName) ?? [];
$currentValue = $currentMap[$mapKey] ?? null;
$update = [$mapName => [$mapKey => $value]];
} else {
$type = $this->getType($property);
$currentValue = $project->getProperty($property);
$update = [$property => $value];
}

if (!$type) {
$this->stdErr->writeln("Property not writable: <error>$property</error>");
return 1;
Expand All @@ -122,17 +134,18 @@ protected function setProperty(string $property, string $value, Project $project
$value = false;
}
settype($value, $type);
$currentValue = $project->getProperty($property);

if ($currentValue === $value) {
$this->stdErr->writeln(
"Property <info>$property</info> already set as: " . $this->propertyFormatter->format($value, $property),
);

return 0;

}

$project->ensureFull();
$result = $project->update([$property => $value]);
$result = $project->update($update);
$this->stdErr->writeln(sprintf(
'Property <info>%s</info> set to: %s',
$property,
Expand Down Expand Up @@ -160,6 +173,7 @@ protected function getType(string $property): string|false
'description' => 'string',
'default_domain' => 'string',
'default_branch' => 'string',
'attributes.*' => 'string',
];

return $writableProperties[$property] ?? false;
Expand Down
Loading