-
Notifications
You must be signed in to change notification settings - Fork 93
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
comments for K8 describe package #294
Changes from 6 commits
38d4915
6e9756d
66f0273
a085bf3
3b612b3
4a4a055
3bdd184
c59ad50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package describe | ||
|
||
// describe package provides a way to describe Kubernetes objects for the kubernetes Api | ||
|
||
import ( | ||
meshkitkube "github.com/layer5io/meshkit/utils/kubernetes" | ||
appsv1 "k8s.io/api/apps/v1" | ||
|
@@ -17,13 +19,14 @@ import ( | |
|
||
// DescriberOptions give control of which kubernetes object to describe. | ||
type DescriberOptions struct { | ||
Name string // Name of the kubernetes obj | ||
Namespace string // Namespace of the kubernetes obj | ||
ShowEvents bool | ||
ChunkSize int64 | ||
Type DescribeType | ||
Name string // Name of the kubernetes obj | ||
Namespace string // Namespace of the kubernetes obj | ||
ShowEvents bool // A boolean flag indicating whether to show events associated with the Kubernetes object or not. | ||
ChunkSize int64 //Size of the chunk in which the Kubernetes object's output is written. | ||
Type DescribeType //an integer value that represents the Kubernetes source that needs to be described | ||
} | ||
|
||
// DescribeType is an integer value that represents the Kubernetes resource that needs to be described. | ||
type DescribeType int | ||
|
||
const ( | ||
|
@@ -57,6 +60,7 @@ const ( | |
EndpointSlice | ||
) | ||
|
||
// The ResourceMap variable contains the GroupKind information of all the Kubernetes resources that can be described. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here. |
||
var ResourceMap = map[DescribeType]schema.GroupKind{ | ||
Pod: {Group: corev1.GroupName, Kind: "Pod"}, | ||
Deployment: {Group: appsv1.GroupName, Kind: "Deployment"}, | ||
|
@@ -88,22 +92,23 @@ var ResourceMap = map[DescribeType]schema.GroupKind{ | |
EndpointSlice: {Group: discoveryv1.GroupName, Kind: "EndpointSlice"}, | ||
} | ||
|
||
// The Describe() function takes a meshkitkube.Client object and a DescriberOptions object as input. | ||
// And it returns the description of the specified Kubernetes resource as a string. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You want me to remove the comments or the spaces in between the comments ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The space at the second comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i have removed the spaces |
||
func Describe(client *meshkitkube.Client, options DescriberOptions) (string, error) { | ||
// getting schema.GroupKind from Resource map | ||
kind := ResourceMap[options.Type] | ||
describer, ok := describe.DescriberFor(kind, &client.RestConfig) | ||
if !ok { | ||
return "", ErrGetDescriberFunc() | ||
} | ||
|
||
describerSetting := describe.DescriberSettings{ | ||
ShowEvents: options.ShowEvents, | ||
ChunkSize: options.ChunkSize, | ||
} | ||
//calls a corresponding "describer" function to retrieve the description of the specified Kubernetes resource | ||
output, err := describer.Describe(options.Namespace, options.Name, describerSetting) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return output, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a blank at the beginning, CI cannot run succeed. So, please remove it.