Failing on KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined

This commit is contained in:
Chris Stuurman 2024-03-21 19:10:12 +02:00
parent ab1d643157
commit d71658e83a
4 changed files with 15 additions and 13 deletions

View File

@ -1,5 +1,7 @@
FROM golang:1.21-alpine3.18 AS build_deps FROM golang:1.21-alpine3.18 AS build_deps
ARG GROUP_NAME=api.sthome.net
RUN apk add --no-cache git RUN apk add --no-cache git
WORKDIR /workspace WORKDIR /workspace

19
main.go
View File

@ -6,6 +6,7 @@ import (
"os" "os"
extapi "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" extapi "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
"github.com/cert-manager/cert-manager/pkg/acme/webhook/apis/acme/v1alpha1" "github.com/cert-manager/cert-manager/pkg/acme/webhook/apis/acme/v1alpha1"
@ -13,7 +14,7 @@ import (
) )
const ( const (
providerName = "sthome" providerName = "sthome-solver"
) )
var GroupName = os.Getenv("GROUP_NAME") var GroupName = os.Getenv("GROUP_NAME")
@ -44,7 +45,7 @@ type customDNSProviderSolver struct {
// 3. uncomment the relevant code in the Initialize method below // 3. uncomment the relevant code in the Initialize method below
// 4. ensure your webhook's service account has the required RBAC role // 4. ensure your webhook's service account has the required RBAC role
// assigned to it for interacting with the Kubernetes APIs you need. // assigned to it for interacting with the Kubernetes APIs you need.
//client kubernetes.Clientset client kubernetes.Clientset
} }
// customDNSProviderConfig is a structure that is used to decode into when // customDNSProviderConfig is a structure that is used to decode into when
@ -67,7 +68,7 @@ type customDNSProviderConfig struct {
// These fields will be set by users in the // These fields will be set by users in the
// `issuer.spec.acme.dns01.providers.webhook.config` field. // `issuer.spec.acme.dns01.providers.webhook.config` field.
//Email string `json:"email"` Email string `json:"email"`
//APIKeySecretRef v1alpha1.SecretKeySelector `json:"apiKeySecretRef"` //APIKeySecretRef v1alpha1.SecretKeySelector `json:"apiKeySecretRef"`
} }
@ -123,12 +124,12 @@ func (c *customDNSProviderSolver) Initialize(kubeClientConfig *rest.Config, stop
///// UNCOMMENT THE BELOW CODE TO MAKE A KUBERNETES CLIENTSET AVAILABLE TO ///// UNCOMMENT THE BELOW CODE TO MAKE A KUBERNETES CLIENTSET AVAILABLE TO
///// YOUR CUSTOM DNS PROVIDER ///// YOUR CUSTOM DNS PROVIDER
//cl, err := kubernetes.NewForConfig(kubeClientConfig) cl, err := kubernetes.NewForConfig(kubeClientConfig)
//if err != nil { if err != nil {
// return err return err
//} }
//
//c.client = cl c.client = *cl
///// END OF CODE TO MAKE KUBERNETES CLIENTSET AVAILABLE ///// END OF CODE TO MAKE KUBERNETES CLIENTSET AVAILABLE
return nil return nil

View File

@ -22,13 +22,13 @@ func TestRunsSuite(t *testing.T) {
//fixture := acmetest.NewFixture(&customDNSProviderSolver{}, //fixture := acmetest.NewFixture(&customDNSProviderSolver{},
// acmetest.SetResolvedZone(zone), // acmetest.SetResolvedZone(zone),
// acmetest.SetAllowAmbientCredentials(false), // acmetest.SetAllowAmbientCredentials(false),
// acmetest.SetManifestPath("testdata/my-custom-solver"), // acmetest.SetManifestPath("testdata/sthome-solver"),
// acmetest.SetBinariesPath("_test/kubebuilder/bin"), // acmetest.SetBinariesPath("_test/kubebuilder/bin"),
//) //)
solver := sthome.New("59351") solver := sthome.New("59351")
fixture := acmetest.NewFixture(solver, fixture := acmetest.NewFixture(solver,
acmetest.SetResolvedZone("sthome.net."), acmetest.SetResolvedZone("sthome.net."),
acmetest.SetManifestPath("testdata/my-custom-solver"), acmetest.SetManifestPath("testdata/sthome-solver"),
acmetest.SetDNSServer("127.0.0.1:59351"), acmetest.SetDNSServer("127.0.0.1:59351"),
acmetest.SetUseAuthoritative(false), acmetest.SetUseAuthoritative(false),
) )

View File

@ -1,5 +1,4 @@
// package sthome contains a self-contained sthome of a webhook that passes the cert-manager // must pass cert-manager DNS conformance tests
// DNS conformance tests
package sthome package sthome
import ( import (