Moved sthome kacgae to pkg/dns. Simplified config.go
This commit is contained in:
parent
99642343d1
commit
5b51498b5b
@ -1,5 +1,5 @@
|
||||
apiVersion: v1
|
||||
appVersion: v0.0.4-alpha.100
|
||||
appVersion: v0.0.4-alpha.107
|
||||
description: Cert-Manager webhook for sthome
|
||||
name: sthome-webhook
|
||||
version: 0.0.4-alpha.100
|
||||
version: 0.0.4-alpha.107
|
||||
|
||||
@ -31,7 +31,7 @@ clusterIssuer:
|
||||
image:
|
||||
repository: stuurmcp/cert-manager-webhook-sthome
|
||||
#repository: wstat.sthome.net:5000/cert-manager-webhook-sthome
|
||||
tag: 0.0.4-alpha.100
|
||||
tag: 0.0.4-alpha.107
|
||||
#pullPolicy should be IfNotPresent. Set to Always for testing purposes
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
|
||||
4
go.mod
4
go.mod
@ -6,8 +6,7 @@ toolchain go1.22.1
|
||||
|
||||
require (
|
||||
github.com/cert-manager/cert-manager v1.14.4
|
||||
github.com/miekg/dns v1.1.58
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/miekg/dns v1.1.58 // indirect
|
||||
k8s.io/api v0.29.0
|
||||
k8s.io/apiextensions-apiserver v0.29.0
|
||||
k8s.io/client-go v0.29.0
|
||||
@ -59,7 +58,6 @@ require (
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/prometheus/client_golang v1.18.0 // indirect
|
||||
github.com/prometheus/client_model v0.5.0 // indirect
|
||||
github.com/prometheus/common v0.45.0 // indirect
|
||||
|
||||
2
main.go
2
main.go
@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/cert-manager/cert-manager/pkg/acme/webhook/cmd"
|
||||
|
||||
"github.com/stuurmcp/cert-manager-webhook-sthome/sthome"
|
||||
sthome "github.com/stuurmcp/cert-manager-webhook-sthome/pkg/dns"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package sthome
|
||||
package dns
|
||||
|
||||
import (
|
||||
"strings"
|
||||
@ -39,26 +39,26 @@ type LocalDNSProviderConfig struct {
|
||||
// secret which contains the sthome API Key.
|
||||
APIKeySecretRef v1.SecretKeySelector `json:"apiKeySecretRef"`
|
||||
// Host is the Base URL (e.g. https://dns.example.ca) of the sthome API.
|
||||
Host string `json:"host"`
|
||||
//Host string `json:"host"`
|
||||
|
||||
// Scheme supports HTTP AuthSchemes
|
||||
// https://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml
|
||||
//
|
||||
// +optional default ""
|
||||
APIKeyScheme string `json:"apiKeyScheme"`
|
||||
//APIKeyScheme string `json:"apiKeyScheme"`
|
||||
|
||||
// APIKeyHeaderName is the header name where apiKey will be set
|
||||
//
|
||||
// +optional default "X-API-Key"
|
||||
APIKeyHeaderName string `json:"apiKeyHeaderName"`
|
||||
//APIKeyHeaderName string `json:"apiKeyHeaderName"`
|
||||
|
||||
// ServerID is the server ID in the sthome API.
|
||||
// When unset, defaults to "localhost".
|
||||
ServerID string `json:"serverID"`
|
||||
//ServerID string `json:"serverID"`
|
||||
|
||||
// Headers are additional headers added to requests to the
|
||||
// sthome API server.
|
||||
Headers map[string]string `json:"headers"`
|
||||
//Headers map[string]string `json:"headers"`
|
||||
|
||||
// CABundle is a PEM encoded CA bundle which will be used in
|
||||
// certificate validation when connecting to the sthome server.
|
||||
@ -66,18 +66,18 @@ type LocalDNSProviderConfig struct {
|
||||
// When left blank, the default system store will be used.
|
||||
//
|
||||
// +optional
|
||||
CABundle []byte `json:"caBundle"`
|
||||
//CABundle []byte `json:"caBundle"`
|
||||
|
||||
// TTL is the time-to-live value of the inserted DNS records.
|
||||
//
|
||||
// +optional
|
||||
TTL int `json:"ttl"`
|
||||
//TTL int `json:"ttl"`
|
||||
|
||||
// Timeout is the timeout value for requests to the sthome API.
|
||||
// The value is specified in seconds.
|
||||
//
|
||||
// +optional
|
||||
Timeout int `json:"timeout"`
|
||||
//Timeout int `json:"timeout"`
|
||||
|
||||
// AllowedZones is the list of zones that may be edited. If the list is
|
||||
// empty, all zones are permitted.
|
||||
@ -1,4 +1,4 @@
|
||||
package sthome
|
||||
package dns
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -1,4 +1,4 @@
|
||||
package sthome
|
||||
package dns
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -47,7 +47,7 @@ func (p *LocalDNSProviderSolver) Name() string {
|
||||
// cert-manager itself will later perform a self check to ensure that the
|
||||
// solver has correctly configured the DNS provider.
|
||||
func (loc *LocalDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error {
|
||||
domainName := extractDomainName(ch.ResolvedZone)
|
||||
//domainName := extractDomainName(ch.ResolvedZone)
|
||||
cfg, err := loadConfig(ch.Config)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -80,7 +80,17 @@ func (loc *LocalDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error
|
||||
*/
|
||||
// TODO: do something more useful with the decoded configuration
|
||||
klog.Infof("Decoded configuration %v\n", cfg)
|
||||
klog.Infof("Presenting record for %s, ch: %s, domain: %s", ch.DNSName, ch.ResolvedFQDN, domainName)
|
||||
klog.Infof("Presenting record for %s, type: %s, uid: %s, key: %s, ns: %s, fqdn: %s, zone: %s, allowambcred: %t, cfg: %s",
|
||||
ch.DNSName,
|
||||
ch.UID,
|
||||
ch.Type,
|
||||
ch.Key,
|
||||
ch.ResourceNamespace,
|
||||
ch.ResolvedFQDN,
|
||||
ch.ResolvedZone,
|
||||
ch.AllowAmbientCredentials,
|
||||
ch.Config,
|
||||
)
|
||||
// TODO: convert shell script to golang
|
||||
localip := getOutboundIP(dnsserver_net)
|
||||
success, _ := Execute(
|
||||
@ -1,7 +1,7 @@
|
||||
// private repo workaround
|
||||
// Will use this file and remove same content from main.go when github repo is made public
|
||||
|
||||
package sthome
|
||||
package dns
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
@ -1,4 +1,4 @@
|
||||
package sthome
|
||||
package dns
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -1,3 +1,3 @@
|
||||
0.0.4-alpha.100
|
||||
20240402-1118
|
||||
100
|
||||
0.0.4-alpha.107
|
||||
20240405-1950
|
||||
107
|
||||
Loading…
Reference in New Issue
Block a user