Skip to content

Commit

Permalink
Adds build information to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
bomoko committed Mar 1, 2022
1 parent 09becc9 commit efdc206
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 5 additions & 6 deletions controllers/configmap_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ import (
"context"
"fmt"
"github.com/cheshir/go-mq"
"k8s.io/apimachinery/pkg/util/json"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"time"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/json"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"time"
)

const InsightsLabel = "lagoon.sh/insightsType"
Expand Down Expand Up @@ -150,7 +149,7 @@ func insightsProcessedAnnotationExists(eventObject client.Object) bool {
annotations := eventObject.GetAnnotations()
annotationExists := false
if _, ok := annotations[InsightsUpdatedAnnotationLabel]; ok {
fmt.Println("Insights update annotation exists for " + eventObject.GetName())
log.Log.Info(fmt.Sprintf("Insights update annotation exists for '%v' in ns '%v'", eventObject.GetName(), eventObject.GetNamespace()))
annotationExists = true
}
return annotationExists
Expand Down
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,15 @@ func main() {
for _, x := range configMapList.Items {
//check the annotations
if _, okay := x.Annotations[controllers.InsightsUpdatedAnnotationLabel]; okay {
//grab the build this is linked to
buildName := ""
if val, ok := x.Labels["lagoon.sh/buildName"]; ok {
buildName = fmt.Sprintf(" (build: '%v')", val)
}
if err := client.Delete(context.Background(), &x); err != nil {
log.Printf("Unable to delete configMap '%v' in ns '%v': %v\n\n", x.Name, x.Namespace, err)
} else {
log.Printf("Deleted Insights configMap '%v' in ns '%v'", x.Name, x.Namespace)
log.Printf("Deleted Insights configMap '%v' in ns '%v' %v", x.Name, x.Namespace, buildName)
}
}
}
Expand Down

0 comments on commit efdc206

Please sign in to comment.