Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 3, 2025. It is now read-only.
/coder-xrayPublic archive

Commit5d111f2

Browse files
committed
printlns
1 parent27a7d20 commit5d111f2

File tree

5 files changed

+50
-9
lines changed

5 files changed

+50
-9
lines changed

‎go.mod‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ replace github.com/gliderlabs/ssh => github.com/coder/ssh v0.0.0-20230621095435-
88

99
require (
1010
cdr.dev/slogv1.6.2-0.20230929193652-f0c466fabe10
11-
github.com/coder/coder/v2v2.6.1-0.20240124004842-3c9f7e892945
11+
github.com/coder/coder/v2v2.6.1-0.20240125021520-d9f5cdda9bae
1212
github.com/google/go-containerregistryv0.14.0
1313
github.com/jfrog/jfrog-client-gov1.31.6
1414
github.com/spf13/cobrav1.8.0
@@ -54,10 +54,12 @@ require (
5454
github.com/aws/aws-sdk-go-v2/service/ssooidcv1.15.1// indirect
5555
github.com/aws/aws-sdk-go-v2/service/stsv1.21.1// indirect
5656
github.com/aws/smithy-gov1.19.0// indirect
57+
github.com/aymanbagabas/go-osc52/v2v2.0.1// indirect
5758
github.com/benbjohnson/clockv1.3.5// indirect
5859
github.com/beorn7/perksv1.0.1// indirect
5960
github.com/cenkalti/backoff/v4v4.2.1// indirect
6061
github.com/cespare/xxhash/v2v2.2.0// indirect
62+
github.com/charmbracelet/lipglossv0.8.0// indirect
6163
github.com/cloudflare/circlv1.3.7// indirect
6264
github.com/coder/retryv1.5.1// indirect
6365
github.com/coder/terraform-provider-coderv0.13.0// indirect
@@ -112,6 +114,7 @@ require (
112114
github.com/hashicorp/yamuxv0.1.1// indirect
113115
github.com/hdevalence/ed25519consensusv0.1.0// indirect
114116
github.com/illarion/gonotifyv1.0.1// indirect
117+
github.com/imdario/mergov0.3.15// indirect
115118
github.com/inconshreveable/mousetrapv1.1.0// indirect
116119
github.com/insomniacslk/dhcpv0.0.0-20231206064809-8c70d406f6d2// indirect
117120
github.com/jbenet/go-contextv0.0.0-20150711004518-d14ea06fba99// indirect
@@ -127,9 +130,11 @@ require (
127130
github.com/klauspost/cpuid/v2v2.2.5// indirect
128131
github.com/klauspost/pgzipv1.2.5// indirect
129132
github.com/kortschak/wolv0.0.0-20200729010619-da482cc4850a// indirect
133+
github.com/lucasb-eyer/go-colorfulv1.2.0// indirect
130134
github.com/mailru/easyjsonv0.7.7// indirect
131135
github.com/mattn/go-colorablev0.1.13// indirect
132136
github.com/mattn/go-isattyv0.0.20// indirect
137+
github.com/mattn/go-runewidthv0.0.15// indirect
133138
github.com/mdlayher/genetlinkv1.3.2// indirect
134139
github.com/mdlayher/netlinkv1.7.2// indirect
135140
github.com/mdlayher/sdnotifyv1.0.0// indirect
@@ -145,6 +150,8 @@ require (
145150
github.com/mitchellh/reflectwalkv1.0.2// indirect
146151
github.com/modern-go/concurrentv0.0.0-20180306012644-bacd9c7ef1dd// indirect
147152
github.com/modern-go/reflect2v1.0.2// indirect
153+
github.com/muesli/reflowv0.3.0// indirect
154+
github.com/muesli/termenvv0.15.2// indirect
148155
github.com/munnerz/goautonegv0.0.0-20191010083416-a7dc8b61c822// indirect
149156
github.com/nwaples/rardecodev1.1.0// indirect
150157
github.com/opencontainers/go-digestv1.0.0// indirect

‎go.sum‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ github.com/cilium/ebpf v0.11.0/go.mod h1:WE7CZAnqOL2RouJ4f1uyNhqr2P4CCvXFIqdRDUg
146146
github.com/cloudflare/circlv1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
147147
github.com/cloudflare/circlv1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
148148
github.com/cloudflare/circlv1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
149-
github.com/coder/coder/v2v2.6.1-0.20240124004842-3c9f7e892945 h1:xFhm+pRkoAbWNrDxHybdca9V2XhMtloIhsgtTSWEiko=
150-
github.com/coder/coder/v2v2.6.1-0.20240124004842-3c9f7e892945/go.mod h1:jSDTCnwDgcqPUcP17SJsDs/HW18pfQj4WEE3AAE+8o4=
149+
github.com/coder/coder/v2v2.6.1-0.20240125021520-d9f5cdda9bae h1:k3mhC2/RtoVon6NCljR9wY6u322Zib1CnNZ9GMyQZCk=
150+
github.com/coder/coder/v2v2.6.1-0.20240125021520-d9f5cdda9bae/go.mod h1:jSDTCnwDgcqPUcP17SJsDs/HW18pfQj4WEE3AAE+8o4=
151151
github.com/coder/retryv1.5.1 h1:iWu8YnD8YqHs3XwqrqsjoBTAVqT9ml6z9ViJ2wlMiqc=
152152
github.com/coder/retryv1.5.1/go.mod h1:blHMk9vs6LkoRT9ZHyuZo360cufXEhrxqvEzeMtRGoY=
153153
github.com/coder/sshv0.0.0-20230621095435-9a7e23486f1c h1:TI7TzdFI0UvQmwgyQhtI1HeyYNRxAQpr8Tw/rjT8VSA=
@@ -492,6 +492,7 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
492492
github.com/mattn/go-isattyv0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
493493
github.com/mattn/go-isattyv0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
494494
github.com/mattn/go-isattyv0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
495+
github.com/mattn/go-runewidthv0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
495496
github.com/mattn/go-runewidthv0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
496497
github.com/mattn/go-runewidthv0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
497498
github.com/mdlayher/genetlinkv1.3.2 h1:KdrNKe+CTu+IbZnm/GVUMXSqBBLqcGpRDa0xkQy56gw=
@@ -600,6 +601,8 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5X
600601
github.com/rcrowley/go-metricsv0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
601602
github.com/richardartoul/moleculev1.0.1-0.20221107223329-32cfee06a052 h1:Qp27Idfgi6ACvFQat5+VJvlYToylpM/hcyLBI3WaKPA=
602603
github.com/richardartoul/moleculev1.0.1-0.20221107223329-32cfee06a052/go.mod h1:uvX/8buq8uVeiZiFht+0lqSLBHF+uGV8BrTv8W/SIwk=
604+
github.com/rivo/unisegv0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
605+
github.com/rivo/unisegv0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
603606
github.com/rivo/unisegv0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
604607
github.com/rivo/unisegv0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
605608
github.com/robfig/cron/v3v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=

‎jfrog/client.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func ParseImage(image string) (Image, error) {
115115

116116
funcroot(pathstring)string {
117117
dir:=filepath.Dir(path)
118-
ifdir==path {
118+
ifdir=="." {
119119
returnpath
120120
}
121121
returnroot(dir)

‎main.go‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package main
22

3-
funcmain() {
3+
import (
4+
"os"
5+
)
46

7+
funcmain() {
8+
err:=root().Execute()
9+
iferr!=nil {
10+
os.Exit(1)
11+
}
512
}

‎root.go‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ import (
1010
"k8s.io/client-go/kubernetes"
1111
"k8s.io/client-go/tools/clientcmd"
1212

13+
"cdr.dev/slog"
14+
"cdr.dev/slog/sloggers/sloghuman"
15+
1316
"github.com/coder/xray/jfrog"
17+
reporter"github.com/coder/xray/k8s"
1418
)
1519

1620
funcroot()*cobra.Command {
1721
var (
1822
coderURLstring
23+
coderTokenstring
1924
artifactoryURLstring
2025
artifactoryUserstring
2126
artifactoryTokenstring
@@ -64,22 +69,41 @@ func root() *cobra.Command {
6469
returnxerrors.Errorf("create kubernetes config: %w",err)
6570
}
6671

67-
jClient,err:=jfrog.XRayClient(artifactoryURL,artifactoryUser,artifactoryToken)
72+
jclient,err:=jfrog.XRayClient(artifactoryURL,artifactoryUser,artifactoryToken)
6873
iferr!=nil {
6974
returnxerrors.Errorf("create artifactory client: %w",err)
7075
}
7176

77+
kr:= reporter.K8sReporter{
78+
Client:kclient,
79+
JFrogClient:jclient,
80+
Namespace:namespace,
81+
CoderURL:coderParsed,
82+
Logger:slog.Make(sloghuman.Sink(cmd.ErrOrStderr())),
83+
CoderToken:coderToken,
84+
}
85+
86+
err=kr.Init(cmd.Context())
87+
iferr!=nil {
88+
returnxerrors.Errorf("initialize reporter: %w",err)
89+
}
90+
91+
stopCh:=make(chanstruct{})
92+
deferclose(stopCh)
93+
gokr.Start(stopCh)
94+
<-cmd.Context().Done()
95+
7296
returnnil
7397
},
7498
}
75-
cmd.Flags().StringVarP(&coderURL,"coder-url","cu",os.Getenv("CODER_URL"),"URL of the Coder instance")
99+
cmd.Flags().StringVarP(&coderURL,"coder-url","",os.Getenv("CODER_URL"),"URL of the Coder instance")
100+
cmd.Flags().StringVarP(&coderToken,"coder-token","",os.Getenv("CODER_TOKEN"),"Access Token for the Coder instance. Requires Template Admin privileges.")
76101
cmd.Flags().StringVarP(&artifactoryURL,"artifactory-url","",os.Getenv("ARTIFACTORY_URL"),"URL of the JFrog Artifactory instance")
77102
cmd.Flags().StringVarP(&artifactoryToken,"artifactory-token","",os.Getenv("ARTIFACTORY_TOKEN"),"Access Token for JFrog Artifactory instance")
78103
cmd.Flags().StringVarP(&artifactoryUser,"artifactory-user","",os.Getenv("ARTIFACTORY_USER"),"User to interface with JFrog Artifactory instance")
79-
cmd.Flags().StringVarP(&kubeConfig,"kubeconfig","k","~/.kube/config","Path to the kubeconfig file")
104+
cmd.Flags().StringVarP(&kubeConfig,"kubeconfig","k","/home/coder/.kube/config","Path to the kubeconfig file")
80105
cmd.Flags().StringVarP(&namespace,"namespace","n",os.Getenv("CODER_NAMESPACE"),"Namespace to use when listing pods")
81106
cmd.Flags().StringVarP(&fieldSelector,"field-selector","f","","Field selector to use when listing pods")
82107
cmd.Flags().StringVarP(&labelSelector,"label-selector","l","","Label selector to use when listing pods")
83-
cmd.Flags().StringVarP(&artifactoryToken,"artifactory-token","","","Token to use to fetch scan results for an image")
84108
returncmd
85109
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp