-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add egctl edit, egctl logs, update egctl create cmd (#1067)
* add egctl edit command * add verbose flag for egctl describe * fix bug for edit custom data * update egctl cheat sheet * finish egctl create httpproxy command, add some test * add more test for egctl create cmd * add more test, add integration test * finish egctl logs command * optim egctl logs command * add integration test for egctl logs * udpate doc, add examples * update based on github action * close watcher * udpate based on comments * update egctl edit example
- Loading branch information
1 parent
ac7d43d
commit 8f2dc59
Showing
27 changed files
with
2,170 additions
and
260 deletions.
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.