-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
k8s-tester/wordpress: initial commit
Signed-off-by: Gyuho Lee <[email protected]>
- Loading branch information
Showing
16 changed files
with
1,944 additions
and
3 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
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
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,155 @@ | ||
// k8s-tester-wordpress installs Kubernetes wordpress tester. | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/aws/aws-k8s-tester/client" | ||
"github.com/aws/aws-k8s-tester/k8s-tester/wordpress" | ||
"github.com/aws/aws-k8s-tester/utils/log" | ||
"github.com/spf13/cobra" | ||
"go.uber.org/zap" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "k8s-tester-wordpress", | ||
Short: "Kubernetes wordpress tester", | ||
SuggestFor: []string{"wordpress"}, | ||
} | ||
|
||
func init() { | ||
cobra.EnablePrefixMatching = true | ||
} | ||
|
||
var ( | ||
prompt bool | ||
logLevel string | ||
logOutputs []string | ||
minimumNodes int | ||
kubectlDownloadURL string | ||
kubectlPath string | ||
kubeconfigPath string | ||
) | ||
|
||
func init() { | ||
rootCmd.PersistentFlags().BoolVar(&prompt, "prompt", true, "'true' to enable prompt mode") | ||
rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", log.DefaultLogLevel, "Logging level") | ||
rootCmd.PersistentFlags().StringSliceVar(&logOutputs, "log-outputs", []string{"stderr"}, "Additional logger outputs") | ||
rootCmd.PersistentFlags().IntVar(&minimumNodes, "minimum-nodes", wordpress.DefaultMinimumNodes, "minimum number of Kubernetes nodes required for installing this addon") | ||
rootCmd.PersistentFlags().StringVar(&kubectlDownloadURL, "kubectl-download-url", client.DefaultKubectlDownloadURL(), "kubectl download URL") | ||
rootCmd.PersistentFlags().StringVar(&kubectlPath, "kubectl-path", client.DefaultKubectlPath(), "kubectl path") | ||
rootCmd.PersistentFlags().StringVar(&kubeconfigPath, "kubeconfig-path", "", "KUBECONFIG path") | ||
|
||
rootCmd.AddCommand( | ||
newApply(), | ||
newDelete(), | ||
) | ||
} | ||
|
||
func main() { | ||
if err := rootCmd.Execute(); err != nil { | ||
fmt.Fprintf(os.Stderr, "k8s-tester-wordpress failed %v\n", err) | ||
os.Exit(1) | ||
} | ||
os.Exit(0) | ||
} | ||
|
||
var ( | ||
partition string | ||
region string | ||
) | ||
|
||
func newApply() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "apply", | ||
Short: "Apply tests", | ||
Run: createApplyFunc, | ||
} | ||
|
||
cmd.PersistentFlags().StringVar(&partition, "partition", "aws", "partition for AWS region") | ||
cmd.PersistentFlags().StringVar(®ion, "region", "", "region for ELB resource") | ||
|
||
return cmd | ||
} | ||
|
||
func createApplyFunc(cmd *cobra.Command, args []string) { | ||
lg, logWriter, _, err := log.NewWithStderrWriter(logLevel, logOutputs) | ||
if err != nil { | ||
panic(err) | ||
} | ||
_ = zap.ReplaceGlobals(lg) | ||
|
||
cli, err := client.New(&client.Config{ | ||
Logger: lg, | ||
KubectlDownloadURL: kubectlDownloadURL, | ||
KubectlPath: kubectlPath, | ||
KubeconfigPath: kubeconfigPath, | ||
}) | ||
if err != nil { | ||
lg.Panic("failed to create client", zap.Error(err)) | ||
} | ||
|
||
cfg := &wordpress.Config{ | ||
Prompt: prompt, | ||
Logger: lg, | ||
LogWriter: logWriter, | ||
MinimumNodes: minimumNodes, | ||
Client: cli, | ||
|
||
Partition: partition, | ||
Region: region, | ||
} | ||
|
||
ts := wordpress.New(cfg) | ||
if err := ts.Apply(); err != nil { | ||
fmt.Fprintf(os.Stderr, "failed to apply (%v)\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Printf("\n*********************************\n") | ||
fmt.Printf("'k8s-tester-wordpress apply' success\n") | ||
} | ||
|
||
func newDelete() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete resources", | ||
Run: createDeleteFunc, | ||
} | ||
return cmd | ||
} | ||
|
||
func createDeleteFunc(cmd *cobra.Command, args []string) { | ||
lg, logWriter, _, err := log.NewWithStderrWriter(logLevel, logOutputs) | ||
if err != nil { | ||
panic(err) | ||
} | ||
_ = zap.ReplaceGlobals(lg) | ||
|
||
cli, err := client.New(&client.Config{ | ||
Logger: lg, | ||
KubectlDownloadURL: kubectlDownloadURL, | ||
KubectlPath: kubectlPath, | ||
KubeconfigPath: kubeconfigPath, | ||
}) | ||
if err != nil { | ||
lg.Panic("failed to create client", zap.Error(err)) | ||
} | ||
|
||
cfg := &wordpress.Config{ | ||
Prompt: prompt, | ||
Logger: lg, | ||
LogWriter: logWriter, | ||
Client: cli, | ||
} | ||
|
||
ts := wordpress.New(cfg) | ||
if err := ts.Delete(); err != nil { | ||
fmt.Fprintf(os.Stderr, "failed to delete (%v)\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Printf("\n*********************************\n") | ||
fmt.Printf("'k8s-tester-wordpress delete' success\n") | ||
} |
Oops, something went wrong.