io.yupiik.kubernetes.bindings.v1_25_0.v1.PodSecurityContext Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2022 - Yupiik SAS - https://www.yupiik.com
* 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
*
* http://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 io.yupiik.kubernetes.bindings.v1_25_0.v1;
import io.yupiik.kubernetes.bindings.v1_25_0.Exportable;
import io.yupiik.kubernetes.bindings.v1_25_0.JsonStrings;
import io.yupiik.kubernetes.bindings.v1_25_0.Validable;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
import static java.util.stream.Collectors.joining;
public class PodSecurityContext implements Validable, Exportable {
private Integer fsGroup;
private String fsGroupChangePolicy;
private Integer runAsGroup;
private Boolean runAsNonRoot;
private Integer runAsUser;
private SELinuxOptions seLinuxOptions;
private SeccompProfile seccompProfile;
private List supplementalGroups;
private List sysctls;
private WindowsSecurityContextOptions windowsOptions;
public PodSecurityContext() {
// no-op
}
public PodSecurityContext(final Integer fsGroup,
final String fsGroupChangePolicy,
final Integer runAsGroup,
final Boolean runAsNonRoot,
final Integer runAsUser,
final SELinuxOptions seLinuxOptions,
final SeccompProfile seccompProfile,
final List supplementalGroups,
final List sysctls,
final WindowsSecurityContextOptions windowsOptions) {
this.fsGroup = fsGroup;
this.fsGroupChangePolicy = fsGroupChangePolicy;
this.runAsGroup = runAsGroup;
this.runAsNonRoot = runAsNonRoot;
this.runAsUser = runAsUser;
this.seLinuxOptions = seLinuxOptions;
this.seccompProfile = seccompProfile;
this.supplementalGroups = supplementalGroups;
this.sysctls = sysctls;
this.windowsOptions = windowsOptions;
}
public Integer getFsGroup() {
return fsGroup;
}
public void setFsGroup(final Integer fsGroup) {
this.fsGroup = fsGroup;
}
public String getFsGroupChangePolicy() {
return fsGroupChangePolicy;
}
public void setFsGroupChangePolicy(final String fsGroupChangePolicy) {
this.fsGroupChangePolicy = fsGroupChangePolicy;
}
public Integer getRunAsGroup() {
return runAsGroup;
}
public void setRunAsGroup(final Integer runAsGroup) {
this.runAsGroup = runAsGroup;
}
public Boolean getRunAsNonRoot() {
return runAsNonRoot;
}
public void setRunAsNonRoot(final Boolean runAsNonRoot) {
this.runAsNonRoot = runAsNonRoot;
}
public Integer getRunAsUser() {
return runAsUser;
}
public void setRunAsUser(final Integer runAsUser) {
this.runAsUser = runAsUser;
}
public SELinuxOptions getSeLinuxOptions() {
return seLinuxOptions;
}
public void setSeLinuxOptions(final SELinuxOptions seLinuxOptions) {
this.seLinuxOptions = seLinuxOptions;
}
public SeccompProfile getSeccompProfile() {
return seccompProfile;
}
public void setSeccompProfile(final SeccompProfile seccompProfile) {
this.seccompProfile = seccompProfile;
}
public List getSupplementalGroups() {
return supplementalGroups;
}
public void setSupplementalGroups(final List supplementalGroups) {
this.supplementalGroups = supplementalGroups;
}
public List getSysctls() {
return sysctls;
}
public void setSysctls(final List sysctls) {
this.sysctls = sysctls;
}
public WindowsSecurityContextOptions getWindowsOptions() {
return windowsOptions;
}
public void setWindowsOptions(final WindowsSecurityContextOptions windowsOptions) {
this.windowsOptions = windowsOptions;
}
@Override
public int hashCode() {
return Objects.hash(
fsGroup,
fsGroupChangePolicy,
runAsGroup,
runAsNonRoot,
runAsUser,
seLinuxOptions,
seccompProfile,
supplementalGroups,
sysctls,
windowsOptions);
}
@Override
public boolean equals(final Object __other) {
if (!(__other instanceof PodSecurityContext)) {
return false;
}
final PodSecurityContext __otherCasted = (PodSecurityContext) __other;
return Objects.equals(fsGroup, __otherCasted.fsGroup) &&
Objects.equals(fsGroupChangePolicy, __otherCasted.fsGroupChangePolicy) &&
Objects.equals(runAsGroup, __otherCasted.runAsGroup) &&
Objects.equals(runAsNonRoot, __otherCasted.runAsNonRoot) &&
Objects.equals(runAsUser, __otherCasted.runAsUser) &&
Objects.equals(seLinuxOptions, __otherCasted.seLinuxOptions) &&
Objects.equals(seccompProfile, __otherCasted.seccompProfile) &&
Objects.equals(supplementalGroups, __otherCasted.supplementalGroups) &&
Objects.equals(sysctls, __otherCasted.sysctls) &&
Objects.equals(windowsOptions, __otherCasted.windowsOptions);
}
public PodSecurityContext fsGroup(final Integer fsGroup) {
this.fsGroup = fsGroup;
return this;
}
public PodSecurityContext fsGroupChangePolicy(final String fsGroupChangePolicy) {
this.fsGroupChangePolicy = fsGroupChangePolicy;
return this;
}
public PodSecurityContext runAsGroup(final Integer runAsGroup) {
this.runAsGroup = runAsGroup;
return this;
}
public PodSecurityContext runAsNonRoot(final Boolean runAsNonRoot) {
this.runAsNonRoot = runAsNonRoot;
return this;
}
public PodSecurityContext runAsUser(final Integer runAsUser) {
this.runAsUser = runAsUser;
return this;
}
public PodSecurityContext seLinuxOptions(final SELinuxOptions seLinuxOptions) {
this.seLinuxOptions = seLinuxOptions;
return this;
}
public PodSecurityContext seccompProfile(final SeccompProfile seccompProfile) {
this.seccompProfile = seccompProfile;
return this;
}
public PodSecurityContext supplementalGroups(final List supplementalGroups) {
this.supplementalGroups = supplementalGroups;
return this;
}
public PodSecurityContext sysctls(final List sysctls) {
this.sysctls = sysctls;
return this;
}
public PodSecurityContext windowsOptions(final WindowsSecurityContextOptions windowsOptions) {
this.windowsOptions = windowsOptions;
return this;
}
@Override
public PodSecurityContext validate() {
return this;
}
@Override
public String asJson() {
return Stream.of(
(fsGroup != null ? "\"fsGroup\":" + fsGroup : ""),
(fsGroupChangePolicy != null ? "\"fsGroupChangePolicy\":\"" + JsonStrings.escapeJson(fsGroupChangePolicy) + "\"" : ""),
(runAsGroup != null ? "\"runAsGroup\":" + runAsGroup : ""),
(runAsNonRoot != null ? "\"runAsNonRoot\":" + runAsNonRoot : ""),
(runAsUser != null ? "\"runAsUser\":" + runAsUser : ""),
(seLinuxOptions != null ? "\"seLinuxOptions\":" + seLinuxOptions.asJson() : ""),
(seccompProfile != null ? "\"seccompProfile\":" + seccompProfile.asJson() : ""),
(supplementalGroups != null ? "\"supplementalGroups\":" + supplementalGroups.stream().map(__it -> __it == null ? "null" : String.valueOf(__it)).collect(joining(",", "[", "]")) : ""),
(sysctls != null ? "\"sysctls\":" + sysctls.stream().map(__it -> __it == null ? "null" : __it.asJson()).collect(joining(",", "[", "]")) : ""),
(windowsOptions != null ? "\"windowsOptions\":" + windowsOptions.asJson() : ""))
.filter(__it -> !__it.isBlank())
.collect(joining(",", "{", "}"));
}
}