-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial CLI of controller-bootstrap with Makefile (#5)
Issue: [aws-controllers-k8s/community/issues/1358](aws-controllers-k8s/community#1358) Description of changes: - This PR is to add the initial implementation of controller-bootstrap CLI with subcommand, arguments, and Makefile. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
- Loading branch information
1 parent
1bdef64
commit 357b00d
Showing
7 changed files
with
221 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. 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. A copy of the | ||
// License is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. This file 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 command | ||
|
||
// TODO: getServiceResources infers aws-sdk-go to fetch the service metadata and custom resource names | ||
func getServiceResources() error { | ||
return nil | ||
} |
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,32 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. 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. A copy of the | ||
// License is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. This file 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 command | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var templateCmd = &cobra.Command{ | ||
Use: "generate", | ||
Short: "generate template files in an ACK service controller repository", | ||
RunE: generateController, | ||
} | ||
|
||
// TODO: generateController creates the initial directories and files for a service controller | ||
// repository by rendering go template files. | ||
// When a controller is already existing, then this method only updates the project | ||
// description files. | ||
func generateController(cmd *cobra.Command, args []string) error { | ||
return nil | ||
} |
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,82 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. 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. A copy of the | ||
// License is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. This file 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 command | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
const ( | ||
appName = "controller-bootstrap" | ||
appShortDesc = "A bootstrap tool to initialize an ACK service controller repository" | ||
) | ||
|
||
var ( | ||
optServiceAlias string | ||
optRuntimeVersion string | ||
optAWSSDKGoVersion string | ||
optDryRun bool | ||
optExistingController bool | ||
optOutputPath string | ||
optModelName string | ||
) | ||
|
||
// rootCmd represents the base command when called without any subcommands | ||
// placeholder for cobra description | ||
var rootCmd = &cobra.Command{ | ||
Use: appName, | ||
Short: appShortDesc, | ||
} | ||
|
||
func init() { | ||
rootCmd.PersistentFlags().StringVarP( | ||
&optServiceAlias, "aws-service-alias", "s", "", "AWS service alias", | ||
) | ||
rootCmd.PersistentFlags().StringVarP( | ||
&optRuntimeVersion, "ack-runtime-version", "r", "", "Version of aws-controllers-k8s/runtime", | ||
) | ||
rootCmd.PersistentFlags().StringVarP( | ||
&optAWSSDKGoVersion, "aws-sdk-go-version", "v", "", "Version of github.com/aws/aws-sdk-go used to infer service metadata and resources", | ||
) | ||
rootCmd.PersistentFlags().BoolVarP( | ||
&optDryRun, "dry-run", "d", false, "Optional: if true, output files to stdout", | ||
) | ||
rootCmd.PersistentFlags().BoolVarP( | ||
&optExistingController, "existing-controller", "e", false, "Optional: if true, update the existing service controller", | ||
) | ||
rootCmd.PersistentFlags().StringVarP( | ||
&optOutputPath, "output", "o", "", "Path to ACK service controller directory to bootstrap", | ||
) | ||
rootCmd.PersistentFlags().StringVarP( | ||
&optModelName, "model-name", "m", "", "Optional: service model name of the corresponding service alias", | ||
) | ||
rootCmd.MarkPersistentFlagRequired("aws-service-alias") | ||
rootCmd.MarkPersistentFlagRequired("ack-runtime-version") | ||
rootCmd.MarkPersistentFlagRequired("aws-sdk-go-version") | ||
rootCmd.MarkPersistentFlagRequired("output") | ||
rootCmd.AddCommand(templateCmd) | ||
} | ||
|
||
// Execute adds all child commands to the root command and sets flags appropriately. | ||
// This is called by main.main(). It only needs to happen once to the rootCmd. | ||
func Execute() { | ||
err := rootCmd.Execute() | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
} |
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,20 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. 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. A copy of the | ||
// License is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. This file 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 main | ||
|
||
import "controller-bootstrap/cmd/controller-bootstrap/command" | ||
|
||
func main() { | ||
command.Execute() | ||
} |
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,10 @@ | ||
module controller-bootstrap | ||
|
||
go 1.18 | ||
|
||
require github.com/spf13/cobra v1.5.0 | ||
|
||
require ( | ||
github.com/inconshreveable/mousetrap v1.0.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
) |
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,10 @@ | ||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= | ||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= | ||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= | ||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | ||
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= | ||
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= | ||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= | ||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= |