Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor controller #185

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ build-manager: generate fmt vet ## Build manager binary.
go build -o bin/manager ./cmd/manager/main.go

run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/manager/main.go
go run ./cmd/manager/main.go --agent-image "ghcr.io/jodevsa/wireguard-operator/agent:dev-last-today-131"



Expand Down
2 changes: 1 addition & 1 deletion cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func main() {
}

if wgImage == "" {
setupLog.Error(fmt.Errorf("--wireguard-container-image flag is not set"), "unable to start manager")
setupLog.Error(fmt.Errorf("--agent-image flag is not set"), "unable to start manager")
os.Exit(1)
}

Expand Down
30 changes: 27 additions & 3 deletions config/crd/bases/vpn.wireguard-operator.io_wireguardpeers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,39 @@ spec:
spec:
description: The desired state of the peer.
properties:
PrivateKeyRef:
description: The private key of the peer
properties:
secretKeyRef:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must be
a valid secret key.
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
type: string
optional:
description: Specify whether the Secret or its key must be
defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
required:
- secretKeyRef
type: object
address:
description: |-
INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Important: Run "make" to regenerate code after modifying this file
The address of the peer.
type: string
allowedIPs:
description: The AllowedIPs of the peer.
type: string
disabled:
description: Set to true to temporarily disable the peer.
type: boolean
Expand Down
17 changes: 17 additions & 0 deletions config/crd/bases/vpn.wireguard-operator.io_wireguards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,16 @@ spec:
status:
description: WireguardStatus defines the observed state of Wireguard
properties:
UniqueIdentifier:
type: string
address:
description: A string field that specifies the address for the Wireguard
VPN server that is currently being used.
type: string
dns:
type: string
dnssearchdomain:
type: string
message:
description: A string field that provides additional information about
the status of Wireguard. This could include error messages or other
Expand All @@ -222,6 +226,19 @@ spec:
description: A string field that specifies the port for the Wireguard
VPN server that is currently being used.
type: string
publickey:
type: string
resources:
items:
properties:
name:
type: string
status:
type: string
type:
type: string
type: object
type: array
status:
description: A string field that represents the current status of
Wireguard. This could include values like ready, pending, or error.
Expand Down
450 changes: 1 addition & 449 deletions go.mod

Large diffs are not rendered by default.

1,552 changes: 6 additions & 1,546 deletions go.sum

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions pkg/api/v1alpha1/wireguard_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,29 @@ type WireguardPodSpec struct {
// WireguardStatus defines the observed state of Wireguard
type WireguardStatus struct {
// A string field that specifies the address for the Wireguard VPN server that is currently being used.
Address string `json:"address,omitempty"`
Dns string `json:"dns,omitempty"`
Address string `json:"address,omitempty"`
Dns string `json:"dns,omitempty"`
DnsSearchDomain string `json:"dnssearchdomain,omitempty"`
PublicKey string `json:"publickey,omitempty"`
// A string field that specifies the port for the Wireguard VPN server that is currently being used.
Port string `json:"port,omitempty"`
// A string field that represents the current status of Wireguard. This could include values like ready, pending, or error.
Status string `json:"status,omitempty"`
// A string field that provides additional information about the status of Wireguard. This could include error messages or other information that helps to diagnose issues with the wg instance.
Message string `json:"message,omitempty"`
Message string `json:"message,omitempty"`
Resources []Resource `json:"resources,omitempty"`
UniqueIdentifier string `json:"UniqueIdentifier,omitempty"`
}
type Resource struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Status string `json:"status,omitempty"`
}

type DeploymentResource struct {
Name string `json:"name,omitempty"`
Status string `json:"status,omitempty"`
Image string `json:"image,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/v1alpha1/wireguardpeer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ type WireguardPeerList struct {
Items []WireguardPeer `json:"items"`
}

func (in *WireguardPeerList) Error() string {
panic("implement me")
}

func init() {
SchemeBuilder.Register(&WireguardPeer{}, &WireguardPeerList{})
}
37 changes: 36 additions & 1 deletion pkg/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading