nginxconf icon indicating copy to clipboard operation
nginxconf copied to clipboard

请问能否不通过调用crossplane 实现conf -> json

Open originnets opened this issue 5 years ago • 9 comments

originnets avatar May 12 '20 03:05 originnets

嗯,暂时是用过crossplane 实现的,因为 crossplane 是会持续维护的;当然,咱们也可以自己实现,但是工作量比较巨大且需要持续的关注

imyuliz avatar May 12 '20 13:05 imyuliz

@flytd

imyuliz avatar May 12 '20 13:05 imyuliz

谢谢, 因为需要额外安装相关环境, 不太友好, 调用crossplane二进制文件是不是更方便一点?

originnets avatar May 12 '20 13:05 originnets

@flytd 是的,代码里面有两种实现,一种是调用二进制,一种是调用代码 你看下

imyuliz avatar May 16 '20 05:05 imyuliz

好的 , 我看一下

originnets avatar May 16 '20 05:05 originnets

你好 , 我测试使用这个把crossplane 转换成go 结构体出现错误 panic: json: cannot unmarshal number into Go struct field Block.config.parsed.block.includes of type string

originnets avatar Aug 28 '20 03:08 originnets

另外 , 现在可以不调用python的crossplane , 该作者写了一个golang库 https://github.com/aluttik/go-crossplane

originnets avatar Aug 28 '20 03:08 originnets

type Block struct { Line int json:"line" Args []string json:"args" Directive string json:"directive" InnerBlocks []InnerBlock json:"block,omitempty" Includes []string json:"includes,omitempty" } Includes 应该是一个[]int 类型

originnets avatar Aug 28 '20 04:08 originnets

@flytd 使用 includes 是为了保证他有更好的兼容性,在字段语义明确的情况下,我们会优先使用更精准的数据类型, 如果不能的话,或者变化大的话,会使用string,或者[]string

imyuliz avatar Sep 01 '20 05:09 imyuliz