Skip to content

Commit

Permalink
Merge pull request #15 from NBISweden/hot-fix/ingress
Browse files Browse the repository at this point in the history
cronjob fix and minor web fixes
  • Loading branch information
darthvader2 authored May 6, 2024
2 parents a5b7b16 + 0118ccc commit 8b7cf77
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
web/public/*
web/content/datasets/test*
web/content/datasets/test*
web/data/*
dev_utils/config.yaml
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ENV CGO_ENABLED=0
RUN go build -o app .

FROM alpine:3.17
WORKDIR /gen_app
RUN apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community hugo
COPY --from=build /lp_app/app .
COPY --from=build /lp_app/web web/
Expand Down
2 changes: 1 addition & 1 deletion charts/landing-pages-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.4
version: 0.1.5

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
1 change: 1 addition & 0 deletions charts/landing-pages-chart/templates/lp_cj.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ spec:
- name: lp-generator-container
image: {{ .Values.images.lp_image }}
imagePullPolicy: Always
command: ["sh" , "-c", "cp app -r web tmp/ && /tmp/app"]
env:
- name: CONFIGFILE
value: "/.secrets/config.yaml"
Expand Down
6 changes: 2 additions & 4 deletions download_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func metadataDownloader(Metadataclient *MetadataBackend) {
for paginator.HasMorePages() {
page, err := paginator.NextPage(context.TODO())
if err != nil {
log.Fatalln("error:", err)
log.Fatalln("Error while paginating the s3 bucket", err)
}
for _, obj := range page.Contents {
err := downloadToFile(manager, LocalDirectory, Bucket, aws.ToString(obj.Key))
Expand Down Expand Up @@ -58,12 +58,10 @@ func downloadToFile(downloader *manager.Downloader, targetDirectory, bucket, key
log.Fatal("Error while writing XML files to folder", err)
}
defer fd.Close()
// Download the file using the AWS SDK for Go
//fmt.Printf("Downloading s3://%s/%s to %s...\n", bucket, key, file)

_, err = downloader.Download(context.TODO(), fd, &s3.GetObjectInput{Bucket: &bucket, Key: &key})
if err != nil {
log.Infoln("Failed to download metadatafiles")
log.Fatal("Failed to download metadatafiles", err)
}
return err
}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

func main() {
log.SetLevel(log.InfoLevel)
log.Infoln("started app successfully")
mConf := getMetadataConfig()
Metadataclient := connectMetadatas3(mConf)
Expand Down
15 changes: 8 additions & 7 deletions markdown_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"os"
"path/filepath"
"strings"

log "github.com/sirupsen/logrus"
)

func markDownCreator() {
Expand All @@ -16,14 +18,14 @@ func markDownCreator() {

// Create the Markdown directory if it doesn't exist
if err := os.MkdirAll(markdownDir, 0755); err != nil {
fmt.Println("Error creating directory:", err)
log.Fatal("Error creating directory:", err)
os.Exit(1)
}

// Walk through the XML directory
err := filepath.Walk(xmlDirPath, func(xmlFilePath string, info os.FileInfo, err error) error {
if err != nil {
fmt.Printf("Error accessing file %s: %v\n", xmlFilePath, err)
log.Fatal("Error accessing file", err)
return nil
}
// Skip directories
Expand Down Expand Up @@ -52,25 +54,24 @@ Filename of the associated XML file: %s
mdFileName := filepath.Join(markdownDir, fileNameWithoutExt+".md")
mdFile, err := os.Create(mdFileName)
if err != nil {
fmt.Printf("Error creating Markdown file %s: %v\n", mdFileName, err)
log.Fatal("Error creating Markdown file %V", err)
return nil
}
defer mdFile.Close()

// Write Markdown content to the file
_, err = mdFile.WriteString(markdownContent)
if err != nil {
fmt.Printf("Error writing to Markdown file %s: %v\n", mdFileName, err)
log.Fatal("Error writing to Markdown file %V", mdFileName, err)
return nil
}

fmt.Printf("Markdown file %s created successfully!\n", mdFileName)
log.Infoln("Markdown file %S created successfully!\n", mdFileName)

return nil
})

if err != nil {
fmt.Println("Error walking through directory:", err)
os.Exit(1)
log.Fatal("Error walking through directory:", err)
}
}
13 changes: 12 additions & 1 deletion s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,25 @@ func connectMetadatas3(mConf MetadataS3Config) *MetadataBackend {
Client: client,
Bucket: mConf.Bucket,
}
_, err = metadata_client.Client.ListObjectsV2(context.TODO(), &s3.ListObjectsV2Input{
resp, err := metadata_client.Client.ListObjectsV2(context.TODO(), &s3.ListObjectsV2Input{
Bucket: aws.String(metadata_client.Bucket),
})
if err != nil {
log.Fatalf("Error while connecting to the metadata bucket %v\n ", err)
} else {
log.Infoln("Connection established to metadata bucket", metadata_client.Bucket)
}

// Abort if 0 metadata files found in bucket
numberOfFiles := 0
for _, obj := range resp.Contents {
if obj.Key != nil {
numberOfFiles++
}
}
if numberOfFiles == 0 {
log.Fatal("No Metadata files found in bucket. Length of files ", numberOfFiles)
}
return metadata_client
}

Expand Down
2 changes: 1 addition & 1 deletion static_files_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func test(DeploymenClient *DeploymentBackend) {
Body: bytes.NewReader(buf),
ContentType: aws.String(contentType),
})
println(contentType)
log.Debug(contentType)
file.Close()
if err != nil {
log.Fatalln("Failed to upload", path, err)
Expand Down
2 changes: 1 addition & 1 deletion web/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
baseurl = "https://lp.bp.nbis.se"
baseurl = "https://datasets.bp.nbis.se"
title = "Bigpicture datasets"
languageCode = "en-us"

Expand Down
6 changes: 3 additions & 3 deletions web/layouts/datasets/list.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{ define "main" }}
<h2> Bigpicture Datasets</h2>
<ul>
{{ range .Pages }}
<li>
<a href="{{ .RelPermalink }}"> {{ .Page }}</a>
</li>
<a href="{{ .RelPermalink }}"><p>HUS mock dataset</p></a>

{{ end }}
</ul>
{{ .Params.datasets.name }}
Expand Down
48 changes: 45 additions & 3 deletions web/layouts/shortcodes/datafetch.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,54 @@

{{- $variable := .Get "variable" -}}
<div>
{{ $data := index .Site.Data.datasets $variable }}
{{ if $data }}
{{ range $data.LANDING_PAGE.ATTRIBUTES.STRING_ATTRIBUTE }}
<p>{{ .TAG }} : {{ .VALUE }} </p>
{{ $stringAttributes2 := index $data.LANDING_PAGE.ATTRIBUTES.STRING_ATTRIBUTE }}
{{ $rte := where $stringAttributes2 "TAG" "header" }}
{{ range $rte }}
<h1>{{ .VALUE }} </h1>
{{ end }}
<table>
<!-- String attributes section -->
{{ $stringAttributes := index $data.LANDING_PAGE.ATTRIBUTES.STRING_ATTRIBUTE }}
{{ $filtered := where $stringAttributes "TAG" "!=" "header" }}
{{ $filtered := where $filtered "TAG" "!=" "rems_link" }}
{{ range $filtered }}
<tr>
<td>{{ replaceRE `(_{1,})` " " .TAG }}</td>
<td>{{ .VALUE }}</td>
</tr>

{{ end }}
<!-- Set attributes section -->

{{ range index $data.LANDING_PAGE.ATTRIBUTES.SET_ATTRIBUTE }}
<tr>
<td>{{ replaceRE `(_{1,})` " " .TAG }}</td>
<td>{{ .VALUE.STRING_ATTRIBUTE.VALUE }}</td>
</tr>
{{ end }}



<!-- Numeric attributes section -->
{{ $numAttributes := index $data.LANDING_PAGE.ATTRIBUTES.NUMERIC_ATTRIBUTE }}
{{ range $numAttributes }}
<tr>
<td>{{ replaceRE `(_{1,})` " " .TAG }}</td>
<td>{{ .VALUE }}</td>
</tr>
{{ end }}
</table>
{{ else }}
<p>Data for '{{ $variable }}' not found.</p>
{{ end }}

<h2>Comments</h2>
{{ $stringAttributes2 := index $data.LANDING_PAGE.ATTRIBUTES.STRING_ATTRIBUTE }}
{{ $rte := where $stringAttributes2 "TAG" "rems_link" }}
{{ range $rte }}
<a href= "{{ .VALUE }}"> <h2 >Apply for access</h2></a>
<p>If you are interested to access data, apply through clicking link above</p>

{{ end }}
</div>

0 comments on commit 8b7cf77

Please sign in to comment.