@@ -22,9 +22,20 @@ func main() {
2222 }
2323
2424 http .HandleFunc ("/" , func (w http.ResponseWriter , req * http.Request ) {
25- switch req .URL .Path {
25+ var withoutAgentPath bool
26+ path := req .URL .Path
27+
28+ uri := application .ApplicationURIs [0 ]
29+
30+ if strings .HasPrefix (path , "/without-agent-path" ) {
31+ uri = fmt .Sprintf ("%s/without-agent-path" , uri )
32+ path = strings .TrimPrefix (path , "/without-agent-path" )
33+ withoutAgentPath = true
34+ }
35+
36+ switch path {
2637 case "/v1/deployment/installer/agent/unix/paas-sh/latest" :
27- context := struct { URI string }{URI : application . ApplicationURIs [ 0 ] }
38+ context := struct { URI string }{URI : uri }
2839 t := template .Must (template .New ("install.sh" ).ParseFiles ("install.sh" ))
2940 err := t .Execute (w , context )
3041 if err != nil {
@@ -33,7 +44,7 @@ func main() {
3344 return
3445 }
3546
36- case "/manifest.json" , "/ dynatrace-env.sh" , "/liboneagentproc.so" :
47+ case "/dynatrace-env.sh" , "/liboneagentproc.so" , "/ruxitagentproc.conf " :
3748 contents , err := ioutil .ReadFile (strings .TrimPrefix (req .URL .Path , "/" ))
3849 if err != nil {
3950 w .WriteHeader (http .StatusInternalServerError )
@@ -42,6 +53,42 @@ func main() {
4253 }
4354 w .Write (contents )
4455
56+ case "/manifest.json" :
57+ var payload map [string ]interface {}
58+ file , err := os .Open ("manifest.json" )
59+ if err != nil {
60+ w .WriteHeader (http .StatusInternalServerError )
61+ w .Write ([]byte (err .Error ()))
62+ return
63+ }
64+
65+ err = json .NewDecoder (file ).Decode (& payload )
66+ if err != nil {
67+ w .WriteHeader (http .StatusInternalServerError )
68+ w .Write ([]byte (err .Error ()))
69+ return
70+ }
71+
72+ if withoutAgentPath {
73+ payload ["technologies" ] = map [string ]interface {}{
74+ "process" : map [string ]interface {}{
75+ "linux-x86-64" : []struct {}{},
76+ },
77+ }
78+ }
79+
80+ json .NewEncoder (w ).Encode (payload )
81+
82+ case "/v1/deployment/installer/agent/processmoduleconfig" :
83+ fakeConfig , err := ioutil .ReadFile ("fake_config.json" )
84+ if err != nil {
85+ w .WriteHeader (http .StatusInternalServerError )
86+ w .Write ([]byte (err .Error ()))
87+ return
88+ }
89+ w .Write (fakeConfig )
90+
91+
4592 default :
4693 w .WriteHeader (http .StatusNotFound )
4794 }
0 commit comments