func createRC( rcs rcstore.Store, applicator labels.Applicator, manifest manifest.Manifest, desired int, nodes map[types.NodeName]bool, ) (rc_fields.RC, error) { created, err := rcs.Create(manifest, nil, nil) if err != nil { return rc_fields.RC{}, fmt.Errorf("Error creating RC: %s", err) } podID := string(manifest.ID()) for node := range nodes { if err = applicator.SetLabel(labels.POD, node.String()+"/"+podID, rc.RCIDLabel, string(created.ID)); err != nil { return rc_fields.RC{}, fmt.Errorf("Error applying RC ID label: %s", err) } } return created, rcs.SetDesiredReplicas(created.ID, desired) }
func applyLabels(applicator labels.Applicator, entityID string, labelType labels.Type, additiveLabels map[string]string, destructiveKeys []string) error { var err error if !confirm(fmt.Sprintf("mutate the labels for %s/%s", labelType, entityID)) { return nil } if len(additiveLabels) > 0 { for k, v := range additiveLabels { err = applicator.SetLabel(labelType, entityID, k, v) if err != nil { fmt.Fprintf(os.Stderr, "Error while appyling label. k/v: %s/%s.\n%v\n", k, v, err) } } } if len(destructiveKeys) > 0 { for _, key := range destructiveKeys { err = applicator.RemoveLabel(labelType, entityID, key) if err != nil { fmt.Fprintf(os.Stderr, "Error while destroying label with key: %s.\n%v\n", key, err) } } } return nil }