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 6 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.

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
20 changes: 0 additions & 20 deletions PROJECT

This file was deleted.

19 changes: 17 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ 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/openmfp-system
KCP_APIGEN_VERSION: v0.21.0
KCP_VERSION: 0.26.1
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:kcp:
internal: true
cmds:
- 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:envtest:
internal: true
cmds:
Expand All @@ -36,7 +46,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 Down Expand Up @@ -76,4 +87,8 @@ tasks:
cmds:
- task: lint
- task: test
start-kcp:
deps: [setup:kcp]
cmds:
- "{{ .LOCAL_BIN}}/kcp start"

54 changes: 54 additions & 0 deletions api/v1alpha1/account_info_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
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"
)

// AccountLocationSpec defines the desired state of Account
type AccountLocationSpec struct {
}

// AccountLocationStatus defines the observed state of Account
type AccountLocationStatus struct {
}

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

Spec AccountLocationSpec `json:"spec,omitempty"`
Status AccountLocationStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// AccountLocationList contains a list of Account
type AccountLocationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Account `json:"items"`
}

func init() {
SchemeBuilder.Register(&AccountLocation{}, &AccountLocationList{})
}
5 changes: 3 additions & 2 deletions api/v1alpha1/account_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type AccountType string
const (
AccountTypeFolder AccountType = "folder"
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
Expand Down Expand Up @@ -76,6 +76,7 @@ type AccountStatus struct {

//+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=".spec.type",name="Type",type=string
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
106 changes: 105 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 11 additions & 17 deletions cmd/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook"

tenancyv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1"

"github.com/openmfp/account-operator/api/v1alpha1"
"github.com/openmfp/account-operator/internal/config"
"github.com/openmfp/account-operator/internal/controller"
Expand Down Expand Up @@ -97,10 +98,7 @@ func RunController(_ *cobra.Command, _ []string) { // coverage-ignore
tlsOpts = append(tlsOpts, disableHTTP2)
}

if cfg.Kcp.Enabled {
utilruntime.Must(tenancyv1alpha1.AddToScheme(scheme))
}

utilruntime.Must(tenancyv1alpha1.AddToScheme(scheme))
webhookServer := webhook.NewServer(webhook.Options{
TLSOpts: tlsOpts,
CertDir: cfg.Webhooks.CertDir,
Expand All @@ -117,21 +115,17 @@ func RunController(_ *cobra.Command, _ []string) { // coverage-ignore
WebhookServer: webhookServer,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "8c290d9a.openmfp.io",
LeaderElectionID: "8c290d9a.openmfp.org",
LeaderElectionConfig: restCfg,
LeaderElectionReleaseOnCancel: true,
}
var mgr ctrl.Manager
var err error
if cfg.Kcp.Enabled {
mgrConfig := rest.CopyConfig(restCfg)
if len(cfg.Kcp.VirtualWorkspaceUrl) > 0 {
mgrConfig.Host = cfg.Kcp.VirtualWorkspaceUrl
}
mgr, err = kcp.NewClusterAwareManager(mgrConfig, opts)
} else {
mgr, err = ctrl.NewManager(restCfg, opts)
mgrConfig := rest.CopyConfig(restCfg)
if len(cfg.Kcp.VirtualWorkspaceUrl) > 0 {
mgrConfig.Host = cfg.Kcp.VirtualWorkspaceUrl
}
mgr, err = kcp.NewClusterAwareManager(mgrConfig, opts)
if err != nil {
log.Fatal().Err(err).Msg("unable to start manager")
}
Expand Down Expand Up @@ -161,10 +155,10 @@ func RunController(_ *cobra.Command, _ []string) { // coverage-ignore
}

func initLog() *logger.Logger { // coverage-ignore
logcfg := logger.DefaultConfig()
logcfg.Level = loglevel
logcfg.NoJSON = logNoJson
log, err := logger.New(logcfg)
cfg := logger.DefaultConfig()
cfg.Level = loglevel
cfg.NoJSON = logNoJson
log, err := logger.New(cfg)
if err != nil {
setupLog.Error(err, "unable to create logger")
os.Exit(1)
Expand Down
Loading
Loading