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

refractor summary api #268

Merged
merged 1 commit into from
Feb 15, 2023
Merged

Conversation

Prateeknandle
Copy link
Contributor

@Prateeknandle Prateeknandle commented Feb 13, 2023

Signed-off-by: Prateeknandle prateeknandle@gmail.com
refactoring summary api:
changes :

  • returning the summary output when GetSummary() is called
  • printing the output is now done by Summary() func, when comand is used

after this we can use summary api to get the karmor summary command output rather than executing command in code.

summary/summary.go Show resolved Hide resolved
summary/summary.go Show resolved Hide resolved
summary/summary.go Outdated Show resolved Hide resolved
summary/summary.go Outdated Show resolved Hide resolved
Copy link
Contributor

@rksharma95 rksharma95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 PTAL at comment by @yasin-cs-ko-ak

Signed-off-by: Prateeknandle <prateeknandle@gmail.com>
Copy link
Contributor

@yasin-cs-ko-ak yasin-cs-ko-ak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Job!
LGTM

@yasin-cs-ko-ak
Copy link
Contributor

@Prateeknandle If you can attach a screenshot of a JSON output, that would be better.

@Prateeknandle
Copy link
Contributor Author

Prateeknandle commented Feb 14, 2023

screenshot was not possible because summary is big, therefore pasting the output with command

prateek@prateek-lenovo-ideapad-310-15isk:~/go/src/github.com/kubearmor/discovery-engine$ ~/go/bin/karmor summary -t network -o json
local port to be used for port forwarding discovery-engine-746fccb855-d9c4r: 32827 
{
    "PodName": "mysql-76ddc6ddc4-279dx",
    "ClusterName": "default",
    "Namespace": "wordpress-mysql",
    "Label": "app=mysql",
    "ContainerName": "mysql",
    "IngressConnection": [
        {
            "Protocol": "TCPv6",
            "Command": "/usr/sbin/mysqld",
            "IP": "pod/wordpress-787f45786f-84dr6",
            "Port": "3306",
            "Labels": "app=wordpress",
            "Namespace": "wordpress-mysql",
            "Count": "1",
            "UpdatedTime": "Tue Feb 14 08:00:03 UTC 2023"
        }
    ],
    "EgressConnection": [
        {
            "Protocol": "AF_UNIX",
            "Command": "/usr/bin/mysqladmin",
            "IP": "/var/run/mysqld/mysqld.sock",
            "Port": "0",
            "Count": "1",
            "UpdatedTime": "Tue Feb 14 07:59:57 UTC 2023"
        }
    ],
    "BindConnection": [
        {
            "Protocol": "AF_INET6",
            "Command": "/usr/sbin/mysqld",
            "Count": "1",
            "UpdatedTime": "Tue Feb 14 08:00:00 UTC 2023",
            "BindPort": "3306",
            "BindAddress": "::"
        }
    ]
}
{
    "PodName": "wordpress-787f45786f-84dr6",
    "ClusterName": "default",
    "Namespace": "wordpress-mysql",
    "Label": "app=wordpress",
    "ContainerName": "wordpress",
    "EgressConnection": [
        {
            "Protocol": "TCP",
            "Command": "/usr/local/bin/php",
            "IP": "svc/mysql",
            "Port": "3306",
            "Labels": "app=mysql",
            "Namespace": "wordpress-mysql",
            "Count": "7",
            "UpdatedTime": "Tue Feb 14 07:59:43 UTC 2023"
        }
    ]
}

@Prateeknandle
Copy link
Contributor Author

Here's a glance to it
Screenshot from 2023-02-14 18-45-54

@rksharma95
Copy link
Contributor

rksharma95 commented Feb 14, 2023

@yasin-cs-ko-ak is it okay to merge this PR now?

@rksharma95 Let @seswarrajan take look at it once and let eswar merge this. Because previously he was the one review it. That's why. I hope there is no issue with that.

@Prateeknandle
Copy link
Contributor Author

actually tests for summary are ready, those tests are dependent on this pr

@rksharma95
Copy link
Contributor

@Prateeknandle @yasin-cs-ko-ak IMO we're good to merge it.
// cc: @seswarrajan

@rksharma95 rksharma95 merged commit 52c7556 into kubearmor:main Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants