Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugins): improve logging #190

Merged
merged 3 commits into from
Dec 26, 2023
Merged

fix(plugins): improve logging #190

merged 3 commits into from
Dec 26, 2023

Conversation

fritzduchardt
Copy link
Collaborator

@fritzduchardt fritzduchardt commented Dec 26, 2023

Small tweaks to the log output to get a clean log output. Please feast your eyes on my new "apply" plugin output driven by sops, kubeconform and kapp:

8:59AM INF [local-kind > my-workload > apply] Plugin execution succeeded:

Decrypting secrets
Validating Kubernetes manifests
Applying Kubernetes manifests
Target cluster 'https://127.0.0.1:45811' (nodes: dev-cluster-control-plane, 2+)

Changes

Namespace  Name  Kind  Age  Op  Op st.  Wait to  Rs  Ri  

Op:      0 create, 0 delete, 0 update, 0 noop, 0 exists
Wait to: 0 reconcile, 0 delete, 0 noop

Succeeded
Encrypting secrets

FYI: This is my apply script:

#! /usr/bin/env bash

function prepare() {
  local action="$1"
  local exit_code=0
  if [[ -e "$MYKS_RENDERED_APP_DIR"/static ]]; then
    case "$action" in
    "encrypt")
      echo "Encrypting secrets"
      find "$MYKS_RENDERED_APP_DIR"/static -type f -name "*.sops.yaml" -exec sops -e -i {} \;
      exit_code=$?
      ;;
    "decrypt")
      echo "Decrypting secrets"
      find "$MYKS_RENDERED_APP_DIR"/static -type f -name "*.sops.yaml" -exec sops -d -i {} \;
      exit_code=$?
      ;;
    esac
  fi
  if [[ "$exit_code" == 1 ]]; then
    echo "Failed to $action secrets"
  fi
  return $exit_code
}

function validate() {
  echo "Validating Kubernetes manifests"
  kubeconform \
    -schema-location 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/{{.NormalizedKubernetesVersion}}-standalone{{.StrictSuffix}}/{{.ResourceKind}}{{.KindSuffix}}.json' \
    -strict \
    -skip "CustomResourceDefinition,NetworkAttachmentDefinition" \
    "$MYKS_RENDERED_APP_DIR"
  return $?
}

function apply() {
  echo "Applying Kubernetes manifests"
  set -x
  kapp --wait=false --yes deploy -a "$MYKS_APP" -f "$MYKS_RENDERED_APP_DIR"
  set +x
  return $?
}

main() {
  if ! prepare "decrypt"; then
    exit 1
  fi
  trap "prepare encrypt" EXIT
  if ! validate; then
    echo "Validation failed"
    exit 1
  fi
  if ! apply; then
    echo "Failed to apply manifests"
    exit 1
  fi
}

main


@fritzduchardt fritzduchardt changed the title Logging tweaks fix: Logging tweaks Dec 26, 2023
Copy link

codecov bot commented Dec 26, 2023

Codecov Report

Attention: 21 lines in your changes are missing coverage. Please review.

Comparison is base (4a3becc) 48.16% compared to head (c140e91) 47.92%.
Report is 4 commits behind head on dev.

Files Patch % Lines
internal/myks/plugins.go 0.00% 20 Missing ⚠️
cmd/root.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #190      +/-   ##
==========================================
- Coverage   48.16%   47.92%   -0.24%     
==========================================
  Files          26       26              
  Lines        2448     2460      +12     
==========================================
  Hits         1179     1179              
- Misses       1085     1097      +12     
  Partials      184      184              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Zebradil Zebradil changed the title fix: Logging tweaks fix(plugins): improve logging Dec 26, 2023
@Zebradil Zebradil merged commit ba31a3b into dev Dec 26, 2023
6 checks passed
@Zebradil Zebradil deleted the logging-tweaks branch December 26, 2023 13:16
mykso-bot added a commit that referenced this pull request Dec 29, 2023
# [3.1.0](v3.0.4...v3.1.0) (2023-12-29)

### Bug Fixes

* **deps:** update golang.org/x/exp digest to 02704c9 ([#160](#160)) ([e9fe05e](e9fe05e))
* **plugins:** improve logging ([#190](#190)) ([ba31a3b](ba31a3b))
* **smart_mode:** add static files directory ([#193](#193)) ([3f52709](3f52709))

### Features

* Execute helm dependency build ([#154](#154)) ([c2c0baa](c2c0baa)), closes [#146](#146)
mykso-bot added a commit that referenced this pull request Dec 29, 2023
# [3.1.0](v3.0.4...v3.1.0) (2023-12-29)

### Bug Fixes

* **deps:** update golang.org/x/exp digest to 02704c9 ([#160](#160)) ([e9fe05e](e9fe05e))
* **plugins:** improve logging ([#190](#190)) ([ba31a3b](ba31a3b))
* **smart_mode:** add static files directory ([#193](#193)) ([3f52709](3f52709))

### Features

* Execute helm dependency build ([#154](#154)) ([c2c0baa](c2c0baa)), closes [#146](#146)
mykso-bot added a commit that referenced this pull request Dec 29, 2023
# [3.1.0](v3.0.4...v3.1.0) (2023-12-29)

### Bug Fixes

* **deps:** update golang.org/x/exp digest to 02704c9 ([#160](#160)) ([e9fe05e](e9fe05e))
* **plugins:** improve logging ([#190](#190)) ([ba31a3b](ba31a3b))
* **smart_mode:** add static files directory ([#193](#193)) ([3f52709](3f52709))

### Features

* Execute helm dependency build ([#154](#154)) ([c2c0baa](c2c0baa)), closes [#146](#146)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants