Skip to content
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: account info and larger refactoring for cluster level CRDs and KCP #202

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bd49d82
fix: update domain references from openmfp.io to openmfp.org
nexus49 Feb 12, 2025
3ee8f16
refactor: Removing namespace subroutine and prepare workspace subroutine
nexus49 Feb 12, 2025
2bc8566
feat: further iterating
nexus49 Feb 18, 2025
abfc839
feat: add start-kcp task to Taskfile
nexus49 Feb 18, 2025
c6d1de4
feat: further test dev
nexus49 Feb 18, 2025
2ada6d7
feat: iterating
nexus49 Feb 18, 2025
4ad7b5a
feat: further test dev
nexus49 Feb 20, 2025
cdcd05c
feat: further test dev
nexus49 Feb 20, 2025
c926428
feat: further test dev
nexus49 Feb 21, 2025
cafdd19
feat: rename AccountLocation to AccountInfo and update related schemas
nexus49 Feb 21, 2025
f1af48a
feat: further iterating, adding accountinfo subroutine
nexus49 Feb 24, 2025
7d491e5
feat: add AccountInfo subroutine and related configurations
nexus49 Feb 25, 2025
7c8d5b5
fix: update domain references from openmfp.io to openmfp.org
nexus49 Feb 12, 2025
f8319f0
refactor: Removing namespace subroutine and prepare workspace subroutine
nexus49 Feb 12, 2025
36f9870
feat: further iterating
nexus49 Feb 18, 2025
de05b60
feat: add start-kcp task to Taskfile
nexus49 Feb 18, 2025
1b5c6d5
feat: further test dev
nexus49 Feb 18, 2025
f5d27c9
feat: iterating
nexus49 Feb 18, 2025
5f4ba36
feat: further test dev
nexus49 Feb 20, 2025
d3ae20d
feat: further test dev
nexus49 Feb 20, 2025
fecfcee
feat: further test dev
nexus49 Feb 21, 2025
0901f4b
feat: rename AccountLocation to AccountInfo and update related schemas
nexus49 Feb 21, 2025
94fde77
feat: further iterating, adding accountinfo subroutine
nexus49 Feb 24, 2025
42d2831
feat: add AccountInfo subroutine and related configurations
nexus49 Feb 25, 2025
4eed860
feat: update dependencies in go.mod and go.sum
nexus49 Feb 25, 2025
51b00f2
Merge remote-tracking branch 'origin/feat/account-info' into feat/acc…
nexus49 Feb 25, 2025
355ea82
feat: update dependencies in go.mod and go.sum
nexus49 Feb 25, 2025
59f3e4a
feat: remove setup-envtest task and update dependencies in Taskfile.yml
nexus49 Feb 25, 2025
8d639aa
feat: reduce default timeout values in account controller and server
nexus49 Feb 25, 2025
ebe4f5e
Update internal/controller/account_controller_test.go
nexus49 Feb 25, 2025
933eaee
Update internal/controller/account_controller_test.go
nexus49 Feb 25, 2025
290f38d
feat: update AccountInfo subroutine to use CAData instead of CAFile
nexus49 Feb 25, 2025
24285af
feat: further iterating, adding accountinfo subroutine
nexus49 Feb 27, 2025
d9b22e8
Merge remote-tracking branch 'origin/feat/account-info' into feat/acc…
nexus49 Feb 27, 2025
afd3e84
refactor: pr feedback
nexus49 Feb 27, 2025
c5a62d1
refactor: pr feedback
nexus49 Feb 27, 2025
c04a71d
refactor: pr feedback
nexus49 Feb 27, 2025
cb71cf0
refactor: pr feedback
nexus49 Feb 27, 2025
c26848b
ci: adjusting pipeline trigger for tagging
nexus49 Feb 27, 2025
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
18 changes: 0 additions & 18 deletions .github/workflows/licenses.yml

This file was deleted.

9 changes: 8 additions & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
name: ci
on: [push]
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize

