Skip to content

Commit

Permalink
move reconciler
Browse files Browse the repository at this point in the history
  • Loading branch information
skonto committed Apr 24, 2024
1 parent a279ff7 commit 740f03a
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 45 deletions.
4 changes: 2 additions & 2 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"knative.dev/pkg/reconciler"
"knative.dev/pkg/signals"
"knative.dev/pkg/system"
"knative.dev/serving/pkg/netcertmanager"
"knative.dev/serving/pkg/reconciler/certificate"
"knative.dev/serving/pkg/reconciler/configuration"
"knative.dev/serving/pkg/reconciler/domainmapping"
"knative.dev/serving/pkg/reconciler/gc"
Expand Down Expand Up @@ -85,7 +85,7 @@ func main() {
for _, inf := range []injection.InformerInjector{challenge.WithInformer, v1certificate.WithInformer, certificaterequest.WithInformer, clusterissuer.WithInformer, issuer.WithInformer} {
injection.Default.RegisterInformer(inf)
}
ctors = append(ctors, netcertmanager.NewController)
ctors = append(ctors, certificate.NewController)
}

sharedmain.MainWithConfig(ctx, "controller", cfg, ctors...)
Expand Down
2 changes: 1 addition & 1 deletion cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"context"
certconfig "knative.dev/serving/pkg/reconciler/certificate/config"

"k8s.io/apimachinery/pkg/runtime/schema"
"knative.dev/pkg/configmap"
Expand Down Expand Up @@ -49,7 +50,6 @@ import (
autoscalerconfig "knative.dev/serving/pkg/autoscaler/config"
"knative.dev/serving/pkg/deployment"
"knative.dev/serving/pkg/gc"
certconfig "knative.dev/serving/pkg/netcertmanager/config"
domainconfig "knative.dev/serving/pkg/reconciler/route/config"
)

Expand Down
1 change: 0 additions & 1 deletion pkg/netcertmanager/config/testdata/config-certmanager.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions pkg/netcertmanager/doc.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package netcertmanager
package certificate

