Skip to content

Commit 6e598d3

Browse files
committed
Merge remote-tracking branch 'origin/master' into gen1.34.0
2 parents eb6f16b + c41906e commit 6e598d3

File tree

7 files changed

+60
-30
lines changed

7 files changed

+60
-30
lines changed

.github/workflows/buildtest.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
with:
1313
fetch-depth: 0
1414
- name: Setup dotnet
15-
uses: actions/setup-dotnet@v4
15+
uses: actions/setup-dotnet@v5
1616
with:
1717
dotnet-version: |
1818
8.0.x
@@ -48,7 +48,7 @@ jobs:
4848
- name: Add msbuild to PATH
4949
uses: microsoft/setup-msbuild@v2
5050
- name: Setup dotnet SDK
51-
uses: actions/setup-dotnet@v4
51+
uses: actions/setup-dotnet@v5
5252
with:
5353
dotnet-version: '9.0.x'
5454
- name: Restore nugets (msbuild)
@@ -63,7 +63,7 @@ jobs:
6363
with:
6464
fetch-depth: 0
6565
- name: Setup dotnet
66-
uses: actions/setup-dotnet@v4
66+
uses: actions/setup-dotnet@v5
6767
with:
6868
dotnet-version: |
6969
8.0.x

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
fetch-depth: 0
3232

3333
- name: Setup dotnet
34-
uses: actions/setup-dotnet@v4
34+
uses: actions/setup-dotnet@v5
3535
with:
3636
dotnet-version: |
3737
8.0.x

.github/workflows/docfx.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
fetch-depth: 0
3131

3232
- name: Setup dotnet
33-
uses: actions/setup-dotnet@v4
33+
uses: actions/setup-dotnet@v5
3434
with:
3535
dotnet-version: |
3636
8.0.x

.github/workflows/draft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fetch-depth: 0
1919

2020
- name: Setup dotnet
21-
uses: actions/setup-dotnet@v4
21+
uses: actions/setup-dotnet@v5
2222
with:
2323
dotnet-version: |
2424
8.0.x

.github/workflows/nuget.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fetch-depth: 0
1616

1717
- name: Setup dotnet
18-
uses: actions/setup-dotnet@v4
18+
uses: actions/setup-dotnet@v5
1919
with:
2020
dotnet-version: |
2121
8.0.x

src/KubernetesClient/KubernetesYaml.cs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeseria
7878
return null;
7979
}
8080

81-
return Encoding.UTF8.GetBytes(scalar.Value);
81+
return Convert.FromBase64String(scalar.Value);
8282
}
8383
finally
8484
{
@@ -91,19 +91,15 @@ public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeseria
9191

9292
public void WriteYaml(IEmitter emitter, object value, Type type, ObjectSerializer serializer)
9393
{
94+
if (value == null)
95+
{
96+
emitter.Emit(new Scalar(string.Empty));
97+
return;
98+
}
99+
94100
var obj = (byte[])value;
95-
var strValue = Encoding.UTF8.GetString(obj);
96-
97-
// Check if the string is multi-line by looking for a newline character.
98-
var scalarStyle = strValue.Contains('\n') ? ScalarStyle.Literal : ScalarStyle.Any;
99-
100-
emitter.Emit(new Scalar(
101-
AnchorName.Empty,
102-
TagName.Empty,
103-
strValue,
104-
scalarStyle,
105-
true,
106-
true));
101+
var encoded = Convert.ToBase64String(obj);
102+
emitter.Emit(new Scalar(encoded));
107103
}
108104
}
109105

tests/KubernetesClient.Tests/KubernetesYamlTests.cs

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -804,12 +804,12 @@ public void LoadSecret()
804804
{
805805
var kManifest = @"
806806
apiVersion: v1
807+
data:
808+
username: YlhrdFlYQnc=
809+
password: TXprMU1qZ2tkbVJuTjBwaQ==
807810
kind: Secret
808811
metadata:
809812
name: test-secret
810-
data:
811-
username: bXktYXBw
812-
password: Mzk1MjgkdmRnN0pi
813813
";
814814

815815
var result = KubernetesYaml.Deserialize<V1Secret>(kManifest, true);
@@ -823,13 +823,8 @@ public void WriteSecret()
823823
var kManifest = """
824824
apiVersion: v1
825825
data:
826-
username: bXktYXBw
827-
tls2.crt: |
828-
-----BEGIN CERTIFICATE-----
829-
FAKE CERT
830-
FAKE CERT
831-
FAKE CERT
832-
-----END CERTIFICATE-----
826+
username: YlhrdFlYQnc=
827+
password: TXprMU1qZ2tkbVJuTjBwaQ==
833828
kind: Secret
834829
metadata:
835830
name: test-secret
@@ -841,6 +836,45 @@ FAKE CERT
841836
Assert.Equal(kManifest, yaml);
842837
}
843838

839+
[Fact]
840+
public void LoadConfigMap()
841+
{
842+
var kManifest = @"
843+
apiVersion: v1
844+
binaryData:
845+
username: YlhrdFlYQnc=
846+
data:
847+
password: Mzk1MjgkdmRnN0pi
848+
kind: ConfigMap
849+
metadata:
850+
name: test-configmap
851+
";
852+
853+
var result = KubernetesYaml.Deserialize<V1ConfigMap>(kManifest, true);
854+
Assert.Equal("bXktYXBw", Encoding.UTF8.GetString(result.BinaryData["username"]));
855+
Assert.Equal("Mzk1MjgkdmRnN0pi", result.Data["password"]);
856+
}
857+
858+
[Fact]
859+
public void WriteConfigMap()
860+
{
861+
var kManifest = """
862+
apiVersion: v1
863+
binaryData:
864+
username: YlhrdFlYQnc=
865+
data:
866+
password: Mzk1MjgkdmRnN0pi
867+
kind: ConfigMap
868+
metadata:
869+
name: test-configmap
870+
""";
871+
872+
var result = KubernetesYaml.Deserialize<V1ConfigMap>(kManifest, true);
873+
var yaml = KubernetesYaml.Serialize(result);
874+
875+
Assert.Equal(kManifest, yaml);
876+
}
877+
844878
[Fact]
845879
public void DeserializeWithJsonPropertyName()
846880
{

0 commit comments

Comments
 (0)