fix: updating to the smarter client

This commit is contained in:
Aditya
2025-11-21 19:23:17 +05:30
parent afc9c6cfc7
commit b6f56ed7a2
5 changed files with 50 additions and 23 deletions
+9 -6
View File
@@ -21,7 +21,6 @@ import (
"github.com/docker/docker/api/types"
//"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/client"
newdockerclient "github.com/fsouza/go-dockerclient"
"github.com/go-git/go-billy/v5"
@@ -35,12 +34,13 @@ import (
"os"
"strings"
"time"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"time"
// "k8s.io/client-go/tools/clientcmd"
// "k8s.io/client-go/util/homedir"
)
@@ -206,7 +206,8 @@ func fixTags(tags []string) []string {
// Custom Docker image builder wrapper in memory
func buildImageMemory(fs billy.Filesystem, tags []string, dockerfileFolder string, downloadIfFail bool) error {
ctx := context.Background()
client, err := client.NewEnvClient()
// client, err := client.NewEnvClient()
client, _, err := shuffle.GetDockerClient()
defer client.Close()
if err != nil {
log.Printf("Unable to create docker client: %s", err)
@@ -474,7 +475,8 @@ func buildImage(tags []string, dockerfileLocation string) error {
}
ctx := context.Background()
client, err := client.NewEnvClient()
// client, err := client.NewEnvClient()
client, _, err := shuffle.GetDockerClient()
defer client.Close()
if err != nil {
log.Printf("Unable to create docker client: %s", err)
@@ -562,7 +564,8 @@ func imageCheckBuilder(images []string) error {
return nil
ctx := context.Background()
client, err := client.NewEnvClient()
// client, err := client.NewEnvClient()
client, _, err := shuffle.GetDockerClient()
if err != nil {
log.Printf("Unable to create docker client: %s", err)
return err
@@ -651,7 +654,7 @@ func getDockerImage(resp http.ResponseWriter, request *http.Request) {
}
//log.Printf("[DEBUG] Image to load: %s", version.Name)
dockercli, err := client.NewEnvClient()
dockercli, _, err := shuffle.GetDockerClient()
if err != nil {
log.Printf("[WARNING] Unable to create docker client: %s", err)
resp.WriteHeader(422)
+4 -3
View File
@@ -3,7 +3,7 @@ package main
import (
uuid "github.com/satori/go.uuid"
"github.com/shuffle/shuffle-shared"
"github.com/shuffle/singul/pkg"
singul "github.com/shuffle/singul/pkg"
"net/http/pprof"
@@ -44,11 +44,12 @@ import (
"github.com/go-git/go-git/v5/storage/memory"
// Random
"sort"
xj "github.com/basgys/goxml2json"
newscheduler "github.com/carlescere/scheduler"
"golang.org/x/crypto/bcrypt"
"gopkg.in/yaml.v3"
"sort"
// Web
"github.com/gorilla/mux"
@@ -5433,7 +5434,7 @@ func initHandlers() {
r.HandleFunc("/api/v1/users/getsettings", shuffle.HandleSettings).Methods("GET", "OPTIONS")
r.HandleFunc("/api/v1/users/getusers", shuffle.HandleGetUsers).Methods("GET", "OPTIONS")
r.HandleFunc("/api/v1/users/updateuser", shuffle.HandleUpdateUser).Methods("PUT", "OPTIONS")
r.HandleFunc("/api/v1/users/{userID}/remove", shuffle.HandleDeleteUsersAccount).Methods("DELETE", "OPTIONS")
// r.HandleFunc("/api/v1/users/{userID}/remove", shuffle.HandleDeleteUsersAccount).Methods("DELETE", "OPTIONS")
r.HandleFunc("/api/v1/users/{user}", shuffle.DeleteUser).Methods("DELETE", "OPTIONS")
r.HandleFunc("/api/v1/users/passwordchange", shuffle.HandlePasswordChange).Methods("POST", "OPTIONS")
r.HandleFunc("/api/v1/users/{key}/get2fa", shuffle.HandleGet2fa).Methods("GET", "OPTIONS")
+3 -2
View File
@@ -11,6 +11,7 @@ import (
"io"
"io/ioutil"
"log"
//"math/rand"
"net/http"
"net/url"
@@ -21,7 +22,6 @@ import (
"time"
"github.com/docker/docker/api/types/image"
dockerclient "github.com/docker/docker/client"
"github.com/h2non/filetype"
uuid "github.com/satori/go.uuid"
@@ -3527,7 +3527,8 @@ func LoadSpecificApps(resp http.ResponseWriter, request *http.Request) {
// As it's not even Docker
if tmpBody.ForceUpdate {
dockercli, err := dockerclient.NewEnvClient()
// dockercli, err := dockerclient.NewEnvClient()
dockercli, _, err := shuffle.GetDockerClient()
if err == nil {
appSdk := os.Getenv("SHUFFLE_APP_SDK_VERSION")