-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: fully support project CRD #1388
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
73adf5d
resource type changes
krancour 82c4220
corresponding protobuf changes
krancour 336b8a8
run codegen
krancour a3cb70e
corresponding type conversion changes
krancour d265b8c
corresponding api server endpoint changes
krancour f87dd66
make api server apply projects before other resource types
krancour 876e935
corresponding cli changes
krancour 52cb918
create project webhook
krancour 97b960a
corresponding controller changes
krancour 0981640
corresponding garbage collector changes
krancour 4fc3c02
corresponding chart changes
krancour bbcc79f
corresponding ui changes
krancour 43ac0d5
go mod tidy
krancour 18cc23a
corresponding tilt changes
krancour 83e8283
additional predicate and comments on namespace reconciler
krancour File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ package v1alpha1 | |
|
||
const ( | ||
AliasLabelKey = "kargo.akuity.io/alias" | ||
LabelProjectKey = "kargo.akuity.io/project" | ||
FreightLabelKey = "kargo.akuity.io/freight" | ||
ProjectLabelKey = "kargo.akuity.io/project" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed this symbol just for consistency with the others. |
||
ShardLabelKey = "kargo.akuity.io/shard" | ||
StageLabelKey = "kargo.akuity.io/stage" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
"k8s.io/apimachinery/pkg/types" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
// GetProject returns a pointer to the cluster-scoped Project resource specified | ||
// by the name argument. If no such resource is found, nil is returned instead. | ||
func GetProject( | ||
ctx context.Context, | ||
c client.Client, | ||
name string, | ||
) (*Project, error) { | ||
project := Project{} | ||
if err := c.Get( | ||
ctx, types.NamespacedName{ | ||
Name: name, | ||
}, | ||
&project, | ||
); err != nil { | ||
if err = client.IgnoreNotFound(err); err == nil { | ||
return nil, nil | ||
} | ||
return nil, errors.Wrapf(err, "error getting Project %q", name) | ||
} | ||
return &project, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
k8sruntime "k8s.io/apimachinery/pkg/runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/client/fake" | ||
) | ||
|
||
func TestGetProject(t *testing.T) { | ||
scheme := k8sruntime.NewScheme() | ||
require.NoError(t, SchemeBuilder.AddToScheme(scheme)) | ||
|
||
testCases := []struct { | ||
name string | ||
client client.Client | ||
assertions func(*Project, error) | ||
}{ | ||
{ | ||
name: "not found", | ||
client: fake.NewClientBuilder().WithScheme(scheme).Build(), | ||
assertions: func(project *Project, err error) { | ||
require.NoError(t, err) | ||
require.Nil(t, project) | ||
}, | ||
}, | ||
|
||
{ | ||
name: "found", | ||
client: fake.NewClientBuilder().WithScheme(scheme).WithObjects( | ||
&Project{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "fake-project", | ||
}, | ||
}, | ||
).Build(), | ||
assertions: func(project *Project, err error) { | ||
require.NoError(t, err) | ||
require.Equal(t, "fake-project", project.Name) | ||
}, | ||
}, | ||
} | ||
|
||
for _, testCase := range testCases { | ||
t.Run(testCase.name, func(t *testing.T) { | ||
project, err := GetProject( | ||
context.Background(), | ||
testCase.client, | ||
"fake-project", | ||
) | ||
testCase.assertions(project, err) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,21 @@ webhooks: | |
resources: ["freights"] | ||
operations: ["CREATE", "UPDATE", "DELETE"] | ||
failurePolicy: Fail | ||
- name: project.kargo.akuity.io | ||
admissionReviewVersions: ["v1"] | ||
sideEffects: None | ||
clientConfig: | ||
service: | ||
namespace: {{ .Release.Namespace }} | ||
name: kargo-webhooks-server | ||
path: /validate-kargo-akuity-io-v1alpha1-project | ||
rules: | ||
- scope: Cluster | ||
apiGroups: ["kargo.akuity.io"] | ||
apiVersions: ["v1alpha1"] | ||
resources: ["projects"] | ||
operations: ["CREATE"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the moment, only need to validate creates. |
||
failurePolicy: Fail | ||
- name: promotion.kargo.akuity.io | ||
admissionReviewVersions: ["v1"] | ||
sideEffects: None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This moved to
types.proto
where we have the protobuf definitions of anything that's also a CRD.