diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..dbcfb1d9 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python Debugger: Current File with Arguments", + "type": "debugpy", + "request": "launch", + "program": "main.py", + "console": "integratedTerminal", + "args": [ + "200", + "/home/paulmaidment/Documents/swarm-test/testplan.yaml", + "/home/paulmaidment/Documents/swarm-test/service_config.yaml", + ], + "env": { + "KUBECONFIG": "/home/paulmaidment/Downloads/kubeconfig.testcluster" + }, + "sudo": true, + } + ] +} \ No newline at end of file diff --git a/Dockerfile.assisted-swarm b/Dockerfile.assisted-swarm index 62bee20a..509a6995 100644 --- a/Dockerfile.assisted-swarm +++ b/Dockerfile.assisted-swarm @@ -1,4 +1,4 @@ -FROM quay.io/centos/centos:stream8 +FROM quay.io/centos/centos:stream9 ARG WORK_DIR=/data diff --git a/Dockerfile.assisted-swarm-build b/Dockerfile.assisted-swarm-build index f79b35ea..f0aedaf5 100644 --- a/Dockerfile.assisted-swarm-build +++ b/Dockerfile.assisted-swarm-build @@ -1,15 +1,33 @@ -FROM registry.ci.openshift.org/openshift/release:golang-1.17 -ENV GO111MODULE=on -ENV GOFLAGS="" +FROM registry.ci.openshift.org/openshift/release:golang-1.20 AS golang +RUN chmod g+xw -R /usr/local/go + +FROM quay.io/centos/centos:stream9 + +ENV GOPATH=/go +ENV GOROOT=/usr/local/go +ENV VIRTUAL_ENV=/opt/venv +# A directory in the path with write permission even for non-root users +ENV TOOLS=/tools/ +ENV PATH="$VIRTUAL_ENV/bin:$GOROOT/bin:$GOPATH/bin:$TOOLS:$PATH" + +RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/bin v1.53.2 +COPY --from=quay.io/goswagger/swagger:sha-5d0a00d /usr/bin/swagger /usr/bin/goswagger -COPY --from=quay.io/goswagger/swagger:v0.28.0 /usr/bin/swagger /usr/bin/goswagger COPY --from=quay.io/edge-infrastructure/swagger-codegen-cli:2.4.18 /opt/swagger-codegen-cli /opt/swagger-codegen-cli +COPY --from=golang /usr/bin/gotestsum /usr/bin/make /usr/bin/ +COPY --from=golang /usr/local/go /usr/local/go +COPY --from=quay.io/openshift/origin-cli:latest /usr/bin/oc /usr/bin +COPY --from=quay.io/operator-framework/upstream-opm-builder:v1.16.1 /bin/opm /bin +COPY --from=registry.k8s.io/kustomize/kustomize:v4.3.0 /app/kustomize /usr/bin/ +COPY --from=quay.io/coreos/shellcheck-alpine:v0.5.0 /bin/shellcheck /usr/bin/shellcheck USER 0 - RUN curl -L https://github.com/stoplightio/spectral/releases/download/v5.9.1/spectral-linux -o /usr/local/bin/spectral && chmod +x /usr/local/bin/spectral -RUN yum install -y --setopt=skip_missing_names_on_install=False docker podman -RUN mkdir build && chmod g+xw -R build/ +COPY ./hack/setup_env.sh ./ +RUN ./setup_env.sh podman_remote && \ + dnf clean all + + + -RUN chmod g+xw -R . diff --git a/Makefile b/Makefile index 4e8e225b..5fcc087d 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,6 @@ ASSISTED_SWARM = build/assisted-swarm -CONTAINER_COMMAND := $(or $(CONTAINER_COMMAND),docker) +CONTAINER_COMMAND := podman-remote IMAGE := $(or $(IMAGE),quay.io/oamizur/assisted-swarm:latest) -ifeq ($(CONTAINER_COMMAND), docker) - CONTAINER_COMMAND = $(shell docker -v | cut -f1 -d' ' | tr '[:upper:]' '[:lower:]') -endif .PHONY: build-image generate clean diff --git a/assisted_swarm_client/assisted_swarm/models/new_agent_params.py b/assisted_swarm_client/assisted_swarm/models/new_agent_params.py index dd0de00c..898d533d 100644 --- a/assisted_swarm_client/assisted_swarm/models/new_agent_params.py +++ b/assisted_swarm_client/assisted_swarm/models/new_agent_params.py @@ -40,6 +40,7 @@ class NewAgentParams(object): 'containers_storage_conf': 'str', 'dry_forced_host_id': 'str', 'dry_forced_host_ipv4': 'str', + 'dry_forced_host_ipv6': 'str', 'dry_forced_mac_address': 'str', 'dry_forced_hostname': 'str', 'dry_fake_reboot_marker_path': 'str', @@ -56,13 +57,14 @@ class NewAgentParams(object): 'containers_storage_conf': 'containers_storage_conf', 'dry_forced_host_id': 'dry_forced_host_id', 'dry_forced_host_ipv4': 'dry_forced_host_ipv4', + 'dry_forced_host_ipv6': 'dry_forced_host_ipv6', 'dry_forced_mac_address': 'dry_forced_mac_address', 'dry_forced_hostname': 'dry_forced_hostname', 'dry_fake_reboot_marker_path': 'dry_fake_reboot_marker_path', 'dry_cluster_hosts_path': 'dry_cluster_hosts_path' } - def __init__(self, service_url=None, infra_env_id=None, agent_version=None, cacert=None, pull_secret=None, containers_conf=None, containers_storage_conf=None, dry_forced_host_id=None, dry_forced_host_ipv4=None, dry_forced_mac_address=None, dry_forced_hostname=None, dry_fake_reboot_marker_path=None, dry_cluster_hosts_path=None): # noqa: E501 + def __init__(self, service_url=None, infra_env_id=None, agent_version=None, cacert=None, pull_secret=None, containers_conf=None, containers_storage_conf=None, dry_forced_host_id=None, dry_forced_host_ipv4=None, dry_forced_host_ipv6=None, dry_forced_mac_address=None, dry_forced_hostname=None, dry_fake_reboot_marker_path=None, dry_cluster_hosts_path=None): # noqa: E501 """NewAgentParams - a model defined in Swagger""" # noqa: E501 self._service_url = None @@ -74,6 +76,7 @@ def __init__(self, service_url=None, infra_env_id=None, agent_version=None, cace self._containers_storage_conf = None self._dry_forced_host_id = None self._dry_forced_host_ipv4 = None + self._dry_forced_host_ipv6 = None self._dry_forced_mac_address = None self._dry_forced_hostname = None self._dry_fake_reboot_marker_path = None @@ -98,6 +101,8 @@ def __init__(self, service_url=None, infra_env_id=None, agent_version=None, cace self.dry_forced_host_id = dry_forced_host_id if dry_forced_host_ipv4 is not None: self.dry_forced_host_ipv4 = dry_forced_host_ipv4 + if dry_forced_host_ipv6 is not None: + self.dry_forced_host_ipv6 = dry_forced_host_ipv6 if dry_forced_mac_address is not None: self.dry_forced_mac_address = dry_forced_mac_address if dry_forced_hostname is not None: @@ -296,6 +301,27 @@ def dry_forced_host_ipv4(self, dry_forced_host_ipv4): self._dry_forced_host_ipv4 = dry_forced_host_ipv4 + @property + def dry_forced_host_ipv6(self): + """Gets the dry_forced_host_ipv6 of this NewAgentParams. # noqa: E501 + + + :return: The dry_forced_host_ipv6 of this NewAgentParams. # noqa: E501 + :rtype: str + """ + return self._dry_forced_host_ipv6 + + @dry_forced_host_ipv6.setter + def dry_forced_host_ipv6(self, dry_forced_host_ipv6): + """Sets the dry_forced_host_ipv6 of this NewAgentParams. + + + :param dry_forced_host_ipv6: The dry_forced_host_ipv6 of this NewAgentParams. # noqa: E501 + :type: str + """ + + self._dry_forced_host_ipv6 = dry_forced_host_ipv6 + @property def dry_forced_mac_address(self): """Gets the dry_forced_mac_address of this NewAgentParams. # noqa: E501 diff --git a/assisted_swarm_client/docs/NewAgentParams.md b/assisted_swarm_client/docs/NewAgentParams.md index 0d0cefff..52e39cfc 100644 --- a/assisted_swarm_client/docs/NewAgentParams.md +++ b/assisted_swarm_client/docs/NewAgentParams.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **containers_storage_conf** | **str** | | [optional] **dry_forced_host_id** | **str** | | [optional] **dry_forced_host_ipv4** | **str** | | [optional] +**dry_forced_host_ipv6** | **str** | | [optional] **dry_forced_mac_address** | **str** | | [optional] **dry_forced_hostname** | **str** | | [optional] **dry_fake_reboot_marker_path** | **str** | | [optional] diff --git a/client/swarm/create_new_agent_parameters.go b/client/swarm/create_new_agent_parameters.go index 5963ca38..c4d42e9f 100644 --- a/client/swarm/create_new_agent_parameters.go +++ b/client/swarm/create_new_agent_parameters.go @@ -54,10 +54,12 @@ func NewCreateNewAgentParamsWithHTTPClient(client *http.Client) *CreateNewAgentP } } -/* CreateNewAgentParams contains all the parameters to send to the API endpoint - for the create new agent operation. +/* +CreateNewAgentParams contains all the parameters to send to the API endpoint - Typically these are written to a http.Request. + for the create new agent operation. + + Typically these are written to a http.Request. */ type CreateNewAgentParams struct { diff --git a/client/swarm/create_new_agent_responses.go b/client/swarm/create_new_agent_responses.go index 93963bc0..b8838939 100644 --- a/client/swarm/create_new_agent_responses.go +++ b/client/swarm/create_new_agent_responses.go @@ -63,7 +63,8 @@ func NewCreateNewAgentCreated() *CreateNewAgentCreated { return &CreateNewAgentCreated{} } -/* CreateNewAgentCreated describes a response with status code 201, with default header values. +/* +CreateNewAgentCreated describes a response with status code 201, with default header values. Success. */ @@ -71,9 +72,39 @@ type CreateNewAgentCreated struct { Payload *models.Agent } +// IsSuccess returns true when this create new agent created response has a 2xx status code +func (o *CreateNewAgentCreated) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create new agent created response has a 3xx status code +func (o *CreateNewAgentCreated) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create new agent created response has a 4xx status code +func (o *CreateNewAgentCreated) IsClientError() bool { + return false +} + +// IsServerError returns true when this create new agent created response has a 5xx status code +func (o *CreateNewAgentCreated) IsServerError() bool { + return false +} + +// IsCode returns true when this create new agent created response a status code equal to that given +func (o *CreateNewAgentCreated) IsCode(code int) bool { + return code == 201 +} + func (o *CreateNewAgentCreated) Error() string { return fmt.Sprintf("[POST /agents][%d] createNewAgentCreated %+v", 201, o.Payload) } + +func (o *CreateNewAgentCreated) String() string { + return fmt.Sprintf("[POST /agents][%d] createNewAgentCreated %+v", 201, o.Payload) +} + func (o *CreateNewAgentCreated) GetPayload() *models.Agent { return o.Payload } @@ -95,7 +126,8 @@ func NewCreateNewAgentBadRequest() *CreateNewAgentBadRequest { return &CreateNewAgentBadRequest{} } -/* CreateNewAgentBadRequest describes a response with status code 400, with default header values. +/* +CreateNewAgentBadRequest describes a response with status code 400, with default header values. Error. */ @@ -103,9 +135,39 @@ type CreateNewAgentBadRequest struct { Payload *models.Error } +// IsSuccess returns true when this create new agent bad request response has a 2xx status code +func (o *CreateNewAgentBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create new agent bad request response has a 3xx status code +func (o *CreateNewAgentBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create new agent bad request response has a 4xx status code +func (o *CreateNewAgentBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this create new agent bad request response has a 5xx status code +func (o *CreateNewAgentBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this create new agent bad request response a status code equal to that given +func (o *CreateNewAgentBadRequest) IsCode(code int) bool { + return code == 400 +} + func (o *CreateNewAgentBadRequest) Error() string { return fmt.Sprintf("[POST /agents][%d] createNewAgentBadRequest %+v", 400, o.Payload) } + +func (o *CreateNewAgentBadRequest) String() string { + return fmt.Sprintf("[POST /agents][%d] createNewAgentBadRequest %+v", 400, o.Payload) +} + func (o *CreateNewAgentBadRequest) GetPayload() *models.Error { return o.Payload } @@ -127,7 +189,8 @@ func NewCreateNewAgentUnauthorized() *CreateNewAgentUnauthorized { return &CreateNewAgentUnauthorized{} } -/* CreateNewAgentUnauthorized describes a response with status code 401, with default header values. +/* +CreateNewAgentUnauthorized describes a response with status code 401, with default header values. Unauthorized. */ @@ -135,9 +198,39 @@ type CreateNewAgentUnauthorized struct { Payload *models.Error } +// IsSuccess returns true when this create new agent unauthorized response has a 2xx status code +func (o *CreateNewAgentUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create new agent unauthorized response has a 3xx status code +func (o *CreateNewAgentUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create new agent unauthorized response has a 4xx status code +func (o *CreateNewAgentUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this create new agent unauthorized response has a 5xx status code +func (o *CreateNewAgentUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this create new agent unauthorized response a status code equal to that given +func (o *CreateNewAgentUnauthorized) IsCode(code int) bool { + return code == 401 +} + func (o *CreateNewAgentUnauthorized) Error() string { return fmt.Sprintf("[POST /agents][%d] createNewAgentUnauthorized %+v", 401, o.Payload) } + +func (o *CreateNewAgentUnauthorized) String() string { + return fmt.Sprintf("[POST /agents][%d] createNewAgentUnauthorized %+v", 401, o.Payload) +} + func (o *CreateNewAgentUnauthorized) GetPayload() *models.Error { return o.Payload } @@ -159,7 +252,8 @@ func NewCreateNewAgentForbidden() *CreateNewAgentForbidden { return &CreateNewAgentForbidden{} } -/* CreateNewAgentForbidden describes a response with status code 403, with default header values. +/* +CreateNewAgentForbidden describes a response with status code 403, with default header values. Forbidden. */ @@ -167,9 +261,39 @@ type CreateNewAgentForbidden struct { Payload *models.Error } +// IsSuccess returns true when this create new agent forbidden response has a 2xx status code +func (o *CreateNewAgentForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create new agent forbidden response has a 3xx status code +func (o *CreateNewAgentForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create new agent forbidden response has a 4xx status code +func (o *CreateNewAgentForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this create new agent forbidden response has a 5xx status code +func (o *CreateNewAgentForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this create new agent forbidden response a status code equal to that given +func (o *CreateNewAgentForbidden) IsCode(code int) bool { + return code == 403 +} + func (o *CreateNewAgentForbidden) Error() string { return fmt.Sprintf("[POST /agents][%d] createNewAgentForbidden %+v", 403, o.Payload) } + +func (o *CreateNewAgentForbidden) String() string { + return fmt.Sprintf("[POST /agents][%d] createNewAgentForbidden %+v", 403, o.Payload) +} + func (o *CreateNewAgentForbidden) GetPayload() *models.Error { return o.Payload } @@ -191,7 +315,8 @@ func NewCreateNewAgentInternalServerError() *CreateNewAgentInternalServerError { return &CreateNewAgentInternalServerError{} } -/* CreateNewAgentInternalServerError describes a response with status code 500, with default header values. +/* +CreateNewAgentInternalServerError describes a response with status code 500, with default header values. Error. */ @@ -199,9 +324,39 @@ type CreateNewAgentInternalServerError struct { Payload *models.Error } +// IsSuccess returns true when this create new agent internal server error response has a 2xx status code +func (o *CreateNewAgentInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create new agent internal server error response has a 3xx status code +func (o *CreateNewAgentInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create new agent internal server error response has a 4xx status code +func (o *CreateNewAgentInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this create new agent internal server error response has a 5xx status code +func (o *CreateNewAgentInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this create new agent internal server error response a status code equal to that given +func (o *CreateNewAgentInternalServerError) IsCode(code int) bool { + return code == 500 +} + func (o *CreateNewAgentInternalServerError) Error() string { return fmt.Sprintf("[POST /agents][%d] createNewAgentInternalServerError %+v", 500, o.Payload) } + +func (o *CreateNewAgentInternalServerError) String() string { + return fmt.Sprintf("[POST /agents][%d] createNewAgentInternalServerError %+v", 500, o.Payload) +} + func (o *CreateNewAgentInternalServerError) GetPayload() *models.Error { return o.Payload } diff --git a/hack/setup_env.sh b/hack/setup_env.sh new file mode 100755 index 00000000..a0b88cd1 --- /dev/null +++ b/hack/setup_env.sh @@ -0,0 +1,8 @@ +function podman_remote() { + curl --retry 5 --connect-timeout 30 -L https://github.com/containers/podman/releases/download/v4.1.1/podman-remote-static.tar.gz -o "podman-remote.tar.gz" + tar -zxvf podman-remote.tar.gz + mv podman-remote-static /usr/local/bin/podman-remote + rm -f podman-remote.tar.gz +} + +"$@" \ No newline at end of file diff --git a/models/new_agent_params.go b/models/new_agent_params.go index 3bb66b37..5818db46 100644 --- a/models/new_agent_params.go +++ b/models/new_agent_params.go @@ -45,6 +45,10 @@ type NewAgentParams struct { // Pattern: ^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[\/]([1-9]|[1-2][0-9]|3[0-2]?)$ DryForcedHostIPV4 string `json:"dry_forced_host_ipv4,omitempty"` + // dry forced host ipv6 + // Pattern: ^((([0-9A-Fa-f]{1,4}:){1,6}:)|(([0-9A-Fa-f]{1,4}:){7}))([0-9A-Fa-f]{1,4}?)[\/]([0-9]*)$ + DryForcedHostIPV6 string `json:"dry_forced_host_ipv6,omitempty"` + // dry forced hostname DryForcedHostname string `json:"dry_forced_hostname,omitempty"` @@ -75,6 +79,10 @@ func (m *NewAgentParams) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateDryForcedHostIPV6(formats); err != nil { + res = append(res, err) + } + if err := m.validateDryForcedMacAddress(formats); err != nil { res = append(res, err) } @@ -113,6 +121,18 @@ func (m *NewAgentParams) validateDryForcedHostIPV4(formats strfmt.Registry) erro return nil } +func (m *NewAgentParams) validateDryForcedHostIPV6(formats strfmt.Registry) error { + if swag.IsZero(m.DryForcedHostIPV6) { // not required + return nil + } + + if err := validate.Pattern("dry_forced_host_ipv6", "body", m.DryForcedHostIPV6, `^((([0-9A-Fa-f]{1,4}:){1,6}:)|(([0-9A-Fa-f]{1,4}:){7}))([0-9A-Fa-f]{1,4}?)[\/]([0-9]*)$`); err != nil { + return err + } + + return nil +} + func (m *NewAgentParams) validateDryForcedMacAddress(formats strfmt.Registry) error { if swag.IsZero(m.DryForcedMacAddress) { // not required return nil diff --git a/restapi/embedded_spec.go b/restapi/embedded_spec.go index bbaec052..cbfbbafd 100644 --- a/restapi/embedded_spec.go +++ b/restapi/embedded_spec.go @@ -364,6 +364,10 @@ func init() { "type": "string", "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[\\/]([1-9]|[1-2][0-9]|3[0-2]?)$" }, + "dry_forced_host_ipv6": { + "type": "string", + "pattern": "^((([0-9A-Fa-f]{1,4}:){1,6}:)|(([0-9A-Fa-f]{1,4}:){7}))([0-9A-Fa-f]{1,4}?)[\\/]([0-9]*)$" + }, "dry_forced_hostname": { "type": "string" }, @@ -738,6 +742,10 @@ func init() { "type": "string", "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[\\/]([1-9]|[1-2][0-9]|3[0-2]?)$" }, + "dry_forced_host_ipv6": { + "type": "string", + "pattern": "^((([0-9A-Fa-f]{1,4}:){1,6}:)|(([0-9A-Fa-f]{1,4}:){7}))([0-9A-Fa-f]{1,4}?)[\\/]([0-9]*)$" + }, "dry_forced_hostname": { "type": "string" }, diff --git a/skipper.env b/skipper.env new file mode 100644 index 00000000..a0f2bcff --- /dev/null +++ b/skipper.env @@ -0,0 +1 @@ +IMAGE \ No newline at end of file diff --git a/skipper.yaml b/skipper.yaml index 03d2f7cf..0878c9f5 100644 --- a/skipper.yaml +++ b/skipper.yaml @@ -6,8 +6,13 @@ volumes: - $HOME/.cache/go-build:/go/pkg/mod # Registry credentials - $HOME/.docker/:$HOME/.docker + # Podman socket for podman-remote + - $(podman info --format "{{.Host.RemoteSocket.Path}}" 2> /dev/null || echo "$XDG_RUNTIME_DIR/podman/podman.sock"):/run/podman/podman.sock containers: assisted-swarm-build: Dockerfile.assisted-swarm-build +env_file: + - skipper.env env: GOCACHE: "/go/pkg/mod" + CONTAINER_HOST: unix://run/podman/podman.sock diff --git a/swagger.yaml b/swagger.yaml index 0933b169..e79c1f78 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -194,6 +194,9 @@ definitions: dry_forced_host_ipv4: type: string pattern: '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[\/]([1-9]|[1-2][0-9]|3[0-2]?)$' + dry_forced_host_ipv6: + type: string + pattern: '^((([0-9A-Fa-f]{1,4}:){1,6}:)|(([0-9A-Fa-f]{1,4}:){7}))([0-9A-Fa-f]{1,4}?)[\/]([0-9]*)$' dry_forced_mac_address: type: string format: mac