generated from layer5io/layer5-repo-template
-
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
38d4915
created unit test for the k8 describe package
Philip-21 6e9756d
Added signoff DCO
Philip-21 66f0273
created comments for the k8 describe.go file
Philip-21 a085bf3
Merge branch 'master' into k8-describe-package
Philip-21 3b612b3
Delete describe_test.go
Philip-21 4a4a055
adjusting comments
Philip-21 3bdd184
removing spaces
Philip-21 c59ad50
adjusting spaces
Philip-21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,13 @@ 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 ( | ||
|
@@ -56,7 +58,7 @@ const ( | |
CertificateSigningRequest | ||
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"}, | ||
|
@@ -87,23 +89,23 @@ var ResourceMap = map[DescribeType]schema.GroupKind{ | |
CertificateSigningRequest: {Group: certificatesv1beta1.GroupName, Kind: "CertificateSigningRequest"}, | ||
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. | ||
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 | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.