Skip to content

Commit

Permalink
✨ Add friendly link
Browse files Browse the repository at this point in the history
  • Loading branch information
tosone committed Oct 9, 2023
1 parent db1843f commit 011c437
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Image CI

on:
schedule:
- cron: "0 0 * * 6"
- cron: "0 1 * * *"
push:
branches:
- main
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ docker run --name sigma -v /home/admin/config:/etc/sigma \
./scripts/samples/samples.sh
```

Visit: <https://sigma.tosone.cn>, username/password: sigma/sigma.
Visit: <https://sigma.tosone.cn>, username/password: sigma/sigma

I will periodically reboot the container, and since the container doesn't have any disk mount, every reboot will clear all the data.

Expand Down
3 changes: 1 addition & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ COPY --from=web-builder /web/dist /go/src/github.com/go-sigma/sigma/web/dist

WORKDIR /go/src/github.com/go-sigma/sigma

RUN --mount=type=cache,target=/root/.cache/go-build make all
RUN --mount=type=cache,target=/root/.cache/go-build make build

FROM alpine:${ALPINE_VERSION}

Expand All @@ -70,6 +70,5 @@ COPY --from=trivy /usr/local/bin/trivy /usr/local/bin/trivy
COPY --from=trivy /opt/trivy/trivy.db /opt/trivy/db/trivy.db
COPY ./conf/config.yaml /etc/sigma/config.yaml
COPY --from=builder /go/src/github.com/go-sigma/sigma/bin/sigma /usr/local/bin/sigma
COPY --from=builder /go/src/github.com/go-sigma/sigma/bin/sigma-builder /usr/local/bin/sigma-builder

CMD ["sigma", "server"]
1 change: 0 additions & 1 deletion build/Dockerfile.builder.local
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ FROM moby/buildkit:v0.12.2-rootless

USER root
RUN set -eux && \
sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories && \
apk add --no-cache git-lfs && \
mkdir -p /code/ && \
chown -R 1000:1000 /opt/ && \
Expand Down
3 changes: 1 addition & 2 deletions build/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ COPY --from=web-builder /web/dist /go/src/github.com/go-sigma/sigma/web/dist

WORKDIR /go/src/github.com/go-sigma/sigma

RUN --mount=type=cache,target=/root/.cache/go-build make all
RUN --mount=type=cache,target=/root/.cache/go-build make build

FROM debian:${DEBIAN_VERSION}

Expand All @@ -87,6 +87,5 @@ COPY --from=trivy /usr/local/bin/trivy /usr/local/bin/trivy
COPY --from=trivy /opt/trivy/trivy.db /opt/trivy/db/trivy.db
COPY ./conf/config.yaml /etc/sigma/config.yaml
COPY --from=builder /go/src/github.com/go-sigma/sigma/bin/sigma /usr/local/bin/sigma
COPY --from=builder /go/src/github.com/go-sigma/sigma/bin/sigma-builder /usr/local/bin/sigma-builder

CMD ["sigma", "server"]
1 change: 0 additions & 1 deletion build/Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,5 @@ COPY --from=trivy /opt/trivy/trivy.db /opt/trivy/db/trivy.db
COPY --from=trivy /opt/trivy/metadata.json /opt/trivy/db/metadata.json
COPY ./conf/config.yaml /etc/sigma/config.yaml
COPY ./bin/sigma /usr/local/bin/sigma
COPY ./bin/sigma-builder /usr/local/bin/sigma-builder

CMD ["sigma", "server"]
8 changes: 6 additions & 2 deletions pkg/configs/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func defaultSettings() {
viper.SetDefault("server.endpoint", "http://127.0.0.1:3000")
viper.SetDefault("server.internalEndpoint", "http://127.0.0.1:3000")

// configuration.HTTP.Endpoint = "http://127.0.0.1:3000"
// configuration.HTTP.InternalEndpoint = "http://127.0.0.1:3000"
if configuration.HTTP.Endpoint == "" {
configuration.HTTP.Endpoint = "http://127.0.0.1:3000"
}
if configuration.HTTP.InternalEndpoint == "" {
configuration.HTTP.InternalEndpoint = "http://127.0.0.1:3000"
}
}
8 changes: 1 addition & 7 deletions pkg/logger/glog.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@ func (l ZLogger) Info(ctx context.Context, msg string, opts ...interface{}) {
// Trace is the trace log
func (l ZLogger) Trace(ctx context.Context, begin time.Time, f func() (string, int64), err error) {
zl := zerolog.Ctx(ctx)
var event *zerolog.Event

if err != nil {
event = zl.Error()
} else {
event = zl.Info()
}
var event = zl.Debug()

event = event.Str("elapsed", time.Since(begin).String())

Expand Down
3 changes: 1 addition & 2 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import NamespaceDaemonTasks from "./pages/Namespace/DaemonTask";

import CodeRepositoryHome from './pages/CodeRepository';
import CodeRepositoryList from './pages/CodeRepository/List';
import BuilderRunner from './pages/CodeRepository/BuilderRunner';

import BuildersSetup from './pages/Builder/Setup';
import BuilderRunnerList from './pages/Builder/RunnerList';
Expand Down Expand Up @@ -60,7 +59,7 @@ export default function App() {
style={{ top: "3rem" }}
/>
<Routes>
<Route path="/" element={<Home localServer={localServer} />} />
<Route path="/" element={<Namespaces localServer={localServer} />} />

<Route path="/home" element={<Home localServer={localServer} />} />

Expand Down
16 changes: 8 additions & 8 deletions web/src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Link, useSearchParams, useNavigate } from 'react-router-dom';
import Toast from "../../components/Notification";
import { INamespaceItem, INamespaceList, IHTTPError, IUserSelf, IEndpoint } from "../../interfaces";

export default function ({ localServer, item, namespace, repository, tag }: { localServer: string, item: string, namespace?: string, repository?: string, tag?: string }) {
export default function ({ localServer, item, namespace, repository, tag, selfClick }: { localServer: string, item: string, namespace?: string, repository?: string, tag?: string, selfClick?: boolean }) {
const [showProfileMenu, setShowProfileMenu] = useState(false);
const [menuActive, setMenuActive] = useState(item === "" ? "home" : item);
const navigate = useNavigate();
Expand Down Expand Up @@ -164,7 +164,7 @@ export default function ({ localServer, item, namespace, repository, tag }: { lo
}
<nav className="px-3 mt-6">
<div className="space-y-1">
{
{/* {
!isAnonymous && (
<Link to={`/home`} className={`text-gray-700 group flex items-center px-2 py-2 text-sm font-medium rounded-md ${menuActive === "home" ? "bg-gray-100" : "hover:bg-gray-50 text-gray-700"}`} onClick={e => {
setMenuActive("home");
Expand All @@ -178,7 +178,7 @@ export default function ({ localServer, item, namespace, repository, tag }: { lo
Home
</Link>
)
}
} */}
<Link to={`/namespaces`} className={`text-gray-700 group flex items-center px-2 py-2 text-sm font-medium rounded-md ${menuActive === "namespaces" ? "bg-gray-100" : "hover:bg-gray-50 text-gray-700"}`} onClick={e => {
setMenuActive("namespaces");
item === "namespaces" && e.preventDefault();
Expand All @@ -192,9 +192,9 @@ export default function ({ localServer, item, namespace, repository, tag }: { lo
</Link>
{
(item === "repositories" || item === "tags" || item === "artifacts") && (
<Link to={`/namespaces/${namespace}/repositories`} className={`text-gray-700 group flex items-center px-4 py-2 text-sm font-medium rounded-md ${menuActive === "repositories" ? "bg-gray-100" : "hover:bg-gray-50 text-gray-700"}`} onClick={e => {
<Link to={`/namespaces/${namespace}/repositories?repository=${repository}`} className={`text-gray-700 group flex items-center px-6 py-2 text-sm font-medium rounded-md ${menuActive === "repositories" ? "bg-gray-100" : "hover:bg-gray-50 text-gray-700"}`} onClick={e => {
setMenuActive("repositories");
item === "repositories" && e.preventDefault();
(item === "repositories" && selfClick !== true) && e.preventDefault();
}}>
<span className="text-gray-400 mr-3 h-6 w-6">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="w-6 h-6">
Expand All @@ -207,7 +207,7 @@ export default function ({ localServer, item, namespace, repository, tag }: { lo
}
{
(item === "tags" || item === "artifacts") && (
<Link to={`/namespaces/${namespace}/repository/tags?repository=${repository}`} className={`text-gray-700 group flex items-center px-4 py-2 text-sm font-medium rounded-md ${menuActive === "tags" ? "bg-gray-100" : "hover:bg-gray-50 text-gray-700"}`} onClick={e => {
<Link to={`/namespaces/${namespace}/repository/tags?repository=${repository}`} className={`text-gray-700 group flex items-center px-6 py-2 text-sm font-medium rounded-md ${menuActive === "tags" ? "bg-gray-100" : "hover:bg-gray-50 text-gray-700"}`} onClick={e => {
setMenuActive("tags");
item === "tags" && e.preventDefault();
}}>
Expand Down Expand Up @@ -247,7 +247,7 @@ export default function ({ localServer, item, namespace, repository, tag }: { lo
</span>
Code Repository
</Link>
{
{/* {
!isAnonymous && (
<Link to={`/settings`} className={`text-gray-700 group flex items-center px-2 py-2 text-sm font-medium rounded-md ${menuActive === "settings" ? "bg-gray-100" : "hover:bg-gray-50 text-gray-700"}`} onClick={e => {
setMenuActive("settings");
Expand All @@ -262,7 +262,7 @@ export default function ({ localServer, item, namespace, repository, tag }: { lo
Setting
</Link>
)
}
} */}
</div>
<div className="mt-8">
{
Expand Down
9 changes: 7 additions & 2 deletions web/src/pages/Builder/RunnerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export default function ({ localServer }: { localServer: string }) {
</Helmet>
</HelmetProvider>
<div className="min-h-screen max-h-screen flex overflow-hidden bg-white">
<Menu localServer={localServer} item="repositories" namespace={namespace} />
<Menu localServer={localServer} item="repositories" namespace={namespace} repository={repositoryObj?.name} selfClick={true} />
<div className="flex flex-col w-0 flex-1 overflow-hidden">
<main className="relative z-0 focus:outline-none">
<Header title="Repository"
Expand All @@ -204,8 +204,13 @@ export default function ({ localServer }: { localServer: string }) {
<li>
<div className="flex items-center">
<span className="text-gray-500 text-sm ml-1">/</span>
<span className="ml-1 text-sm font-medium text-gray-500 dark:text-gray-400">
{/* <span className="ml-1 text-sm font-medium text-gray-500 dark:text-gray-400">
{repositoryObj?.name?.substring((namespace?.length || 0) + 1)}
</span> */}
<span className="ml-1 inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600 dark:text-gray-400 dark:hover:text-white">
<Link to={`/namespaces/${namespace}/repository/tags?repository=${repositoryObj?.name}&repository_id=${repositoryObj?.id}`} className="inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600 dark:text-gray-400 dark:hover:text-white">
{repositoryObj?.name?.substring((namespace?.length || 0) + 1)}
</Link>
</span>
<span className="text-gray-500 text-sm ml-1">/</span>
</div>
Expand Down
13 changes: 8 additions & 5 deletions web/src/pages/Builder/RunnerLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default function ({ localServer }: { localServer: string }) {
</Helmet>
</HelmetProvider>
<div className="min-h-screen max-h-screen flex overflow-hidden bg-white">
<Menu localServer={localServer} item="repositories" namespace={"namespace"} />
<Menu localServer={localServer} item="repositories" namespace={namespace} repository={repositoryObj?.name} selfClick={true} />
<div className="flex flex-col w-0 flex-1 overflow-hidden">
<main className="relative z-0 focus:outline-none">
<Header title="Repository"
Expand All @@ -233,8 +233,10 @@ export default function ({ localServer }: { localServer: string }) {
<li>
<div className="flex items-center">
<span className="text-gray-500 text-sm ml-1">/</span>
<span className="ml-1 text-sm font-medium text-gray-500 dark:text-gray-400">
{repositoryObj?.name?.substring((namespace?.length || 0) + 1)}
<span className="ml-1 inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600 dark:text-gray-400 dark:hover:text-white">
<Link to={`/namespaces/${namespace}/repository/tags?repository=${repositoryObj?.name}&repository_id=${repositoryObj?.id}`} className="inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600 dark:text-gray-400 dark:hover:text-white">
{repositoryObj?.name?.substring((namespace?.length || 0) + 1)}
</Link>
</span>
<span className="text-gray-500 text-sm ml-1">/</span>
</div>
Expand All @@ -252,11 +254,12 @@ export default function ({ localServer }: { localServer: string }) {
>
Summary
</Link>
<span
<Link
to={`/namespaces/${namespace}/repository/runners?repository=${repositoryObj?.name}&repository_id=${repository_id}`}
className="z-10 inline-flex items-center border-b border-indigo-500 px-1 pt-1 text-sm font-medium text-gray-900 capitalize cursor-pointer"
>
Runners
</span>
</Link>
<Link
to={`/namespaces/${namespace}/repository/tags?repository=${repositoryObj?.name}&repository_id=${repository_id}`}
className="inline-flex items-center border-b border-transparent px-1 pt-1 text-sm font-medium text-gray-500 hover:border-gray-300 hover:text-gray-700 capitalize"
Expand Down
21 changes: 0 additions & 21 deletions web/src/pages/CodeRepository/BuilderRunner.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions web/src/pages/Home/index.css

This file was deleted.

2 changes: 0 additions & 2 deletions web/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import Header from "../../components/Header";

import { ScaleIcon } from '@heroicons/react/24/outline';

import "./index.css";

const cards = [
{ name: 'Account balance1', href: '#', icon: ScaleIcon, amount: '$30,659.45' },
{ name: 'Account balance2', href: '#', icon: ScaleIcon, amount: '$30,659.45' },
Expand Down
10 changes: 5 additions & 5 deletions web/src/pages/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function Login({ localServer }: { localServer: string }) {
const resp = response.data as IUserLoginResponse;
localStorage.setItem("token", resp.token);
localStorage.setItem("refresh_token", resp.refresh_token);
navigate("/");
navigate("/namespaces");
}).catch(err => {
console.log(err)
})
Expand Down Expand Up @@ -95,9 +95,9 @@ export default function Login({ localServer }: { localServer: string }) {
}}
/>
</div>
<div className="h-1">
{/* <div className="h-1">
<p className="text-red-600 text-sm">xxx</p>
</div>
</div> */}
</div>

<div>
Expand All @@ -117,9 +117,9 @@ export default function Login({ localServer }: { localServer: string }) {
}}
/>
</div>
<div className="h-1">
{/* <div className="h-1">
<p className="text-red-600 text-sm">xxx</p>
</div>
</div> */}
</div>

<div className="flex items-center justify-between">
Expand Down

0 comments on commit 011c437

Please sign in to comment.