mirror of
https://github.com/cert-manager/webhook-example.git
synced 2025-07-01 22:35:49 +02:00
add domainzone v1beta1 api
This commit is contained in:
parent
f4f6ff4598
commit
96a07982bc
3 changed files with 535 additions and 0 deletions
166
api/v1beta1/domainzone_types.go
Normal file
166
api/v1beta1/domainzone_types.go
Normal file
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
Copyright 2019 Cafe Bazaar Cloud.
|
||||
|
||||
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 v1beta1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
||||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
|
||||
|
||||
// DomainZoneSpec defines the desired state of DomainZone
|
||||
type DomainZoneSpec struct {
|
||||
Wsid string `json:"wsid,omitempty"`
|
||||
Origin string `json:"origin" validate:"hostname_rfc1123"`
|
||||
TTL int `json:"ttl,omitempty" validate:"min=0"`
|
||||
Email string `json:"email,omitempty" validate:"email"`
|
||||
DedicatedNSDomain string `json:"NSDomain,omitempty" validate:"hostname_rfc1123"` // deprecated
|
||||
Nameservers []string `json:"nameservers,omitempty" validate:"min=2,dive,hostname_rfc1123"`
|
||||
Records RecordsMap `json:"records,omitempty" validate:"max=1000,dive,keys,recordname|eq=@|eq=*,endkeys,max=100,dive"`
|
||||
}
|
||||
|
||||
// RecordsMap ...
|
||||
type RecordsMap map[string]RecordList
|
||||
|
||||
// RecordList ...
|
||||
type RecordList []Record
|
||||
|
||||
// Record ..
|
||||
type Record struct {
|
||||
Name string `json:"-"` // retrieved from DomainZoneSpec.Records map and set in Zone.FindRecords on runtime
|
||||
SpecifiedType string `json:"type,omitempty"`
|
||||
|
||||
TTL int `json:"ttl,omitempty" validate:"min=0"`
|
||||
Weight *int `json:"weight,omitempty" validate:"omitempty,min=0"`
|
||||
GeoLocation []GeoLocation `json:"geo,omitempty" validate:"max=20,dive"`
|
||||
HealthCheck *HealthCheck `json:"hc,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
MX *MX `json:"MX,omitempty" validate:"omitempty,dive"`
|
||||
A []string `json:"A,omitempty" validate:"omitempty,max=100,dive,ipv4"`
|
||||
AFallback []string `json:"AFallback,omitempty" validate:"omitempty,max=100,dive,ipv4"`
|
||||
AAAA []string `json:"AAAA,omitempty" validate:"omitempty,max=100,dive,ipv6"`
|
||||
AAAAFallback []string `json:"AAAAFallback,omitempty" validate:"omitempty,max=100,dive,ipv6"`
|
||||
CNAME string `json:"CNAME,omitempty" validate:"omitempty,hostname_rfc1123"`
|
||||
TXT string `json:"TXT,omitempty" validate:"omitempty,lt=2048"`
|
||||
SPF string `json:"SPF,omitempty" validate:"omitempty,lt=2048"`
|
||||
NS []string `json:"NS,omitempty" validate:"omitempty,max=100,dive,hostname_rfc1123"`
|
||||
PTR string `json:"PTR,omitempty" validate:"omitempty,hostname_rfc1123"`
|
||||
SRV *SRV `json:"SRV,omitempty" validate:"omitempty,dive"`
|
||||
URI *URI `json:"URI,omitempty" validate:"omitempty,dive"`
|
||||
ALIAS string `json:"ALIAS,omitempty" validate:"omitempty,hostname_rfc1123"`
|
||||
}
|
||||
|
||||
// GeoLocation ...
|
||||
type GeoLocation struct {
|
||||
ContinentCode string `json:"continent"`
|
||||
CountryCode string `json:"country"`
|
||||
}
|
||||
|
||||
// HealthCheck ...
|
||||
type HealthCheck struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Protocol string `json:"protocol" validate:"oneof=tcp http https"`
|
||||
Port int `json:"port" validate:"gte=1,lte=65535"`
|
||||
Host string `json:"host" validate:"omitempty,hostname_rfc1123"`
|
||||
Path string `json:"path" validate:"omitempty,lte=128"`
|
||||
}
|
||||
|
||||
// MX ...
|
||||
type MX struct {
|
||||
Priority int `json:"priority" validate:"min=0"`
|
||||
Host string `json:"host" validate:"hostname_rfc1123|ip"`
|
||||
}
|
||||
|
||||
// SRV ...
|
||||
type SRV struct {
|
||||
Priority int `json:"priority" validate:"min=0"`
|
||||
Weight int `json:"weight" validate:"min=0"`
|
||||
Port int `json:"port" validate:"min=1,max=65535"`
|
||||
Target string `json:"target" validate:"lte=255"`
|
||||
}
|
||||
|
||||
// URI ...
|
||||
type URI struct {
|
||||
Priority int `json:"priority" validate:"min=0"`
|
||||
Weight int `json:"weight" validate:"min=0"`
|
||||
Target string `json:"target" validate:"uri"`
|
||||
}
|
||||
|
||||
// DomainZoneStatus defines the observed state of DomainZone
|
||||
type DomainZoneStatus struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:printcolumn:name="origin",type="string",JSONPath=".spec.origin",description="origin"
|
||||
// +kubebuilder:printcolumn:name="nameservers",type="string",JSONPath=".spec.nameservers",description="authoritative nameservers to be set by user"
|
||||
// +kubebuilder:printcolumn:name="ns (legacy)",type="string",JSONPath=".spec.NSDomain",description="legacy ns domain"
|
||||
// +kubebuilder:printcolumn:name="status",type="string",JSONPath=".status.status",description="status"
|
||||
// +kubebuilder:printcolumn:name="age",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
|
||||
// DomainZone is the Schema for the domainzones API
|
||||
type DomainZone struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec DomainZoneSpec `json:"spec,omitempty"`
|
||||
Status DomainZoneStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// DomainZoneList contains a list of DomainZone
|
||||
type DomainZoneList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []DomainZone `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&DomainZone{}, &DomainZoneList{})
|
||||
}
|
||||
|
||||
// Type returns type of the record
|
||||
// TODO(ali) SPF, TLSA, CAA, SMIME?, LOC, SSHP
|
||||
func (r *Record) Type() string {
|
||||
if len(r.A) > 0 {
|
||||
return "A"
|
||||
} else if len(r.AAAA) > 0 {
|
||||
return "AAAA"
|
||||
} else if r.TXT != "" {
|
||||
return "TXT"
|
||||
} else if r.SPF != "" {
|
||||
return "SPF"
|
||||
} else if r.SRV != nil {
|
||||
return "SRV"
|
||||
} else if r.CNAME != "" {
|
||||
return "CNAME"
|
||||
} else if len(r.NS) > 0 {
|
||||
return "NS"
|
||||
} else if r.PTR != "" {
|
||||
return "PTR"
|
||||
} else if r.URI != nil {
|
||||
return "URI"
|
||||
} else if r.MX != nil {
|
||||
return "MX"
|
||||
} else if r.ALIAS != "" {
|
||||
return "ALIAS"
|
||||
}
|
||||
|
||||
return "A"
|
||||
}
|
36
api/v1beta1/groupversion_info.go
Normal file
36
api/v1beta1/groupversion_info.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
Copyright 2019 Cafe Bazaar Cloud.
|
||||
|
||||
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 v1beta1 contains API Schema definitions for the delivery v1beta1 API group
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=delivery.cafebazaar.cloud
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/scheme"
|
||||
)
|
||||
|
||||
var (
|
||||
// GroupVersion is group version used to register these objects
|
||||
GroupVersion = schema.GroupVersion{Group: "delivery.cafebazaar.cloud", Version: "v1beta1"}
|
||||
|
||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
||||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
|
||||
|
||||
// AddToScheme adds the types in this group-version to the given scheme.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
333
api/v1beta1/zz_generated.deepcopy.go
Normal file
333
api/v1beta1/zz_generated.deepcopy.go
Normal file
|
@ -0,0 +1,333 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2019 Cafe Bazaar Cloud.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// Code generated by controller-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DomainZone) DeepCopyInto(out *DomainZone) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
out.Status = in.Status
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DomainZone.
|
||||
func (in *DomainZone) DeepCopy() *DomainZone {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DomainZone)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *DomainZone) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DomainZoneList) DeepCopyInto(out *DomainZoneList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]DomainZone, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DomainZoneList.
|
||||
func (in *DomainZoneList) DeepCopy() *DomainZoneList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DomainZoneList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *DomainZoneList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DomainZoneSpec) DeepCopyInto(out *DomainZoneSpec) {
|
||||
*out = *in
|
||||
if in.Nameservers != nil {
|
||||
in, out := &in.Nameservers, &out.Nameservers
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Records != nil {
|
||||
in, out := &in.Records, &out.Records
|
||||
*out = make(RecordsMap, len(*in))
|
||||
for key, val := range *in {
|
||||
var outVal []Record
|
||||
if val == nil {
|
||||
(*out)[key] = nil
|
||||
} else {
|
||||
in, out := &val, &outVal
|
||||
*out = make(RecordList, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
(*out)[key] = outVal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DomainZoneSpec.
|
||||
func (in *DomainZoneSpec) DeepCopy() *DomainZoneSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DomainZoneSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DomainZoneStatus) DeepCopyInto(out *DomainZoneStatus) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DomainZoneStatus.
|
||||
func (in *DomainZoneStatus) DeepCopy() *DomainZoneStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DomainZoneStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *GeoLocation) DeepCopyInto(out *GeoLocation) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GeoLocation.
|
||||
func (in *GeoLocation) DeepCopy() *GeoLocation {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(GeoLocation)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HealthCheck) DeepCopyInto(out *HealthCheck) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HealthCheck.
|
||||
func (in *HealthCheck) DeepCopy() *HealthCheck {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HealthCheck)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *MX) DeepCopyInto(out *MX) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MX.
|
||||
func (in *MX) DeepCopy() *MX {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(MX)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Record) DeepCopyInto(out *Record) {
|
||||
*out = *in
|
||||
if in.Weight != nil {
|
||||
in, out := &in.Weight, &out.Weight
|
||||
*out = new(int)
|
||||
**out = **in
|
||||
}
|
||||
if in.GeoLocation != nil {
|
||||
in, out := &in.GeoLocation, &out.GeoLocation
|
||||
*out = make([]GeoLocation, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.HealthCheck != nil {
|
||||
in, out := &in.HealthCheck, &out.HealthCheck
|
||||
*out = new(HealthCheck)
|
||||
**out = **in
|
||||
}
|
||||
if in.MX != nil {
|
||||
in, out := &in.MX, &out.MX
|
||||
*out = new(MX)
|
||||
**out = **in
|
||||
}
|
||||
if in.A != nil {
|
||||
in, out := &in.A, &out.A
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.AFallback != nil {
|
||||
in, out := &in.AFallback, &out.AFallback
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.AAAA != nil {
|
||||
in, out := &in.AAAA, &out.AAAA
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.AAAAFallback != nil {
|
||||
in, out := &in.AAAAFallback, &out.AAAAFallback
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.NS != nil {
|
||||
in, out := &in.NS, &out.NS
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.SRV != nil {
|
||||
in, out := &in.SRV, &out.SRV
|
||||
*out = new(SRV)
|
||||
**out = **in
|
||||
}
|
||||
if in.URI != nil {
|
||||
in, out := &in.URI, &out.URI
|
||||
*out = new(URI)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Record.
|
||||
func (in *Record) DeepCopy() *Record {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Record)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in RecordList) DeepCopyInto(out *RecordList) {
|
||||
{
|
||||
in := &in
|
||||
*out = make(RecordList, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecordList.
|
||||
func (in RecordList) DeepCopy() RecordList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RecordList)
|
||||
in.DeepCopyInto(out)
|
||||
return *out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in RecordsMap) DeepCopyInto(out *RecordsMap) {
|
||||
{
|
||||
in := &in
|
||||
*out = make(RecordsMap, len(*in))
|
||||
for key, val := range *in {
|
||||
var outVal []Record
|
||||
if val == nil {
|
||||
(*out)[key] = nil
|
||||
} else {
|
||||
in, out := &val, &outVal
|
||||
*out = make(RecordList, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
(*out)[key] = outVal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecordsMap.
|
||||
func (in RecordsMap) DeepCopy() RecordsMap {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RecordsMap)
|
||||
in.DeepCopyInto(out)
|
||||
return *out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *SRV) DeepCopyInto(out *SRV) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SRV.
|
||||
func (in *SRV) DeepCopy() *SRV {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(SRV)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *URI) DeepCopyInto(out *URI) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new URI.
|
||||
func (in *URI) DeepCopy() *URI {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(URI)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
Loading…
Reference in a new issue