Skip to content

Commit

Permalink
feat: added code to update hubs
Browse files Browse the repository at this point in the history
  • Loading branch information
demeyerthom committed Aug 2, 2024
1 parent 5144cdb commit f32f42f
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Added-20240802-112936.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Added
body: Added hub update logic and extended Hub struct
time: 2024-08-02T11:29:36.677278883+02:00
81 changes: 81 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '44 19 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ jobs:
uses: paultyng/[email protected]
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 9 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
go-version: ["1.15"]
go-version: ["1.15", "1.22"]
steps:
- uses: actions/checkout@v4

Expand All @@ -31,6 +31,13 @@ jobs:
with:
verbose: true

changes-file:
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
steps:
- uses: actions/checkout@v4
- uses: mach-composer/check-changie-changes-action@main

changie:
runs-on: ubuntu-latest
needs: test
Expand All @@ -45,7 +52,7 @@ jobs:
fetch-depth: 0

- name: Prepare release
uses: labd/changie-release-action@main
uses: labd/changie-release-action@v0.3.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
release-workflow: 'release.yaml'
5 changes: 0 additions & 5 deletions Makefile

This file was deleted.

20 changes: 20 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3'

tasks:
format:
cmds:
- go fmt ./...

test:
cmds:
- go test -v ./...

coverage-html:
cmds:
- go test -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=./... ./...
- go tool cover -html=coverage.txt

coverage:
cmds:
- go test -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=./... ./...
- go tool cover -func=coverage.txt
95 changes: 80 additions & 15 deletions content/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,79 @@ import (
"encoding/json"
"fmt"
"net/http"
"time"
)

type Hub struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Label string `json:"label"`
Description string `json:"description"`
Status string `json:"status"`
ID string `json:"id,omitempty"`
Name string `json:"name"`
Label string `json:"label"`
Description *string `json:"description,omitempty"`
Plan *string `json:"plan,omitempty"`
AlgoliaSearch string `json:"algoliaSearch"`
CDV2 string `json:"cdv2"`
OrganizationID string `json:"organizationId"`
Settings *Settings `json:"settings,omitempty"`
Links map[string]Link `json:"_links"`
}

type AmplienceDamSettings struct {
ApiKey string `json:"API_KEY"`
ApiSecret string `json:"API_SECRET"`
Endpoint string `json:"endpoint"`
}

type PlatformSettings struct {
AmplienceDam *AmplienceDamSettings `json:"amplience_dam,omitempty"`
}

type PublishingSettings struct {
Platforms *PlatformSettings `json:"platforms,omitempty"`
}

type DeviceSettings struct {
Name string `json:"name"`
Width int `json:"width"`
Height int `json:"height"`
Orientate bool `json:"orientate"`
}

type LocalizationSettings struct {
Locales []string `json:"locales,omitempty"`
}

type ApplicationSettings struct {
Name string `json:"name"`
TemplatedUri string `json:"templatedUri"`
}

CreatedBy string `json:"createdBy"`
CreatedDate *time.Time `json:"createdDate"`
LastModifiedBy string `json:"lastModifiedBy"`
LastModifiedDate *time.Time `json:"lastModifiedDate"`
type PreviewVirtualStagingEnvironmentSettings struct {
Hostname string `json:"hostname"`
}

type VirtualStagingEnvironmentSettings struct {
Hostname string `json:"hostname"`
}

type AssetManagementSettings struct {
Enabled *bool `json:"enabled,omitempty"`
ClientConfig *string `json:"clientConfig,omitempty"`
}

type Settings struct {
Publishing *PublishingSettings `json:"publishing,omitempty"`
Devices []DeviceSettings `json:"devices,omitempty"`
Localization *LocalizationSettings `json:"localization,omitempty"`
Applications []ApplicationSettings `json:"applications,omitempty"`
PreviewVirtualStagingEnvironment *PreviewVirtualStagingEnvironmentSettings `json:"previewVirtualStagingEnvironment,omitempty"`
VirtualStagingEnvironment *VirtualStagingEnvironmentSettings `json:"virtualStagingEnvironment,omitempty"`
AssetManagement *AssetManagementSettings `json:"assetManagement,omitempty"`
}

type HubUpdateInput struct {
Name string `json:"name"`
Label string `json:"label"`
Description *string `json:"description"`
Settings *Settings `json:"settings"`
}

type HubResults struct {
Expand Down Expand Up @@ -69,15 +128,21 @@ func (client *Client) HubGetAll() ([]Hub, error) {
return result, err
}

func (client *Client) HubCreate() {
}
func (client *Client) HubUpdate(id string, input HubUpdateInput) (Hub, error) {
endpoint := fmt.Sprintf("/hubs/%s", id)
result := Hub{}

func (client *Client) HubUpdate() {
body, err := json.Marshal(input)
if err != nil {
return Hub{}, err
}

err = client.request(http.MethodPatch, endpoint, body, &result)
return result, err
}

func (client *Client) HubGet(ID string) (Hub, error) {
endpoint := fmt.Sprintf("/hubs/%s", ID)
func (client *Client) HubGet(id string) (Hub, error) {
endpoint := fmt.Sprintf("/hubs/%s", id)
result := Hub{}

err := client.request(http.MethodGet, endpoint, nil, &result)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,6 @@ github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0+
github.com/envoyproxy/protoc-gen-validate v0.10.0/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss=
github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k=
github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ=
github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg=
github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
Expand Down

0 comments on commit f32f42f

Please sign in to comment.