Skip to content

Commit

Permalink
Status struct renamed to Encrypt.
Browse files Browse the repository at this point in the history
Signed-off-by: viktor-kurchenko <[email protected]>
  • Loading branch information
viktor-kurchenko authored and tklauser committed Feb 6, 2024
1 parent 2bf4dde commit 17bb086
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions encrypt/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ type Parameters struct {
Output string
}

// Status is used to get encrypt status from cilium agents
type Status struct {
// Encrypt is used to get encrypt status from cilium agents
type Encrypt struct {
client *k8s.Client
params Parameters
}

// NewStatus returns new encrypt.Status struct
func NewStatus(client *k8s.Client, p Parameters) *Status {
return &Status{
// NewEncrypt returns new encrypt.Encrypt struct
func NewEncrypt(client *k8s.Client, p Parameters) *Encrypt {
return &Encrypt{
client: client,
params: p,
}
Expand All @@ -43,7 +43,7 @@ func NewStatus(client *k8s.Client, p Parameters) *Status {
// fetchCiliumPods returns slice of cilium agent pods.
// If option NodeName is specified then only that nodes' cilium-agent
// pod is returned else all cilium-agents in the cluster are returned.
func (s *Status) fetchCiliumPods(ctx context.Context) ([]corev1.Pod, error) {
func (s *Encrypt) fetchCiliumPods(ctx context.Context) ([]corev1.Pod, error) {
opts := metav1.ListOptions{LabelSelector: s.params.AgentPodSelector}
if s.params.NodeName != "" {
opts.FieldSelector = fmt.Sprintf("spec.nodeName=%s", s.params.NodeName)
Expand Down
2 changes: 1 addition & 1 deletion encrypt/ipsec_rotate_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type ipsecKey struct {
}

// IPsecRotateKey rotates IPsec key.
func (s *Status) IPsecRotateKey(ctx context.Context) error {
func (s *Encrypt) IPsecRotateKey(ctx context.Context) error {
ctx, cancelFn := context.WithTimeout(ctx, s.params.WaitDuration)
defer cancelFn()

Expand Down
8 changes: 4 additions & 4 deletions encrypt/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

// GetEncryptStatus gets encryption status from all/specific cilium agent pods.
func (s *Status) GetEncryptStatus(ctx context.Context) error {
func (s *Encrypt) GetEncryptStatus(ctx context.Context) error {
ctx, cancelFn := context.WithTimeout(ctx, s.params.WaitDuration)
defer cancelFn()

Expand All @@ -36,7 +36,7 @@ func (s *Status) GetEncryptStatus(ctx context.Context) error {
return s.writeStatus(res)
}

func (s *Status) fetchEncryptStatusConcurrently(ctx context.Context, pods []corev1.Pod) (map[string]EncryptionStatus, error) {
func (s *Encrypt) fetchEncryptStatusConcurrently(ctx context.Context, pods []corev1.Pod) (map[string]EncryptionStatus, error) {
// res contains data returned from cilium pod
type res struct {
nodeName string
Expand Down Expand Up @@ -72,7 +72,7 @@ func (s *Status) fetchEncryptStatusConcurrently(ctx context.Context, pods []core
return data, err
}

func (s *Status) fetchEncryptStatusFromPod(ctx context.Context, pod corev1.Pod) (EncryptionStatus, error) {
func (s *Encrypt) fetchEncryptStatusFromPod(ctx context.Context, pod corev1.Pod) (EncryptionStatus, error) {
cmd := []string{"cilium", "encrypt", "status", "-o", "json"}
output, err := s.client.ExecInPod(ctx, pod.Namespace, pod.Name, defaults.AgentContainerName, cmd)
if err != nil {
Expand Down Expand Up @@ -149,7 +149,7 @@ func nodeStatusFromText(str string) (EncryptionStatus, error) {
return res, nil
}

func (s *Status) writeStatus(res map[string]EncryptionStatus) error {
func (s *Encrypt) writeStatus(res map[string]EncryptionStatus) error {
if s.params.PerNodeDetails {
for nodeName, n := range res {
if err := printStatus(nodeName, n, s.params.Output); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/cmd/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func newCmdEncryptStatus() *cobra.Command {
Long: "This command returns encryption status from all nodes in the cluster",
RunE: func(cmd *cobra.Command, args []string) error {
params.CiliumNamespace = namespace
s := encrypt.NewStatus(k8sClient, params)
s := encrypt.NewEncrypt(k8sClient, params)
if err := s.GetEncryptStatus(context.Background()); err != nil {
fatalf("Unable to get encrypt status: %s", err)
}
Expand All @@ -57,7 +57,7 @@ func newCmdIPsecRotateKey() *cobra.Command {
Long: "This command rotates IPsec encryption key in the cluster",
RunE: func(cmd *cobra.Command, args []string) error {
params.CiliumNamespace = namespace
s := encrypt.NewStatus(k8sClient, params)
s := encrypt.NewEncrypt(k8sClient, params)
if err := s.IPsecRotateKey(context.Background()); err != nil {
fatalf("Unable to rotate IPsec key: %s", err)
}
Expand Down

0 comments on commit 17bb086

Please sign in to comment.