jobs:
pipe:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Dockerfile.cross
.secret
.env
.taskenv
.kcp/*

# Test binary, built with `go test -c`
*.test
Expand All @@ -29,4 +30,5 @@ go.work
*.swp
*.swo
*~
.DS_Store
.DS_Store
kcp.log
1 change: 1 addition & 0 deletions .testcoverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ exclude:
- api/v1alpha1 # skipping generated files and crd type definitions
- main\.go$ # skip covering main.go
- ^cmd # skip covering cmd directory
- ^pkg/testing/kcpenvtest # skip covering kcpenvtest
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ You are welcome to contribute with your pull requests. These steps explain the c

To let tests run locally, run `go test ./...` in the root directory of the repository.


### Test your change in a locally running OpenMFP instance


```bash
docker build -t account-operator:latest . && \
kind load docker-image account-operator:latest --name=openmfp && \
kubectl patch deployment openmfp-account-operator -n openmfp-system --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/imagePullPolicy", "value": "IfNotPresent"}]' && \
kubectl patch deployment openmfp-account-operator -n openmfp-system --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "account-operator:latest"}]' && \
kubectl rollout restart deployment openmfp-account-operator -n openmfp-system && \
kubectl rollout status deployment openmfp-account-operator -n openmfp-system
```
## Issues
We use GitHub issues to track bugs. Please ensure your description is
clear and includes sufficient instructions to reproduce the issue.
Expand Down
20 changes: 0 additions & 20 deletions PROJECT

This file was deleted.

32 changes: 22 additions & 10 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,29 @@ vars:
CONTROLLER_TOOLS_VERSION: v0.14.0
ENVTEST_K8S_VERSION: "1.29.0"
ENVTEST_VERSION: release-0.17
CRD_DIRECTORY: config/crd/bases
CRD_DIRECTORY: config/crd
TEST_SETUP_DIRECTORY: test/setup/01-openmfp-system
KCP_APIGEN_VERSION: v0.21.0
KCP_VERSION: 0.26.1
GOMPLATE_VERSION: v4.3.0
GOARCH:
sh: go env GOARCH
GOOS:
sh: go env GOOS
tasks:
## Setup
setup:controller-gen:
internal: true
cmds:
- test -s {{.LOCAL_BIN}}/controller-gen || GOBIN=$(pwd)/{{.LOCAL_BIN}} go install sigs.k8s.io/controller-tools/cmd/controller-gen@{{.CONTROLLER_TOOLS_VERSION}}
setup:envtest:
setup:kcp:
internal: true
cmds:
- test -s {{.LOCAL_BIN}}/setup-envtest|| GOBIN=$(pwd)/{{.LOCAL_BIN}} go install sigs.k8s.io/controller-runtime/tools/setup-envtest@{{.ENVTEST_VERSION}}
- test -s {{.LOCAL_BIN}}/kcp || GOBIN=$(pwd)/{{.LOCAL_BIN}} ./hack/download-tool.sh https://github.com/kcp-dev/kcp/releases/download/v{{ .KCP_VERSION }}/kcp_{{ .KCP_VERSION }}_{{ .GOOS }}_{{ .GOARCH }}.tar.gz kcp {{.KCP_VERSION}}
setup:gomplate:
internal: true
cmds:
- test -s {{.LOCAL_BIN}}/gomplate || curl -o {{.LOCAL_BIN}}/gomplate -sSL https://github.com/hairyhenderson/gomplate/releases/download/{{ .GOMPLATE_VERSION }}/gomplate_{{ .GOOS }}-{{ .GOARCH }} && chmod +x {{.LOCAL_BIN}}/gomplate && chmod 755 {{.LOCAL_BIN}}/gomplate
setup:golangci-lint:
internal: true
cmds:
Expand All @@ -36,7 +47,8 @@ tasks:
cmds:
- task: manifests
- "{{.LOCAL_BIN}}/controller-gen object:headerFile=hack/boilerplate.go.txt paths=./..."
- "{{.LOCAL_BIN}}/apigen --input-dir ./config/crd/bases --output-dir ./config/resources"
- "{{.LOCAL_BIN}}/apigen --input-dir {{.CRD_DIRECTORY}} --output-dir ./config/resources"
- "{{.LOCAL_BIN}}/apigen --input-dir {{.CRD_DIRECTORY}} --output-dir {{ .TEST_SETUP_DIRECTORY }}"
build:
cmds:
- go build ./...
Expand All @@ -53,18 +65,14 @@ tasks:
- task: fmt
- "{{.LOCAL_BIN}}/golangci-lint run --timeout 15m ./..."
envtest:
env:
KUBEBUILDER_ASSETS:
sh: $(pwd)/{{.LOCAL_BIN}}/setup-envtest use {{.ENVTEST_K8S_VERSION}} --bin-dir $(pwd)/{{.LOCAL_BIN}} -p path
GO111MODULE: on
cmds:
- go test ./... {{.ADDITIONAL_COMMAND_ARGS}}
test:
deps: [setup:envtest]
deps: [setup:kcp, setup:gomplate]
cmds:
- task: envtest
cover:
deps: [setup:envtest]
deps: [setup:kcp, setup:gomplate]
cmds:
- task: envtest
vars:
Expand All @@ -76,4 +84,8 @@ tasks:
cmds:
- task: lint
- task: test
start-kcp:
deps: [setup:kcp]
cmds:
- "{{ .LOCAL_BIN}}/kcp start"

79 changes: 79 additions & 0 deletions api/v1alpha1/account_info_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
Copyright 2024.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// AccountInfoSpec defines the desired state of Account
type AccountInfoSpec struct {
FGA FGAInfo `json:"fga"`
Account AccountLocation `json:"account"`
ParentAccount *AccountLocation `json:"parentAccount,omitempty"`
Organization AccountLocation `json:"organization"`
Comment on lines +26 to +28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some descriptive comments would be helpful to be able to distinguish as a consumer of that resource between the specifics of these fields - also maybe including some information on what is published depending on what account type we have at hand

ClusterInfo ClusterInfo `json:"clusterInfo"`
}

type ClusterInfo struct {
CA string `json:"ca"`
}

type AccountLocation struct {
Name string `json:"name"`
ClusterId string `json:"clusterId"`
Path string `json:"path"`
URL string `json:"url"`
Type AccountType `json:"type"`
}

type FGAInfo struct {
Store StoreInfo `json:"store"`
}

type StoreInfo struct {
Id string `json:"id"`
}

// AccountInfoStatus defines the observed state of AccountInfo
type AccountInfoStatus struct {
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=accountinfos
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// AccountInfo is the Schema for the accountinfo API
type AccountInfo struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AccountInfoSpec `json:"spec,omitempty"`
Status AccountInfoStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
// AccountInfoList contains a list of AccountInfos
type AccountInfoList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []AccountInfo `json:"items"`
}

func init() {
SchemeBuilder.Register(&AccountInfo{}, &AccountInfoList{})
}
19 changes: 8 additions & 11 deletions api/v1alpha1/account_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,18 @@ import (
type AccountType string

const (
AccountTypeFolder AccountType = "folder"
AccountTypeOrg AccountType = "org"
AccountTypeAccount AccountType = "account"
NamespaceAccountOwnerLabel = "account.core.openmfp.io/owner"
NamespaceAccountOwnerNamespaceLabel = "account.core.openmfp.io/owner-namespace"
NamespaceAccountOwnerLabel = "account.core.openmfp.org/owner"
NamespaceAccountOwnerNamespaceLabel = "account.core.openmfp.org/owner-namespace"
)

// AccountSpec defines the desired state of Account
type AccountSpec struct {
// Type specifies the intended type for this Account object.
// +kubebuilder:validation:Enum=folder;account
// +kubebuilder:validation:Enum=org;account
Type AccountType `json:"type"`

// Namespace is the account should take ownership of
Namespace *string `json:"namespace,omitempty"`

// The display name for this account
// +kubebuilder:validation:MaxLength=255
DisplayName string `json:"displayName"`
Expand Down Expand Up @@ -69,15 +66,15 @@ type Extension struct {
// AccountStatus defines the observed state of Account
type AccountStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty"`
Namespace *string `json:"namespace,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"`
NextReconcileTime metav1.Time `json:"nextReconcileTime,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:printcolumn:JSONPath=".spec.displayName",name="Display Name",type=string
// +kubebuilder:printcolumn:JSONPath=".status.namespace",name="Account Namespace",type=string
// +kubebuilder:printcolumn:JSONPath=".status.namespace",name="Account Workspace",type=string
// +kubebuilder:printcolumn:JSONPath=".spec.type",name="Type",type=string
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`

Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

// Package v1alpha1 contains API Schema definitions for the core v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=core.openmfp.io
// +groupName=core.openmfp.org
package v1alpha1

import (
Expand All @@ -26,7 +26,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "core.openmfp.io", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "core.openmfp.org", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
Loading
Loading