cuelang.org/go@v0.13.0/tools/trim/testdata/shared.txtar (about)

     1  Removing fields from shared nodes not supported.
     2  
     3  issue 760
     4  -- in.cue --
     5  import "strings"
     6  
     7  // TODO: this would be okay to normalize. Consider whether
     8  // this makes sense, though.
     9  a: {
    10  	service: [ID=_]: name: "a"
    11  
    12  	service: foo: shared
    13  	service: bar: shared
    14  
    15  	shared: name: "a"
    16  }
    17  
    18  b: {
    19  	service: [ID=_]: {
    20  		name: ID
    21  	}
    22  	service: foo: _shared
    23  	_shared: {
    24  		name: "foo" // Do not remove!
    25  	}
    26  }
    27  
    28  c: {
    29  	service: [ID=_]: {
    30  		_service_name: *strings.TrimSuffix(ID, "-suffix") | string
    31  	}
    32  	service: "a-suffix": _shared
    33  	service: "b-suffix": _shared
    34  	_shared: {
    35  		_service_name: "a" // Do not remove!
    36  	}
    37  }
    38  -- out/trim --
    39  == in.cue
    40  import "strings"
    41  
    42  // TODO: this would be okay to normalize. Consider whether
    43  // this makes sense, though.
    44  a: {
    45  	service: [ID=_]: name: "a"
    46  
    47  	service: foo: shared
    48  	service: bar: shared
    49  
    50  	shared: name: "a"
    51  }
    52  
    53  b: {
    54  	service: [ID=_]: {
    55  		name: ID
    56  	}
    57  	service: foo: _shared
    58  	_shared: {
    59  		name: "foo" // Do not remove!
    60  	}
    61  }
    62  
    63  c: {
    64  	service: [ID=_]: {
    65  		_service_name: *strings.TrimSuffix(ID, "-suffix") | string
    66  	}
    67  	service: "a-suffix": _shared
    68  	service: "b-suffix": _shared
    69  	_shared: {
    70  		_service_name: "a" // Do not remove!
    71  	}
    72  }