Skip to content

Commit

Permalink
update permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
niraj-elastic committed Apr 12, 2024
1 parent 2d4e6d4 commit 256b3c5
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 48 deletions.

This file was deleted.

Empty file modified packages/mongodb_atlas/_dev/deploy/docker/mongodb_atlas/go.mod
100644 → 100755
Empty file.
43 changes: 0 additions & 43 deletions packages/mongodb_atlas/_dev/deploy/docker/mongodb_atlas/main.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package main

import (
"compress/gzip"
"crypto/md5"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"strings"
)

Expand Down Expand Up @@ -115,42 +112,6 @@ func hostHandler(w http.ResponseWriter, r *http.Request) {
}
}

func logsHandler(w http.ResponseWriter, r *http.Request) {
// Digest Authentication
realm := "MyRealm"
nonce := "123456"
qop := "auth"

authorized := digestAuth(w, r, realm, nonce, qop)
if !authorized {
return
}

logFilePath := "data.log"

// Open the log file
logFile, err := os.Open(logFilePath)
if err != nil {
http.Error(w, fmt.Sprintf("Error opening log file: %v", err), http.StatusInternalServerError)
return
}
defer logFile.Close()

// Create a gzip writer for the response
w.Header().Set("Content-Type", "application/vnd.atlas.2023-02-01+gzip")
w.Header().Set("Content-Disposition", `attachment; filename="mongodb-log.gz"`)

gzipWriter := gzip.NewWriter(w)
defer gzipWriter.Close()

// Copy the log file content to the gzip writer
_, err = io.Copy(gzipWriter, logFile)
if err != nil {
http.Error(w, fmt.Sprintf("Error reading log file: %v", err), http.StatusInternalServerError)
return
}
}

func metricsHandler(w http.ResponseWriter, r *http.Request) {

realm := "MyRealm"
Expand Down Expand Up @@ -230,10 +191,6 @@ func metricsHandler(w http.ResponseWriter, r *http.Request) {
}

func main() {
// Existing handler for serving the compressed file
http.HandleFunc("/api/atlas/v2/groups/mongodb-group1/clusters/hostname1/logs/mongodb-audit-log.gz", logsHandler)

http.HandleFunc("/api/atlas/v2/groups/mongodb-group1/clusters/hostname1/logs/mongodb.gz", logsHandler)

// Existing handler for serving the JSON response
http.HandleFunc("/api/atlas/v2/groups/mongodb-group1/processes/hostname1/measurements", metricsHandler)
Expand Down

0 comments on commit 256b3c5

Please sign in to comment.