Skip to content

Commit

Permalink
refactor: Add setup for every api group
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Blatt <[email protected]>
  • Loading branch information
MisterMX committed Feb 27, 2024
1 parent c43835f commit bc056bb
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 79 deletions.
17 changes: 0 additions & 17 deletions pkg/controller/doc.go

This file was deleted.

62 changes: 0 additions & 62 deletions pkg/controller/gitlab.go

This file was deleted.

File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions pkg/controller/groups/setup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright 2021 The Crossplane Authors.
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 groups

import (
ctrl "sigs.k8s.io/controller-runtime"

"github.com/crossplane/crossplane-runtime/pkg/controller"

"github.com/crossplane-contrib/provider-gitlab/pkg/controller/groups/deploytokens"
"github.com/crossplane-contrib/provider-gitlab/pkg/controller/groups/groups"
"github.com/crossplane-contrib/provider-gitlab/pkg/controller/groups/members"
"github.com/crossplane-contrib/provider-gitlab/pkg/controller/groups/variables"
)

// Setup all group controllers
func Setup(mgr ctrl.Manager, o controller.Options) error {
for _, setup := range []func(ctrl.Manager, controller.Options) error{
groups.SetupGroup,
members.SetupMember,
deploytokens.SetupDeployToken,
variables.SetupVariable,
} {
if err := setup(mgr, o); err != nil {
return err
}
}
return nil
}
File renamed without changes.
File renamed without changes.
51 changes: 51 additions & 0 deletions pkg/controller/projects/setup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Copyright 2024 The Crossplane Authors.
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 projects

import (
ctrl "sigs.k8s.io/controller-runtime"

"github.com/crossplane/crossplane-runtime/pkg/controller"

"github.com/crossplane-contrib/provider-gitlab/pkg/controller/projects/accesstokens"
"github.com/crossplane-contrib/provider-gitlab/pkg/controller/projects/deploykeys"
"github.com/crossplane-contrib/provider-gitlab/pkg/controller/projects/deploytokens"
"github.com/crossplane-contrib/provider-gitlab/pkg/controller/projects/hooks"
"github.com/crossplane-contrib/provider-gitlab/pkg/controller/projects/members"
"github.com/crossplane-contrib/provider-gitlab/pkg/controller/projects/pipelineschedules"
"github.com/crossplane-contrib/provider-gitlab/pkg/controller/projects/projects"
"github.com/crossplane-contrib/provider-gitlab/pkg/controller/projects/variables"
)

// Setup all project controllers
func Setup(mgr ctrl.Manager, o controller.Options) error {
for _, setup := range []func(ctrl.Manager, controller.Options) error{
projects.SetupProject,
hooks.SetupHook,
members.SetupMember,
deploytokens.SetupDeployToken,
accesstokens.SetupAccessToken,
variables.SetupVariable,
deploykeys.SetupDeployKey,
pipelineschedules.SetupPipelineSchedule,
} {
if err := setup(mgr, o); err != nil {
return err
}
}
return nil
}
42 changes: 42 additions & 0 deletions pkg/controller/setup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2021 The Crossplane Authors.
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 controller

import (
ctrl "sigs.k8s.io/controller-runtime"

"github.com/crossplane/crossplane-runtime/pkg/controller"

"github.com/crossplane-contrib/provider-gitlab/pkg/controller/config"
"github.com/crossplane-contrib/provider-gitlab/pkg/controller/groups"
"github.com/crossplane-contrib/provider-gitlab/pkg/controller/projects"
)

// Setup creates all Gitlab API controllers with the supplied logger and adds
// them to the supplied manager.
func Setup(mgr ctrl.Manager, o controller.Options) error {
for _, setup := range []func(ctrl.Manager, controller.Options) error{
config.Setup,
groups.Setup,
projects.Setup,
} {
if err := setup(mgr, o); err != nil {
return err
}
}
return nil
}

0 comments on commit bc056bb

Please sign in to comment.