-
Notifications
You must be signed in to change notification settings - Fork 492
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
add egctl edit, egctl logs, update egctl create cmd #1067
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
02a4901
add egctl edit command
suchen-sci c527116
add verbose flag for egctl describe
suchen-sci e7cc5b7
fix bug for edit custom data
suchen-sci fad067a
update egctl cheat sheet
suchen-sci 0782333
finish egctl create httpproxy command, add some test
suchen-sci ff07cdb
add more test for egctl create cmd
suchen-sci 392a393
add more test, add integration test
suchen-sci 267f0a0
finish egctl logs command
suchen-sci 023dafe
optim egctl logs command
suchen-sci afcf76a
add integration test for egctl logs
suchen-sci 4b04d19
udpate doc, add examples
suchen-sci 0d9548f
update based on github action
suchen-sci 7f62308
close watcher
suchen-sci 2ad235c
udpate based on comments
suchen-sci b38fc6b
update egctl edit example
suchen-sci 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
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
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
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) 2017, MegaEase | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// Package create provides create commands. | ||
package create | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/megaease/easegress/v2/cmd/client/general" | ||
"github.com/megaease/easegress/v2/cmd/client/resources" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// Cmd returns create command. | ||
func Cmd() *cobra.Command { | ||
examples := []general.Example{ | ||
{Desc: "Create a resource from a file", Command: "egctl create -f <filename>.yaml"}, | ||
{Desc: "Create a resource from stdin", Command: "cat <filename>.yaml | egctl create -f -"}, | ||
} | ||
|
||
var specFile string | ||
cmd := &cobra.Command{ | ||
Use: "create", | ||
Short: "Create a resource from a file or from stdin.", | ||
Example: general.CreateMultiExample(examples), | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
if specFile == "" { | ||
return errors.New("yaml file is required") | ||
} | ||
return nil | ||
}, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
visitor := general.BuildSpecVisitor(specFile, cmd) | ||
visitor.Visit(func(s *general.Spec) error { | ||
var err error | ||
defer func() { | ||
if err != nil { | ||
general.ExitWithError(err) | ||
} | ||
}() | ||
|
||
switch s.Kind { | ||
case resources.CustomDataKind().Kind: | ||
err = resources.CreateCustomDataKind(cmd, s) | ||
case resources.CustomData().Kind: | ||
err = resources.CreateCustomData(cmd, s) | ||
default: | ||
err = resources.CreateObject(cmd, s) | ||
} | ||
return err | ||
}) | ||
visitor.Close() | ||
}, | ||
} | ||
|
||
cmd.Flags().StringVarP(&specFile, "file", "f", "", "A yaml file specifying the object.") | ||
return cmd | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2017, MegaEase | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// Package create provides create commands. | ||
package create | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCmd(t *testing.T) { | ||
cmd := Cmd() | ||
assert.NotNil(t, cmd) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
propose not adding
-server
suffix to the name, user may get confused what he/she has created.for the pipeline names, also propose not using the
pipeline-x
suffixes.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.
good idea. I will update that!