cloudfoundry-incubator/eirini

View on GitHub

Showing 59 of 59 total issues

Method LRPToStatefulSet.Convert has 135 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *LRPToStatefulSet) Convert(statefulSetName string, lrp *api.LRP, privateRegistrySecret *corev1.Secret) (*appsv1.StatefulSet, error) {
envs := shared.MapToEnvVar(lrp.Env)
fieldEnvs := []corev1.EnvVar{
{
Name: eirini.EnvPodName,
Severity: Major
Found in k8s/stset/lrp_to_statefulset.go - About 4 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    package patching
     
    import (
    "encoding/json"
     
     
    Severity: Major
    Found in k8s/patching/annotation.go and 1 other location - About 2 hrs to fix
    k8s/patching/label.go on lines 1..37

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    package patching
     
    import (
    "encoding/json"
     
     
    Severity: Major
    Found in k8s/patching/label.go and 1 other location - About 2 hrs to fix
    k8s/patching/annotation.go on lines 1..37

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (c *StatefulSet) GetByLRPIdentifier(ctx context.Context, id api.LRPIdentifier) ([]appsv1.StatefulSet, error) {
    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
    defer cancel()
     
    statefulSetList, err := c.clientSet.AppsV1().StatefulSets(c.workloadsNamespace).List(ctx, metav1.ListOptions{
    Severity: Major
    Found in k8s/client/statefulset_client.go and 1 other location - About 1 hr to fix
    k8s/client/pod_client.go on lines 46..62

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (c *Pod) GetByLRPIdentifier(ctx context.Context, id api.LRPIdentifier) ([]corev1.Pod, error) {
    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
    defer cancel()
     
    podList, err := c.clientSet.CoreV1().Pods(c.workloadsNamespace).List(ctx, metav1.ListOptions{
    Severity: Major
    Found in k8s/client/pod_client.go and 1 other location - About 1 hr to fix
    k8s/client/statefulset_client.go on lines 57..73

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    func (c *StatefulSet) SetAnnotation(ctx context.Context, statefulSet *appsv1.StatefulSet, key, value string) (*appsv1.StatefulSet, error) {
    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
    defer cancel()
     
    annotation := patching.NewAnnotation(key, value)
    Severity: Major
    Found in k8s/client/statefulset_client.go and 3 other locations - About 1 hr to fix
    k8s/client/job_client.go on lines 82..95
    k8s/client/job_client.go on lines 97..109
    k8s/client/pod_client.go on lines 71..84

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    func (c *Pod) SetAnnotation(ctx context.Context, pod *corev1.Pod, key, value string) (*corev1.Pod, error) {
    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
    defer cancel()
     
    annotation := patching.NewAnnotation(key, value)
    Severity: Major
    Found in k8s/client/pod_client.go and 3 other locations - About 1 hr to fix
    k8s/client/job_client.go on lines 82..95
    k8s/client/job_client.go on lines 97..109
    k8s/client/statefulset_client.go on lines 82..95

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    func (c *Job) SetAnnotation(ctx context.Context, job *batchv1.Job, key, value string) (*batchv1.Job, error) {
    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
    defer cancel()
     
    annotation := patching.NewAnnotation(key, value)
    Severity: Major
    Found in k8s/client/job_client.go and 3 other locations - About 1 hr to fix
    k8s/client/job_client.go on lines 97..109
    k8s/client/pod_client.go on lines 71..84
    k8s/client/statefulset_client.go on lines 82..95

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

    func (c *Job) SetLabel(ctx context.Context, job *batchv1.Job, label, value string) (*batchv1.Job, error) {
    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
    defer cancel()
     
    labelPatch := patching.NewLabel(label, value)
    Severity: Major
    Found in k8s/client/job_client.go and 3 other locations - About 1 hr to fix
    k8s/client/job_client.go on lines 82..95
    k8s/client/pod_client.go on lines 71..84
    k8s/client/statefulset_client.go on lines 82..95

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func registerCounter(registry prometheus_api.Registerer, name, help string) (prometheus_api.Counter, error) {
    c := prometheus_api.NewCounter(prometheus_api.CounterOpts{
    Name: name,
    Help: help,
    })
    Severity: Major
    Found in prometheus/lrp_client.go and 1 other location - About 1 hr to fix
    prometheus/lrp_client.go on lines 93..110

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (c *Secret) SetOwner(ctx context.Context, secret *corev1.Secret, owner metav1.Object) (*corev1.Secret, error) {
    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
    defer cancel()
     
    if err := controllerutil.SetOwnerReference(owner, secret, scheme.Scheme); err != nil {
    Severity: Major
    Found in k8s/client/secret_client.go and 1 other location - About 1 hr to fix
    k8s/client/pod_disruption_budget_client.go on lines 45..56

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (c *PodDisruptionBudget) SetOwner(ctx context.Context, pdb *policyv1beta1.PodDisruptionBudget, owner *appsv1.StatefulSet) (*policyv1beta1.PodDisruptionBudget, error) {
    ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
    defer cancel()
     
    if err := controllerutil.SetOwnerReference(owner, pdb, scheme.Scheme); err != nil {
    Severity: Major
    Found in k8s/client/pod_disruption_budget_client.go and 1 other location - About 1 hr to fix
    k8s/client/secret_client.go on lines 51..62

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func registerHistogram(registry prometheus_api.Registerer, name, help string) (prometheus_api.Histogram, error) {
    h := prometheus_api.NewHistogram(prometheus_api.HistogramOpts{
    Name: name,
    Help: help,
    })
    Severity: Major
    Found in prometheus/lrp_client.go and 1 other location - About 1 hr to fix
    prometheus/lrp_client.go on lines 74..91

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (e *Executor) setStatefulSetAnnotation(ctx context.Context, obj runtime.Object, seq int) error {
    stSet, ok := obj.(*appsv1.StatefulSet)
    if !ok {
    return fmt.Errorf("expected *appsv1.StatefulSet, got %T", obj)
    }
    Severity: Major
    Found in migrations/executor.go and 1 other location - About 1 hr to fix
    migrations/executor.go on lines 176..187

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (e *Executor) setJobAnnotation(ctx context.Context, obj runtime.Object, seq int) error {
    job, ok := obj.(*batchv1.Job)
    if !ok {
    return fmt.Errorf("expected *batchv1.Job got %T", obj)
    }
    Severity: Major
    Found in migrations/executor.go and 1 other location - About 1 hr to fix
    migrations/executor.go on lines 163..174

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    type SecretsClient interface {
    Create(ctx context.Context, namespace string, secret *corev1.Secret) (*corev1.Secret, error)
    SetOwner(ctx context.Context, secret *corev1.Secret, owner metav1.Object) (*corev1.Secret, error)
    Delete(ctx context.Context, namespace string, name string) error
    }
    Severity: Major
    Found in k8s/jobs/desire.go and 1 other location - About 1 hr to fix
    k8s/stset/desire.go on lines 28..32

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    type SecretsClient interface {
    Create(ctx context.Context, namespace string, secret *corev1.Secret) (*corev1.Secret, error)
    SetOwner(ctx context.Context, secret *corev1.Secret, owner metav1.Object) (*corev1.Secret, error)
    Delete(ctx context.Context, namespace string, name string) error
    }
    Severity: Major
    Found in k8s/stset/desire.go and 1 other location - About 1 hr to fix
    k8s/jobs/desire.go on lines 29..33

    Function main has 54 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func main() {
    var opts options
    _, err := flags.ParseArgs(&opts, os.Args)
    cmdcommons.ExitfIfError(err, "Failed to parse args")
     
     
    Severity: Minor
    Found in cmd/task-reporter/main.go - About 1 hr to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (d *Desirer) cleanupAndError(ctx context.Context, stsetCreationError error, privateRegistrySecret *corev1.Secret) error {
      resultError := multierror.Append(nil, stsetCreationError)
       
      if privateRegistrySecret != nil {
      err := d.secrets.Delete(ctx, privateRegistrySecret.Namespace, privateRegistrySecret.Name)
      Severity: Major
      Found in k8s/stset/desire.go and 1 other location - About 1 hr to fix
      k8s/jobs/desire.go on lines 126..137

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (d *Desirer) cleanupAndError(ctx context.Context, jobCreationError error, privateRegistrySecret *corev1.Secret) error {
      resultError := multierror.Append(nil, jobCreationError)
       
      if privateRegistrySecret != nil {
      err := d.secrets.Delete(ctx, privateRegistrySecret.Namespace, privateRegistrySecret.Name)
      Severity: Major
      Found in k8s/jobs/desire.go and 1 other location - About 1 hr to fix
      k8s/stset/desire.go on lines 143..154
      Severity
      Category
      Status
      Source
      Language