Skip to content

Commit

Permalink
Pre-release fixups (#1273)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino authored Aug 9, 2024
1 parent f1c1ac7 commit 047b665
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go/controller/internal/controller/project_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (in *ProjectReconciler) addOrRemoveFinalizer(ctx context.Context, project *
// If it fails to delete the external dependency here, return with error
// so that it can be retried.
utils.MarkCondition(project.SetCondition, v1alpha1.SynchronizedConditionType, v1.ConditionFalse, v1alpha1.SynchronizedConditionReasonError, err.Error())
return &ctrl.Result{}
return &requeue
}

// project deletion is synchronous so can just fall back to removing the finalizer and reconciling
Expand Down
2 changes: 1 addition & 1 deletion lib/console/deployments/pipelines.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ defmodule Console.Deployments.Pipelines do
|> add_operation(:pipe, fn _ ->
case pipe do
%Pipeline{} = pipe -> pipe
nil -> %Pipeline{project_id: Settings.default_project!().id}
nil -> %Pipeline{project_id: attrs[:project_id] || Settings.default_project!().id}
end
|> ok()
end)
Expand Down
1 change: 1 addition & 0 deletions lib/console/schema/stage_service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ defmodule Console.Schema.StageService do
|> foreign_key_constraint(:stage_id)
|> foreign_key_constraint(:service_id)
|> foreign_key_constraint(:criteria_id)
|> unique_constraint(:service_id)
|> unique_constraint([:stage_id, :service_id])
end
end
14 changes: 14 additions & 0 deletions test/console/deployments/clusters_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,20 @@ defmodule Console.Deployments.ClustersTest do
assert svc.helm.values == "bogus: values"
end

test "it will respect project rbac" do
user = insert(:user)
proj = insert(:project, write_bindings: [%{user_id: user.id}])
deployment_settings(read_bindings: [%{user_id: user.id}])

{:ok, cluster} = Clusters.create_cluster(%{
name: "test",
project_id: proj.id
}, user)

assert cluster.name == "test"
assert cluster.project_id == proj.id
end

test "it will respect rbac" do
user = insert(:user)
deployment_settings(create_bindings: [%{user_id: user.id}])
Expand Down
21 changes: 20 additions & 1 deletion test/console/deployments/pipelines_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ defmodule Console.Deployments.PipelinesTest do

test "it will respect rbac" do
user = insert(:user)
project = insert(:project, write_bindings: [%{user_id: user.id}])
[svc, svc2] = insert_list(2, :service)
pipe = insert(:pipeline, name: "my-pipeline", write_bindings: [%{user_id: user.id}])
dev = insert(:pipeline_stage, pipeline: pipe, name: "dev")
Expand Down Expand Up @@ -163,6 +164,24 @@ defmodule Console.Deployments.PipelinesTest do
}, "my-pipeline", insert(:user))


[svc, svc2] = insert_list(2, :service)
{:ok, pipe} = Pipelines.upsert(%{
project_id: project.id,
stages: [
%{name: "dev", services: [%{name: svc.name, handle: svc.cluster.handle}]},
%{name: "prod", services: [
%{name: svc2.name, handle: svc2.cluster.handle, criteria: %{
name: svc.name,
handle: svc.cluster.handle,
secrets: ["test-secret"]
}},
]}
],
edges: [%{from: "dev", to: "prod"}]
}, "new-pipeline", user)

assert pipe.project_id == project.id

[svc, svc2] = insert_list(2, :service)
user = insert(:user)
{:error, _} = Pipelines.upsert(%{
Expand All @@ -178,7 +197,7 @@ defmodule Console.Deployments.PipelinesTest do
]}
],
edges: [%{from: "dev", to: "prod"}]
}, "new-pipeline", user)
}, "new-pipeline-2", user)
end
end

Expand Down

0 comments on commit 047b665

Please sign in to comment.