I am working through getting this example to work.. but not sure how to troubleshoot.
/*
Copyright 2019 NetFoundry Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"fmt"
This file has been truncated. show original
After I compile the application, I run it using the following command
./simple-server -c /Users/houst/.zssh/zssh.json -s golanghttp
Is this correct?
This is the error I receive.
Error binding service failed to initialize context: (unable to configure ziti as config environment variable ZITI_SDK_CONFIG not populated)
github.com/openziti/sdk-golang/ziti.(*contextImpl).ListenWithOptions
/Users/houst/go/pkg/mod/github.com/openziti/sdk-golang@v0.16.56/ziti/ziti.go:584
main.withZiti
/Users/houst/DevTech/zitiapps/sdk-golang/example/simple-server/simple-server.go:66
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1571
panic: failed to initialize context: (unable to configure ziti as config environment variable ZITI_SDK_CONFIG not populated)
goroutine 19 [running]:
main.withZiti({0x7ff7bfeff9d0, 0x2})
/Users/houst/DevTech/zitiapps/sdk-golang/example/simple-server/simple-server.go:69 +0x1ad
created by main.main
/Users/houst/DevTech/zitiapps/sdk-golang/example/simple-server/simple-server.go:86 +0x145
markamind:
./simple-server -c /Users/houst/.zssh/zssh.json -s golanghttp
You need to read that code and follow it along. It's not expecting an argument to be passed that indicates the identity nor does it support flags (the -c
and -s
you supplied). Not all samples are uniform. This one expects you to set an environment variable named ZITI_SDK_CONFIG
which represents the path to the json file.
This should work:
export ZITI_SDK_CONFIG=/Users/houst/.zssh/zssh.json
./simple-server golanghttp
1 Like
addendum: ZITI_SDK_CONFIG processing will be buried down in the golang-sdk. If the file isn’t supplied to NewContext, the sdk will look for that env variable and use the value as the path to the identity
1 Like
Awesome… this makes a lot of sense now…