Skip to content

Commit

Permalink
Fix: linting issues in checks package
Browse files Browse the repository at this point in the history
Signed-off-by: Sibasish Behera <[email protected]>
  • Loading branch information
TheRealSibasishBehera committed Feb 14, 2023
1 parent fa22368 commit 30f27f4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions checks/updates.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package checks provides utility for checks in karmor CLI tool
package checks

import (
Expand All @@ -9,10 +10,12 @@ import (
"strings"
)

// UpdateChecker structure
type UpdateChecker struct {
Client *github.Client
}

// Fetches all the releases from kubearmor-client repository
func (c *UpdateChecker) FetchReleases() ([]*github.RepositoryRelease, error) {
releases, _, err := c.Client.Repositories.ListReleases(context.Background(),
"kubearmor",
Expand All @@ -28,6 +31,7 @@ func (c *UpdateChecker) FetchReleases() ([]*github.RepositoryRelease, error) {
return releases, nil
}

// Gets the mandatory latest release
func (c *UpdateChecker) GetLatestMandatoryRelease(releases []*github.RepositoryRelease) (*github.RepositoryRelease, error) {
var latestMandatoryRelease *github.RepositoryRelease
for _, release := range releases {
Expand All @@ -42,6 +46,7 @@ func (c *UpdateChecker) GetLatestMandatoryRelease(releases []*github.RepositoryR
return latestMandatoryRelease, nil
}

// Compares the current karmor version and the mandatory release present in releases
func (c *UpdateChecker) CompareVersions(currentVersion string, latestMandatoryRelease *github.RepositoryRelease) error {
if latestMandatoryRelease == nil {
color.HiGreen("The client is up to date.")
Expand All @@ -58,6 +63,7 @@ func (c *UpdateChecker) CompareVersions(currentVersion string, latestMandatoryRe
return nil
}

// Checks for releases in kubearmor-client repository and displays a log if update is present
func (c *UpdateChecker) CheckForUpdates() error {
releases, err := c.FetchReleases()
if err != nil {
Expand All @@ -77,12 +83,14 @@ func (c *UpdateChecker) CheckForUpdates() error {
return nil
}

// NewUpdateChecker : Returns a new instance of UpdateChecker
func NewUpdateChecker() *UpdateChecker {
return &UpdateChecker{
Client: github.NewClient(nil),
}
}

// Init function for call UpdateChecker functions
func (c *UpdateChecker) Init() error {
err := c.CheckForUpdates()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions utils/portforward.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package utils provides utility for port forwarding.
package utils

import (
Expand Down
1 change: 1 addition & 0 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func PrintVersion(c *k8s.Client) error {
return nil
}

// GetKubeArmorVersion :Returns the current version of KubeArmor
func GetKubeArmorVersion(c *k8s.Client) (string, error) {
pods, err := c.K8sClientset.CoreV1().Pods("kube-system").List(context.Background(), metav1.ListOptions{LabelSelector: "kubearmor-app=kubearmor"})
if err != nil {
Expand Down

0 comments on commit 30f27f4

Please sign in to comment.