-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79e9823
commit f0b67f2
Showing
22 changed files
with
306 additions
and
254 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Copyright © 2020 Maksym Postument [email protected] | ||
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://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 cmd | ||
|
||
import ( | ||
"awstaghelper/pkg" | ||
"github.com/aws/aws-sdk-go/service/ecr" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// ecrCmd represents the ecr command | ||
var ecrCmd = &cobra.Command{ | ||
Use: "ecr", | ||
Short: "Root command for interaction with AWS ecr services", | ||
Long: `Root command for interaction with AWS ecr services.`, | ||
} | ||
|
||
var getEcrTagsCmd = &cobra.Command{ | ||
Use: "get-repository-tags", | ||
Short: "Write arn and required tags to csv", | ||
Long: `Write to csv data with arn and required tags to csv. | ||
This csv can be used with tag-repository command to tag aws environment. | ||
Specify list of tags which should be read using tags flag: --tags Name,Env,Project. | ||
Csv filename can be specified with flag filename.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
tags, _ := cmd.Flags().GetString("tags") | ||
filename, _ := cmd.Flags().GetString("filename") | ||
profile, _ := cmd.Flags().GetString("profile") | ||
region, _ := cmd.Flags().GetString("region") | ||
sess := pkg.GetSession(region, profile) | ||
client := ecr.New(sess) | ||
pkg.WriteCsv(pkg.ParseEcrRepositoriesTags(tags, client), filename) | ||
}, | ||
} | ||
|
||
var tagEcrRepoCmd = &cobra.Command{ | ||
Use: "tag-repository", | ||
Short: "Read csv and tag ecr repository with csv data", | ||
Long: `Read csv generated with get-repository-tags command and tag ecr repository with tags from csv.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
filename, _ := cmd.Flags().GetString("filename") | ||
profile, _ := cmd.Flags().GetString("profile") | ||
region, _ := cmd.Flags().GetString("region") | ||
sess := pkg.GetSession(region, profile) | ||
client := ecr.New(sess) | ||
csvData := pkg.ReadCsv(filename) | ||
pkg.TagEcrRepo(csvData, client) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(ecrCmd) | ||
ecrCmd.AddCommand(tagEcrRepoCmd) | ||
ecrCmd.AddCommand(getEcrTagsCmd) | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright © 2020 NAME HERE <EMAIL ADDRESS> | ||
Copyright © 2020 Maksym Postument [email protected] | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
|
@@ -27,9 +27,6 @@ var s3Cmd = &cobra.Command{ | |
Use: "s3", | ||
Short: "Root command for interaction with AWS s3 services", | ||
Long: `Root command for interaction with AWS s3 services.`, | ||
//Run: func(cmd *cobra.Command, args []string) { | ||
// fmt.Println("s3 called") | ||
//}, | ||
} | ||
|
||
var getS3Cmd = &cobra.Command{ | ||
|
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
Oops, something went wrong.