Skip to content

Commit 5151555

Browse files
authored
chore: update validations (#1337)
When updating ash in #1324 we did not run proper test validation. Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
1 parent 18be141 commit 5151555

26 files changed

Lines changed: 161 additions & 41 deletions

File tree

backend/lib/edgehog/astarte/cluster/validations/url.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#
21
# This file is part of Edgehog.
32
#
4-
# Copyright 2023 SECO Mind Srl
3+
# Copyright 2023-2026 SECO Mind Srl
54
#
65
# Licensed under the Apache License, Version 2.0 (the "License");
76
# you may not use this file except in compliance with the License.
@@ -16,7 +15,6 @@
1615
# limitations under the License.
1716
#
1817
# SPDX-License-Identifier: Apache-2.0
19-
#
2018

2119
defmodule Edgehog.Astarte.Cluster.Validations.URL do
2220
@moduledoc false
@@ -56,4 +54,10 @@ defmodule Edgehog.Astarte.Cluster.Validations.URL do
5654
:ok
5755
end
5856
end
57+
58+
@impl Ash.Resource.Validation
59+
def batch_callbacks?(_changeset, _opts, _context), do: false
60+
61+
@impl Ash.Resource.Validation
62+
def has_batch_validate?, do: false
5963
end

backend/lib/edgehog/base_images/base_image/validations/base_image_not_in_use.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,10 @@ defmodule Edgehog.BaseImages.BaseImage.Validations.BaseImageNotInUse do
5757
"Base image is currently in use by the following running campaigns: #{campaign_names}"}
5858
end
5959
end
60+
61+
@impl Ash.Resource.Validation
62+
def batch_callbacks?(_changeset, _opts, _context), do: false
63+
64+
@impl Ash.Resource.Validation
65+
def has_batch_validate?, do: false
6066
end

backend/lib/edgehog/campaigns/campaign/validations/require_campaign_mechanism.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,10 @@ defmodule Edgehog.Campaigns.Campaign.Validations.RequireCampaignMechanism do
3939
)}
4040
end
4141
end
42+
43+
@impl Ash.Resource.Validation
44+
def batch_callbacks?(_changeset, _opts, _context), do: false
45+
46+
@impl Ash.Resource.Validation
47+
def has_batch_validate?, do: false
4248
end

backend/lib/edgehog/campaigns/campaign/validations/validate_operation_type_requirements.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ defmodule Edgehog.Campaigns.Campaign.Validations.ValidateOperationTypeRequiremen
5959
end
6060
end
6161

62+
@impl Ash.Resource.Validation
63+
def batch_callbacks?(_changeset, _opts, _context), do: false
64+
65+
@impl Ash.Resource.Validation
66+
def has_batch_validate?, do: false
67+
6268
defp validate_upgrade_requirements(campaign_mechanism, %{tenant: tenant}) do
6369
release_id = Map.get(campaign_mechanism, :release_id)
6470
target_release_id = Map.get(campaign_mechanism, :target_release_id)

backend/lib/edgehog/campaigns/campaign/validations/validate_status.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ defmodule Edgehog.Campaigns.Campaign.Validations.ValidateStatus do
3737
validate_transition(status, operation)
3838
end
3939

40+
@impl Ash.Resource.Validation
41+
def batch_callbacks?(_changeset, _opts, _context), do: false
42+
43+
@impl Ash.Resource.Validation
44+
def has_batch_validate?, do: false
45+
4046
defp validate_transition(status, :pause) do
4147
case status do
4248
:in_progress ->

backend/lib/edgehog/containers/application.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ defmodule Edgehog.Containers.Application do
7373
timestamps()
7474
end
7575

76+
postgres do
77+
table "applications"
78+
end
79+
7680
relationships do
7781
has_many :releases, Edgehog.Containers.Release do
7882
public? true
7983
end
8084
end
81-
82-
postgres do
83-
table "applications"
84-
end
8585
end

backend/lib/edgehog/containers/container/validations/binds_format.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#
21
# This file is part of Edgehog.
32
#
4-
# Copyright 2025 SECO Mind Srl
3+
# Copyright 2025-2026 SECO Mind Srl
54
#
65
# Licensed under the Apache License, Version 2.0 (the "License");
76
# you may not use this file except in compliance with the License.
@@ -16,7 +15,6 @@
1615
# limitations under the License.
1716
#
1817
# SPDX-License-Identifier: Apache-2.0
19-
#
2018

2119
defmodule Edgehog.Containers.Container.Validations.BindsFormat do
2220
@moduledoc false
@@ -57,4 +55,10 @@ defmodule Edgehog.Containers.Container.Validations.BindsFormat do
5755
end
5856

5957
defp valid_bind?(_), do: false
58+
59+
@impl Ash.Resource.Validation
60+
def batch_callbacks?(_changeset, _opts, _context), do: false
61+
62+
@impl Ash.Resource.Validation
63+
def has_batch_validate?, do: false
6064
end

backend/lib/edgehog/containers/container/validations/cpu_period_quota_consistency.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#
21
# This file is part of Edgehog.
32
#
4-
# Copyright 2025 SECO Mind Srl
3+
# Copyright 2025-2026 SECO Mind Srl
54
#
65
# Licensed under the Apache License, Version 2.0 (the "License");
76
# you may not use this file except in compliance with the License.
@@ -16,7 +15,6 @@
1615
# limitations under the License.
1716
#
1817
# SPDX-License-Identifier: Apache-2.0
19-
#
2018

2119
defmodule Edgehog.Containers.Container.Validations.CpuPeriodQuotaConsistency do
2220
@moduledoc false
@@ -56,4 +54,10 @@ defmodule Edgehog.Containers.Container.Validations.CpuPeriodQuotaConsistency do
5654
vars: []
5755
]
5856
end
57+
58+
@impl Ash.Resource.Validation
59+
def batch_callbacks?(_changeset, _opts, _context), do: false
60+
61+
@impl Ash.Resource.Validation
62+
def has_batch_validate?, do: false
5963
end

backend/lib/edgehog/containers/container/validations/volume_target_uniqueness.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#
21
# This file is part of Edgehog.
32
#
4-
# Copyright 2025 SECO Mind Srl
3+
# Copyright 2025-2026 SECO Mind Srl
54
#
65
# Licensed under the Apache License, Version 2.0 (the "License");
76
# you may not use this file except in compliance with the License.
@@ -16,7 +15,6 @@
1615
# limitations under the License.
1716
#
1817
# SPDX-License-Identifier: Apache-2.0
19-
#
2018

2119
defmodule Edgehog.Containers.Container.Validations.VolumeTargetUniqueness do
2220
@moduledoc false
@@ -56,4 +54,10 @@ defmodule Edgehog.Containers.Container.Validations.VolumeTargetUniqueness do
5654
vars: []
5755
]
5856
end
57+
58+
@impl Ash.Resource.Validation
59+
def batch_callbacks?(_changeset, _opts, _context), do: false
60+
61+
@impl Ash.Resource.Validation
62+
def has_batch_validate?, do: false
5963
end

backend/lib/edgehog/containers/deployment/validations/device_is_compatible.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ defmodule Edgehog.Containers.Deployment.Validations.DeviceIsCompatible do
3939
end
4040
end
4141

42+
@impl Ash.Resource.Validation
43+
def batch_callbacks?(_changeset, _opts, _context), do: false
44+
45+
@impl Ash.Resource.Validation
46+
def has_batch_validate?, do: false
47+
4248
defp invalid_argument_error(changeset) do
4349
Ash.Changeset.add_error(
4450
changeset,

0 commit comments

Comments
 (0)