blob: 1124d2766f0de0358d37f83c02274b4658e96a6f [file] [log] [blame]
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +02001// Copyright 2020 The Monogon Project Authors.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17package common
18
Lorenz Bruna4ea9d02019-10-31 11:40:30 +010019import "git.monogon.dev/source/nexantic.git/core/generated/api"
20
Leopold Schabel68c58752019-11-14 21:00:59 +010021// TODO(leo): merge api and node packages and get rid of this extra layer of indirection?
22
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020023type (
24 SetupService interface {
25 CurrentState() SmalltownState
26 GetJoinClusterToken() string
Leopold Schabel68c58752019-11-14 21:00:59 +010027 SetupNewCluster() error
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020028 EnterJoinClusterMode() error
Leopold Schabel68c58752019-11-14 21:00:59 +010029 JoinCluster(initialCluster string, certs *api.ConsensusCertificates) error
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020030 }
31
32 SmalltownState string
33)
34
35const (
Leopold Schabel68c58752019-11-14 21:00:59 +010036 // Node is unprovisioned and waits for Setup to be called.
37 StateSetupMode SmalltownState = "setup"
38 // Setup() has been called, node waits for a JoinCluster or BootstrapCluster call.
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020039 StateClusterJoinMode SmalltownState = "join"
Leopold Schabel68c58752019-11-14 21:00:59 +010040 // Node is fully provisioned.
41 StateConfigured SmalltownState = "configured"
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020042)