github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/cmd/remote-delete.go (about) 1 // Copyright © 2016 NAME HERE <EMAIL ADDRESS> 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package cmd 16 17 import ( 18 "fmt" 19 20 "github.com/sirupsen/logrus" 21 "github.com/solo-io/unik/pkg/client" 22 "github.com/spf13/cobra" 23 ) 24 25 // remote-deleteCmd represents the remote-delete command 26 var remoteDeleteCmd = &cobra.Command{ 27 Use: "remote-delete", 28 Short: "Deleted a pushed image from a Unik Hub Repository", 29 Long: ` 30 Example usage: 31 unik remote-delete --image myImage 32 33 Requires that you first authenticate to a unik image repository with 'unik login' 34 `, 35 Run: func(cmd *cobra.Command, args []string) { 36 if err := readClientConfig(); err != nil { 37 logrus.Fatal(err) 38 } 39 c, err := getHubConfig() 40 if err != nil { 41 logrus.Fatal(err) 42 } 43 if imageName == "" { 44 logrus.Fatal("--imageName must be set") 45 } 46 if host == "" { 47 host = clientConfig.Host 48 } 49 if err := client.UnikClient(host).Images().RemoteDelete(c, imageName); err != nil { 50 logrus.Fatal(err) 51 } 52 fmt.Println(imageName + " pushed") 53 }, 54 } 55 56 func init() { 57 RootCmd.AddCommand(remoteDeleteCmd) 58 remoteDeleteCmd.Flags().StringVar(&imageName, "image", "", "<string,required> image to push") 59 }