import (
"context"
"fmt"
"hash/adler32"
"knative.dev/serving/pkg/reconciler/certificate/config"
"knative.dev/serving/pkg/reconciler/certificate/resources"
"strconv"
"time"

Expand All @@ -46,8 +48,6 @@ import (
certmanagerclientset "knative.dev/serving/pkg/netcertmanager/client/certmanager/clientset/versioned"
acmelisters "knative.dev/serving/pkg/netcertmanager/client/certmanager/listers/acme/v1"
certmanagerlisters "knative.dev/serving/pkg/netcertmanager/client/certmanager/listers/certmanager/v1"
"knative.dev/serving/pkg/netcertmanager/config"
"knative.dev/serving/pkg/netcertmanager/resources"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package netcertmanager
package certificate

import (
"context"
"errors"
"fmt"
"hash/adler32"
testing3 "knative.dev/serving/pkg/netcertmanager/testing"
"knative.dev/serving/pkg/reconciler/certificate/config"
"knative.dev/serving/pkg/reconciler/certificate/resources"
"testing"
"time"

netcertmanageronfig "knative.dev/serving/pkg/netcertmanager/config"
"knative.dev/serving/pkg/netcertmanager/resources"
netcertmanagertesting "knative.dev/serving/pkg/netcertmanager/testing"

acmev1 "github.com/cert-manager/cert-manager/pkg/apis/acme/v1"
cmv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
cmmeta "github.com/cert-manager/cert-manager/pkg/apis/meta/v1"
Expand Down Expand Up @@ -112,7 +111,7 @@ func TestNewController(t *testing.T) {

configMapWatcher := configmap.NewStaticWatcher(&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: netcertmanageronfig.CertManagerConfigName,
Name: config.CertManagerConfigName,
Namespace: system.Namespace(),
},
Data: map[string]string{
Expand Down Expand Up @@ -559,7 +558,7 @@ func TestReconcile(t *testing.T) {
}},
}}

table.Test(t, netcertmanagertesting.MakeFactory(func(ctx context.Context, listers *netcertmanagertesting.Listers, cmw configmap.Watcher) controller.Reconciler {
table.Test(t, testing3.MakeFactory(func(ctx context.Context, listers *testing3.Listers, cmw configmap.Watcher) controller.Reconciler {
retryAttempted = false
r := &Reconciler{
cmCertificateLister: listers.GetCMCertificateLister(),
Expand All @@ -573,7 +572,7 @@ func TestReconcile(t *testing.T) {
listers.GetCertificateLister(), controller.GetEventRecorder(ctx), r,
netcfg.CertManagerCertificateClassName, controller.Options{
ConfigStore: &testConfigStore{
config: &netcertmanageronfig.Config{
config: &config.Config{
CertManager: certmanagerConfig(),
},
},
Expand Down Expand Up @@ -748,7 +747,7 @@ func TestReconcile_HTTP01Challenges(t *testing.T) {
},
}}

table.Test(t, netcertmanagertesting.MakeFactory(func(ctx context.Context, listers *netcertmanagertesting.Listers, cmw configmap.Watcher) controller.Reconciler {
table.Test(t, testing3.MakeFactory(func(ctx context.Context, listers *testing3.Listers, cmw configmap.Watcher) controller.Reconciler {
r := &Reconciler{
cmCertificateLister: listers.GetCMCertificateLister(),
cmChallengeLister: listers.GetCMChallengeLister(),
Expand All @@ -761,7 +760,7 @@ func TestReconcile_HTTP01Challenges(t *testing.T) {
listers.GetCertificateLister(), controller.GetEventRecorder(ctx), r,
netcfg.CertManagerCertificateClassName, controller.Options{
ConfigStore: &testConfigStore{
config: &netcertmanageronfig.Config{
config: &config.Config{
CertManager: certmanagerConfig(),
},
},
Expand All @@ -770,17 +769,17 @@ func TestReconcile_HTTP01Challenges(t *testing.T) {
}

type testConfigStore struct {
config *netcertmanageronfig.Config
config *config.Config
}

func (t *testConfigStore) ToContext(ctx context.Context) context.Context {
return netcertmanageronfig.ToContext(ctx, t.config)
return config.ToContext(ctx, t.config)
}

var _ pkgreconciler.ConfigStore = (*testConfigStore)(nil)

func certmanagerConfig() *netcertmanageronfig.CertManagerConfig {
return &netcertmanageronfig.CertManagerConfig{
func certmanagerConfig() *config.CertManagerConfig {
return &config.CertManagerConfig{
IssuerRef: &cmmeta.ObjectReference{
Kind: "ClusterIssuer",
Name: "Letsencrypt-issuer",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package netcertmanager
package certificate

import (
"context"

"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/tools/cache"
"knative.dev/serving/pkg/reconciler/certificate/config"

netapi "knative.dev/networking/pkg/apis/networking"
"knative.dev/networking/pkg/apis/networking/v1alpha1"
Expand All @@ -38,7 +38,6 @@ import (
cmchallengeinformer "knative.dev/serving/pkg/netcertmanager/client/certmanager/injection/informers/acme/v1/challenge"
cmcertinformer "knative.dev/serving/pkg/netcertmanager/client/certmanager/injection/informers/certmanager/v1/certificate"
clusterinformer "knative.dev/serving/pkg/netcertmanager/client/certmanager/injection/informers/certmanager/v1/clusterissuer"
netcertmanageronfig "knative.dev/serving/pkg/netcertmanager/config"
)

const controllerAgentName = "certificate-controller"
Expand Down Expand Up @@ -82,7 +81,7 @@ func NewController(

impl := certreconciler.NewImpl(ctx, c, netcfg.CertManagerCertificateClassName,
func(impl *controller.Impl) controller.Options {
configStore := netcertmanageronfig.NewStore(logger.Named("config-store"), configmap.TypeFilter(&netcertmanageronfig.CertManagerConfig{})(func(string, interface{}) {
configStore := config.NewStore(logger.Named("config-store"), configmap.TypeFilter(&config.CertManagerConfig{})(func(string, interface{}) {
impl.FilteredGlobalResync(classFilterFunc, knCertificateInformer.Informer())
}))
configStore.WatchConfigs(cmw)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package resources

import (
"fmt"
"knative.dev/serving/pkg/reconciler/certificate/config"

cmv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
cmeta "github.com/cert-manager/cert-manager/pkg/apis/meta/v1"
Expand All @@ -28,7 +29,6 @@ import (
netapi "knative.dev/networking/pkg/config"
"knative.dev/pkg/apis"
"knative.dev/pkg/kmeta"
"knative.dev/serving/pkg/netcertmanager/config"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package resources

import (
"fmt"
"knative.dev/serving/pkg/reconciler/certificate/config"
"strings"
"testing"

Expand All @@ -31,7 +32,6 @@ import (
"knative.dev/networking/pkg/apis/networking"
"knative.dev/networking/pkg/apis/networking/v1alpha1"
"knative.dev/pkg/kmeta"
"knative.dev/serving/pkg/netcertmanager/config"
)

const (
Expand Down

0 comments on commit 740f03a

Please sign in to comment.