Documentation ¶
Index ¶
Constants ¶
View Source
const ( Passed = "Passed" Failed = "Failed" Published = "Published" )
Variables ¶
View Source
var ErrNoPages = errors.New("no more pages")
View Source
var GetPublishStatusCommand = &cobra.Command{ Use: "status", Short: "Retrieves the current status of publish", PreRun: func(cmd *cobra.Command, args []string) { if !verbose { log.SetOutput(io.Discard) } else { log.SetOutput(cmd.OutOrStderr()) } }, RunE: func(cmd *cobra.Command, args []string) error { urlToShas, err := parseArgs() if err != nil { return err } statuses := []*ImagePublishStatus{} err = cmdFunction(cmd, args, urlToShas, func(_ context.Context, url string, _ *cdp.Node, img *ImagePublishStatus) error { matched := matchAndMark(urlToShas, img) if !matched { return nil } statuses = append(statuses, img) return nil }) if err != nil { return err } data, err := json.Marshal(statuses) if err != nil { return err } cmd.OutOrStdout().Write(data) return nil }, }
View Source
var ListSizeIds = map[ListSize][]string{ ListSize10: {"10", "ten"}, ListSize20: {"20", "twenty"}, ListSize50: {"50", "fifth"}, ListSize100: {"100", "hundred"}, }
View Source
var PublishCommand = &cobra.Command{ Use: "publish", Short: "Publish's the image on PC.", PreRun: func(cmd *cobra.Command, args []string) { if !verbose { log.SetOutput(io.Discard) } else { log.SetOutput(cmd.OutOrStderr()) } }, RunE: func(cmd *cobra.Command, args []string) error { urlToShas, err := parseArgs() if err != nil { return err } err = cmdFunction(cmd, args, urlToShas, func(ctx context.Context, url string, node *cdp.Node, result *ImagePublishStatus) error { matched := matchAndMark(urlToShas, result) if !matched { return nil } if result.CertificationStatus == Passed && result.PublishStatus != Published { if dryRun { return nil } err := publishImageByNode(ctx, node) if err != nil { log.Println("failed to publish", err) } log.Println("publishing result", result) } else if result.CertificationStatus == Passed && result.PublishStatus == Published { log.Println("image is already published", result) } else { log.Println("image is not ready to publish", result) } return nil }) if err != nil { log.Println("failed to publish", err) return err } return nil }, }
View Source
var (
Stop error = errors.New("stop")
)
View Source
var WaitAndPublishCmd = &cobra.Command{ Use: "wait-and-publish", Short: "Wait for the set of images to have a passing result and then publish it", SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { token := os.Getenv("RH_CONNECT_TOKEN") if token == "" { return errors.New("no api token provided, set RH_CONNECT_TOKEN") } ctx, cancel := context.WithTimeout(context.Background(), time.Minute*time.Duration(timeout)) defer cancel() results := newContainerResults(pidsToDigest) client := NewConnectClient(token) ticker := time.NewTicker(30 * time.Second) defer ticker.Stop() start := make(chan bool, 1) defer close(start) select { case start <- true: } process := func() (bool, error) { fmt.Printf("processing containers for tag %s\n", tag) results.Process(client, pidsToDigest, tag) if results.IsFinished() { if results.HasError() { results.PrintErrors() return false, errors.New("failed to publish all images") } fmt.Println("publish success") return true, nil } return false, nil } for { var ( done bool err error ) select { case <-start: done, err = process() case <-ticker.C: done, err = process() case <-ctx.Done(): err = errors.New("timed out") done = true } if err != nil { return err } if done { return nil } } }, }
Functions ¶
func GetChromeContext ¶
func GetChromeContext(dir string) (context.Context, context.CancelFunc)
func NewConnectClient ¶
func NewConnectClient(token string) *connectClient
func WithHeader ¶
func WithHeader(rt http.RoundTripper) withHeader
Types ¶
type ConnectWebsite ¶
type ConnectWebsite struct {
Username, Password string
// contains filtered or unexported fields
}
func (*ConnectWebsite) Login ¶
func (c *ConnectWebsite) Login(inCtx context.Context, username, password string) error
func (*ConnectWebsite) Publish ¶
func (c *ConnectWebsite) Publish(ctx context.Context, image *ImagePublishStatus) (bool, error)
func (*ConnectWebsite) Start ¶
func (c *ConnectWebsite) Start() (context.Context, context.CancelFunc)
type ImagePublishStatus ¶
Click to show internal directories.
Click to hide internal directories.