Documentation ¶
Overview ¶
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
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.
Index ¶
- Variables
- func CreateECRRepo(reponame string, accessKey string, secretKey string, regionName string, ...) error
- func PullDockerImageFromECR(remoteImageTag string, localRepository string, ecrRepoName string, ...) (string, error)
- func PushDockerImageToECR(localImageTag string, ecrRepoName string, accessKey string, secretKey string, ...) (string, error)
- type LoggerStruct
Constants ¶
This section is empty.
Variables ¶
var ECRctlCmd = &cobra.Command{ Use: "ecrctl", Short: "ecrctl is a stand alone wrapper for AWS ECR CLI", Long: ` _______ ______ .______ ______ .___________. __ | ____| / || _ \ / || || | | |__ | ,----'| |_) | | ,----''---| |----'| | | __| | | | / | | | | | | | |____ | '----.| |\ \----.| '----. | | | '----. |_______| \______|| _| ''._____| \______| |__| |_______| `, Run: func(cmd *cobra.Command, args []string) { create, _ := cmd.Flags().GetBool("create") push, _ := cmd.Flags().GetBool("push") pull, _ := cmd.Flags().GetBool("pull") repo, _ := cmd.Flags().GetString("repo") accesskey, _ := cmd.Flags().GetString("accesskey") secretkey, _ := cmd.Flags().GetString("secretkey") region, _ := cmd.Flags().GetString("region") image, _ := cmd.Flags().GetString("image") tag, _ := cmd.Flags().GetString("tag") ipCSVString, _ := cmd.Flags().GetString("whitelistips") localdockerrepo, _ := cmd.Flags().GetString("localdockerrepo") user, err := user.Current() if err != nil { panic(err) } logFile := "logs.txt" file, err := os.OpenFile(logFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666) if err != nil { panic(err) } usr := fmt.Sprintf(user.Name + " ") log := LoggerStruct{ filename: logFile, Logger: log.New(file, usr, log.LstdFlags), } mw := io.MultiWriter(os.Stdout, file) log.SetOutput(mw) if create { if len(ipCSVString) < 1 { log.Println(" --whitelistips <ips> flag is needed for creating repo") os.Exit(1) } CreateECRRepo(repo, accesskey, secretkey, region, ipCSVString, log) } else if push { if len(image) < 1 { log.Println(" --image <image_name> flag is needed for pushing image into repo") os.Exit(1) } PushDockerImageToECR(image, repo, accesskey, secretkey, region, log) } else if pull { if len(localdockerrepo) < 1 { log.Println(" --localdockerrepo <local_docker_reponame> flag is needed for pullinh image into repo") os.Exit(1) } if len(tag) < 1 { log.Println(" --tag <image_tag> flag is needed for pulling image into repo") os.Exit(1) } PullDockerImageFromECR(image, localdockerrepo, repo, accesskey, secretkey, region, log) } else { log.Println("ecrctl called") } }, }
ECRctlCmd represents the ecrctl command
Functions ¶
func CreateECRRepo ¶
func CreateECRRepo(reponame string, accessKey string, secretKey string, regionName string, ips string, log LoggerStruct) error
CreateECRRepo create a repository for the image on AWS ECR(EC2 Container Repository)
func PullDockerImageFromECR ¶
func PullDockerImageFromECR(remoteImageTag string, localRepository string, ecrRepoName string, accessKey string, secretKey string, regionName string, log LoggerStruct) (string, error)
PullDockerImageFromECR pulls a local Docker image to an ECR repository
func PushDockerImageToECR ¶
func PushDockerImageToECR(localImageTag string, ecrRepoName string, accessKey string, secretKey string, regionName string, log LoggerStruct) (string, error)
PushDockerImageToECR pushes a local Docker image to an ECR repository