From: Gottox <Gottox@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] RFC: k9s: remove code that checks for new versions.
Date: Fri, 26 Mar 2021 17:44:17 +0100 [thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-29762@inbox.vuxu.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 541 bytes --]
There is a new pull request by Gottox against master on the void-packages repository
https://github.com/Gottox/void-packages k9s-no-connecting-to-github
https://github.com/void-linux/void-packages/pull/29762
RFC: k9s: remove code that checks for new versions.
This PR adds a patch to `k9s` that prevents the program to connect to github once per hour to check for new versions. We track that with void anyway and in my opinion it's an antifeature.
A patch file from https://github.com/void-linux/void-packages/pull/29762.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-k9s-no-connecting-to-github-29762.patch --]
[-- Type: text/x-diff, Size: 3398 bytes --]
From ee3b9f4c282033b3c3c22483025c0ac0ecbc3fb7 Mon Sep 17 00:00:00 2001
From: Enno Boland <gottox@voidlinux.org>
Date: Fri, 26 Mar 2021 17:30:57 +0100
Subject: [PATCH] k9s: remove code that checks for new versions.
---
srcpkgs/k9s/patches/no-phoning-home.diff | 89 ++++++++++++++++++++++++
srcpkgs/k9s/template | 2 +-
2 files changed, 90 insertions(+), 1 deletion(-)
create mode 100644 srcpkgs/k9s/patches/no-phoning-home.diff
diff --git a/srcpkgs/k9s/patches/no-phoning-home.diff b/srcpkgs/k9s/patches/no-phoning-home.diff
new file mode 100644
index 000000000000..45373c6f1081
--- /dev/null
+++ b/srcpkgs/k9s/patches/no-phoning-home.diff
@@ -0,0 +1,89 @@
+diff --git a/internal/model/cluster_info.go b/internal/model/cluster_info.go
+index 05564a07..ee04ae87 100644
+--- internal/model/cluster_info.go
++++ internal/model/cluster_info.go
+@@ -2,10 +2,6 @@ package model
+
+ import (
+ "context"
+- "encoding/json"
+- "errors"
+- "io/ioutil"
+- "net/http"
+ "time"
+
+ "github.com/derailed/k9s/internal/client"
+@@ -94,22 +90,6 @@ func NewClusterInfo(f dao.Factory, version string) *ClusterInfo {
+ return &c
+ }
+
+-func (c *ClusterInfo) fetchK9sLatestRev() string {
+- rev, ok := c.cache.Get(k9sLatestRevKey)
+- if ok {
+- return rev.(string)
+- }
+-
+- latestRev, err := fetchLastestRev()
+- if err != nil {
+- log.Error().Msgf("k9s latest rev fetch failed")
+- } else {
+- c.cache.Add(k9sLatestRevKey, latestRev, cacheExpiry)
+- }
+-
+- return latestRev
+-}
+-
+ // Reset resets context and reload.
+ func (c *ClusterInfo) Reset(f dao.Factory) {
+ c.cluster, c.data = NewCluster(f), NewClusterMeta()
+@@ -123,7 +103,7 @@ func (c *ClusterInfo) Refresh() {
+ data.Cluster = c.cluster.ClusterName()
+ data.User = c.cluster.UserName()
+ data.K9sVer = c.version
+- v1, v2 := NewSemVer(data.K9sVer), NewSemVer(c.fetchK9sLatestRev())
++ v1, v2 := NewSemVer(data.K9sVer), NewSemVer(data.K9sVer)
+ data.K9sVer, data.K9sLatest = v1.String(), v2.String()
+ if v1.IsCurrent(v2) {
+ data.K9sLatest = ""
+@@ -178,41 +158,3 @@ func (c *ClusterInfo) fireNoMetaChanged(data ClusterMeta) {
+ l.ClusterInfoUpdated(data)
+ }
+ }
+-
+-// Helpers...
+-
+-func fetchLastestRev() (string, error) {
+- log.Debug().Msgf("Fetching latest k9s rev...")
+- ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
+- defer cancel()
+-
+- req, err := http.NewRequestWithContext(ctx, http.MethodGet, k9sGitURL, nil)
+- if err != nil {
+- return "", err
+- }
+- resp, err := http.DefaultClient.Do(req)
+- if err != nil {
+- return "", err
+- }
+- defer func() {
+- if resp.Body != nil {
+- _ = resp.Body.Close()
+- }
+- }()
+-
+- b, err := ioutil.ReadAll(resp.Body)
+- if err != nil {
+- return "", err
+- }
+- m := make(map[string]interface{}, 20)
+- if err := json.Unmarshal(b, &m); err != nil {
+- return "", err
+- }
+-
+- if v, ok := m["name"]; ok {
+- log.Debug().Msgf("K9s latest rev: %q", v.(string))
+- return v.(string), nil
+- }
+-
+- return "", errors.New("No version found")
+-}
diff --git a/srcpkgs/k9s/template b/srcpkgs/k9s/template
index da44bfaf06d7..579c9f2d541c 100644
--- a/srcpkgs/k9s/template
+++ b/srcpkgs/k9s/template
@@ -1,7 +1,7 @@
# Template file for 'k9s'
pkgname=k9s
version=0.24.4
-revision=1
+revision=2
build_style=go
go_import_path="github.com/derailed/k9s"
go_ldflags="-X ${go_import_path}/cmd.version=${version}"
next reply other threads:[~2021-03-26 16:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-26 16:44 Gottox [this message]
2021-03-26 16:50 ` leahneukirchen
2021-03-26 16:52 ` ericonr
2021-03-29 12:16 ` [PR PATCH] [Updated] " Gottox
2022-05-14 2:17 ` github-actions
2022-05-29 2:13 ` [PR PATCH] [Closed]: " github-actions
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-29762@inbox.vuxu.org \
--to=gottox@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).