Skip to content

Commit

Permalink
Add ability to update the ssh public keys of an allocated machine (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Jun 20, 2023
1 parent ea6a6e3 commit fe8bd58
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 141 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ jobs:
uses: actions/checkout@v3

- name: Set up Go 1.20
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: '1.20.x'

- name: setup buf
uses: bufbuild/[email protected]
with:
github_token: ${{ github.token }}

- name: generate proto and lint
working-directory: proto
run: make protoc
Expand All @@ -57,7 +52,7 @@ jobs:
[ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true
- name: Build and push image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
push: true
Expand All @@ -70,7 +65,7 @@ jobs:
uses: actions/checkout@v3

- name: Set up Go 1.20
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: '1.20.x'

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM metalstack/builder:latest as builder

FROM alpine:3.17
FROM alpine:3.18
RUN apk -U add ca-certificates
COPY --from=builder /work/bin/metal-api /metal-api
CMD ["/metal-api"]
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.17
FROM alpine:3.18
RUN apk add ca-certificates
COPY bin/metal-api /metal-api
ENTRYPOINT [ "/metal-api" ]
8 changes: 7 additions & 1 deletion cmd/metal-api/internal/service/machine-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,13 @@ func (r *machineResource) updateMachine(request *restful.Request, response *rest
newMachine.Allocation.Description = *requestPayload.Description
}

newMachine.Tags = makeMachineTags(&newMachine, requestPayload.Tags)
if len(requestPayload.Tags) > 0 {
newMachine.Tags = makeMachineTags(&newMachine, requestPayload.Tags)
}

if len(requestPayload.SSHPubKeys) > 0 {
newMachine.Allocation.SSHPubKeys = requestPayload.SSHPubKeys
}

err = r.ds.UpdateMachine(oldMachine, &newMachine)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/metal-api/internal/service/v1/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ type MachineUpdateRequest struct {
Identifiable
Description *string `json:"description" description:"a description for this machine"`
Tags []string `json:"tags" description:"tags for this machine." optional:"true"`
SSHPubKeys []string `json:"ssh_pub_keys" description:"the public ssh keys to access the machine with" optional:"true"`
}

type MachineResponse struct {
Expand Down
58 changes: 29 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ require (
github.com/aws/aws-sdk-go v1.44.175
github.com/dustin/go-humanize v1.0.1
github.com/emicklei/go-restful-openapi/v2 v2.9.1
// FIXME go-restful v3.10.x breaks imageCreate
github.com/emicklei/go-restful/v3 v3.9.0
github.com/emicklei/go-restful/v3 v3.10.2
github.com/go-openapi/spec v0.20.9
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.0
Expand All @@ -19,46 +18,49 @@ require (
github.com/looplab/fsm v0.3.0
github.com/metal-stack/go-ipam v1.8.5
github.com/metal-stack/masterdata-api v0.9.0
github.com/metal-stack/metal-lib v0.11.7
github.com/metal-stack/metal-lib v0.11.10
github.com/metal-stack/security v0.6.6
github.com/metal-stack/v v1.0.3
github.com/nsqio/go-nsq v1.1.0
github.com/prometheus/client_golang v1.15.1
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.2
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.20.1
github.com/undefinedlabs/go-mpatch v1.0.6
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.9.0
golang.org/x/crypto v0.10.0
golang.org/x/sync v0.2.0
google.golang.org/grpc v1.55.0
google.golang.org/protobuf v1.30.0
gopkg.in/rethinkdb/rethinkdb-go.v6 v6.2.2
)

// Keep this because v3.10.x breaks image-create
replace github.com/emicklei/go-restful/v3 => github.com/emicklei/go-restful/v3 v3.9.0

require (
filippo.io/edwards25519 v1.0.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/akutz/memconn v0.1.0 // indirect
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/avast/retry-go v3.0.0+incompatible // indirect
github.com/benbjohnson/clock v1.3.4 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bufbuild/connect-go v1.7.0 // indirect
github.com/bufbuild/connect-go v1.8.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/containerd v1.6.19 // indirect
github.com/coreos/go-oidc/v3 v3.5.0 // indirect
github.com/containerd/containerd v1.7.2 // indirect
github.com/coreos/go-oidc/v3 v3.6.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set/v2 v2.3.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v23.0.6+incompatible // indirect
github.com/docker/docker v24.0.2+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
Expand Down Expand Up @@ -86,7 +88,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
github.com/icza/dyno v0.0.0-20230330125955-09f820a8d9c0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.14.0 // indirect
Expand All @@ -104,7 +106,7 @@ require (
github.com/josharian/native v1.1.0 // indirect
github.com/jsimonetti/rtnetlink v1.3.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.16.3 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.1 // indirect
Expand All @@ -120,7 +122,7 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mdlayher/netlink v1.7.2 // indirect
github.com/mdlayher/socket v0.4.1 // indirect
github.com/meilisearch/meilisearch-go v0.24.0 // indirect
github.com/meilisearch/meilisearch-go v0.25.0 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
Expand All @@ -135,7 +137,7 @@ require (
github.com/opencontainers/runc v1.1.7 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/philip-bui/grpc-zerolog v1.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand All @@ -144,9 +146,8 @@ require (
github.com/prometheus/procfs v0.9.0 // indirect
github.com/puzpuzpuz/xsync/v2 v2.4.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/rs/zerolog v1.29.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand All @@ -155,24 +156,23 @@ require (
github.com/subosito/gotenv v1.4.2 // indirect
github.com/tailscale/hujson v0.0.0-20220630195928-54599719472f // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.45.0 // indirect
github.com/valyala/fasthttp v1.47.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.mongodb.org/mongo-driver v1.11.3 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.1.12 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.mongodb.org/mongo-driver v1.11.7 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go4.org/intern v0.0.0-20230205224052-192e9f60865c // indirect
go4.org/mem v0.0.0-20220726221520-4f986261bf13 // indirect
go4.org/netipx v0.0.0-20220925034521-797b0c90d8ab // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230221090011-e4bae7ad2296 // indirect
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/oauth2 v0.9.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/time v0.3.0 // indirect; indirecct
golang.org/x/tools v0.9.1 // indirect
golang.org/x/tools v0.9.3 // indirect
golang.zx2c4.com/wireguard/windows v0.5.3 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
Expand Down
Loading

0 comments on commit fe8bd58

Please sign in to comment.