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 26, 2024
1 parent 0e11dcb commit 192898d
Show file tree
Hide file tree
Showing 9 changed files with 138 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.
44 changes: 44 additions & 0 deletions pkg/controller/groups/setup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
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/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 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{
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.
52 changes: 52 additions & 0 deletions pkg/controller/projects/setup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
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 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{
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"

Check failure on line 22 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / e2e-tests

other declaration of controller

Check failure on line 22 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / publish-artifacts

other declaration of controller

Check failure on line 22 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / publish-artifacts

other declaration of controller

Check failure on line 22 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / unit-tests

other declaration of controller

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

Check failure on line 25 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / e2e-tests

controller redeclared in this block

Check failure on line 25 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / e2e-tests

"github.com/crossplane-contrib/provider-gitlab/pkg/controller/groups" imported as controller and not used

Check failure on line 25 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / publish-artifacts

controller redeclared in this block

Check failure on line 25 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / publish-artifacts

"github.com/crossplane-contrib/provider-gitlab/pkg/controller/groups" imported as controller and not used

Check failure on line 25 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / publish-artifacts

controller redeclared in this block

Check failure on line 25 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / publish-artifacts

"github.com/crossplane-contrib/provider-gitlab/pkg/controller/groups" imported as controller and not used

Check failure on line 25 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / unit-tests

controller redeclared in this block

Check failure on line 25 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / unit-tests

"github.com/crossplane-contrib/provider-gitlab/pkg/controller/groups" imported as controller and not used
"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,

Check failure on line 34 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / e2e-tests

undefined: groups

Check failure on line 34 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / publish-artifacts

undefined: groups

Check failure on line 34 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / publish-artifacts

undefined: groups

Check failure on line 34 in pkg/controller/setup.go

View workflow job for this annotation

GitHub Actions / unit-tests

undefined: groups
projects.Setup,
} {
if err := setup(mgr, o); err != nil {
return err
}
}
return nil
}

0 comments on commit 192898d

Please sign in to comment.